1 | #! /usr/bin/php
|
---|
2 | <?php
|
---|
3 | $dirs = array();
|
---|
4 | $vers = array();
|
---|
5 |
|
---|
6 | date_default_timezone_set( "GMT" );
|
---|
7 | $date = date( "Y-m-d H:i:s" );
|
---|
8 |
|
---|
9 | // Special cases
|
---|
10 | $exceptions = array();
|
---|
11 | //$exceptions[ 'gmp' ] = "UPDIR=/.*(gmp-\d[\d\.-]*\d).*/:DOWNDIR=";
|
---|
12 |
|
---|
13 | $regex = array();
|
---|
14 | //$regex[ 'bzip2' ] = "/^.*current version is ([\d\.]+).*$/";
|
---|
15 | $regex[ 'check' ] = "/^.*Check (\d[\d\.]+\d).*$/";
|
---|
16 | $regex[ 'intltool' ] = "/^.*Latest version is (\d[\d\.]+\d).*$/";
|
---|
17 | $regex[ 'less' ] = "/^.*current released version is less-(\d+).*$/";
|
---|
18 | $regex[ 'mpfr' ] = "/^mpfr-([\d\.]+)\.tar.*$/";
|
---|
19 | $regex[ 'Python' ] = "/^.*Latest Python 3.*Python (3[\d\.]+\d).*$/";
|
---|
20 | $regex[ 'systemd' ] = "/^.*v([\d]+)$/";
|
---|
21 | //$regex[ 'sysvinit' ] = "/^.*sysvinit-([\d\.]+)dsf\.tar.*$/";
|
---|
22 | $regex[ 'tzdata' ] = "/^.*tzdata([\d]+[a-z]).*$/";
|
---|
23 | $regex[ 'xz' ] = "/^.*xz-([\d\.]*\d).*$/";
|
---|
24 | $regex[ 'zlib' ] = "/^.*zlib ([\d\.]*\d).*$/";
|
---|
25 |
|
---|
26 | function find_max( $lines, $regex_match, $regex_replace )
|
---|
27 | {
|
---|
28 | $a = array();
|
---|
29 | if ( ! is_array( $lines ) ) return -1;
|
---|
30 |
|
---|
31 | foreach ( $lines as $line )
|
---|
32 | {
|
---|
33 | if ( ! preg_match( $regex_match, $line ) ) continue;
|
---|
34 |
|
---|
35 | // Isolate the version and put in an array
|
---|
36 | $slice = preg_replace( $regex_replace, "$1", $line );
|
---|
37 | if ( strcmp( $slice, $line ) == 0 ) continue;
|
---|
38 |
|
---|
39 | array_push( $a, $slice );
|
---|
40 | }
|
---|
41 |
|
---|
42 | // SORT_NATURAL requires php-5.4.0 or later
|
---|
43 | rsort( $a, SORT_NATURAL ); // Max version is at the top
|
---|
44 | return ( isset( $a[0] ) ) ? $a[0] : -2;
|
---|
45 | }
|
---|
46 |
|
---|
47 | function find_even_max( $lines, $regex_match, $regex_replace )
|
---|
48 | {
|
---|
49 | $a = array();
|
---|
50 | foreach ( $lines as $line )
|
---|
51 | {
|
---|
52 | if ( ! preg_match( $regex_match, $line ) ) continue;
|
---|
53 |
|
---|
54 | // Isolate the version and put in an array
|
---|
55 | $slice = preg_replace( $regex_replace, "$1", $line );
|
---|
56 |
|
---|
57 | if ( "x$slice" == "x$line" ) continue;
|
---|
58 |
|
---|
59 | // Skip odd numbered minor versions and minors > 80
|
---|
60 | list( $major, $minor, $rest ) = explode( ".", $slice . ".0" );
|
---|
61 | if ( $minor % 2 == 1 ) continue;
|
---|
62 | if ( $minor > 80 ) continue;
|
---|
63 | array_push( $a, $slice );
|
---|
64 | }
|
---|
65 |
|
---|
66 | rsort( $a, SORT_NATURAL ); // Max version is at the top
|
---|
67 | return ( isset( $a[0] ) ) ? $a[0] : -2;
|
---|
68 | }
|
---|
69 |
|
---|
70 | function http_get_file( $url )
|
---|
71 | {
|
---|
72 | if ( ! preg_match( "/sourceforge/", $url ) &&
|
---|
73 | ! preg_match( "/mpfr/", $url ) &&
|
---|
74 | ! preg_match( "/psmisc/", $url ) )
|
---|
75 | {
|
---|
76 | exec( "curl --location --silent --max-time 30 $url", $dir );
|
---|
77 |
|
---|
78 | $s = implode( "\n", $dir );
|
---|
79 | $dir = strip_tags( $s );
|
---|
80 | return explode( "\n", $dir );
|
---|
81 | }
|
---|
82 | else if ( preg_match( "/mpfr/", $url ) )
|
---|
83 | {
|
---|
84 | # There seems to be a problem with the mpfs certificate
|
---|
85 | exec( "curl --location --silent --insecure --max-time 30 $url", $dir );
|
---|
86 | $s = implode( "\n", $dir );
|
---|
87 | $dir = strip_tags( $s );
|
---|
88 | return explode( "\n", $dir );
|
---|
89 | }
|
---|
90 | else
|
---|
91 | {
|
---|
92 | exec( "lynx -dump $url 2>/dev/null", $lines );
|
---|
93 | return $lines;
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | function max_parent( $dirpath, $prefix )
|
---|
98 | {
|
---|
99 | // First, remove a directory
|
---|
100 | $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
|
---|
101 | $position = strrpos( $dirpath, "/" );
|
---|
102 | $dirpath = substr ( $dirpath, 0, $position );
|
---|
103 |
|
---|
104 | $lines = http_get_file( $dirpath );
|
---|
105 |
|
---|
106 | $regex_match = "#${prefix}[\d\.]+/#";
|
---|
107 | $regex_replace = "#^.*(${prefix}[\d\.]+)/.*$#";
|
---|
108 | $max = find_max( $lines, $regex_match, $regex_replace );
|
---|
109 |
|
---|
110 | return "$dirpath/$max";
|
---|
111 | }
|
---|
112 |
|
---|
113 | function get_packages( $package, $dirpath )
|
---|
114 | {
|
---|
115 | global $exceptions;
|
---|
116 | global $regex;
|
---|
117 |
|
---|
118 | //if ( $package != "psmisc" ) return 0; // debug
|
---|
119 |
|
---|
120 | if ( $package == "bc" ) $dirpath = "https://github.com/gavinhoward/bc/releases";
|
---|
121 | if ( $package == "check" ) $dirpath = "https://github.com/libcheck/check/releases";
|
---|
122 | if ( $package == "e2fsprogs" ) $dirpath = "https://sourceforge.net/projects/e2fsprogs/files/e2fsprogs";
|
---|
123 | if ( $package == "expat" ) $dirpath = "https://sourceforge.net/projects/expat/files";
|
---|
124 | if ( $package == "elfutils" ) $dirpath = "https://sourceware.org/ftp/elfutils";
|
---|
125 | if ( $package == "expect" ) $dirpath = "https://sourceforge.net/projects/expect/files";
|
---|
126 | if ( $package == "eudev" ) $dirpath = "https://github.com/eudev-project/eudev/releases";
|
---|
127 | if ( $package == "file" ) $dirpath = "https://github.com/file/file/tags";
|
---|
128 | if ( $package == "flex" ) $dirpath = "https://github.com/westes/flex/releases";
|
---|
129 | if ( $package == "gcc" ) $dirpath = max_parent( $dirpath, "gcc-" );
|
---|
130 | if ( $package == "iana-etc" ) $dirpath = "https://github.com/Mic92/iana-etc/releases";
|
---|
131 | if ( $package == "intltool" ) $dirpath = "https://launchpad.net/intltool/trunk";
|
---|
132 | if ( $package == "libffi" ) $dirpath = "https://github.com/libffi/libffi/releases";
|
---|
133 | if ( $package == "meson" ) $dirpath = "https://github.com/mesonbuild/meson/releases";
|
---|
134 | if ( $package == "mpc" ) $dirpath = "https://ftp.gnu.org/gnu/mpc";
|
---|
135 | if ( $package == "mpfr" ) $dirpath = "https://mpfr.loria.fr/mpfr-current";
|
---|
136 | if ( $package == "ncurses" ) $dirpath = "https://invisible-mirror.net/archives/ncurses";
|
---|
137 | if ( $package == "ninja" ) $dirpath = "https://github.com/ninja-build/ninja/releases";
|
---|
138 | if ( $package == "procps-ng" ) $dirpath = "https://gitlab.com/procps-ng/procps/-/tags";
|
---|
139 | if ( $package == "psmisc" ) $dirpath = "https://gitlab.com/psmisc/psmisc/-/tags";
|
---|
140 | if ( $package == "Python" ) $dirpath = "https://www.python.org/downloads/source/";
|
---|
141 | if ( $package == "shadow" ) $dirpath = "https://github.com/shadow-maint/shadow/releases";
|
---|
142 | if ( $package == "MarkupSafe" ) $dirpath = "https://pypi.python.org/pypi/MarkupSafe/";
|
---|
143 | if ( $package == "Jinja" ) $dirpath = "https://pypi.python.org/pypi/Jinja2/";
|
---|
144 | if ( $package == "systemd" ) $dirpath = "https://github.com/systemd/systemd/releases";
|
---|
145 | //if ( $package == "tcl" ) $dirpath = "https://sourceforge.net/projects/tcl/files";
|
---|
146 | if ( $package == "tcl" ) $dirpath = "https://www.tcl.tk/software/tcltk/download.html";
|
---|
147 | if ( $package == "util-linux" ) $dirpath = max_parent( $dirpath, "v." );
|
---|
148 | if ( $package == "vim" ) $dirpath = "https://github.com/vim/vim/tags";
|
---|
149 | if ( $package == "wheel" ) $dirpath = "https://pypi.org/project/wheel/#files";
|
---|
150 | if ( $package == "zstd" ) $dirpath = "https://github.com/facebook/zstd/releases";
|
---|
151 |
|
---|
152 | // Check for ftp
|
---|
153 | if ( preg_match( "/^ftp/", $dirpath ) )
|
---|
154 | {
|
---|
155 | echo "ftp should not occur\n";
|
---|
156 | /*
|
---|
157 | $dirpath = substr( $dirpath, 6 ); // Remove ftp://
|
---|
158 | $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
|
---|
159 | $position = strpos( $dirpath, "/" ); // Divide at first slash
|
---|
160 | $server = substr( $dirpath, 0, $position );
|
---|
161 | $path = substr( $dirpath, $position );
|
---|
162 |
|
---|
163 | $conn = ftp_connect( $server );
|
---|
164 | ftp_login( $conn, "anonymous", "" );
|
---|
165 |
|
---|
166 | // See if we need special handling
|
---|
167 | if ( isset( $exceptions[ $package ] ) )
|
---|
168 | {
|
---|
169 | $specials = explode( ":", $exceptions[ $package ] );
|
---|
170 |
|
---|
171 | foreach ( $specials as $i )
|
---|
172 | {
|
---|
173 | list( $op, $regexp ) = explode( "=", $i );
|
---|
174 |
|
---|
175 | switch ($op)
|
---|
176 | {
|
---|
177 | case "UPDIR":
|
---|
178 | // Remove last dir from $path
|
---|
179 | $position = strrpos( $path, "/" );
|
---|
180 | $path = substr( $path, 0, $position );
|
---|
181 |
|
---|
182 | // Get dir listing
|
---|
183 | $lines = ftp_rawlist ($conn, $path);
|
---|
184 | $max = find_max( $lines, $regexp, $regexp );
|
---|
185 | break;
|
---|
186 |
|
---|
187 | case "DOWNDIR":
|
---|
188 | // Append found directory
|
---|
189 | $path .= "/$max";
|
---|
190 | break;
|
---|
191 |
|
---|
192 | default:
|
---|
193 | echo "Error in specials array for $package\n";
|
---|
194 | return -5;
|
---|
195 | break;
|
---|
196 | }
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | $lines = ftp_rawlist ($conn, $path);
|
---|
201 | ftp_close( $conn );
|
---|
202 | */
|
---|
203 | }
|
---|
204 | else // http(s)
|
---|
205 | {
|
---|
206 | // Customize http directories as needed
|
---|
207 | if ( $package == "tzdata" )
|
---|
208 | {
|
---|
209 | // Remove two directories
|
---|
210 | $dirpath = rtrim ( $dirpath, "/" ); // Trim any trailing slash
|
---|
211 | $position = strrpos( $dirpath, "/" );
|
---|
212 | $dirpath = substr ( $dirpath, 0, $position );
|
---|
213 | $position = strrpos( $dirpath, "/" );
|
---|
214 | $dirpath = substr ( $dirpath, 0, $position );
|
---|
215 | }
|
---|
216 |
|
---|
217 | $lines = http_get_file( $dirpath );
|
---|
218 | if ( ! is_array( $lines ) ) return -6;
|
---|
219 | } // End fetch
|
---|
220 |
|
---|
221 | if ( isset( $regex[ $package ] ) )
|
---|
222 | {
|
---|
223 | // Custom search for latest package name
|
---|
224 | foreach ( $lines as $l )
|
---|
225 | {
|
---|
226 | $ver = preg_replace( $regex[ $package ], "$1", $l );
|
---|
227 | if ( $ver == $l ) continue;
|
---|
228 | return $ver; // Return first match of regex
|
---|
229 | }
|
---|
230 |
|
---|
231 | return -7; // This is an error
|
---|
232 | }
|
---|
233 |
|
---|
234 | if ( $package == "perl" ) // Custom for perl
|
---|
235 | {
|
---|
236 | $tmp = array();
|
---|
237 |
|
---|
238 | foreach ( $lines as $l )
|
---|
239 | {
|
---|
240 | if ( preg_match( "/sperl/", $l ) ) continue; // Don't want this
|
---|
241 | $ver = preg_replace( "/^.*perl-([\d\.]+\d)\.tar.*$/", "$1", $l );
|
---|
242 | if ( $ver == $l ) continue;
|
---|
243 | list( $s1, $s2, $rest ) = explode( ".", $ver );
|
---|
244 | if ( $s2 % 2 == 1 ) continue; // Remove odd minor versions
|
---|
245 | array_push( $tmp, $l );
|
---|
246 | }
|
---|
247 |
|
---|
248 | $lines = $tmp;
|
---|
249 | }
|
---|
250 |
|
---|
251 | if ( $package == "attr" ||
|
---|
252 | $package == "acl" )
|
---|
253 | {
|
---|
254 | return find_max( $lines, "/$package/", "/^.*$package-([\d\.-]*\d).tar.*$/" );
|
---|
255 | }
|
---|
256 |
|
---|
257 | if ( $package == "e2fsprogs" )
|
---|
258 | return find_max( $lines, "/v\d/", "/^.*v(\d[\d\.]+\d).*$/" );
|
---|
259 |
|
---|
260 | if ( $package == "eudev" )
|
---|
261 | return find_max( $lines, "/Release/", "/^.*Release (\d[\d\.]+\d).*$/" );
|
---|
262 |
|
---|
263 | if ( $package == "expect" )
|
---|
264 | return find_max( $lines, "/expect/", "/^.*expect(\d[\d\.]+\d).tar.*$/" );
|
---|
265 |
|
---|
266 | if ( $package == "elfutils" )
|
---|
267 | return find_max( $lines, "/^\d/", "/^(\d[\d\.]+\d)\/.*$/" );
|
---|
268 |
|
---|
269 | if ( $package == "iana-etc" )
|
---|
270 | return find_max( $lines, "/^\s*20\d\d/", "/^\s+(\d+).*$/" );
|
---|
271 |
|
---|
272 | if ( $package == "meson" )
|
---|
273 | return find_max( $lines, "/^\s+\d\./", "/^\s+([\d\.]+)$/" );
|
---|
274 |
|
---|
275 | if ( $package == "shadow" )
|
---|
276 | return find_max( $lines, "/^\s+\d\./", "/^\s+([\d\.]+)$/" );
|
---|
277 |
|
---|
278 | if ( $package == "XML-Parser" )
|
---|
279 | {
|
---|
280 | $max = find_max( $lines, "/$package/", "/^.*$package-([\d\._]*\d).tar.*$/" );
|
---|
281 | # 2.44_01 is a developer release
|
---|
282 | if ( $max == "2.44_01" ) { return "2.44"; }
|
---|
283 | return $max;
|
---|
284 | }
|
---|
285 |
|
---|
286 | if ( $package == "tcl" )
|
---|
287 | return find_max( $lines, "/tcl\d/", "/^.*tcl(\d\.[\d\.]*\d)-src.*$/" );
|
---|
288 |
|
---|
289 | if ( $package == "ninja" )
|
---|
290 | return find_max( $lines, "/v\d/", "/^.*v(\d[\d\.]*\d).*$/" );
|
---|
291 |
|
---|
292 | if ( $package == "gmp" )
|
---|
293 | return find_max( $lines, "/$package/", "/^.*$package-([\d\._]*\d[a-z]?).tar.*$/" );
|
---|
294 |
|
---|
295 | if ( $package == "dbus" )
|
---|
296 | return find_even_max( $lines, "/$package/", "/^.*$package-([\d\.]+).tar.*$/" );
|
---|
297 |
|
---|
298 | if ( $package == "file" )
|
---|
299 | {
|
---|
300 | $max = find_max( $lines, "/FILE5/", "/^.*FILE(5_\d+)*$/" );
|
---|
301 | return str_replace( "_", ".", $max );
|
---|
302 | }
|
---|
303 |
|
---|
304 | if ( $package == "procps-ng" )
|
---|
305 | return find_max( $lines, "/v\d/", "/^.*v([\d\.]+)$/" );
|
---|
306 |
|
---|
307 | if ( $package == "psmisc" )
|
---|
308 | return find_max( $lines, "/v\d/", "/^.*v([\d\.]+).tar.*$/" );
|
---|
309 |
|
---|
310 | if ( $package == "grub" )
|
---|
311 | return find_max( $lines, "/grub/", "/^.*grub-([\d\.]+).tar.xz.*$/" );
|
---|
312 |
|
---|
313 | if ( $package == "Jinja" )
|
---|
314 | return find_max( $lines, "/Jinja/", "/^.*Jinja2 ([\d\.]+).*$/" );
|
---|
315 |
|
---|
316 | if ( $package == "openssl" )
|
---|
317 | return find_max( $lines, "/openssl/", "/^.*openssl-([\d\.p]*\d.?).tar.*$/" );
|
---|
318 |
|
---|
319 | if ( $package == "vim" )
|
---|
320 | return find_max( $lines, "/v\d\./", "/^.*v([\d\.]+).*$/" );
|
---|
321 |
|
---|
322 | if ( $package == "zstd" )
|
---|
323 | return find_max( $lines, "/Zstandard v/", "/^.*v([\d\.]+).*$/" );
|
---|
324 |
|
---|
325 | // Most packages are in the form $package-n.n.n
|
---|
326 | // Occasionally there are dashes (e.g. 201-1)
|
---|
327 | return find_max( $lines, "/$package/", "/^.*$package-([\d\.-]*\d)\.tar.*$/" );
|
---|
328 | }
|
---|
329 |
|
---|
330 | function get_current()
|
---|
331 | {
|
---|
332 | global $dirs;
|
---|
333 | global $vers;
|
---|
334 |
|
---|
335 | // Fetech from git and get wget-list
|
---|
336 | $current = array();
|
---|
337 | #$lfssvn = "svn://svn.linuxfromscratch.org/LFS/trunk";
|
---|
338 | $lfsgit = "git://git.linuxfromscratch.org/lfs.git";
|
---|
339 |
|
---|
340 | $tmpdir = exec( "mktemp -d /tmp/lfscheck.XXXXXX" );
|
---|
341 | $cdir = getcwd();
|
---|
342 | chdir( $tmpdir );
|
---|
343 | #exec ( "svn --quiet export $lfssvn LFS" );
|
---|
344 | exec ( "git clone $lfsgit LFS" );
|
---|
345 |
|
---|
346 | # Make version.ent
|
---|
347 | chdir( "$tmpdir/LFS" );
|
---|
348 | exec ( "./git-version.sh systemd" );
|
---|
349 |
|
---|
350 | chdir( $cdir );
|
---|
351 |
|
---|
352 | $PAGE = "$tmpdir/LFS/chapter03/chapter03.xml";
|
---|
353 | $STYLESHEET = "$tmpdir/LFS/stylesheets/wget-list.xsl";
|
---|
354 |
|
---|
355 | exec( "xsltproc --xinclude --nonet $STYLESHEET $PAGE", $current );
|
---|
356 | exec( "rm -rf $tmpdir" );
|
---|
357 |
|
---|
358 | foreach ( $current as $line )
|
---|
359 | {
|
---|
360 | $file = basename( $line ) . "\n";
|
---|
361 | if ( preg_match( "/patch$/", $file ) ) { continue; } // Skip patches
|
---|
362 |
|
---|
363 | $file = preg_replace( "/bz2/", '', $file ); // The 2 confusses the regex
|
---|
364 |
|
---|
365 | $file = rtrim( $file );
|
---|
366 | $pkg_pattern = "/(\D*).*/";
|
---|
367 | //$pattern = "/\D*(\d.*\d)\D*/";
|
---|
368 | $pattern = "/\D*(\d.*\d)\D*/";
|
---|
369 |
|
---|
370 | if ( preg_match( "/e2fsprogs/", $file ) )
|
---|
371 | {
|
---|
372 | $pattern = "/e2\D*(\d.*\d)\D*/";
|
---|
373 | $pkg_pattern = "/(e2\D*).*/";
|
---|
374 | }
|
---|
375 |
|
---|
376 | else if ( preg_match( "/tzdata/", $file ) )
|
---|
377 | {
|
---|
378 | $pattern = "/\D*(\d.*[a-z])\.tar\D*/";
|
---|
379 | }
|
---|
380 |
|
---|
381 | else if ( preg_match( "/openssl/", $file ) )
|
---|
382 | {
|
---|
383 | $pattern = "/\D*(\d.*\d.*).tar.*$/";
|
---|
384 | }
|
---|
385 |
|
---|
386 | else if ( preg_match( "/gmp/", $file ) )
|
---|
387 | {
|
---|
388 | $pattern = "/\D*(\d.*[a-z]*)\.tar\D*/";
|
---|
389 | }
|
---|
390 |
|
---|
391 | else if ( preg_match( "/systemd-man-pages/", $file ) ) continue;
|
---|
392 | else if ( preg_match( "/python/" , $file ) ) continue;
|
---|
393 |
|
---|
394 | $version = preg_replace( $pattern, "$1", $file ); // Isolate version
|
---|
395 | $version = preg_replace( "/^\d-/", "", $version ); // Remove leading #-
|
---|
396 |
|
---|
397 | // Touch up package names
|
---|
398 | $pkg_name = preg_replace( $pkg_pattern, "$1", $file );
|
---|
399 | $pkg_name = trim( $pkg_name, "-" );
|
---|
400 |
|
---|
401 | if ( preg_match( "/bzip|iproute/", $pkg_name ) ) { $pkg_name .= "2"; }
|
---|
402 | if ( preg_match( "/^m$/" , $pkg_name ) ) { $pkg_name .= "4"; }
|
---|
403 | if ( preg_match( "/shadow/" , $pkg_name ) ) { $pkg_name = "shadow"; }
|
---|
404 |
|
---|
405 | $dirs[ $pkg_name ] = dirname( $line );
|
---|
406 | $vers[ $pkg_name ] = $version;
|
---|
407 | }
|
---|
408 | }
|
---|
409 |
|
---|
410 | function mail_to_lfs()
|
---|
411 | {
|
---|
412 | global $date;
|
---|
413 | global $vers;
|
---|
414 | global $dirs;
|
---|
415 |
|
---|
416 | $to = "lfs-book@lists.linuxfromscratch.org";
|
---|
417 | $from = "bdubbs@linuxfromscratch.org";
|
---|
418 | $subject = "LFS Package Currency Check - $date GMT";
|
---|
419 | $headers = "From: bdubbs@linuxfromscratch.org";
|
---|
420 |
|
---|
421 | $message = "Package LFS Upstream Flag\n\n";
|
---|
422 |
|
---|
423 | foreach ( $dirs as $pkg => $dir )
|
---|
424 | {
|
---|
425 | //if ( $pkg != "gmp" ) continue; //debug
|
---|
426 | $v = get_packages( $pkg, $dir );
|
---|
427 |
|
---|
428 | $flag = ( $vers[ $pkg ] != $v ) ? "*" : "";
|
---|
429 |
|
---|
430 | // Pad for output
|
---|
431 | $pad = " ";
|
---|
432 | $p = substr( $pkg . $pad, 0, 15 );
|
---|
433 | $l = substr( $vers[ $pkg ] . $pad, 0, 10 );
|
---|
434 | $c = substr( $v . $pad, 0, 10 );
|
---|
435 |
|
---|
436 | $message .= "$p $l $c $flag\n";
|
---|
437 | }
|
---|
438 |
|
---|
439 | exec ( "echo '$message' | mailx -r $from -s '$subject' $to" );
|
---|
440 | }
|
---|
441 |
|
---|
442 | function html()
|
---|
443 | {
|
---|
444 |
|
---|
445 | global $date;
|
---|
446 | global $vers;
|
---|
447 | global $dirs;
|
---|
448 |
|
---|
449 | echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
---|
450 | 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
---|
451 | <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
---|
452 | <head>
|
---|
453 | <title>LFS Package Currency Check - $date</title>
|
---|
454 | <style type='text/css'>
|
---|
455 | h1, h2 {
|
---|
456 | text-align : center;
|
---|
457 | }
|
---|
458 |
|
---|
459 | table {
|
---|
460 | border-width : 1px;
|
---|
461 | border-spacing : 0px;
|
---|
462 | border-style : outset;
|
---|
463 | border-color : gray;
|
---|
464 | border-collapse : separate;
|
---|
465 | background-color: white;
|
---|
466 | margin : 0px auto;
|
---|
467 | }
|
---|
468 |
|
---|
469 | table th {
|
---|
470 | border-width : 1px;
|
---|
471 | padding : 2px;
|
---|
472 | border-style : inset;
|
---|
473 | border-color : gray;
|
---|
474 | background-color: white;
|
---|
475 | }
|
---|
476 |
|
---|
477 | table td {
|
---|
478 | border-width : 1px;
|
---|
479 | padding : 2px;
|
---|
480 | border-style : inset;
|
---|
481 | border-color : gray;
|
---|
482 | background-color: white;
|
---|
483 | }
|
---|
484 | </style>
|
---|
485 |
|
---|
486 | </head>
|
---|
487 | <body>
|
---|
488 | <h1>LFS Package Currency Check</h1>
|
---|
489 | <h2>As of $date GMT</h1>
|
---|
490 |
|
---|
491 | <table>
|
---|
492 | <tr><th>LFS Package</th> <th>LFS Version</th> <th>Latest</th> <th>Flag</th></tr>\n";
|
---|
493 |
|
---|
494 | // Get the latest version of each package
|
---|
495 | foreach ( $dirs as $pkg => $dir )
|
---|
496 | {
|
---|
497 | $v = get_packages( $pkg, $dir );
|
---|
498 | $flag = ( $vers[ $pkg ] != $v ) ? "*" : "";
|
---|
499 | echo "<tr><td>$pkg</td> <td>${vers[ $pkg ]}</td> <td>$v</td> <td>$flag</td></tr>\n";
|
---|
500 | }
|
---|
501 |
|
---|
502 | echo "</table>
|
---|
503 | </body>
|
---|
504 | </html>\n";
|
---|
505 |
|
---|
506 | }
|
---|
507 |
|
---|
508 | function write_to_stdout()
|
---|
509 | {
|
---|
510 |
|
---|
511 | global $date;
|
---|
512 | global $vers;
|
---|
513 | global $dirs;
|
---|
514 |
|
---|
515 | echo "
|
---|
516 | LFS Package Currency Check
|
---|
517 | As of $date GMT
|
---|
518 |
|
---|
519 | LFS Package LFS Version Latest Flag\n";
|
---|
520 |
|
---|
521 | // Get the latest version of each package
|
---|
522 | foreach ( $dirs as $pkg => $dir )
|
---|
523 | {
|
---|
524 | $p_name = sprintf( "%-15s", $pkg ); // package name formatted
|
---|
525 |
|
---|
526 | $b_version = $vers[ $pkg ]; // book version
|
---|
527 | $b_string = sprintf( "%-11s", $b_version ); // book version formatted
|
---|
528 |
|
---|
529 | $latest = get_packages( $pkg, $dir ); // latest version
|
---|
530 | $l_string = sprintf( "%-6s", $latest ); // latest version formatted
|
---|
531 |
|
---|
532 | $flag = ( $b_version != $latest ) ? "*" : "";
|
---|
533 | echo "$p_name $b_string $l_string $flag\n";
|
---|
534 | }
|
---|
535 | }
|
---|
536 |
|
---|
537 | get_current(); // Get what is in the book
|
---|
538 | mail_to_lfs();
|
---|
539 | //html(); // Write html output
|
---|
540 | //write_to_stdout(); // For debugging
|
---|
541 | ?>
|
---|