source: lfs-latest-git.php@ fc9a319

12.0 12.0-rc1 12.1 12.1-rc1 bdubbs/gcc13 multilib renodr/libudev-from-systemd trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since fc9a319 was fc9a319, checked in by Bruce Dubbs <bdubbs@…>, 13 months ago

Update currency for flit-core

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