source: lfs-latest-git.php@ b56430b

12.2 12.2-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.2 xry111/multilib
Last change on this file since b56430b was b56430b, checked in by Bruce Dubbs <bdubbs@…>, 8 weeks ago

Update currency for lz.

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