4 include 'blfs-include.php';
7 $CHAPTERS = 'Chapters 14-16';
8 $START_PACKAGE = 'dhcpcd';
9 $STOP_PACKAGE = 'wireshark';
12 //$renames[ 'net-tools-CVS_' ] = 'net-tools';
13 $renames[ 'wireless_tools.' ] = 'wireless_tools';
14 $renames[ 'whois_' ] = 'whois';
15 $renames[ 'bind' ] = 'bind9';
19 //$current="bridge-utils";
21 $regex[ 'mod_dnssd' ] = "/^.*mod_dnssd ([\d\.]*).*$/";
22 $regex[ 'wireless_tools.' ] = "/^.*latest stable version.*version (\d\d).*$/";
23 $regex[ 'wicd' ] = "/^.*Latest version is ([\d\.]*).*$/";
27 array( 'pkg' => 'rsync',
29 'replace' => "https://download.samba.org/pub/rsync" ),
31 array( 'pkg' => 'cifs-utils',
33 'replace' => "https://download.samba.org/pub/linux-cifs/cifs-utils" ),
35 array( 'pkg' => 'samba',
37 'replace' => "https://download.samba.org/pub/samba/stable" ),
39 array( 'pkg' => 'dhcpcd',
41 'replace' => "http://roy.marples.name/downloads/dhcpcd" ),
43 array( 'pkg' => 'bind',
45 'replace' => "https://downloads.isc.org/isc/bind9" ),
47 array( 'pkg' => 'dhcp',
49 'replace' => "https://downloads.isc.org/isc/dhcp" ),
51 array( 'pkg' => 'nfs-utils',
53 'replace' => "http://sourceforge.net/projects/nfs/files" ),
55 array( 'pkg' => 'NetworkManager',
57 'replace' => "https://download.gnome.org/sources/NetworkManager" ),
59 array( 'pkg' => 'ntp',
61 'replace' => "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2" ),
63 array( 'pkg' => 'rpcbind',
65 'replace' => "http://sourceforge.net/projects/rpcbind/files" ),
67 array( 'pkg' => 'wireless_tools.',
69 'replace' => "https://hewlettpackard.github.io/wireless-tools/Tools.html#latest" ),
71 array( 'pkg' => 'avahi',
73 'replace' => "https://github.com/lathiat/avahi/releases" ),
75 array( 'pkg' => 'whois',
77 'replace' => "https://github.com/rfc1036/whois/releases" ),
79 array( 'pkg' => 'nmap',
81 'replace' => "http://nmap.org/dist" ),
83 array( 'pkg' => 'traceroute',
85 'replace' => "http://sourceforge.net/projects/traceroute/files" ),
87 array( 'pkg' => 'wicd',
89 'replace' => "https://launchpad.net/wicd" ),
92 function get_packages( $package, $dirpath )
99 if ( isset( $current ) && $book_index != "$current" ) return 0;
101 // Fix up directory path
102 foreach ( $url_fix as $u )
104 $replace = $u[ 'replace' ];
105 $match = $u[ 'match' ];
107 if ( isset( $u[ 'pkg' ] ) )
109 if ( $package == $u[ 'pkg' ] )
111 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
117 if ( preg_match( "/$match/", $dirpath ) )
119 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
126 if ( preg_match( "/^ftp/", $dirpath ) )
129 if ( $book_index == "bind" )
131 // Get the max directory and adjust the directory path
132 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
133 $position = strrpos( $dirpath, "/" );
134 $dirpath = substr ( $dirpath, 0, $position ); // Up 1
135 $lines1 = http_get_file( "$dirpath/" );
136 $dir = find_even_max( $lines1, "/\.[\d\.P-]+\s*$/", "/^.* (\d\.[\d\.P-]+)$/" );
137 $dirpath .= "/$dir/";
138 $lines2 = http_get_file( $dirpath );
139 return find_max( $lines2, "/bind-9/", "/^.*bind-(\d+[\d\.P\-]+).tar.*$/" );
143 if ( $book_index == "dhcp" )
145 // Get the max directory and adjust the directory path
146 $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
147 $position = strrpos( $dirpath, "/" );
148 $dirpath = substr ( $dirpath, 0, $position );
149 $lines = http_get_file( "$dirpath/" );
150 $dir = find_max( $lines, "/\d$/", "/^.* (\d\.[\d\.P\-]+)$/" );
151 $dirpath .= "/$dir/";
155 $lines = http_get_file( "$dirpath/" );
159 if ( $book_index == "NetworkManager" )
161 // Get the max directory and adjust the directory path
162 $lines1 = http_get_file( "$dirpath/" );
163 $dir = find_even_max( $lines1, "/\d[\d\.]+/", "/^\s*(\d[\d\.]+).*$/" );
164 $dirpath .= "/$dir/";
167 $lines = http_get_file( $dirpath );
169 if ( ! is_array( $lines ) ) return $lines;
172 if ( isset( $regex[ $package ] ) )
174 // Custom search for latest package name
175 foreach ( $lines as $l )
177 if ( preg_match( '/^\h*$/', $l ) ) continue;
178 $ver = preg_replace( $regex[ $package ], "$1", $l );
179 if ( $ver == $l ) continue;
181 if ( $book_index == "exiv" ) $ver = "2-$ver";
183 return $ver; // Return first match of regex
186 return 0; // This is an error
189 if ( $book_index == "dhcp" )
190 //return find_max( $lines, '/dhcp/', '/^.*dhcp-([\d\.P-]+).tar.*$/' );
191 return find_even_max( $lines, '/^ *\d\./', '/^.* ([\d\.P-]+)\/\d.*$/' );
193 if ( $book_index == "bind" )
194 return find_even_max( $lines, '/^ *\d\./', '/^.* ([\d\.P-]+)\/\d.*$/' );
196 if ( $book_index == "ncftp" )
197 return find_max( $lines, '/ncftp/', '/^.*ncftp-([\d\.]+)-src.tar.*$/' );
199 if ( $book_index == "net-tools-CVS" )
200 return find_max( $lines, '/net-tools/', '/^.*_(\d+).tar.*$/' );
202 if ( $book_index == "ntp" )
204 $dir = max_parent( $dirpath, "ntp-" );
205 $lines = http_get_file( "$dir" );
206 return find_max( $lines, '/ntp-.*tar/', '/^ntp-([\d\.p]+).tar.*$/' );
209 if ( $book_index == "whois" )
210 return find_even_max( $lines, '/v\d/', '/^.*v([\d\.]+).*$/' );
212 if ( $book_index == "wireshark" )
213 return find_even_max( $lines, '/wireshark/', '/^.*wireshark-([\d\.]+).tar.*$/' );
215 // Most packages are in the form $package-n.n.n
216 // Occasionally there are dashes (e.g. 201-1)
217 $max = find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d)\.tar.*$/" );
221 Function get_pattern( $line )
223 // Set up specific patter matches for extracting book versions
227 //array( 'pkg' => 'bind',
228 // 'regex' => "/bind(\d+\/[\d\.]+)/" ),
231 foreach( $match as $m )
234 if ( preg_match( "/$pkg/", $line ) )
235 return $m[ 'regex' ];
238 return "/\D*(\d.*\d)\D*$/";
241 get_current(); // Get what is in the book
243 // Get latest version for each package
244 foreach ( $book as $pkg => $data )
248 $base = $data[ 'basename' ];
249 $url = $data[ 'url' ];
250 $bver = $data[ 'version' ];
252 echo "book index: $book_index $bver $url\n";
254 $v = get_packages( $book_index, $url );
255 $vers[ $book_index ] = $v;
258 html(); // Write html output