cleanup with a trap
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
0181a1099f
commit
8adeef05bc
15
makepkg-ci
15
makepkg-ci
|
@ -1,19 +1,23 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
|
cleanup() { rm -rf "$tmpdir"; }
|
||||||
|
trap 'cleanup' EXIT
|
||||||
|
|
||||||
did="pkg-build-$$.$SRANDOM"
|
did="pkg-build-$$.$SRANDOM"
|
||||||
mkdir "/tmp/$did"
|
tmpdir="/tmp/$did"
|
||||||
|
mkdir "$tmpdir"
|
||||||
|
|
||||||
pkg_dest=$1
|
pkg_dest=$1
|
||||||
pkg_url=$2
|
pkg_url=$2
|
||||||
|
|
||||||
mkdir -p "$pkg_dest" || exit 1
|
mkdir -p "$pkg_dest" || exit 1
|
||||||
|
|
||||||
git clone "$pkg_url" "/tmp/$did"
|
git clone "$pkg_url" "$tmpdir"
|
||||||
cd "/tmp/$did"
|
cd "$tmpdir"
|
||||||
makepkg-podman --noconfirm -sL
|
makepkg-podman --noconfirm -sL
|
||||||
|
|
||||||
artifacts=( "/tmp/$did/"*.pkg.* )
|
artifacts=( "$tmpdir/"*.pkg.* )
|
||||||
for i in "${artifacts[@]}"; do
|
for i in "${artifacts[@]}"; do
|
||||||
i_name="${i##*/}"
|
i_name="${i##*/}"
|
||||||
|
|
||||||
|
@ -26,6 +30,3 @@ for i in "${artifacts[@]}"; do
|
||||||
cp -vn "$i" "$pkg_dest"
|
cp -vn "$i" "$pkg_dest"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# cleanup
|
|
||||||
rm -rf "/tmp/$did"
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user