4 include 'blfs-include.php';
7 $CHAPTERS = 'Chapter 24';
8 $START_PACKAGE = 'util-macros';
9 $STOP_PACKAGE = 'xinit';
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";
27 $regex[ 'libvdpau-va-gl' ] = "/^.*version (\d[\d\.]+\d).*$/";
29 //$current="v"; // For debugging
33 array( 'pkg' => 'xf86-input-wacom',
35 'replace' => "https://github.com/linuxwacom/xf86-input-wacom/releases" ),
37 array( 'pkg' => 'libva',
39 'replace' => "https://github.com/intel/libva/releases" ),
41 array( 'pkg' => 'intel-vaapi-driver',
43 'replace' => "https://github.com/01org/intel-vaapi-driver/releases" ),
45 array( 'pkg' => 'libvdpau',
47 'replace' => "https://gitlab.freedesktop.org/vdpau/libvdpau/tags" ),
49 array( 'pkg' => 'libvdpau-va-gl',
51 'replace' => "https://github.com/i-rinat/libvdpau-va-gl/releases" ),
53 array( 'pkg' => 'xf86-input-libinput',
55 'replace' => "$xorg_drv" ),
58 function get_packages( $package, $dirpath )
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 );
91 if ( preg_match( "/$match/", $dirpath ) )
93 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
100 if ( preg_match( "/^ftp/", $dirpath ) )
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/" );
117 $lines = http_get_file( "$dirpath/" );
121 // Customize http directories as needed
123 if ( $dirpath == "$freedesk/proto" )
125 if ( count( $proto ) == 0 )
126 $proto = http_get_file( $dirpath );
131 else if ( $dirpath == "$freedesk/lib" )
133 if ( count( $libs ) == 0 )
134 $libs = http_get_file( $dirpath );
139 else if ( $dirpath == "$freedesk/app" )
141 if ( count( $apps ) == 0 )
142 $apps = http_get_file( $dirpath );
147 else if ( $dirpath == "$freedesk/font" )
149 if ( count( $fonts ) == 0 )
150 $fonts = http_get_file( $dirpath );
156 $lines = http_get_file( $dirpath );
158 if ( ! is_array( $lines ) ) return $lines;
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 );
192 function get_pattern( $line )
194 // Set up specific pattern matches for extracting book versions
198 array( 'pkg' => 'xf8',
199 'regex' => "/^xf.*-(\d[\d\.]+).*$/" ),
202 foreach( $match as $m )
206 if ( preg_match( "/$pkg/", $line ) )
207 return $m[ 'regex' ];
210 return "/\D*(\d.*\d)\D*$/";
213 function insert_subsection( $header, $subdir, $type )
219 $xorg_dir = "$BLFS_DIR/x/installing";
222 array( 'basename' => "$header",
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(
235 'url' => "$freedesk/$type",
236 'version' => $version,
241 function get_current_xorg()
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 );
278 $basename = strstr( $file, $version, true );
280 $basename = rtrim( $basename, "-" );
282 if ( $basename == $START_PACKAGE ) $start = true;
283 if ( ! $start ) continue;
286 while ( isset( $book[ $index ] ) ) $index .= "1";
288 $book[ $index ] = array( 'basename' => $basename,
290 'version' => $version );
292 if ( $basename == 'glamor-egl' )
294 $book[ 'Xorg Drivers' ] =
295 array( 'basename' => "Xorg Drivers",
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 )
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 ] = "";
341 $vers[ $book_index ] = $v;
344 html(); // Write html output