From 0a7ea3844b96abc66377773af4daef0c9fb8cf29 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Thu, 17 Jan 2013 06:41:15 +1100 Subject: [PATCH] createing a version file parser for the distro site of nodejs --- lxc/parse_dist.php | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 158 insertions(+), 0 deletions(-) create mode 100644 lxc/parse_dist.php diff --git a/lxc/parse_dist.php b/lxc/parse_dist.php new file mode 100644 index 0000000..eb846a9 --- /dev/null +++ b/lxc/parse_dist.php @@ -0,0 +1,158 @@ +]*href="(.+)"/', $distbase, $firstlist); + +$versions = array(); + +foreach($firstlist[1] as $chk) { + //echo "Got: $chk\n"; + if(preg_match('/v[0-9]+.[0-9]+.[0-9]+\//', $chk)) { + if(preg_match('/v([0-9]+.[0-9]+.[0-9]+)\//', $chk, $vlist)) { + $versions[$vlist[1]] = $chk; + } + } +} + +foreach($versions as $key => $val) { + // now we get each version and parse whats in its directory + echo "Checking $key => $baseurl/$val\n"; + + //if(preg_match("/0\.8\.[1].*/", $key)) { + $urlnow = "$baseurl/$val"; + $vers_dir = file_get_contents($urlnow); + + preg_match_all('/]*href="(.+)"/', $vers_dir, $fileslist); + + checkFilesList(rtrim($val, "/"), $key, $fileslist); + //} +} + + +// done! +//echo "and fver is now\n"; +//var_dump($fver); + +echo "dumping to versions file\n"; +$versfile = fopen("./versions_file", "w"); +if($versfile !== false) { + fwrite($versfile, "baseurl:$baseurl\n"); + foreach($fver as $line) { + fwrite($versfile, "$line\n"); + } + fclose($versfile); +} else { + echo "Failed to open vers file!\n"; +} + +function checkFilesList($url, $vers, $fileslist) { + global $fver, $baseurl, $fvern; + + echo "Checking $url, $vers\n"; + + $shalist = array(); + + foreach($fileslist[1] as $fname) { + $is_echo = false; + $flurl = ""; + $arch = ""; + $plat = ""; + $thissha = ""; + + if($fname == "SHASUMS.txt") { + //$shas = file_get_ + $shas_r = file_get_contents("$baseurl/$url/SHASUMS.txt"); + $shalist = explode("\n", $shas_r); + foreach($shalist as $ssha) { + $fsha = preg_split("/[ \t]+/", $ssha); + if(isset($fsha[1])) $shalist[$fsha[1]] = $fsha[0]; + } + //echo "Shasums file: $fname\n"; + //var_dump($shalist); + } else if($fname == "MD5SUMS.txt") { + // nothing yet + } else if(preg_match("/.*linux.*64\.tar\.gz/", $fname)) { + //echo "64 bit version for linux: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + $is_echo = true; + $plat = "linux"; + $arch = "x86_64"; + } else if(preg_match("/.*linux.*86\.tar\.gz/", $fname)) { + //echo "32 bit version for linux: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:linux:i686:$thissha\n"; + $is_echo = true; + $plat = "linux"; + $arch = "i686"; + } else if(preg_match("/.*darwin.*86\.tar\.gz/", $fname)) { + //echo "32 bit version for darwin: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:darwin:i686:$thissha\n"; + $is_echo = true; + $plat = "darwin"; + $arch = "i686"; + } else if(preg_match("/.*darwin.*64\.tar\.gz/", $fname)) { + //echo "64 bit version for darwin: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:darwin:x86_64:$thissha\n"; + $is_echo = true; + $plat = "darwin"; + $arch = "x86_64"; + } else if(preg_match("/.*sunos.*64\.tar\.gz/", $fname)) { + // echo "64 bit version for sunos: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:sunos:x86_64:$thissha\n"; + $is_echo = true; + $plat = "sunos"; + $arch = "x86_64"; + } else if(preg_match("/.*sunos.*86\.tar\.gz/", $fname)) { + //echo "32 bit version for sunos: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:sunos:i686:$thissha\n"; + $is_echo = true; + $plat = "sunos"; + $arch = "i686"; + } else if(preg_match("/.*linux-arm.*\.tar\.gz/", $fname)) { + // echo "arm for linux: $fname\n"; + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:linux:armhf:$thissha\n"; + $is_echo = true; + $plat = "linux"; + $arch = "armhf"; + } else if(preg_match("/node-v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz/", $fname)) { + $thissha = "-"; + if(isset($shalist[$fname])) $thissha = $shalist[$fname]; + //echo "$vers:$url/$fname:linux:armhf:$thissha\n"; + $is_echo = true; + $plat = "src"; + $arch = "-"; + } + + if($is_echo) { + $fver[$fvern++] = "$vers:$plat:$arch:$url/$fname:$thissha"; + } + } +} +?> \ No newline at end of file -- 1.7.0.4