# dh-virtualenv postinst autoscript set -e #ARGS# # set to empty to enable verbose output test "${DH_VERBOSE:-0}" = "1" && DH_VENV_DEBUG="" || DH_VENV_DEBUG=: $DH_VENV_DEBUG set -x dh_venv_safe_interpreter_update() { # get Python version used local pythonX_Y=$(cd "$dh_venv_install_dir/lib" && ls -1d python[2-9].*[0-9] | tail -n1) local i for i in python ${pythonX_Y%.*} ${pythonX_Y}; do local interpreter_path="$dh_venv_install_dir/bin/$i" # skip any symlinks, and make sure we have an existing target test ! -L "$interpreter_path" || continue test -x "$interpreter_path" || continue # skip if already identical if cmp "/usr/bin/$pythonX_Y" "$interpreter_path" >/dev/null 2>&1; then continue fi # hardlink or copy new interpreter cp -fpl "/usr/bin/$pythonX_Y" "$interpreter_path,new" \ || cp -fp "/usr/bin/$pythonX_Y" "$interpreter_path,new" \ || rm -f "$interpreter_path,new" \ || true # make a backup (once) test -f "$interpreter_path,orig" || ln "$interpreter_path" "$interpreter_path,orig" # atomic move if test -x "$interpreter_path,new" && mv "$interpreter_path,new" "$interpreter_path"; then echo "Successfully updated $interpreter_path" else echo >&2 "WARNING: Some error occured while updating $interpreter_path" fi done } case "$1" in configure|reconfigure) $DH_VENV_DEBUG echo "$0 $1 called with $# args:" "$@" dh_venv_safe_interpreter_update ;; triggered) $DH_VENV_DEBUG echo "$0 $1 called with $# args:" "$@" for trigger in $2; do case "$trigger" in /usr/bin/python?.*) # this trigger might be for the "wrong" interpreter (other version), # but the "cmp" in "dh_venv_safe_interpreter_update" and the fact we only # ever look at our own Python version catches that dh_venv_safe_interpreter_update ;; dh-virtualenv-interpreter-update) dh_venv_safe_interpreter_update ;; *) #echo >&2 "ERROR:" $(basename "$0") "called with unknown trigger '$2'" #exit 1 ;; esac done ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) #echo >&2 "ERROR:" $(basename "$0") "called with unknown argument '$1'" #exit 1 ;; esac $DH_VENV_DEBUG set +x # END dh-virtualenv postinst autoscript