-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat_yaml_check
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: mock-rock | ||
summary: Hello World | ||
description: The most basic example of a rock. | ||
version: "1.0" | ||
base: bare | ||
build-base: ubuntu@22.04 | ||
license: Apache-2.0 | ||
platforms: | ||
amd64: | ||
arm64: | ||
|
||
parts: | ||
hello: | ||
plugin: nil | ||
stage-packages: | ||
- hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: mock-rock | ||
summary: Hello World | ||
description: The most basic example of a rock. | ||
version: "1.1" | ||
base: bare | ||
build-base: ubuntu@22.04 | ||
license: Apache-2.0 | ||
platforms: | ||
amd64: | ||
|
||
parts: | ||
hello: | ||
plugin: nil | ||
stage-packages: | ||
- hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: mock-rock | ||
summary: Hello World | ||
description: The most basic example of a rock. | ||
version: "1.2" | ||
base: bare | ||
build-base: ubuntu@22.04 | ||
license: Apache-2.0 | ||
platforms: | ||
amd64: | ||
|
||
parts: | ||
hello: | ||
plugin: nil | ||
stage-packages: | ||
- hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Rockcraft Patcher | ||
|
||
`patcher.sh` enables quick rockcraft "builds" for development by patching | ||
an existing snap package with changes made to dependencies on the local | ||
system. | ||
|
||
## How to use | ||
|
||
0. Clone rockcraft, craft-application, craft-providers and craft-parts. | ||
1. Build a Rockcraft snap package to use as a donor for the patched package. | ||
2. Place the the `patcher.sh` sciprt in the rockcraft source directory. | ||
3. Edit the paths in the script to point to the other craft repositories on | ||
your system as well as the donor package. | ||
4. Run `patcher.sh` to create the patched package and install it to the system. | ||
The installation can be verified by checking `snap list`. Rockcraft should show | ||
a version number similar to `local-patch-<timestamp>`. | ||
|
||
`patcher.sh` can be run as needed for testing changes made to the local repos. | ||
|
||
## TODO: | ||
- Support debugging Python in rockcraft. Include VSCodes launch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#! /bin/bash | ||
|
||
# Rockcraft snap package patcher | ||
# Version 4 | ||
|
||
set -xe | ||
|
||
# configurable vars | ||
src_snap="rockcraft_1.5.3.post51+gc99aa44.d20241011_amd64.snap" # snap package to modify | ||
rockcraft="." # Path to rockcraft repo | ||
craft_application="../craft-application/" # Path to craft_application repo | ||
craft_providers="../craft-providers/" # Path to craft_providers repo | ||
craft_parts="../craft-parts/" # Path to craft_providers repo | ||
|
||
|
||
# setup | ||
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/$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/$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/$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/$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)" | ||
yq e -i ".version= env(snap_dst_version)" "$snap_rootfs/meta/snap.yaml" | ||
dst_snap="${snap_name}_${snap_dst_version}_${snap_arch}.snap" | ||
|
||
rm -f "$dst_snap" | ||
mksquashfs "$snap_rootfs" "$dst_snap" -noappend -comp lzo -no-fragments | ||
sudo snap install "$dst_snap" --dangerous --classic | ||
|
||
# cleanup | ||
rm -rf "$snap_rootfs" |