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