summaryrefslogtreecommitdiff
path: root/debian/PVER-minimal.postinst.in
diff options
context:
space:
mode:
Diffstat (limited to 'debian/PVER-minimal.postinst.in')
-rw-r--r--debian/PVER-minimal.postinst.in82
1 files changed, 82 insertions, 0 deletions
diff --git a/debian/PVER-minimal.postinst.in b/debian/PVER-minimal.postinst.in
new file mode 100644
index 0000000..6890fb0
--- /dev/null
+++ b/debian/PVER-minimal.postinst.in
@@ -0,0 +1,82 @@
+#! /bin/sh
+
+set -e
+
+if [ ! -f /etc/@PVER@/sitecustomize.py ]; then
+ cat <<-EOF
+ # Empty sitecustomize.py to avoid a dangling symlink
+EOF
+fi
+
+case "$1" in
+ configure)
+ # Create empty directories in /usr/local
+ if [ ! -e /usr/local/lib/@PVER@ ]; then
+ mkdir -p /usr/local/lib/@PVER@ 2> /dev/null || true
+ chmod 2775 /usr/local/lib/@PVER@ 2> /dev/null || true
+ chown root:staff /usr/local/lib/@PVER@ 2> /dev/null || true
+ fi
+ localsite=/usr/local/lib/@PVER@/dist-packages
+ if [ ! -e $localsite ]; then
+ mkdir -p $localsite 2> /dev/null || true
+ chmod 2775 $localsite 2> /dev/null || true
+ chown root:staff $localsite 2> /dev/null || true
+ fi
+
+ if which update-binfmts >/dev/null; then
+ update-binfmts --import @PVER@
+ fi
+
+ ;;
+esac
+
+if [ "$1" = configure ]; then
+
+ # only available before removal of the packaging package
+ rm -f /etc/@PVER@/sysconfig.cfg
+
+ if ls -L /usr/lib/@PVER@/sitecustomize.py >/dev/null 2>&1; then
+ filt='cat'
+ else
+ filt='fgrep -v sitecustomize.py'
+ fi
+ files=$(dpkg -L lib@PVER@-minimal@HOST_QUAL@ \
+ | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p' | $filt)
+ if [ -n "$files" ]; then
+ /usr/bin/@PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files
+ if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then
+ /usr/bin/@PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files
+ fi
+ else
+ echo >&2 "@PVER@-minimal: can't get files for byte-compilation"
+ fi
+ bc=no
+ #if [ -z "$2" ] || dpkg --compare-versions "$2" lt 2.5-3 \
+ # || [ -f /var/lib/python/@PVER@_installed ]; then
+ # bc=yes
+ #fi
+ if ! grep -sq '^supported-versions[^#]*@PVER@' /usr/share/python/debian_defaults
+ then
+ # FIXME: byte compile anyway?
+ bc=no
+ fi
+ if [ "$bc" = yes ]; then
+ # new installation or installation of first version with hook support
+ if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
+ echo "Linking and byte-compiling packages for runtime @PVER@..."
+ fi
+ version=$(dpkg -s @PVER@-minimal | awk '/^Version:/ {print $2}')
+ for hook in /usr/share/python3/runtime.d/*.rtinstall; do
+ [ -x $hook ] || continue
+ $hook rtinstall @PVER@ "$2" "$version"
+ done
+ if [ -f /var/lib/python/@PVER@_installed ]; then
+ rm -f /var/lib/python/@PVER@_installed
+ rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null
+ fi
+ fi
+fi
+
+#DEBHELPER#
+
+exit 0