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