Skip to content

Commit

Permalink
fix(build): auto detection when to use when compressing the image usi…
Browse files Browse the repository at this point in the history
…ng xz
  • Loading branch information
reubenmiller committed Jan 11, 2024
1 parent 92987b9 commit 8a1a2c1
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions scripts/compress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
set -e

SUDO=
if [ -n "$CI" ]; then
# use sudo when running in the CI otherwise the following error occurs
# regardless of the owner of the file and folder.
# xz: Cannot set the file group: Operation not permitted

test_xz() {
# Check if xz can be used without sudo using a dummy file
echo "dummy" > .dummy_compress
failed=0
if ! xz -0 -v .dummy_compress >/dev/null >&2; then
failed=1
fi
rm -f .dummy_compress
rm -f .dummy_compress.xz
return "$failed"
}

# use sudo when running in the CI otherwise the following error occurs
# regardless of the owner of the file and folder.
# xz: Cannot set the file group: Operation not permitted
if ! test_xz; then
echo "xz test file returned a warning, so compressing using sudo" >&2
SUDO=sudo
fi

Expand Down

0 comments on commit 8a1a2c1

Please sign in to comment.