Update to firefox-78.10.0 in svn
[beyond_linux_from_scratch.git] / scripts / blfs-chapter20.php
blob586d419cbd12cbc958bce5b21f3057cb2cacbb44
1 #! /usr/bin/php
2 <?php
4 include 'blfs-include.php';
6 $CHAPTER = '20';
7 $CHAPTERS = 'Chapters 20-23';
8 $START_PACKAGE = 'httpd';
9 $STOP_PACKAGE = 'unbound';
11 $renames = array();
12 $renames[ 'sendmail.' ] = 'sendmail';
13 $renames[ 'virtuoso-opensource' ] = 'virtuoso';
15 $ignores = array();
16 $ignores[ 'sqlite-doc' ] = '';
18 //$current="httpd";
20 $regex = array();
21 $regex[ 'vsftpd' ] = "/^.*vsftpd-(\d[\d\.]+\d) released.*$/";
22 //$regex[ 'db' ] = "/^.*Berkeley DB (\d[\d\.]+\d).tar.*$/";
23 $regex[ 'LMDB' ] = "/^.*LMDB_(\d[\d\.]+\d).*$/";
24 $regex[ 'mysql' ] = "/^.*Current Generally Available Release: (\d[\d\.]+\d).*$/";
25 $regex[ 'soprano' ] = "/^.*Download soprano-(\d[\d\.]*).tar.*$/";
26 $regex[ 'xinetd' ] = "/^.*xinetd_(\d[\d\.]*).orig.tar.*$/";
27 $regex[ 'mariadb' ] = "/^.*Download (\d[\d\.]*\d) Stable.*$/";
28 $regex[ 'sqlite-autoconf' ] = "/^.*sqlite-autoconf-([\d]+).tar.*$/";
29 $regex[ 'virtuoso-opensource' ] = "/^.*Download virtuoso-opensource-(\d[\d\.]*).tar.*$/";
31 $url_fix = array (
33 array( 'pkg' => 'xinetd',
34 'match' => '^.*$',
35 'replace' => "http://packages.debian.org/sid/xinetd" ),
37 array( 'pkg' => 'bind',
38 'match' => '^.*$',
39 'replace' => "https://downloads.isc.org/isc/bind9" ),
41 array( 'pkg' => 'soprano',
42 'match' => '^.*$',
43 'replace' => "http://sourceforge.net/projects/soprano/files" ),
45 array( 'pkg' => 'virtuoso-opensource',
46 'match' => '^.*$',
47 'replace' => "http://sourceforge.net/projects/virtuoso/files" ),
49 array( 'pkg' => 'sqlite-autoconf',
50 'match' => '^.*$',
51 'replace' => "https://sqlite.org/download.html" ),
53 array( 'pkg' => 'mysql',
54 'match' => '^.*$',
55 'replace' => "http://dev.mysql.com/downloads" ),
57 array( 'pkg' => 'mariadb',
58 'match' => '^.*$',
59 'replace' => "https://downloads.mariadb.org" ),
61 array( 'pkg' => 'openldap',
62 'match' => '^.*$',
63 'replace' => "https://www.openldap.org" ),
65 // array( 'pkg' => 'db',
66 // 'match' => '^.*$',
67 // 'replace' => "http://www.oracle.com/technetwork/products/berkeleydb/downloads/index.html" ),
69 array( 'pkg' => 'vsftpd',
70 'match' => '^.*$',
71 'replace' => "https://security.appspot.com/vsftpd.html#download" ),
73 array( 'pkg' => 'postgresql',
74 'match' => '^.*$',
75 'replace' => "http://ftp.postgresql.org/pub/source" ),
77 array( 'pkg' => 'postfix',
78 'match' => '^.*$',
79 'replace' => "ftp://ftp.porcupine.org/mirrors/postfix-release/official" ),
80 #'replace' => "http://www.postfix.org/announcements.html" ),
81 #'replace' => "ftp://ftp.reverse.net/pub/postfix/official" ),
83 array( 'pkg' => 'LMDB',
84 'match' => '^.*$',
85 'replace' => "https://github.com/LMDB/lmdb/releases" ),
89 function get_packages( $package, $dirpath )
91 global $regex;
92 global $book_index;
93 global $url_fix;
94 global $current;
96 if ( isset( $current ) && $book_index != "$current" ) return 0;
98 if ( $package == "db" ) return "manual";
100 // Fix up directory path
101 foreach ( $url_fix as $u )
103 $replace = $u[ 'replace' ];
104 $match = $u[ 'match' ];
106 if ( isset( $u[ 'pkg' ] ) )
108 if ( $package == $u[ 'pkg' ] )
110 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
111 break;
114 else
116 if ( preg_match( "/$match/", $dirpath ) )
118 $dirpath = preg_replace( "/$match/", "$replace", $dirpath );
119 break;
124 // Check for ftp
125 if ( preg_match( "/^ftp/", $dirpath ) )
128 // bind
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/" );
140 return find_max( $lines2, "/bind-9/", "/^.*bind-(\d+[\d\.P-]+).tar.*$/" );
143 // Get listing
144 $lines = http_get_file( "$dirpath/" );
146 else // http
148 // Customize http directories as needed
150 if ( $book_index == "dovecot" )
152 // Get the max directory and adjust the directory path
153 $dirpath = "https://dovecot.org/releases";
154 $lines1 = http_get_file( "$dirpath/" );
155 $dir = find_max( $lines1, "/^\s*\d+/", "/^\s*(\d+[\d\.]+)\/.*$/" );
156 $dirpath .= "/$dir/";
159 $lines = http_get_file( $dirpath );
160 //print_r($lines);
161 if ( ! is_array( $lines ) ) return $lines;
162 } // End fetch
164 if ( isset( $regex[ $package ] ) )
166 // Custom search for latest package name
167 foreach ( $lines as $l )
169 if ( preg_match( '/^\h*$/', $l ) ) continue;
170 $ver = preg_replace( $regex[ $package ], "$1", $l );
172 if ( $ver == $l ) continue;
174 if ( $package == "sqlite-autoconf" )
175 $ver = preg_replace( "/\./", "0", $ver );
177 return $ver; // Return first match of regex
180 return 0; // This is an error
183 if ( $book_index == "qpopper" )
184 return find_max( $lines, '/qpopper[\d\.]+.tar.*$/', '/^.* qpopper([\d\.]+).tar.*$/' );
186 if ( $book_index == "bind" )
187 return find_even_max( $lines, '/^ *\d\./', '/^.* ([\d\.P-]+)\/.*$/' );
189 if ( $book_index == "sendmail." )
190 return find_max( $lines, '/sendmail\.[\d\.]+.tar.*$/', '/^.* sendmail\.([\d\.]+).tar.*$/' );
192 if ( $book_index == "openldap" )
193 return find_max( $lines, '/OpenLDAP \d/', '/^.*OpenLDAP ([\d\.]+)*$/' );
195 if ( $book_index == "proftpd" )
196 return find_max( $lines, '/proftpd-[a-m\d\.]+.tar.*$/',
197 '/^.* proftpd-([a-m\d\.]+).tar.*$/' );
199 if ( $book_index == "dovecot" )
200 return find_max( $lines, '/dovecot-/', '/^.*dovecot-([\d\.]+).tar.*$/' );
202 if ( $book_index == "postgresql" )
203 return find_max( $lines, '/v\d/', '/^.*v([\d\.]+)\/.*$/' );
205 if ( $book_index == "postfix" )
206 return find_max( $lines, '/postfix-/', '/^.*postfix-([\d\.]+).tar.*$/' );
208 // Most packages are in the form $package-n.n.n
209 // Occasionally there are dashes (e.g. 201-1)
210 $max = find_max( $lines, "/$package/", "/^.*$package-([\d\.]*\d)\.tar.*$/" );
211 return $max;
214 Function get_pattern( $line )
216 // Set up specific patter matches for extracting book versions
217 $match = array();
219 $match = array(
220 array( 'pkg' => 'bind',
221 'regex' => "/bind-(\d[\d\.P-]+)/" ),
223 array( 'pkg' => 'proftpd',
224 'regex' => "/proftpd-(\d[a-z\d\.]+)/" ),
227 foreach( $match as $m )
229 $pkg = $m[ 'pkg' ];
230 if ( preg_match( "/$pkg/", $line ) )
231 return $m[ 'regex' ];
234 return "/\D*(\d.*\d)\D*$/";
237 get_current(); // Get what is in the book
239 // Get latest version for each package
240 foreach ( $book as $pkg => $data )
242 $book_index = $pkg;
244 $base = $data[ 'basename' ];
245 $url = $data[ 'url' ];
246 $bver = $data[ 'version' ];
248 echo "book index: $book_index $bver $url\n";
250 $v = get_packages( $book_index, $url );
251 $vers[ $book_index ] = $v;
254 html(); // Write html output