Update to firefox-78.10.0 in svn
[beyond_linux_from_scratch.git] / scripts / blfs-chapter24.php
blobc0a1d029a14d746aa170f7e5dbf6317e9949de21
1 #! /usr/bin/php
2 <?php
4 include 'blfs-include.php';
6 $CHAPTER = '24';
7 $CHAPTERS = 'Chapter 24';
8 $START_PACKAGE = 'util-macros';
9 $STOP_PACKAGE = 'xinit';
11 $renames = array();
12 $ignores = array();
14 $d = getenv( 'BLFS_DIR' );
15 $BLFS_DIR = ($d) ? $d : '.';
17 $freedesk = "http://xorg.freedesktop.org/releases/individual";
18 $xorg_drv = "ftp://ftp.x.org/pub/individual/driver";
20 $proto = array();
21 $apps = array();
22 $libs = array();
23 $fonts = array();
24 $drivers = array();
26 $regex = array();
27 $regex[ 'libvdpau-va-gl' ] = "/^.*version (\d[\d\.]+\d).*$/";
29 //$current="v"; // For debugging
31 $url_fix = array (
33 array( 'pkg' => 'xf86-input-wacom',
34 'match' => '^.*$',
35 'replace' => "https://github.com/linuxwacom/xf86-input-wacom/releases" ),
37 array( 'pkg' => 'libva',
38 'match' => '^.*$',
39 'replace' => "https://github.com/intel/libva/releases" ),
41 array( 'pkg' => 'intel-vaapi-driver',
42 'match' => '^.*$',
43 'replace' => "https://github.com/01org/intel-vaapi-driver/releases" ),
45 array( 'pkg' => 'libvdpau',
46 'match' => '^.*$',
47 'replace' => "https://gitlab.freedesktop.org/vdpau/libvdpau/tags" ),
49 array( 'pkg' => 'libvdpau-va-gl',
50 'match' => '^.*$',
51 'replace' => "https://github.com/i-rinat/libvdpau-va-gl/releases" ),
53 array( 'pkg' => 'xf86-input-libinput',
54 'match' => '^.*$',
55 'replace' => "$xorg_drv" ),
58 function get_packages( $package, $dirpath )
60 global $regex;
61 global $book_index;
62 global $url_fix;
63 global $current;
64 global $freedesk;
65 global $xorg_drv;
66 global $proto;
67 global $apps;
68 global $libs;
69 global $fonts;
70 global $drivers;
72 if ( isset( $current ) && $book_index != "$current" ) return 0;
73 if ( $dirpath == "" ) return "";
75 // Fix up directory path
76 foreach ( $url_fix as $u )
78 $replace = $u[ 'replace' ];
79 $match = $u[ 'match' ];
81 if ( isset( $u[ 'pkg' ] ) )
83 if ( $package == $u[ 'pkg' ] )
85 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
86 break;
89 else
91 if ( preg_match( "/$match/", $dirpath ) )
93 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
94 break;
99 // Check for ftp
100 if ( preg_match( "/^ftp/", $dirpath ) )
102 // MesaLib
103 if ( $book_index == "mesa" )
105 $lines = http_get_file( "$dirpath/" );
106 return find_max( $lines, "/mesa/", "/^.*mesa-(\d+[\d\.]+).tar.*$/" );
109 if ( $dirpath == $xorg_drv )
111 if ( count( $drivers ) == 0 )
112 $drivers = http_get_file( "$dirpath/" );
114 $lines = $drivers;
116 else // Get listing
117 $lines = http_get_file( "$dirpath/" );
119 else // http
121 // Customize http directories as needed
123 if ( $dirpath == "$freedesk/proto" )
125 if ( count( $proto ) == 0 )
126 $proto = http_get_file( $dirpath );
128 $lines = $proto;
131 else if ( $dirpath == "$freedesk/lib" )
133 if ( count( $libs ) == 0 )
134 $libs = http_get_file( $dirpath );
136 $lines = $libs;
139 else if ( $dirpath == "$freedesk/app" )
141 if ( count( $apps ) == 0 )
142 $apps = http_get_file( $dirpath );
144 $lines = $apps;
147 else if ( $dirpath == "$freedesk/font" )
149 if ( count( $fonts ) == 0 )
150 $fonts = http_get_file( $dirpath );
152 $lines = $fonts;
155 else
156 $lines = http_get_file( $dirpath );
158 if ( ! is_array( $lines ) ) return $lines;
159 } // End fetch
161 if ( isset( $regex[ $package ] ) )
163 // Custom search for latest package name
164 foreach ( $lines as $l )
166 if ( preg_match( '/^\h*$/', $l ) ) continue;
167 $ver = preg_replace( $regex[ $package ], "$1", $l );
169 if ( $ver == $l ) continue;
171 //if ( $book_index == "exiv" ) $ver = "2-$ver";
173 return $ver; // Return first match of regex
176 return 0; // This is an error
179 if ( $book_index == "libvdpau" )
180 return find_max( $lines, '/libvdpau-/', '/^.*libvdpau-(\d[\d\.]+).tar.*$/' );
182 if ( $book_index == "xterm" )
183 return find_max( $lines, '/xterm-\d+.tgz/', '/^.*xterm-(\d+).tgz.*$/' );
185 // Most packages are in the form $package-n.n.n
186 // Occasionally there are dashes (e.g. 201-1)
188 $max = find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d)\.tar.*$/", TRUE );
189 return $max;
192 function get_pattern( $line )
194 // Set up specific pattern matches for extracting book versions
195 $match = array();
197 $match = array(
198 array( 'pkg' => 'xf8',
199 'regex' => "/^xf.*-(\d[\d\.]+).*$/" ),
202 foreach( $match as $m )
204 $pkg = $m[ 'pkg' ];
206 if ( preg_match( "/$pkg/", $line ) )
207 return $m[ 'regex' ];
210 return "/\D*(\d.*\d)\D*$/";
213 function insert_subsection( $header, $subdir, $type )
215 global $book;
216 global $freedesk;
217 global $BLFS_DIR;
219 $xorg_dir = "$BLFS_DIR/x/installing";
221 $book[ $header ] =
222 array( 'basename' => "$header",
223 'url' => "",
224 'version' => "" );
226 exec( "grep 'ENTITY.*version' $xorg_dir/$subdir", $lines );
228 foreach ( $lines as $line )
230 $name = preg_replace( "/^.*ENTITY (.*)\-version.*$/", "$1", $line );
231 $version = preg_replace( '/^.*"(.*)".*$/', "$1", $line );
233 $book[ $name ] = array(
234 'basename' => $name,
235 'url' => "$freedesk/$type",
236 'version' => $version,
237 'indent' => $type );
241 function get_current_xorg()
243 global $vers;
244 global $book;
245 global $freedesk;
246 global $start;
247 global $WGET_DIR;
248 global $START_PACKAGE;
249 global $STOP_PACKAGE;
251 $wget_file = "$WGET_DIR/wget-list";
253 $contents = file_get_contents( $wget_file );
254 $wget = explode( "\n", $contents );
256 foreach ( $wget as $line )
258 if ( $line == "" ) continue;
259 if ( preg_match( "/patch/", $line ) ) continue; // Skip patches
261 $file = basename( $line );
262 $url = dirname ( $line );
263 $file = preg_replace( "/\.tar\..z.*$/", "", $file ); // Remove .tar.?z*$
264 $file = preg_replace( "/\.tar$/", "", $file ); // Remove .tar$
265 $file = preg_replace( "/\.gz$/", "", $file ); // Remove .gz$
266 $file = preg_replace( "/\.orig$/", "", $file ); // Remove .orig$
267 $file = preg_replace( "/\.src$/", "", $file ); // Remove .src$
268 $file = preg_replace( "/\.tgz$/", "", $file ); // Remove .tgz$
270 $pattern = get_pattern( $line );
272 $version = preg_replace( $pattern, "$1", $file ); // Isolate version
273 $version = preg_replace( "/^-/", "", $version ); // Remove leading #-
275 if ( preg_match( "/^xf/", $file ))
276 $basename = preg_replace( "/^(.+\-).*$/", "$1", $file );
277 else
278 $basename = strstr( $file, $version, true );
280 $basename = rtrim( $basename, "-" );
282 if ( $basename == $START_PACKAGE ) $start = true;
283 if ( ! $start ) continue;
285 $index = $basename;
286 while ( isset( $book[ $index ] ) ) $index .= "1";
288 $book[ $index ] = array( 'basename' => $basename,
289 'url' => $url,
290 'version' => $version );
292 if ( $basename == 'glamor-egl' )
294 $book[ 'Xorg Drivers' ] =
295 array( 'basename' => "Xorg Drivers",
296 'url' => "",
297 'version' => "" );
300 if ( preg_match( "/^xf86/", $basename ) )
301 $book[ $index ][ 'indent' ] = "driver";
303 #// If $basename is util-macros, add Xorg Protocol Headers
304 #if ( $basename == 'util-macros' )
305 # insert_subsection( "Xorg Protocol Headers", "x7proto.xml", "proto" );
307 // If $basename is libxcb, add Xorg libs
308 if ( $basename == 'libxcb' )
309 insert_subsection( "Xorg Libraries", "x7lib.xml", "lib" );
311 // If $basename is xbitmaps, add Xorg Apps
312 if ( $basename == 'xbitmaps' )
313 insert_subsection( "Xorg Apps", "x7app.xml", "app" );
315 // If $basename is xcursor-themes, add Xorg Fonts
316 if ( $basename == 'xcursor-themes' )
317 insert_subsection( "Xorg Fonts", "x7font.xml", "font" );
319 if ( preg_match( "/$STOP_PACKAGE/", $line ) ) break;
323 get_current_xorg(); // Get what is in the book
325 // Get latest version for each package
326 foreach ( $book as $pkg => $data )
328 $book_index = $pkg;
330 $base = $data[ 'basename' ];
331 $url = $data[ 'url' ];
332 $bver = $data[ 'version' ];
334 echo "book index: $book_index $bver $url \n";
336 $v = get_packages( $book_index, $url );
338 if ( $base == 'Xorg Protocol Headers' )
339 $vers[ $book_index ] = "";
340 else
341 $vers[ $book_index ] = $v;
344 html(); // Write html output