functions.inc.sh: fix tmp rootfs unmounting by killing any gpg-agent spawned

This commit is contained in:
Silvan Calarco 2020-12-17 12:08:33 +01:00
parent 51c07b9cf2
commit 1243a25eba

View File

@ -1,6 +1,6 @@
# Functions used by makedist scripts
#
# Copyright (c) 2004-2011 by Silvan Calarco (silvan.calarco@mambasoft.it)
# Copyright (c) 2004-2020 by Silvan Calarco (silvan.calarco@mambasoft.it)
# Copyright (c) 2004-2005 by Davide Madrisan (davide.madrisan@gmail.com)
#
@ -98,7 +98,7 @@ function initialize_root_dir() {
#[ $MEDIA = "raw" ] && create_raw_filesystem $LOCALSTATEDIR/$MEDIA_NAME $MEDIA_SIZE 1024k $ROOTFS
[ $MEDIA = "raw" ] && create_raw_disk_image $MEDIA_SIZE 1024k
trap "[ $LOOPDEV ] && losetup -d $LOOPDEV; [ -e $MOUNTDIR/proc/version ] && umount $MOUNTDIR/proc; [ \"$MOUNTDIR_TMPFS\" ] && umount $MOUNTDIR_TMPFS" 0 HUP INT QUIT ABRT KILL TERM
trap "[ $LOOPDEV ] && losetup -d $LOOPDEV; [ -e $MOUNTDIR/proc/version ] && umount $MOUNTDIR/proc; chroot $MOUNTDIR /usr/bin/gpgconf --kill gpg-agent; [ \"$MOUNTDIR_TMPFS\" ] && umount $MOUNTDIR_TMPFS" 0 HUP INT QUIT ABRT KILL TERM
}
function create_rpm_database() {
@ -143,6 +143,8 @@ $RPM_CHROOT_PREFIX $RPM $RPM_ROOT_APPEND --initdb" > ${LOCALSTATEDIR}/${BUILDSCR
function clean_rpm_database() {
echo "Cleaning rpm database"
[ "$MOUNTDIR" != "" -a "$MOUNTDIR" != "/" ] && rm -rf $MOUNTDIR/var/lib/rpm/__db.*
# Kill any gpg-agent daemon spawned daemon preventing umount
chroot $MOUNTDIR /usr/bin/gpgconf --kill gpg-agent || :
}
function erase_rpm_database() {
@ -1097,15 +1099,18 @@ function produce_media() {
mkisofs -quiet \
-o $LOCALSTATEDIR/$MEDIUM_FILENAME \
-volid ${MAKEDIST_TARGET}_${PLATFORM} -volset $PLATFORM -publisher mambaSoft -preparer makedist \
$BOOTOPTIONS -l -R -r $MOUNTDIR
$BOOTOPTIONS -l -R -r $MOUNTDIR || {
echo "Error $? returned running mkisofs; aborting."
exit 1
}
isohybrid $LOCALSTATEDIR/$MEDIUM_FILENAME
;;
iso-grub|ISO-GRUB)
echo "Producing ISO-GRUB image $MEDIUM_FILENAME..."
grub_mkisofs_arguments="-volid $MAKEDIST_TARGET -volset $PLATFORM -publisher mambaSoft -preparer makedist -quiet" \
grub-mkrescue --output=$LOCALSTATEDIR/$MEDIUM_FILENAME $MOUNTDIR &> /dev/null
[ $1 ] && {
echo "Error $1 returned by grub-mkrescue; command line was:
[ $? ] && {
echo "Error $? returned by grub-mkrescue; command line was:
grub_mkisofs_arguments=\"-volid $MAKEDIST_TARGET -volset $PLATFORM -publisher mambaSoft -preparer makedist -quiet\" \
grub-mkrescue --output=$LOCALSTATEDIR/$MEDIUM_FILENAME $MOUNTDIR"
}