channel-scripts/mirror-nixpkgs.sh
Eelco Dolstra 4d9d3a88a1 * Base the Nixpkgs channel on
http://hydra.nixos.org/view/nixpkgs/unstable/.  So now the Nixpkgs
  channel corresponds to exactly one revision of Nixpkgs (i.e. no more
  binaries from previous revisions), there is some minimal assurance
  that the channel is okay (because the builds in the "unstable" view
  need to succeed), and older Nixpkgs pre-releases are available under
  http://nixos.org/releases/nixpkgs/.  This means we've come full
  circle, because this is how the Nixpkgs channel used to work before
  we had Hydra :-)

  The downside is that it can take longer for the channel to catch up
  with the Nixpkgs repository.  But that's only a problem for people
  who build from the Nixpkgs repository.


git-svn-id: https://nixos.org/repos/nix/release/trunk/channels@33565 70bd8c7a-acb8-0310-9f0d-9cc1c95dcdbb
2012-04-04 14:45:24 +00:00

40 lines
1.2 KiB
Bash
Executable file

#! /bin/sh -e
viewUrl=http://hydra.nixos.org/view/nixpkgs/unstable/latest-finished
releasesDir=/data/releases/nixpkgs
channelLink=/data/releases/nixpkgs/channels/nixpkgs-unstable
curl="curl --silent --show-error --fail"
url=$($curl --head $viewUrl | sed 's/Location: \(.*\)\r/\1/; t; d')
if [ -z "$url" ]; then exit 1; fi
echo "View page is $url"
release=$($curl $url | sed 's|<h1>View.*(<tt>\(.*\)</tt>.*|\1|; t; d')
if [ -z "$release" ]; then echo "Failed to get release"; exit 1; fi
echo "Release is $release"
releaseDir=$releasesDir/$release
echo $releaseDir
if [ -d $releaseDir ]; then
echo "Release already exists"
else
tmpDir=$releasesDir/.tmp-$release-$$
mkdir -p $tmpDir
echo $url > $tmpDir/src-url
perl -w ./mirror-channel.pl "$url/eval/channel" "$tmpDir" \
/data/releases/nars http://nixos.org/releases/nars \
/data/releases/patches/all-patches "$url/tarball/download/4"
mv $tmpDir $releaseDir
fi
htaccess=$(dirname $channelLink)/.htaccess
echo "Redirect /releases/nixpkgs/channels/nixpkgs-unstable http://nixos.org/releases/nixpkgs/$release" > $htaccess.tmp
ln -sfn $releaseDir $channelLink # dummy symlink
mv $htaccess.tmp $htaccess