source: lfs-latest-git.php@ 6ad40199

12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since 6ad40199 was 3f56392, checked in by Bruce Dubbs <bdubbs@…>, 10 months ago

Fix zlib currency

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