Skip to content

Commit

Permalink
feat: dynamic python versions, swap uuid for mktemp
Browse files Browse the repository at this point in the history
  • Loading branch information
clay-lake committed Oct 30, 2024
1 parent f20e996 commit 48fbab2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions rockcraft_snap_patcher/patcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,30 @@ craft_parts="../craft-parts/" # Path to craft_providers repo


# setup
snap_rootfs="./.patcher/$(uuid)/"
snap_rootfs=$(mktemp -d -p "./.patcher/")
sudo mkdir -p "$snap_rootfs"

# unpack rootfs
unsquashfs -f -d "$snap_rootfs" "$src_snap"
snap_name=$(yq '.name' "$snap_rootfs/meta/snap.yaml")
# snap_src_version=$(yq '.version' "$snap_rootfs/meta/snap.yaml")
snap_arch=$(yq '.architectures[0]' "$snap_rootfs/meta/snap.yaml") #TODO: support multi arch?
snap_python_bin=$(readlink -f "$snap_rootfs/bin/python")
snap_python_name=$(basename $snap_python_bin) # used in locating craft libraries


# modify snap rootfs
rm -rf "$snap_rootfs/lib/python3.10/site-packages/rockcraft"
rsync -r --chown=root:root "$rockcraft/rockcraft" "$snap_rootfs/lib/python3.10/site-packages/"
rm -rf "$snap_rootfs/lib/$snap_python_name/site-packages/rockcraft"
rsync -r --chown=root:root "$rockcraft/rockcraft" "$snap_rootfs/lib/$snap_python_name/site-packages/"

rm -rf "$snap_rootfs/lib/python3.10/site-packages/craft_application"
rsync -r --chown=root:root "$craft_application/craft_application" "$snap_rootfs/lib/python3.10/site-packages/"
rm -rf "$snap_rootfs/lib/$snap_python_name/site-packages/craft_application"
rsync -r --chown=root:root "$craft_application/craft_application" "$snap_rootfs/lib/$snap_python_name/site-packages/"

rm -rf "$snap_rootfs/lib/python3.10/site-packages/craft_parts"
rsync -r --chown=root:root "$craft_parts/craft_parts" "$snap_rootfs/lib/python3.10/site-packages/"
rm -rf "$snap_rootfs/lib/$snap_python_name/site-packages/craft_parts"
rsync -r --chown=root:root "$craft_parts/craft_parts" "$snap_rootfs/lib/$snap_python_name/site-packages/"

rm -rf "$snap_rootfs/lib/python3.10/site-packages/craft_providers"
rsync -r --chown=root:root "$craft_providers/craft_providers" "$snap_rootfs/lib/python3.10/site-packages/"
rm -rf "$snap_rootfs/lib/$snap_python_name/site-packages/craft_providers"
rsync -r --chown=root:root "$craft_providers/craft_providers" "$snap_rootfs/lib/$snap_python_name/site-packages/"

# repack and install snap rootfs
export snap_dst_version="local-patch-$(date +%s)"
Expand Down

0 comments on commit 48fbab2

Please sign in to comment.