4 include 'blfs-include.php';
7 $CHAPTERS = 'Chapter 10';
8 $START_PACKAGE = 'aalib';
9 $STOP_PACKAGE = 'woff2';
12 $renames[ 'mypaint-brushes-v' ] = 'mypaint-brushes';
13 $renames[ 'libspiro-dist' ] = 'libspiro';
16 $ignores[ 'ippicv' ] = "";
18 //$current="opencv_contrib"; // For debugging
21 $regex[ 'LibRaw' ] = "/^.*LibRaw-(\d[\d\.]+\d).tar.*$/";
22 $regex[ 'poppler' ] = "/^.*poppler-([\d\.]+\d).tar.*$/";
23 $regex[ 'popplerdata' ] = "/^.*poppler-data([\d\.]+\d).tar.*$/";
25 $sf = 'sourceforge.net';
29 array( //'pkg' => 'gnome',
30 'match' => '^ftp:\/\/ftp.gnome',
31 'replace' => "http://ftp.gnome" ),
33 array( 'pkg' => 'aalib',
35 'replace' => "http://$sf/projects/aa-project/files" ),
37 array( 'pkg' => 'freetype',
39 'replace' => "http://sourceforge.net/projects/freetype/files/freetype2" ),
41 array( 'pkg' => 'freetype-doc',
43 'replace' => "http://$sf/projects/freetype/files/freetype-docs" ),
45 array( 'pkg' => 'fribidi',
47 'replace' => "https://github.com/fribidi/fribidi/releases" ),
49 array( 'pkg' => 'giflib',
51 'replace' => "http://$sf/projects/giflib/files" ),
53 array( 'pkg' => 'glm',
55 'replace' => "https://github.com/g-truc/glm/releases" ),
57 array( 'pkg' => 'harfbuzz',
59 'replace' => "https://github.com/harfbuzz/harfbuzz/releases" ),
61 array( 'pkg' => 'imlib2',
63 'replace' => "http://$sf/projects/enlightenment/files/imlib2-src" ),
65 array( 'pkg' => 'jasper',
67 'replace' => "https://github.com/jasper-software/jasper/releases" ),
69 array( 'pkg' => 'lcms',
71 'replace' => "http://$sf/projects/lcms/files/lcms" ),
73 array( 'pkg' => 'lcms2',
75 'replace' => "https://sourceforge.net/projects/lcms/files/lcms/" ),
77 array( 'pkg' => 'libexif',
79 'replace' => "https://github.com/libexif/libexif/releases" ),
81 array( 'pkg' => 'libjpeg-turbo',
83 'replace' => "http://$sf/projects/libjpeg-turbo/files" ),
85 array( 'pkg' => 'graphite2',
87 'replace' => "https://sourceforge.net/projects/silgraphite/files/graphite2/" ),
89 array( 'pkg' => 'libmng',
91 'replace' => "http://$sf/projects/libmng/files" ),
93 array( 'pkg' => 'mypaint-brushes-v',
95 'replace' => "https://github.com/Jehan/mypaint-brushes/releases" ),
97 array( 'pkg' => 'libmypaint',
99 'replace' => "https://github.com/mypaint/libmypaint/releases" ),
101 array( 'pkg' => 'libpng',
103 'replace' => "http://sourceforge.net/projects/libpng/files" ),
105 array( 'pkg' => 'sassc',
107 'replace' => "https://github.com/sass/sassc/tags" ),
109 array( 'pkg' => 'libspiro-dist',
111 'replace' => "https://github.com/fontforge/libspiro/releases" ),
113 array( 'pkg' => 'libsass',
115 'replace' => "https://github.com/sass/libsass/tags" ),
117 array( 'pkg' => 'libwebp',
119 'replace' => "http://downloads.webmproject.org/releases/webp/index.html" ),
121 array( 'pkg' => 'qpdf',
123 'replace' => "http://$sf/projects/qpdf/files" ),
125 array( 'pkg' => 'LibRaw',
127 'replace' => "http://www.libraw.org/download" ),
129 array( 'pkg' => 'exiv2',
131 'replace' => "https://www.exiv2.org/download.html" ),
132 //'replace' => "https://github.com/Exiv2/exiv2/releases" ),
134 array( 'pkg' => 'opencv',
136 'replace' => "https://github.com/opencv/opencv/releases" ),
138 array( 'pkg' => 'opencv_contrib',
140 'replace' => "https://github.com/opencv/opencv_contrib/releases" ),
142 array( 'pkg' => 'openjpeg',
144 'replace' => "https://github.com/uclouvain/openjpeg/releases" ),
146 array( 'pkg' => 'ijs',
148 'replace' => "https://www.openprinting.org/download/ijs/download/" ),
150 array( 'pkg' => 'potrace',
152 'replace' => "https://sourceforge.net/projects/potrace/files" ),
154 array( 'pkg' => 'woff2',
156 'replace' => "https://github.com/google/woff2/releases" ),
159 function get_packages( $package, $dirpath )
166 if ( isset( $current ) && $book_index != "$current" ) return 0;
168 // Fix up directory path
169 foreach ( $url_fix as $u )
171 $replace = $u[ 'replace' ];
172 $match = $u[ 'match' ];
174 if ( isset( $u[ 'pkg' ] ) )
176 if ( $package == $u[ 'pkg' ] )
178 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
184 if ( preg_match( "/$match/", $dirpath ) )
186 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
193 if ( preg_match( "/^ftp/", $dirpath ) )
195 if ( $book_index == "libart_lgpl" )
197 // Get the max directory and adjust the directory path
198 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
199 $position = strrpos( $dirpath, "/" );
200 $dirpath = substr ( $dirpath, 0, $position );
201 $lines = http_get_file( $dirpath );
202 $dir = find_max( $lines, "/\d[\d\.]+/", "/(\d[\d\.]+)/" );
203 $dirpath .= "/$dir/";
207 //if ( $book_index == "tiff" ) { $dirpath .= "/"; }
208 $lines = http_get_file( "$dirpath/" );
212 // glib type packages
213 if ( $book_index == "librsvg" )
216 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
217 $position = strrpos( $dirpath, "/" );
218 $dirpath = substr ( $dirpath, 0, $position ); // Up one
219 $lines = http_get_file( $dirpath );
220 $dir = find_even_max( $lines, '/^\s+[\d\.]+\//', '/^\s+([\d\.]+)\/.*$/' );
221 $dirpath .= "/$dir/";
225 if ( $book_index == "babl" ||
226 $book_index == "gegl" )
228 // Get the max directory and adjust the directory path
229 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
230 $position = strrpos( $dirpath, "/" );
231 $dirpath = substr ( $dirpath, 0, $position );
232 $lines = http_get_file( $dirpath );
233 $dir = find_max( $lines, "/\d[\d\.]+\//", "/^.*(\d[\d\.]+)\/.*$/" );
234 $dirpath .= "/$dir/";
237 if ( $book_index == "newt" ) $dirpath .= "/";
238 // Customize http directories as needed
239 $lines = http_get_file( $dirpath );
240 if ( ! is_array( $lines ) ) return $lines;
243 if ( isset( $regex[ $package ] ) )
245 // Custom search for latest package name
246 foreach ( $lines as $l )
248 if ( preg_match( '/^\h*$/', $l ) ) continue;
249 $ver = preg_replace( $regex[ $package ], "$1", $l );
250 if ( $ver == $l ) continue;
252 return $ver; // Return first match of regex
255 return 0; // This is an error
258 //echo "url=$dirpath\n";
261 if ( $book_index == "freetype" )
263 $dir = find_max( $lines, '/\d\./', '/^\s*([\d\.]+)\s.*$/' );
264 $lines = http_get_file( "$dirpath/$dir" );
267 if ( $book_index == "freetype-doc" )
268 return find_max( $lines, '/^\s*\d\./', '/^.*\s(\d\.[\d\.]+) .*$/' );
270 if ( $book_index == "fribidi" )
271 return find_max( $lines, '/fribidi/', '/^.*(\d\.[\d\.]+\d).*$/' );
273 if ( $book_index == "graphite2" )
274 return find_max( $lines, '/graphite2-/', '/^.*graphite2-(\d\.[\d\.]+)\.tgz.*$/' );
276 if ( $book_index == "glm" )
277 return find_max( $lines, '/GLM/', '/^.*GLM (\d\.[\d\.]+).*$/' );
279 if ( $book_index == "libpng" )
281 $dir = find_max( $lines, '/^\s*libpng\d/', '/^\s*libpng(\d[02468]) .*$/' );
282 $lines = http_get_file( "$dirpath/libpng$dir" );
283 return find_max( $lines, '/^\s*\d/', '/^\s*(\d\.[\d\.]+) .*$/' );
286 if ( $book_index == "libjpeg-turbo" )
287 return find_max( $lines, '/^\s*\d/', '/^\s*(\d\.[\d\.]+) .*$/' );
289 if ( $book_index == "libmypaint" )
290 return find_max( $lines, '/libmypaint/', '/^\s*libmypaint-(\d[\d\.]+).tar.*$/' );
292 if ( $book_index == "libspiro-dist" )
293 return find_max( $lines, '/libspiro-dist/', '/^.*libspiro-dist-(\d[\d\.]+).tar.*$/' );
295 if ( $book_index == "sassc" )
296 return find_max( $lines, '/\d\.\d\.\d/', '/^.*(\d\.\d\.\d).*$/' );
298 if ( $book_index == "libsass" )
299 return find_max( $lines, '/\d\.\d\.\d/', '/^.*(\d\.\d\.\d).*$/' );
301 if ( $book_index == "mypaint-brushes-v" )
302 return find_max( $lines, '/v\d/', '/^\s*v(\d[\d\.]+).*$/' );
304 if ( $book_index == "jasper" )
305 return find_max( $lines, '/version-/', '/^.*version-(\d\.[\d\.]+).*$/' );
307 if ( $book_index == "aalib" )
308 return find_max( $lines, "/$book_index/", '/^.*aalib-([rc\d\.]+).tar.*$/' );
310 if ( $book_index == "exiv2" )
311 return find_max( $lines, "/Currently/", '/^.*v(\d\.[\d\.]+)$/' );
314 if ( $book_index == "imlib2" )
316 $dir = find_max( $lines, '/^\s*[\d\.]+\s*$/', '/^\s*([\d\.]+)\s*$/' );
317 $lines = http_get_file( "$dirpath/$dir" );
318 return find_max( $lines, "/imlib/", "/^.*$package-([\d\.]*\d).tar.*$/" );
321 // lcms (actually lcms 1.xx)
322 if ( $book_index == "lcms" )
323 return find_max( $lines, '/^\s*1/', '/^\s*(1[\d\.]+) .*$/' );
325 if ( $book_index == "opencv" )
326 return find_max( $lines, '/OpenCV/', '/^.*OpenCV (\d\.[\d\.]+)$/' );
328 if ( $book_index == "opencv_contrib" )
329 return find_max( $lines, '/ \d\./', '/^.* (\d\.[\d\.]+)$/' );
332 if ( $book_index == "openjpeg" )
333 return find_max( $lines, '/openjpeg/', '/^.*openjpeg-v(\d\.[\d\.]+)-.*$/' );
335 if ( $book_index == "lcms2" )
336 return find_max( $lines, '/^\s*\d\./', '/^\s*([\d\.]+) .*$/' );
338 if ( $book_index == "woff2" )
339 return find_max( $lines, '/v\d/', '/^.*v([\d\.]+).*$/' );
341 if ( $book_index == "babl" )
342 return find_max( $lines, '/babl/', '/^.*babl-([\d\.]+).tar.*$/', FALSE );
344 if ( $package == "graphite2" ) $package = "graphite";
346 // Most packages are in the form $package-n.n.n
347 // Occasionally there are dashes (e.g. 201-1)
348 $max = find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d).tar.*$/", TRUE );
352 Function get_pattern( $line )
354 // Set up specific patter matches for extracting book versions
358 array( 'pkg' => 'libatomic_ops',
359 'regex' => "/\D*(\d.*\d[a-z]{0,1})\D*$/" ),
361 array( 'pkg' => 'lcms2',
362 'regex' => "/\D*lcms2-([\d\.]+)\D*$/" ),
364 array( 'pkg' => 'exiv2',
365 'regex' => "/\D*exiv2-([\d\.]+)\D*$/" ),
367 array( 'pkg' => 'imlib2',
368 'regex' => "/\D*imlib2-([\d\.]+)\D*$/" ),
370 array( 'pkg' => 'mypaint-brushes',
371 'regex' => "/\D*mypaint-brushes-v([\d\.]+)\D*$/" ),
373 array( 'pkg' => 'graphite2',
374 'regex' => "/\D*graphite2-([\d\.]+)\D*$/" ),
376 array( 'pkg' => 'woff',
377 'regex' => "/\D*woff2-([\d\.]+)\D*$/" ),
380 foreach( $match as $m )
383 if ( preg_match( "/$pkg/", $line ) )
384 return $m[ 'regex' ];
387 return "/\D*(\d.*\d)\D*$/";
390 get_current(); // Get what is in the book
394 // Get latest version for each package
395 foreach ( $book as $pkg => $data )
399 $base = $data[ 'basename' ];
400 $url = $data[ 'url' ];
401 $bver = $data[ 'version' ];
403 echo "book index: $book_index $bver $url\n";
405 $v = get_packages( $book_index, $url );
407 $vers[ $book_index ] = $v;
410 html(); // Write html output