mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-25 04:12:44 +03:00
* fetchcvs: cleanup, use nix-store --add-fixed like fetchurl/svn.
Argument "url" renamed to "cvsRoot" (it's not a URL). svn path=/nixpkgs/trunk/; revision=10889
This commit is contained in:
parent
5883330e2c
commit
66738cc356
@ -3,7 +3,7 @@ stdenv.mkDerivation {
|
|||||||
name = "synergy-cvs";
|
name = "synergy-cvs";
|
||||||
|
|
||||||
src = fetchcvs {
|
src = fetchcvs {
|
||||||
url = ":pserver:anonymous@synergy2.cvs.sourceforge.net:/cvsroot/synergy2";
|
cvsRoot = ":pserver:anonymous@synergy2.cvs.sourceforge.net:/cvsroot/synergy2";
|
||||||
module = "synergy";
|
module = "synergy";
|
||||||
date = "NOW";
|
date = "NOW";
|
||||||
sha256 = "ef8e2ebfda6e43240051a7af9417092b2af50ece8b5c6c3fbd908ba91c4fe068";
|
sha256 = "ef8e2ebfda6e43240051a7af9417092b2af50ece8b5c6c3fbd908ba91c4fe068";
|
||||||
|
@ -6,18 +6,17 @@ source $stdenv/setup
|
|||||||
# should work (but didn't - got no response on #cvs)
|
# should work (but didn't - got no response on #cvs)
|
||||||
# See als man Page for those options
|
# See als man Page for those options
|
||||||
|
|
||||||
ensureDir $out export
|
ensureDir export
|
||||||
set -x
|
|
||||||
if [ -n "$tag" ]; then
|
if [ -n "$tag" ]; then
|
||||||
tag="-r $tag"
|
tag="-r $tag"
|
||||||
else
|
else
|
||||||
if [ -n "$date" ]; then
|
if [ -n "$date" ]; then
|
||||||
tag="-D $date"
|
tag="-D $date"
|
||||||
else
|
else
|
||||||
tag="-D NOW"
|
tag="-D NOW"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cd export; cvs -f -d "$url" export $tag "$module"
|
(cd export && cvs -f -z0 -d "$cvsRoot" export $tag "$module")
|
||||||
mv */* $out
|
mv export/* $out
|
||||||
|
|
||||||
stopNest
|
stopNest
|
||||||
|
@ -3,11 +3,18 @@
|
|||||||
# tag="<tagname>" (get version by tag name)
|
# tag="<tagname>" (get version by tag name)
|
||||||
# If you don't specify neither one date="NOW" will be used (get latest)
|
# If you don't specify neither one date="NOW" will be used (get latest)
|
||||||
|
|
||||||
{stdenv, cvs, nix}: {url, module, tag ? null, date ? null, sha256}:
|
{stdenv, cvs}:
|
||||||
|
|
||||||
|
{cvsRoot, module, tag ? null, date ? null, sha256}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "cvs-export";
|
name = "cvs-export";
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
buildInputs = [cvs nix];
|
buildInputs = [cvs];
|
||||||
inherit url module sha256 tag date;
|
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHash = sha256;
|
||||||
|
|
||||||
|
inherit cvsRoot module sha256 tag date;
|
||||||
}
|
}
|
||||||
|
@ -1,89 +1,80 @@
|
|||||||
#! /bin/sh -e
|
#! /bin/sh -e
|
||||||
|
|
||||||
url=$1
|
cvsRoot=$1
|
||||||
module=$2
|
module=$2
|
||||||
tag=$3
|
tag=$3
|
||||||
hash=$4
|
expHash=$4
|
||||||
|
|
||||||
if test -z "$url"; then
|
hashType=$NIX_HASH_ALGO
|
||||||
echo "syntax: nix-prefetch-cvs URL MODULE [TAG [HASH]]" >&2
|
if test -z "$hashType"; then
|
||||||
|
hashType=sha256
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$cvsRoot"; then
|
||||||
|
echo "syntax: nix-prefetch-cvs CVSROOT MODULE [TAG [HASH]]" >&2
|
||||||
exit 1
|
exit 1
|
||||||
elif test -z "$module"; then
|
elif test -z "$module"; then
|
||||||
echo "syntax: nix-prefetch-cvs URL MODULE [TAG [HASH]]" >&2
|
echo "syntax: nix-prefetch-cvs CVSROOT MODULE [TAG [HASH]]" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use a restrictive umask to ensure that the output in the Nix store
|
|
||||||
# is not group- or world-writable. Nix 0.10 complains about this.
|
|
||||||
umask 0022
|
|
||||||
|
|
||||||
# Determine the hash, unless it was given.
|
mkTempDir() {
|
||||||
if test -z "$hash"; then
|
tmpPath=$(mktemp -d -t nix-prefetch-cvs-XXXXXXXX)
|
||||||
|
trap removeTempDir EXIT SIGINT SIGQUIT
|
||||||
|
}
|
||||||
|
|
||||||
# !!! hacky; we should have a way to query the location of the store.
|
removeTempDir() {
|
||||||
if storeDir=$(which nix-store); then
|
if test -n "$tmpPath"; then
|
||||||
storeDir=$(dirname $(dirname "$storeDir"))/store
|
rm -rf "$tmpPath" || true
|
||||||
else
|
|
||||||
storeDir=/nix/store
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# !!! race? should be relatively safe, `svn export' barfs if $tmpPath exists.
|
|
||||||
cvsPath="cvs-checkout-tmp-$$"
|
|
||||||
tmpPath1=$storeDir/$cvsPath
|
|
||||||
|
|
||||||
# Test whether we have write permission in the store. If not,
|
# If the hash was given, a file with that hash may already be in the
|
||||||
# fetch to /tmp and don't copy to the store. This is a hack to
|
# store.
|
||||||
# make this script at least work somewhat in setuid installations.
|
if test -n "$expHash"; then
|
||||||
if ! touch $tmpPath1 2> /dev/null; then
|
finalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" cvs-export)
|
||||||
echo "(cannot write to the store, result won't be cached)" >&2
|
if ! nix-store --check-validity "$finalPath" 2> /dev/null; then
|
||||||
dummyMode=1
|
finalPath=
|
||||||
tmpPath1=/tmp/nix-prefetch-cvs-$$ # !!! security?
|
|
||||||
fi
|
fi
|
||||||
rm -f $tmpPath1
|
hash=$expHash
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# If we don't know the hash or a path with that hash doesn't exist,
|
||||||
|
# download the file and add it to the store.
|
||||||
|
if test -z "$finalPath"; then
|
||||||
|
|
||||||
|
mkTempDir
|
||||||
|
tmpFile=$tmpPath/cvs-export
|
||||||
|
#mkdir $tmpPath
|
||||||
|
|
||||||
# Perform the checkout.
|
# Perform the checkout.
|
||||||
if test -z "$tag"; then
|
if test -z "$tag"; then
|
||||||
rtag="-DNOW"
|
rtag="-DNOW"
|
||||||
else
|
else
|
||||||
rtag="-r $tag"
|
rtag="-r $tag"
|
||||||
fi
|
fi
|
||||||
# CVS has a problem with absolute paths, so cd into the nix store
|
(cd "$tmpPath" && cvs -f -z7 -d $cvsRoot export $rtag -d cvs-export $module >&2)
|
||||||
current=$(pwd)
|
|
||||||
cd $storeDir
|
|
||||||
cvs -f -d $url export $rtag -d $cvsPath $module >&2
|
|
||||||
# Change back to the original directory
|
|
||||||
cd $current
|
|
||||||
|
|
||||||
# Compute the hash.
|
# Compute the hash.
|
||||||
hash=$(nix-hash $tmpPath1)
|
hash=$(nix-hash --type $hashType $hashFormat $tmpFile)
|
||||||
echo "hash is $hash" >&2
|
if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
|
||||||
|
|
||||||
# Rename it so that the fetchcvs builder can find it.
|
# Add the downloaded file to the Nix store.
|
||||||
if test "$dummyMode" != 1; then
|
finalPath=$(nix-store --add-fixed --recursive "$hashType" $tmpFile)
|
||||||
tmpPath2=$storeDir/cvs-checkout-tmp-$hash
|
|
||||||
test -e $tmpPath2 || mv $tmpPath1 $tmpPath2 # !!! race
|
if test -n "$expHash" -a "$expHash" != "$hash"; then
|
||||||
|
echo "hash mismatch for CVS root \`$cvsRoot'"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a Nix expression that does a fetchcvs.
|
if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
|
||||||
nixExpr=$(dirname $0)/../../top-level/all-packages.nix
|
|
||||||
storeExpr=$( \
|
|
||||||
echo "(import $nixExpr {}).fetchcvs {url=\"$url\"; module=\"$module\"; tag=\"$tag\"; md5=\"$hash\";}" \
|
|
||||||
| nix-instantiate -)
|
|
||||||
|
|
||||||
# Realise it.
|
|
||||||
finalPath=$(nix-store -r $storeExpr)
|
|
||||||
|
|
||||||
echo "path is $finalPath" >&2
|
|
||||||
|
|
||||||
if test -n "$tmpPath1" -o -n "$tmpPath2"; then
|
|
||||||
rm -rf $tmpPath1 $tmpPath2 || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "debug hash is $hash" >&2
|
|
||||||
echo $hash
|
echo $hash
|
||||||
|
|
||||||
if test -n "$PRINT_PATH"; then
|
if test -n "$PRINT_PATH"; then
|
||||||
echo "debug path is $finalPath" >&2
|
|
||||||
echo $finalPath
|
echo $finalPath
|
||||||
fi
|
fi
|
||||||
|
@ -9,9 +9,9 @@ stdenv.mkDerivation {
|
|||||||
# Nix <= 0.7 compatibility.
|
# Nix <= 0.7 compatibility.
|
||||||
/*id = if sha256 == "" then md5 else sha256;*/
|
/*id = if sha256 == "" then md5 else sha256;*/
|
||||||
|
|
||||||
outputHashAlgo = if sha256=="" then "md5" else "sha256";
|
outputHashAlgo = if sha256 == "" then "md5" else "sha256";
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
outputHash = if sha256 =="" then md5 else sha256;
|
outputHash = if sha256 == "" then md5 else sha256;
|
||||||
|
|
||||||
inherit url rev sshSupport openssh;
|
inherit url rev sshSupport openssh;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,6 @@ fi
|
|||||||
|
|
||||||
test -n "$rev" || rev="HEAD"
|
test -n "$rev" || rev="HEAD"
|
||||||
|
|
||||||
# Use a restrictive umask to ensure that the output in the Nix store
|
|
||||||
# is not group- or world-writable. Nix 0.10 complains about this.
|
|
||||||
umask 0022
|
|
||||||
|
|
||||||
|
|
||||||
# If the hash was given, a file with that hash may already be in the
|
# If the hash was given, a file with that hash may already be in the
|
||||||
# store.
|
# store.
|
||||||
|
@ -297,7 +297,7 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchcvs = import ../build-support/fetchcvs {
|
fetchcvs = import ../build-support/fetchcvs {
|
||||||
inherit stdenv cvs nix;
|
inherit stdenv cvs;
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchdarcs = import ../build-support/fetchdarcs {
|
fetchdarcs = import ../build-support/fetchdarcs {
|
||||||
|
Loading…
Reference in New Issue
Block a user