Improve `makecontainerpkg`
* Parse `pkgname` from `PKGBUILD` via sourcing to cope with variables * Allow overriding the container name to be able to re-use an existing container * Be verbose when installing packages during the image creation
This commit is contained in:
parent
ecf5bbef00
commit
3c78fa5fa7
|
@ -8,7 +8,7 @@ RUN mkdir -p /startdir /build && \
|
|||
pacman-key --recv-keys B9E36A7275FC61B464B67907E06FE8F53CDC6A4C && \
|
||||
pacman-key --finger B9E36A7275FC61B464B67907E06FE8F53CDC6A4C && \
|
||||
pacman-key --lsign-key B9E36A7275FC61B464B67907E06FE8F53CDC6A4C && \
|
||||
pacman -Syu --noconfirm --needed base-devel pacman-contrib ccache && \
|
||||
pacman -Syu --verbose --noconfirm --needed base-devel pacman-contrib ccache && \
|
||||
pacman -Scc --noconfirm && \
|
||||
paccache -r -k0 && \
|
||||
rm -rf /usr/share/man/* /tmp/* /var/tmp/*
|
||||
|
|
|
@ -2,9 +2,18 @@
|
|||
set -e
|
||||
|
||||
# make basic arguments for cre
|
||||
pkgname=$(grep -oP '(?<=pkgname=).+(?=$)' PKGBUILD | tr '+' 'p')
|
||||
uuid=$(cat /proc/sys/kernel/random/uuid)
|
||||
name=makechrootpkg-$pkgname-$uuid
|
||||
if [[ $CONTAINER ]]; then
|
||||
name=$CONTAINER
|
||||
else
|
||||
if [[ $PKGNAME ]]; then
|
||||
pkgname=$PKGNAME
|
||||
else
|
||||
source PKGBUILD
|
||||
pkgname=$(echo "$pkgname" | tr '+' 'p')
|
||||
fi
|
||||
uuid=$(cat /proc/sys/kernel/random/uuid)
|
||||
name=makechrootpkg-$pkgname-$uuid
|
||||
fi
|
||||
cre_args=(--name "$name" --workdir "/startdir" -v "$PWD":/startdir -it)
|
||||
|
||||
# parse arguments
|
||||
|
@ -33,8 +42,10 @@ fi
|
|||
|
||||
# invoke containerized build
|
||||
ec=0 cre=${CRE:-docker}
|
||||
"$cre" container create "${cre_args[@]}" "${CRE_IMAGE:-archlinux-base-devel}"
|
||||
"$cre" container start "$name"
|
||||
if ! [[ $CONTAINER ]]; then
|
||||
"$cre" container create "${cre_args[@]}" "${CRE_IMAGE:-archlinux-base-devel}"
|
||||
"$cre" container start "$name"
|
||||
fi
|
||||
"$cre" container exec "$name" bash \
|
||||
-c "$script_sync $script $script_args" || ec=$?
|
||||
|
||||
|
@ -46,6 +57,8 @@ ec=0 cre=${CRE:-docker}
|
|||
[[ $ec != 0 ]] && [[ $DEBUG ]] && echo \
|
||||
"You may investigate the failure via:
|
||||
$cre exec -it '$name' bash
|
||||
$cre mount '$name'"
|
||||
$cre mount '$name'
|
||||
You may retry the build using the same container again via:
|
||||
CONTAINER='$name' DEBUG='$DEBUG' $0 $@"
|
||||
|
||||
exit $ec
|
||||
|
|
Loading…
Reference in New Issue