diff options
author | James E.H. Turner <jturner@gemini.edu> | 2016-08-23 16:31:03 -0400 |
---|---|---|
committer | James E.H. Turner <jturner@gemini.edu> | 2016-08-23 16:31:03 -0400 |
commit | 28abcedaa4db00b668399b834af42b8036d39dcd (patch) | |
tree | 3464a9e9e03ec132c449e2cd9ec6a96990ca7137 /scripts/unmangle_interpreter | |
parent | 8ab12cb90f1869fd2ab9c18230675fc4d8625787 (diff) | |
download | astroconda-iraf-helpers-28abcedaa4db00b668399b834af42b8036d39dcd.tar.gz |
A script to undo conda's unwanted interpreter path mangling in update_extern_pkg.
Diffstat (limited to 'scripts/unmangle_interpreter')
-rwxr-xr-x | scripts/unmangle_interpreter | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/unmangle_interpreter b/scripts/unmangle_interpreter new file mode 100755 index 0000000..9b42551 --- /dev/null +++ b/scripts/unmangle_interpreter @@ -0,0 +1,48 @@ +#!/bin/sh + +# Names of the script(s) to be updated in the same directory this is run from: +scripts="update_extern_pkg" + +# Work in the directory where this script and those to be updated live: +cd `dirname $0` || exit 1 # (should never fail if this script can be executed) + +# Put temporary copies in a tmp/ directory in the conda environment or /tmp/: +tmp="$PREFIX/tmp" +if [ -d "$tmp" ]; then + remove_tmp=0 +else + if ! mkdir "$tmp"; then + echo "failed to create $tmp" >&2 + exit 1 + fi + remove_tmp=1 +fi + +# Update each named script in turn: +for script in $scripts; do + + if [ ! -r "$script" ]; then + echo "no such script: $script" >&2 + exit 1 + fi + + tmpscript="$tmp/$script" + + if ! sed -e 's|#\!.*/python$|#\!/usr/bin/python|' "$script" > "$tmpscript" + then + echo "cannot write $tmpscript" >&2 + exit 1 + fi + + chmod 755 "$tmpscript" + + if ! mv -f "$tmpscript" "$script"; then + echo "failed to replace $script" >&2 + exit 1 + fi + +done + +# Clean up: +[ $remove_tmp == 1 ] && rmdir "$tmp" + |