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