summary refs log tree commit diff
path: root/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh')
-rwxr-xr-xpkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh b/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh
new file mode 100755
index 00000000000..b8f2e95923b
--- /dev/null
+++ b/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash -p bash
+
+CWD=$PWD
+
+chko() {
+  (
+    T=`mktemp -d`
+    trap "rm -rf $T" EXIT INT PIPE
+    cd $T
+    cat >check.nix <<EOF
+with import <nixpkgs> {};
+fetchgit `cat $CWD/../mkderivation/src-main.nix`
+EOF
+    nix-build check.nix
+    cat result/libraries/Makefile.libs
+  )
+}
+
+getsha256() {
+  URL=$(echo "$1" | sed 's/^"\(.*\)"$/\1/')
+  REV=$(echo "$2" | sed 's/^"\(.*\)"$/\1/')
+  SHA=$(nix run nixpkgs.nix-prefetch-git -c nix-prefetch-git --fetch-submodules "$URL" "$REV" 2>/dev/null | sed -n 's/.*"sha256": "\(.*\)",/\1/g p')
+  echo "{ url = $1; rev = $2; sha256 = \"$SHA\"; fetchSubmodules = true; }"
+}
+
+OUT=src-libs.nix
+
+echo '[' > $OUT
+
+chko |
+grep checkout-git.sh |
+tr \' \" |
+while read NM TGT URL BR REV ; do
+  echo Trying $TGT $URL $REV >&2
+  getsha256 $URL $REV >> $OUT || exit 1
+done
+
+echo ']' >> $OUT