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