source: lfs-latest.php@ 111dbef

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next 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 111dbef was 111dbef, checked in by Bruce Dubbs <bdubbs@…>, 7 years ago

Update lfs currency adding python and removing systemd man pages

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11313 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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