2012-04-04 14:45:24 +00:00
|
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
2013-08-13 21:04:08 +00:00
|
|
|
|
releaseUrl=http://hydra.nixos.org/job/nixpkgs/trunk/unstable/latest-finished
|
2012-04-04 14:45:24 +00:00
|
|
|
|
releasesDir=/data/releases/nixpkgs
|
2012-11-09 12:40:10 +00:00
|
|
|
|
channelsDir=/data/releases/channels
|
|
|
|
|
channelName=nixpkgs-unstable
|
2012-04-04 14:45:24 +00:00
|
|
|
|
curl="curl --silent --show-error --fail"
|
|
|
|
|
|
2013-08-13 21:04:08 +00:00
|
|
|
|
json=$($curl -L -H 'Accept: application/json' $releaseUrl)
|
2012-04-04 14:45:24 +00:00
|
|
|
|
|
2013-08-13 21:04:08 +00:00
|
|
|
|
releaseId=$(echo "$json" | json id)
|
|
|
|
|
if [ -z "$releaseId" ]; then echo "Failed to get release id"; exit 1; fi
|
2012-04-04 14:45:24 +00:00
|
|
|
|
|
2013-08-13 21:04:08 +00:00
|
|
|
|
release=$(echo "$json" | json nixname)
|
2012-04-04 14:45:24 +00:00
|
|
|
|
if [ -z "$release" ]; then echo "Failed to get release"; exit 1; fi
|
|
|
|
|
|
2013-08-13 21:04:08 +00:00
|
|
|
|
url=$($curl --head http://hydra.nixos.org/build/$releaseId/eval | sed 's/Location: \(.*\)\r/\1/; t; d')
|
|
|
|
|
if [ -z "$url" ]; then exit 1; fi
|
2012-04-04 14:45:24 +00:00
|
|
|
|
|
2013-08-14 10:18:43 +00:00
|
|
|
|
releaseDir=$releasesDir/$release
|
|
|
|
|
|
2013-10-09 12:04:29 +00:00
|
|
|
|
echo "release is ‘$release’ (build $releaseId), eval is ‘$url’, dir is ‘$releaseDir’" >&2
|
2013-08-21 13:45:14 +00:00
|
|
|
|
|
2012-04-04 14:45:24 +00:00
|
|
|
|
if [ -d $releaseDir ]; then
|
2013-10-09 12:04:29 +00:00
|
|
|
|
echo "release already exists" >&2
|
2012-04-04 14:45:24 +00:00
|
|
|
|
else
|
|
|
|
|
tmpDir=$releasesDir/.tmp-$release-$$
|
|
|
|
|
mkdir -p $tmpDir
|
|
|
|
|
|
|
|
|
|
echo $url > $tmpDir/src-url
|
|
|
|
|
|
2013-08-13 21:04:08 +00:00
|
|
|
|
perl -w ./mirror-channel.pl "$url/channel" "$tmpDir" \
|
2013-06-17 23:23:05 +00:00
|
|
|
|
nix-cache http://cache.nixos.org \
|
2013-08-13 21:04:08 +00:00
|
|
|
|
/data/releases/patches/all-patches "$url/job/tarball/download/4"
|
2012-04-04 14:45:24 +00:00
|
|
|
|
|
2013-08-21 13:45:14 +00:00
|
|
|
|
# Extract the manual.
|
|
|
|
|
mkdir $tmpDir/manual
|
|
|
|
|
tar xf $tmpDir/nixexprs.tar.xz --strip-components=2 -C $tmpDir/manual \
|
|
|
|
|
--wildcards '*/doc' --exclude '*.xml' --exclude '*.xsl' --exclude '*.txt' --exclude 'Makefile'
|
|
|
|
|
ln -s manual.html $tmpDir/manual/index.html
|
|
|
|
|
|
2012-04-04 14:45:24 +00:00
|
|
|
|
mv $tmpDir $releaseDir
|
|
|
|
|
fi
|
|
|
|
|
|
2013-10-09 12:04:29 +00:00
|
|
|
|
# Copy over to nixos.org.
|
|
|
|
|
cd "$releasesDir"
|
|
|
|
|
rsync -avR . hydra-mirror@nixos.org:"$releasesDir" --delete >&2
|
|
|
|
|
|
|
|
|
|
# Update the channel.
|
|
|
|
|
htaccess=$channelsDir/.htaccess-$channelName
|
2013-12-19 15:38:27 +00:00
|
|
|
|
echo "Redirect /channels/$channelName http://releases.nixos.org/nixpkgs/$release" > $htaccess.tmp
|
|
|
|
|
echo "Redirect /releases/nixpkgs/channels/$channelName http://releases.nixos.org/nixpkgs/$release" >> $htaccess.tmp # obsolete
|
2012-04-04 14:45:24 +00:00
|
|
|
|
mv $htaccess.tmp $htaccess
|
2013-10-09 12:04:29 +00:00
|
|
|
|
ln -sfn $releaseDir $channelsDir/$channelName # dummy symlink
|
2013-06-17 23:23:05 +00:00
|
|
|
|
|
2013-10-09 12:04:29 +00:00
|
|
|
|
flock -x $channelsDir/.htaccess.lock -c "cat $channelsDir/.htaccess-nix* > $channelsDir/.htaccess"
|
|
|
|
|
|
|
|
|
|
cd "$channelsDir"
|
|
|
|
|
rsync -avR . hydra-mirror@nixos.org:"$channelsDir" --delete >&2
|