summary refs log tree commit diff
path: root/pkgs/applications/science/misc/openmodelica/fakegit.nix
diff options
context:
space:
mode:
authorSergey Mironov <grrwlf@gmail.com>2015-06-20 21:45:37 +0300
committerRok Garbas <rok@garbas.si>2015-07-23 20:42:35 +0200
commit9bb0fee487f639671768bbaa2412cd9c8956c493 (patch)
tree993af3ba158066c0280fb561b7f0ccfcb3d94ae0 /pkgs/applications/science/misc/openmodelica/fakegit.nix
parentdcdd7a37f67d3018d5704e5d10fa4f5e083474f2 (diff)
downloadnixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.tar
nixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.tar.gz
nixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.tar.bz2
nixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.tar.lz
nixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.tar.xz
nixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.tar.zst
nixlib-9bb0fee487f639671768bbaa2412cd9c8956c493.zip
openmodelica: add expression
openmodelica.nix: add git to the list of dependencies

openmodelica: generate library sourcelist with hashes

openmodelica: generate library sources (part 2)

openmodelica: fix fakegit

openmodelica: fix libraries issues

openmodelica: add GTK

openmodelica: successful build
Diffstat (limited to 'pkgs/applications/science/misc/openmodelica/fakegit.nix')
-rw-r--r--pkgs/applications/science/misc/openmodelica/fakegit.nix81
1 files changed, 81 insertions, 0 deletions
diff --git a/pkgs/applications/science/misc/openmodelica/fakegit.nix b/pkgs/applications/science/misc/openmodelica/fakegit.nix
new file mode 100644
index 000000000000..de69626cd3ee
--- /dev/null
+++ b/pkgs/applications/science/misc/openmodelica/fakegit.nix
@@ -0,0 +1,81 @@
+{stdenv, fetchgit, fetchsvn, bash } :
+
+let
+  mkscript = path : text : ''
+    mkdir -pv `dirname ${path}`
+    cat > ${path} <<"EOF"
+    #!${bash}/bin/bash
+    ME=`basename ${path}`
+    ${text}
+    EOF
+    sed -i "s@%out@$out@g" ${path}
+    chmod +x ${path}
+  '';
+  
+  hashname = r: let
+    rpl = stdenv.lib.replaceChars [":" "/"] ["_" "_"];
+  in
+    (rpl r.url) + "-" + (rpl r.rev);
+
+in
+
+stdenv.mkDerivation {
+  name = "fakegit";
+
+  buildCommand = ''
+    mkdir -pv $out/repos
+    ${stdenv.lib.concatMapStrings
+       (r : ''
+        cp -r ${fetchgit r} $out/repos/${hashname r}
+       ''
+       ) (import ./src-libs-git.nix)
+    }
+
+    ${mkscript "$out/bin/checkout-git.sh" ''
+      if test "$#" -ne 4; then
+        echo "Usage: $0 DESTINATION URL GITBRANCH HASH"
+        exit 1
+      fi
+      DEST=$1
+      URL=`echo $2 | tr :/ __`
+      GITBRANCH=$3
+      REVISION=$4
+
+      L=`echo $REVISION | wc -c`
+      if expr $L '<' 10 >/dev/null; then
+        REVISION=refs/tags/$REVISION
+      fi
+
+      REVISION=`echo $REVISION | tr :/ __`
+
+      rm -rf $DEST
+      mkdir -pv $DEST
+      echo "FAKEGIT cp -r %out/repos/$URL-$REVISION $DEST" >&2
+      cp -r %out/repos/$URL-$REVISION/* $DEST
+      chmod u+w -R $DEST
+    ''}
+
+    ${stdenv.lib.concatMapStrings
+       (r : ''
+        cp -r ${fetchsvn r} $out/repos/${hashname r}
+       ''
+       ) (import ./src-libs-svn.nix)
+    }
+
+    ${mkscript "$out/bin/checkout-svn.sh" ''
+      if test "$#" -ne 3; then
+        echo "Usage: $0 DESTINATION URL REVISION"
+        exit 1
+      fi
+      DEST=$1
+      URL=`echo $2 | tr :/ __`
+      REVISION=`echo $4 | tr :/ __`
+
+      rm -rf $DEST
+      mkdir -pv $DEST
+      echo "FAKE COPY %out/repos/$URL-$REVISION $DEST"
+      cp -r %out/repos/$URL-$REVISION/* $DEST
+      chmod u+w -R $DEST
+    ''}
+  '';
+}