source: lfs-latest-git.php@ 18e99c8

11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 bdubbs/gcc13 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 18e99c8 was 18e99c8, checked in by Bruce Dubbs <bdubbs@…>, 2 years ago

Update lfs currency for wheel

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