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