# # # add_file "downloads.php" # content [722c77c266946881a9a0b75e5107c0a7004cbb17] # # patch "index.html" # from [45f46f9c8f432b71678c3d69b6dcdc1c48701762] # to [93d3e87aaa239cc3cd1809943c1f0d8707e5af6f] # ============================================================ --- downloads.php 722c77c266946881a9a0b75e5107c0a7004cbb17 +++ downloads.php 722c77c266946881a9a0b75e5107c0a7004cbb17 @@ -0,0 +1,125 @@ + + * Copyleft: GPLv3 + */ + +// this assumes that all packages for a specific platform +// follow a distinct file naming. %version% is replaced with +// the specific monotone version which is tried to match +$matchers = array( + "Tarball" => "/monotone-%version%\.tar\.gz/", + "Linux x86/glibc 2.3" => "/mtn-%version%-linux-x86\.bz2/", + "Mac OS X Installer" => "/monotone-%version%\.dmg/", + "Mac OS X Binary" => "/mtn-%version%-osx(-univ)?\.bz2/", + "Solaris Package" => "/PMmonotone-%version%\.(i386|sparc)\.pkg/", + "Windows Installer" => "/monotone-%version%-setup\.exe/", +); + +$basedir = dirname(__FILE__) . "/downloads"; +$releaseDirs = scandir($basedir, 1); +$latestFiles = array_flip(array_keys($matchers)); +$matchedPlatforms = array(); + +foreach ($releaseDirs as $dir) +{ + if (!is_dir("$basedir/$dir") || $dir == "." || $dir == "..") + continue; + + if (count($matchedPlatforms) == count($matchers)) + break; + + $files = scandir("$basedir/$dir", 1); + $release = $dir; + $newlyMatchedPlatforms = array(); + + foreach ($files as $file) + { + foreach ($matchers as $platform => $matcher) + { + + if (preg_match(str_replace("%version%", $release, $matcher), $file) && + !in_array($platform, $matchedPlatforms)) + { + if (!is_array($latestFiles[$platform])) + { + $latestFiles[$platform] = array(); + } + $latestFiles[$platform][] = "$release/$file"; + $newlyMatchedPlatforms[] = $platform; + } + } + } + $matchedPlatforms = array_merge($matchedPlatforms, $newlyMatchedPlatforms); +} + +?> + + + +monotone: Downloads + + + + + + + + + +
+

Latest monotone downloads by platform

+
$files) +{ + if (!is_array($files)) + continue; + + echo<<$platform +END; + foreach ($files as $file) + { + $name = basename($file); + $release = dirname($file); + echo << + $name
+ » more packages for $release + +END; + } +} +?>
+
+ + + ============================================================ --- index.html 45f46f9c8f432b71678c3d69b6dcdc1c48701762 +++ index.html 93d3e87aaa239cc3cd1809943c1f0d8707e5af6f @@ -63,7 +63,7 @@ -
  • older releases
  • +
  • latest downloads by platform
  • ...or from your distro