3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
6 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7 ## This is free software, and you are welcome to redistribute it
8 ## under certain conditions; see COPYING for details.
15 if [ "${_DEBUG}" = "true" ]
21 # Always exit true in case we are not able to unmount
22 # (e.g. due to running processes in chroot from user customizations)
23 Echo_message
"Begin unmounting filesystems..."
25 if [ -e /proc
/mounts
]
27 for DIRECTORY
in $
(awk -v dir
="${PWD}/chroot/" '$2 ~ dir { print $2 }' /proc
/mounts |
sort -r)
29 umount
${DIRECTORY} > /dev
/null
2>&1 || true
32 for DIRECTORY
in /dev
/shm
/dev
/pts
/dev
/proc
/selinux
/sys
/root
/config
34 umount
-f chroot
/${DIRECTORY} > /dev
/null
2>&1 || true
38 rm -f .build
/chroot_devpts
39 rm -f .build
/chroot_proc
40 rm -f .build
/chroot_selinuxfs
41 rm -f .build
/chroot_sysfs
43 Echo_message
"Saving caches..."
45 # We can't really know at which part we're failing,
46 # but let's assume that if there's any binary stage file arround
47 # we are in binary stage.
49 if ls .build
/binary
* > /dev
/null
2>&1
51 Save_cache cache
/packages.binary
53 Save_cache cache
/packages.chroot
61 Echo_message
"Setting up cleanup function"
62 trap 'Exit' EXIT HUP INT QUIT TERM