source: lfs-latest.php@ 9901037e

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 8.3 8.3-rc1 8.3-rc2 8.4 8.4-rc1 9.0 9.0-rc1 9.1 9.1-rc1 cross-chap5 ml-11.0 multilib old-trunk trunk xry111/git-transition xry111/glibc-2.34 xry111/tester-nohack xry111/usr-move
Last change on this file since 9901037e was 9901037e, checked in by Bruce Dubbs <bdubbs@…>, 4 years ago

Update currency for mpc

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

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