live-build/helpers/lh_clean

107 lines
1.8 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
# lh_clean(1) - clean up system build directories
2007-09-23 08:04:48 +00:00
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.
2007-09-23 08:04:46 +00:00
set -e
# Source common functions
for FUNCTION in /usr/share/live-helper/functions/*.sh
do
. ${FUNCTION}
done
2007-09-23 08:04:48 +00:00
# Set static variables
DESCRIPTION="clean up system build directories"
HELP=""
USAGE="${PROGRAM} [all|cache|chroot|binary|lock|purge|stage|source]"
Arguments "${@}"
2007-09-23 08:04:46 +00:00
# Reading configuration files
Read_conffile config/common
Set_defaults
case "${1}" in
all)
"${0}" chroot
"${0}" binary
2007-09-23 08:04:48 +00:00
"${0}" lock
2007-09-23 08:04:46 +00:00
"${0}" stage
"${0}" source
2007-09-23 08:04:49 +00:00
if [ -d chroot ]
then
mkdir -p .stage
touch .stage/bootstrap
fi
2007-09-23 08:04:46 +00:00
;;
cache)
2007-09-23 08:04:47 +00:00
rm -rf cache
2007-09-23 08:04:46 +00:00
;;
chroot)
2007-09-23 08:04:47 +00:00
umount -f chroot/sys > /dev/null 2>&1 || true
umount -f chroot/proc > /dev/null 2>&1 || true
umount -f chroot/lib/init/rw > /dev/null 2>&1 || true
umount -f chroot/dev/shm > /dev/null 2>&1 || true
umount -f chroot/dev/pts > /dev/null 2>&1 || true
umount -f chroot/dev > /dev/null 2>&1 || true
rm -rf chroot
2007-09-23 08:04:48 +00:00
2007-09-23 08:04:49 +00:00
if [ "${PURGE}" != "true" ] && [ -d cache/chroot_bootstrap ]
then
cp -a cache/chroot_bootstrap chroot
mkdir -p .stage
touch .stage/bootstrap
fi
2007-09-23 08:04:48 +00:00
rm -f .stage/chroot*
2007-09-23 08:04:46 +00:00
;;
binary)
2007-09-23 08:04:47 +00:00
rm -f binary.iso
rm -f binary.img
rm -f binary*.tar.gz
rm -f packages.txt
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:48 +00:00
rm -rf binary
rm -rf tftpboot
2007-09-23 08:04:47 +00:00
rm -f .stage/binary*
2007-09-23 08:04:46 +00:00
;;
2007-09-23 08:04:48 +00:00
lock)
rm -f .lock
;;
purge)
2007-09-23 08:04:49 +00:00
PURGE="true" "${0}" all
2007-09-23 08:04:48 +00:00
"${0}" cache
;;
2007-09-23 08:04:46 +00:00
stage)
2007-09-23 08:04:47 +00:00
rm -rf .stage
2007-09-23 08:04:46 +00:00
;;
source)
2007-09-23 08:04:47 +00:00
rm -f source.iso
rm -f source.img
rm -f source*.tar.gz
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:48 +00:00
rm -rf source
2007-09-23 08:04:47 +00:00
rm -f .stage/source*
2007-09-23 08:04:46 +00:00
;;
*)
"${0}" all
;;
esac