2007-09-23 08:04:50 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:04:50 +00:00
|
|
|
|
|
|
|
Exit ()
|
|
|
|
{
|
2020-02-12 01:40:38 -01:00
|
|
|
VALUE=$?
|
2009-10-19 11:52:54 +00:00
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
if [ "${_DEBUG}" = "true" ]
|
2007-09-23 08:04:50 +00:00
|
|
|
then
|
2007-09-23 08:04:51 +00:00
|
|
|
# Dump variables
|
2010-12-13 21:36:01 -01:00
|
|
|
set | grep -e ^LB
|
2007-09-23 08:04:50 +00:00
|
|
|
fi
|
|
|
|
|
2008-10-14 19:44:48 +00:00
|
|
|
# Always exit true in case we are not able to unmount
|
|
|
|
# (e.g. due to running processes in chroot from user customizations)
|
2008-10-19 15:02:28 +00:00
|
|
|
Echo_message "Begin unmounting filesystems..."
|
2009-12-23 20:27:18 -01:00
|
|
|
|
|
|
|
if [ -e /proc/mounts ]
|
|
|
|
then
|
|
|
|
for DIRECTORY in $(awk -v dir="${PWD}/chroot/" '$2 ~ dir { print $2 }' /proc/mounts | sort -r)
|
|
|
|
do
|
|
|
|
umount ${DIRECTORY} > /dev/null 2>&1 || true
|
|
|
|
done
|
|
|
|
else
|
2012-01-10 19:36:11 -01:00
|
|
|
for DIRECTORY in /dev/shm /dev/pts /dev /proc /selinux /sys /root/config
|
2009-12-23 20:27:18 -01:00
|
|
|
do
|
|
|
|
umount -f chroot/${DIRECTORY} > /dev/null 2>&1 || true
|
|
|
|
done
|
|
|
|
fi
|
2009-10-19 11:52:54 +00:00
|
|
|
|
2012-06-03 20:42:41 +00:00
|
|
|
rm -f .build/chroot_devpts
|
|
|
|
rm -f .build/chroot_proc
|
|
|
|
rm -f .build/chroot_selinuxfs
|
|
|
|
rm -f .build/chroot_sysfs
|
2012-01-22 20:31:27 -01:00
|
|
|
|
2011-09-07 18:00:40 +00:00
|
|
|
Echo_message "Saving caches..."
|
2011-07-19 09:13:17 +00:00
|
|
|
|
|
|
|
# We can't really know at which part we're failing,
|
|
|
|
# but let's assume that if there's any binary stage file arround
|
|
|
|
# we are in binary stage.
|
|
|
|
|
2012-06-03 20:42:41 +00:00
|
|
|
if ls .build/binary* > /dev/null 2>&1
|
2011-07-19 09:13:17 +00:00
|
|
|
then
|
2015-01-06 02:46:37 -01:00
|
|
|
Save_package_cache binary
|
2011-07-19 09:13:17 +00:00
|
|
|
else
|
2015-01-06 02:46:37 -01:00
|
|
|
Save_package_cache chroot
|
2011-07-19 09:13:17 +00:00
|
|
|
fi
|
|
|
|
|
2009-10-19 11:52:54 +00:00
|
|
|
return ${VALUE}
|
2007-09-23 08:04:50 +00:00
|
|
|
}
|
2008-10-19 14:58:29 +00:00
|
|
|
|
2015-02-05 02:30:47 -01:00
|
|
|
Setup_clean_exit ()
|
2008-10-19 14:58:29 +00:00
|
|
|
{
|
2015-02-05 02:30:47 -01:00
|
|
|
Echo_message "Setting up clean exit handler"
|
2008-10-31 04:45:05 -01:00
|
|
|
trap 'Exit' EXIT HUP INT QUIT TERM
|
2008-10-19 14:58:29 +00:00
|
|
|
}
|