4 include 'blfs-include.php';
7 $CHAPTERS = 'Chapters 17-19';
8 $START_PACKAGE = 'c-ares';
9 $STOP_PACKAGE = 'procmail';
14 $ignores[ 'libnl-doc' ] = '';
19 $regex[ 'serf' ] = "/^.*Serf is ([\d\.]+\d).*$/";
20 $regex[ 'libevent' ] = "/^.*release-(\d[\d\.]*)-stable.*$/";
21 //$regex[ 'libnsl' ] = "/^.*libnsl ([\d\.]+\d)*$/";
22 $regex[ 'rpcsvc-proto' ] = "/^.*Version ([\d\.]+\d)*$/";
26 array( //'pkg' => 'gnome',
27 'match' => '^ftp:\/\/ftp.gnome',
28 'replace' => "http://ftp.gnome" ),
30 array( 'pkg' => 'alpine',
32 'replace' => "http://repo.or.cz/alpine.git/shortlog" ),
34 array( 'pkg' => 'c-ares',
36 'replace' => "https://github.com/c-ares/c-ares/releases" ),
38 array( 'pkg' => 'w3m',
40 'replace' => "http://sourceforge.net/projects/w3m/files" ),
42 array( 'pkg' => 'fetchmail',
44 'replace' => "https://sourceforge.net/projects/fetchmail/files" ),
46 array( 'pkg' => 'links',
48 'replace' => "http://links.twibright.com/download" ),
50 array( 'pkg' => 'serf',
52 'replace' => "http://serf.apache.org/download" ),
54 array( 'pkg' => 'libpsl',
56 'replace' => "https://github.com/rockdaboot/libpsl/releases" ),
58 array( 'pkg' => 'libtirpc',
60 'replace' => "http://sourceforge.net/projects/libtirpc/files/libtirpc" ),
62 array( 'pkg' => 'libevent',
64 'replace' => "https://github.com/libevent/libevent/releases" ),
66 array( 'pkg' => 'geoclue',
68 'replace' => "https://gitlab.freedesktop.org/geoclue/geoclue/tags" ),
70 array( 'pkg' => 'libpcap',
72 'replace' => "http://www.tcpdump.org/#latest-release" ),
74 array( 'pkg' => 'mutt',
76 'replace' => "http://www.mutt.org/download.html" ),
78 array( 'pkg' => 'neon',
80 'replace' => "https://github.com/notroj/neon/releases/" ),
82 array( 'pkg' => 'nghttp2',
84 'replace' => "https://github.com/nghttp2/nghttp2/releases/" ),
86 array( 'pkg' => 'libndp',
88 'replace' => "https://github.com/jpirko/libndp/releases" ),
90 array( 'pkg' => 'lynx',
92 'replace' => "http://invisible-mirror.net/archives/lynx/tarballs" ),
94 array( 'pkg' => 'libnl',
96 'replace' => "https://github.com/thom311/libnl/releases" ),
98 array( 'pkg' => 'libnsl',
100 'replace' => "https://github.com/thkukuk/libnsl/releases" ),
102 array( 'pkg' => 'rpcsvc-proto',
104 'replace' => "https://github.com/thkukuk/rpcsvc-proto/releases" ),
106 array( 'pkg' => 'procmail',
108 'replace' => "http://ftp.osuosl.org/pub/blfs/conglomeration/procmail" ),
111 function get_packages( $package, $dirpath )
118 if ( isset( $current ) && $book_index != "$current" ) return 0;
120 // Fix up directory path
121 foreach ( $url_fix as $u )
123 $replace = $u[ 'replace' ];
124 $match = $u[ 'match' ];
126 if ( isset( $u[ 'pkg' ] ) )
128 if ( $package == $u[ 'pkg' ] )
130 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
136 if ( preg_match( "/$match/", $dirpath ) )
138 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
145 if ( preg_match( "/^ftp/", $dirpath ) )
147 // glib type packages
148 if ( $book_index == "glib-networking" ||
// This shouldn't happen any more
149 $book_index == "libsoup" )
152 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
153 $position = strrpos( $dirpath, "/" );
154 $dirpath = substr ( $dirpath, 0, $position );
155 $lines = http_get_file( "$dirpath/" );
156 $dir = find_even_max( $lines, '/^.* [\d\.]+$/', '/^.* ([\d\.]+)$/' );
157 $dirpath .= "/$dir/";
161 $lines = http_get_file( "$dirpath/" );
165 // Customize http directories as needed
166 if ( $book_index == "glib-networking" ||
167 $book_index == "libsoup" )
170 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
171 $position = strrpos( $dirpath, "/" );
172 $dirpath = substr ( $dirpath, 0, $position );
173 $lines1 = http_get_file( "$dirpath/" );
174 $dir = find_even_max( $lines1, '/^\s*[\d\.]+\/.*$/', '/^\s*([\d\.]+).*$/' );
175 $dirpath .= "/$dir/";
178 // lynx - really has odd name format
179 if ( $book_index == "lynx" )
181 $lines = http_get_file( $dirpath );
182 $max = find_max( $lines, "/rel/", "/^.*lynx(\d[\d\.]+rel\.\d).tar.*$/" );
186 $lines = http_get_file( $dirpath );
187 if ( ! is_array( $lines ) ) return $lines;
190 if ( isset( $regex[ $package ] ) )
192 // Custom search for latest package name
193 foreach ( $lines as $l )
195 if ( preg_match( '/^\h*$/', $l ) ) continue;
196 $ver = preg_replace( $regex[ $package ], "$1", $l );
197 if ( $ver == $l ) continue;
199 //if ( $book_index == "exiv" ) $ver = "2-$ver";
201 return $ver; // Return first match of regex
204 return 0; // This is an error
207 if ( $book_index == "alpine" )
208 return find_max( $lines, '/New version/', '/^.*New version ([\d\.]+).*$/' );
210 if ( $book_index == "c-ares" )
211 return find_max( $lines, '/c-ares/', '/^.*c-ares-([\d\.]+).tar.*$/' );
213 if ( $book_index == "glib-networking" )
215 $version = find_max( $lines, "/$book_index/", "/.*$book_index-([\d\.]*\d)\.tar.*$/" );
218 // Reduce last directory segment by 0.02
220 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
221 $position = strrpos( $dirpath, "/" );
222 $basedir = substr ( $dirpath, 0, $position );
223 $lastdir = substr ( $dirpath, -4 ); // 3.xx
224 $newdir = (float)$lastdir - 0.02 ;
225 $dirpath = $basedir . "/" . $newdir;
227 // Get values from that diretory
228 $lines = http_get_file( "$dirpath/" );
230 $lines = backup_dir( $dirpath, 4, 0.02 );
231 $version = find_max( $lines, "/$book_index/", "/^.*$book_index-([\d\.]*\d)\.tar.*$/" );
235 if ( $book_index == "curl" )
236 return find_max( $lines, '/^\d/', '/^([\d\.]+) .*$/' );
238 if ( $book_index == "libndp" )
239 return find_max( $lines, '/v\d/', '/^.*v([\d\.]+)$/' );
241 if ( $book_index == "heirloom-mailx" )
242 return find_max( $lines, '/orig/', '/^.*_([\d\.]+)\.orig.*$/' );
244 if ( $book_index == "libpcap" )
245 return find_max( $lines, '/libpcap-[\d\.]+/', '/^.*libpcap-([\d\.]+).tar.*$/' );
247 if ( $book_index == "mutt" )
248 return find_max( $lines, '/mutt-/', '/^.*mutt-([\d\.]+).tar.*$/' );
250 if ( $book_index == "neon" )
251 return find_max( $lines, '/\d\./', '/^.* ([\d\.]+\d).*$/' );
253 if ( $book_index == "nghttp2" )
254 return find_max( $lines, '/nghttp2/', '/^.*nghttp2 v([\d\.]+).*$/' );
256 if ( $book_index == "geoclue" )
257 return find_max( $lines, '/Release/', '/^.*Release ([\d\.]+).*$/' );
259 if ( $book_index == "procmail" )
260 return find_max( $lines, '/procmail/', '/^.*procmail-([\d\.]+)\.tar.*$/' );
262 // libtirpc (sourceforge is inconsistent here)
263 // Trying a constant '1' now (2020-07-26)
264 if ( $book_index == "libtirpc" )
265 return find_max( $lines, '/^\s*1/', '/^\s*(\d\.[\d\.]+) .*$/' );
266 //return find_max( $lines, '/^\s*\d/', '/^\s*(\d\.[\d\.]+) .*$/' );
268 if ( $book_index == "fetchmail" )
269 return find_max( $lines, '/fetchmail-/', '/^.*fetchmail-(\d\.[\d\.rc]+).tar.*$/' );
271 // Most packages are in the form $package-n.n.n
272 // Occasionally there are dashes (e.g. 201-1)
273 $max = find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d)\.tar.*$/" );
277 Function get_pattern( $line )
279 // Set up specific patter matches for extracting book versions
283 array( 'pkg' => 'w3m',
284 'regex' => "/w3m-(\d[\d\.]+)/" ),
286 array( 'pkg' => 'nghttp',
287 'regex' => "/nghttp2-(\d[\d\.]+)/" ),
290 foreach( $match as $m )
293 if ( preg_match( "/$pkg/", $line ) )
294 return $m[ 'regex' ];
297 return "/\D*(\d.*\d)\D*$/";
300 get_current(); // Get what is in the book
302 // Get latest version for each package
303 foreach ( $book as $pkg => $data )
307 $base = $data[ 'basename' ];
308 $url = $data[ 'url' ];
309 $bver = $data[ 'version' ];
311 echo "book index: $book_index $bver $url \n";
313 $v = get_packages( $book_index, $url );
314 $vers[ $book_index ] = $v;
317 html(); // Write html output