summary refs log tree commit diff
path: root/pkgs/build-support/fetchsvn
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2009-10-06 13:36:52 +0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2009-10-06 13:36:52 +0000
commitd7897d0d1a5ab6514df238eed2f22fcba65c0183 (patch)
treeea9adb64e5bda5b67daa597e9d815afa64b5771f /pkgs/build-support/fetchsvn
parente528b920bb1fcc616179f5dbd93889ccc6b32329 (diff)
downloadnixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.tar
nixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.tar.gz
nixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.tar.bz2
nixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.tar.lz
nixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.tar.xz
nixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.tar.zst
nixpkgs-d7897d0d1a5ab6514df238eed2f22fcba65c0183.zip
Change fetchsvn as well as nix-prefect-svn to use the repository name and
the revision number inside the derivation name.

svn path=/nixpkgs/trunk/; revision=17677
Diffstat (limited to 'pkgs/build-support/fetchsvn')
-rw-r--r--pkgs/build-support/fetchsvn/default.nix21
-rwxr-xr-xpkgs/build-support/fetchsvn/nix-prefetch-svn12
2 files changed, 29 insertions, 4 deletions
diff --git a/pkgs/build-support/fetchsvn/default.nix b/pkgs/build-support/fetchsvn/default.nix
index 5a5f7533e7f..ae8aabf858c 100644
--- a/pkgs/build-support/fetchsvn/default.nix
+++ b/pkgs/build-support/fetchsvn/default.nix
@@ -1,8 +1,27 @@
 {stdenv, subversion, sshSupport ? false, openssh ? null}: 
 {url, rev ? "HEAD", md5 ? "", sha256 ? ""}:
 
+let
+  repoName = with stdenv.lib;
+    let
+      fst = head;
+      snd = l: head (tail l);
+      trd = l: head (tail (tail l));
+      path_ = reverseList (splitString "/" url);
+      path = if head path_ == "" then tail path_ else path_;
+    in
+      # ../repo/trunk -> repo
+      if fst path == "trunk" then snd path
+      # ../repo/branches/branch -> repo-branch
+      else if snd path == "branches" then "${trd path}-${fst path}"
+      # ../repo/tags/tag -> repo-tag
+      else if snd path == "tags" then     "${trd path}-${fst path}"
+      # ../repo (no trunk) -> repo
+      else fst path;
+in
+
 stdenv.mkDerivation {
-  name = "svn-export";
+  name = "${repoName}-r${toString rev}";
   builder = ./builder.sh;
   buildInputs = [subversion];
 
diff --git a/pkgs/build-support/fetchsvn/nix-prefetch-svn b/pkgs/build-support/fetchsvn/nix-prefetch-svn
index d15eb9a060c..b9d10fea21c 100755
--- a/pkgs/build-support/fetchsvn/nix-prefetch-svn
+++ b/pkgs/build-support/fetchsvn/nix-prefetch-svn
@@ -19,11 +19,18 @@ fi
 
 test -n "$rev" || rev="HEAD"
 
+repoName=$(echo $url | sed '
+  s,.*/\([^/]\+\)/trunk/*$,\1,;t
+  s,.*/\([^/]\+\)/branches/\([^/]\+\)/*$,\1-\2,;t
+  s,.*/\([^/]\+\)/tags/\([^/]\+\)/*$,\1-\2,;t
+  s,.*/\([^/]\+\)/*$,\1,;t
+')
+dstFile=$repoName-r$rev
 
 # If the hash was given, a file with that hash may already be in the
 # store.
 if test -n "$expHash"; then
-    finalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" svn-export)
+    finalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" $dstFile)
     if ! nix-store --check-validity "$finalPath" 2> /dev/null; then
         finalPath=
     fi
@@ -34,9 +41,8 @@ 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
-
     tmpPath=/tmp/svn-checkout-tmp-$$
-    tmpFile=$tmpPath/svn-export
+    tmpFile=$tmpPath/$dstFile
     mkdir $tmpPath
 
     trap "rm -rf $tmpPath" EXIT