Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions hooks/034-python3-move.chroot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -eux

echo "moving python to directory unaccessible to snaps"
python_d=/usr/lib/python
mkdir "$python_d"
mv /usr/bin/python* "$python_d"
ln -sf ../../share/python3/py3versions.py "$python_d"/py3versions

# These are unnecessary
rm /usr/bin/py3clean
rm /usr/bin/py3compile
rm /usr/bin/py3versions

# replace in scripts
scripts=(
/usr/bin/cloud-id
/usr/bin/cloud-init
/usr/bin/ec2metadata
/usr/lib/python*/*.py
/usr/lib/python*/encodings/*.py
/usr/share/netplan/netplan.script
/usr/share/netplan/netplan_cli/*.py
/usr/share/netplan/netplan_cli/cli/*.py
/usr/share/netplan/netplan_cli/cli/commands/*.py
/usr/share/python3/debpython/*.py
/usr/share/python3/py3versions.py
)
for p in "${scripts[@]}"; do
# Some files exist only for the cloud-init track
if [ -f "$p" ]; then
sed -i 's#/usr/bin/python#/usr/lib/python/python#g' "$p"
fi
done
Loading