Skip to content

Commit

Permalink
Fix shellscripts and use sudo for snap
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvervloesem committed Jul 25, 2022
1 parent 69711a1 commit 59cfdbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Install ubuntu-image
run: snap install ubuntu-image --classic
run: sudo snap install ubuntu-image --classic
- name: Build images
run: ./scripts/build-images.sh
34 changes: 17 additions & 17 deletions scripts/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ rm -rf "$build_dir"
mkdir "$build_dir"

for model_assertion in *.model; do
echo "Building image for model assertion $model_assertion..."
ubuntu-image snap "$model_assertion" --output-dir="$build_dir" --validation=enforce
if [[ -f "$build_dir/pi.img" ]]; then
image_file=pi.img
elif [[ -f "$build_dir/pc.img" ]]; then
image_file=pc.img
else
echo "No suitable image file found"
exit 1
fi
echo "Building image for model assertion $model_assertion..."
ubuntu-image snap "$model_assertion" --output-dir="$build_dir" --validation=enforce
if [[ -f "$build_dir/pi.img" ]]; then
image_file=pi.img
elif [[ -f "$build_dir/pc.img" ]]; then
image_file=pc.img
else
echo "No suitable image file found"
exit 1
fi

compressed_image_file="$build_dir/${model_assertion%.model}.img.xz"
manifest_file="$build_dir/${model_assertion%.model}.manifest"
compressed_image_file="$build_dir/${model_assertion%.model}.img.xz"
manifest_file="$build_dir/${model_assertion%.model}.manifest"

echo "Compressing image to $compressed_image_file..."
xz -9 "$build_dir/$image_file"
mv "$build_dir/$image_file.xz" "$compressed_image_file"
echo "Compressing image to $compressed_image_file..."
xz -9 "$build_dir/$image_file"
mv "$build_dir/$image_file.xz" "$compressed_image_file"

echo "Saving seed manifest to $manifest_file"
mv "$build_dir/seed.manifest" "$manifest_file"
echo "Saving seed manifest to $manifest_file"
mv "$build_dir/seed.manifest" "$manifest_file"
done
6 changes: 3 additions & 3 deletions scripts/sign-model-assertions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
set -e

if [ $# -eq 0 ]; then
echo "Specify your snapcraft key to sign the assertion model with"
exit 1
echo "Specify your snapcraft key to sign the assertion model with"
exit 1
fi

signing_key=$1

for model_assertion in *.json; do
snap sign -k "$signing_key" < "$model_assertion" > "${model_assertion%.json}.model"
snap sign -k "$signing_key" <"$model_assertion" >"${model_assertion%.json}.model"
done

0 comments on commit 59cfdbf

Please sign in to comment.