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:49 +00:00
|
|
|
Echo_debug "Init ${PROGRAM}"
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
# Reading configuration files
|
2007-09-23 08:04:52 +00:00
|
|
|
Read_conffile config/common
|
2007-09-23 08:04:49 +00:00
|
|
|
Read_conffile config/bootstrap
|
|
|
|
Read_conffile config/chroot
|
2007-09-23 08:04:52 +00:00
|
|
|
Read_conffile config/binary
|
|
|
|
Read_conffile config/source
|
2007-09-23 08:04:46 +00:00
|
|
|
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:51 +00:00
|
|
|
${LH_ROOT_COMMAND} rm -rf cache
|
2007-09-23 08:04:46 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
chroot)
|
2007-09-23 08:04:51 +00:00
|
|
|
${LH_ROOT_COMMAND} umount -f chroot/sys > /dev/null 2>&1 || true
|
|
|
|
${LH_ROOT_COMMAND} umount -f chroot/proc > /dev/null 2>&1 || true
|
|
|
|
${LH_ROOT_COMMAND} umount -f chroot/lib/init/rw > /dev/null 2>&1 || true
|
|
|
|
${LH_ROOT_COMMAND} umount -f chroot/dev/shm > /dev/null 2>&1 || true
|
|
|
|
${LH_ROOT_COMMAND} umount -f chroot/dev/pts > /dev/null 2>&1 || true
|
|
|
|
${LH_ROOT_COMMAND} umount -f chroot/dev > /dev/null 2>&1 || true
|
2007-09-23 08:04:47 +00:00
|
|
|
|
2007-09-23 08:04:51 +00:00
|
|
|
${LH_ROOT_COMMAND} rm -rf chroot chroot.tmp
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2007-09-23 08:04:52 +00:00
|
|
|
if [ "${PURGE}" != "true" ] && [ -d cache/stages_bootstrap ]
|
2007-09-23 08:04:49 +00:00
|
|
|
then
|
2007-09-23 08:04:52 +00:00
|
|
|
${LH_ROOT_COMMAND} cp -a cache/stages_bootstrap chroot
|
2007-09-23 08:04:49 +00:00
|
|
|
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
|
2007-09-23 08:04:50 +00:00
|
|
|
rm -f source*.tar
|
2007-09-23 08:04:47 +00:00
|
|
|
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
|