2012-04-04 21:18:57 +00:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
2012-04-10 16:00:32 +00:00
|
|
|
viewUrl=http://hydra.nixos.org/view/nixos/tested/latest-finished
|
|
|
|
releasesDir=/data/releases/nixos
|
2012-11-09 12:40:10 +00:00
|
|
|
channelsDir=/data/releases/channels
|
|
|
|
channelName=nixos-unstable
|
2012-04-04 21:18:57 +00:00
|
|
|
curl="curl --silent --show-error --fail"
|
|
|
|
wget="wget --no-verbose --content-disposition"
|
|
|
|
|
2012-04-10 16:00:32 +00:00
|
|
|
url=$($curl --head $viewUrl | sed 's/Location: \(.*\)\r/\1/; t; d')
|
2012-04-04 21:18:57 +00:00
|
|
|
if [ -z "$url" ]; then exit 1; fi
|
|
|
|
|
|
|
|
echo "View page is $url"
|
|
|
|
|
2013-02-24 21:05:32 +00:00
|
|
|
release=$($curl $url | sed 's|.*<h1>.*View \(.*\)</small.*|\1|; t; d')
|
2012-04-04 21:18:57 +00:00
|
|
|
if [ -z "$release" ]; then echo "Failed to get release"; exit 1; fi
|
|
|
|
|
|
|
|
echo "Release is $release"
|
|
|
|
|
2012-04-10 16:00:32 +00:00
|
|
|
releaseDir=$releasesDir/$release
|
|
|
|
echo $releaseDir
|
2012-04-04 21:18:57 +00:00
|
|
|
|
|
|
|
if [ -d $releaseDir ]; then
|
|
|
|
echo "Release already exists"
|
|
|
|
else
|
2012-04-10 16:00:32 +00:00
|
|
|
tmpDir=$releasesDir/.tmp-$release-$$
|
2012-04-04 21:18:57 +00:00
|
|
|
mkdir -p $tmpDir
|
|
|
|
|
2012-04-10 16:00:32 +00:00
|
|
|
echo $url > $tmpDir/src-url
|
2012-04-04 21:18:57 +00:00
|
|
|
|
2013-04-02 11:55:37 +00:00
|
|
|
$wget --directory=$tmpDir $url/nixos.iso_minimal.i686-linux/download
|
|
|
|
$wget --directory=$tmpDir $url/nixos.iso_minimal.x86_64-linux/download
|
|
|
|
$wget --directory=$tmpDir $url/nixos.iso_graphical.i686-linux/download
|
|
|
|
$wget --directory=$tmpDir $url/nixos.iso_graphical.x86_64-linux/download
|
2012-04-10 16:00:32 +00:00
|
|
|
|
|
|
|
perl -w ./mirror-channel.pl "$url/eval/channel" "$tmpDir" \
|
2012-12-09 22:43:26 +00:00
|
|
|
/data/releases/binary-cache http://nixos.org/binary-cache \
|
2012-04-10 16:00:32 +00:00
|
|
|
/data/releases/patches/all-patches "$url/nixos.channel/download/1"
|
2012-04-04 21:18:57 +00:00
|
|
|
|
2013-03-25 13:17:47 +00:00
|
|
|
# Generate the programs.sqlite database and put it in nixexprs.tar.xz.
|
|
|
|
mkdir $tmpDir/unpack
|
|
|
|
tar xfJ $tmpDir/nixexprs.tar.xz -C $tmpDir/unpack
|
|
|
|
exprDir=$(echo $tmpDir/unpack/*)
|
|
|
|
./generate-programs-index.pl "$exprDir" "$exprDir/programs.sqlite"
|
|
|
|
tar cfJ $tmpDir/nixexprs.tar.xz -C $tmpDir/unpack "$(basename "$exprDir")"
|
|
|
|
rm -rf $tmpDir/unpack
|
|
|
|
|
2012-04-10 16:00:32 +00:00
|
|
|
mv $tmpDir $releaseDir
|
2012-04-04 21:18:57 +00:00
|
|
|
fi
|
|
|
|
|
2012-11-09 12:40:10 +00:00
|
|
|
htaccess=$channelsDir/.htaccess-nixos
|
|
|
|
echo "Redirect /channels/$channelName http://nixos.org/releases/nixos/$release" > $htaccess.tmp
|
|
|
|
echo "Redirect /releases/nixos/channels/$channelName http://nixos.org/releases/nixos/$release" >> $htaccess.tmp
|
|
|
|
ln -sfn $releaseDir $channelsDir/$channelName # dummy symlink
|
2012-04-10 16:00:32 +00:00
|
|
|
mv $htaccess.tmp $htaccess
|
2012-11-09 12:40:10 +00:00
|
|
|
flock -x $channelsDir/.htaccess.lock -c "cat $channelsDir/.htaccess-nix* > $channelsDir/.htaccess"
|
2012-04-04 21:18:57 +00:00
|
|
|
|
2012-04-10 16:00:32 +00:00
|
|
|
# Generate a .htaccess with some symbolic redirects to the latest ISOs.
|
|
|
|
htaccess=$releasesDir/.htaccess
|
2012-04-04 21:18:57 +00:00
|
|
|
|
|
|
|
echo "Redirect /releases/nixos/latest http://nixos.org/releases/nixos/$release" > $htaccess.tmp
|
|
|
|
fn=$(cd $releaseDir && echo nixos-minimal-*-i686-linux.iso)
|
|
|
|
echo "Redirect /releases/nixos/latest-iso-minimal-i686-linux http://nixos.org/releases/nixos/$release/$fn" >> $htaccess.tmp
|
|
|
|
fn=$(cd $releaseDir && echo nixos-minimal-*-x86_64-linux.iso)
|
|
|
|
echo "Redirect /releases/nixos/latest-iso-minimal-x86_64-linux http://nixos.org/releases/nixos/$release/$fn" >> $htaccess.tmp
|
|
|
|
fn=$(cd $releaseDir && echo nixos-graphical-*-i686-linux.iso)
|
|
|
|
echo "Redirect /releases/nixos/latest-iso-graphical-i686-linux http://nixos.org/releases/nixos/$release/$fn" >> $htaccess.tmp
|
|
|
|
fn=$(cd $releaseDir && echo nixos-graphical-*-x86_64-linux.iso)
|
|
|
|
echo "Redirect /releases/nixos/latest-iso-graphical-x86_64-linux http://nixos.org/releases/nixos/$release/$fn" >> $htaccess.tmp
|
|
|
|
|
|
|
|
mv $htaccess.tmp $htaccess
|