live-build/scripts/build/clean

164 lines
3.7 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
## live-build(7) - System Build Scripts
2013-05-06 12:48:46 +00:00
## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
##
## This program 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
# Including common functions
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
# Read meta config
if [ "${1}" != "noauto" ] && [ -x auto/clean ]
then
Echo_message "Executing auto/clean script."
./auto/clean "${@}"
exit ${?}
fi
if [ "${1}" = "noauto" ]
then
shift
fi
2007-09-23 08:05:11 +00:00
# Setting static variables
DESCRIPTION="$(Echo 'clean up system build directories')"
2007-09-23 08:04:48 +00:00
HELP=""
USAGE="${PROGRAM} [--all] [--cache] [--chroot] [--binary] [--purge] [--remove] [--stage] [--source]"
2007-09-23 08:04:48 +00:00
#Arguments "${@}"
2007-09-23 08:04:48 +00:00
2007-09-23 08:04:46 +00:00
# Reading configuration files
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
2007-09-23 08:04:46 +00:00
Set_defaults
# Avoid cases were users accidentally nuke their config/binary
if [ ! -d config ] && [ "$(basename ${PWD})" = "config" ]
then
Echo_error "%s is not a good Debian Live working directory to clean." "${PWD}"
exit 1
fi
2007-09-23 08:05:12 +00:00
rm -f .lock
if [ -z "${1}" ]
then
ARGUMENTS="--all"
else
ARGUMENTS="${@}"
fi
for ARGUMENT in ${ARGUMENTS}
2007-09-23 08:05:18 +00:00
do
case "${ARGUMENT}" in
--all)
"${0}" noauto --chroot
"${0}" noauto --binary
"${0}" noauto --stage
"${0}" noauto --source
rmdir --ignore-fail-on-non-empty auto > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty local/bin > /dev/null 2>&1 || true
rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true
2007-09-23 08:05:18 +00:00
;;
--cache)
${LB_ROOT_COMMAND} rm -rf cache
2007-09-23 08:05:18 +00:00
;;
--chroot)
2007-09-23 08:05:18 +00:00
Echo_message "Cleaning chroot"
${LB_ROOT_COMMAND} umount -f chroot/run > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/sys > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/proc/sys/fs/binfmt_misc > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/proc > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/lib/init/rw > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/dev/shm > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/dev/pts > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/dev > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/var/lib/dpkg > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/root/config > /dev/null 2>&1 || true
2007-09-23 08:05:18 +00:00
${LB_ROOT_COMMAND} umount -f chroot/binary.tmp > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} umount -f chroot/dev.tmp/pts > /dev/null 2>&1 || true
${LB_ROOT_COMMAND} rm -rf chroot chroot.tmp
2007-09-23 08:05:18 +00:00
rm -f chroot.packages.live chroot.packages.install
rm -f .build/chroot*
2007-09-23 08:05:18 +00:00
;;
--binary)
${LB_ROOT_COMMAND} umount -f binary.tmp > /dev/null 2>&1 || true
2007-09-23 08:05:18 +00:00
rm -rf binary.tmp binary.deb binary.udeb
rm -f ${LIVE_IMAGE_NAME}*.iso
rm -f ${LIVE_IMAGE_NAME}*.img
rm -f ${LIVE_IMAGE_NAME}*.tar.gz
rm -f ${LIVE_IMAGE_NAME}*.zsync*
rm -f ${LIVE_IMAGE_NAME}.sh
rm -f ${LIVE_IMAGE_NAME}.contents ${LIVE_IMAGE_NAME}.packages md5sum.txt
2007-09-23 08:05:18 +00:00
rm -rf binary
rm -rf tftpboot
rm -f .build/binary*
2007-09-23 08:05:18 +00:00
;;
--remove)
"${0}" --all
rm -rf cache/packages.*
;;
--purge)
"${0}" --all
"${0}" --cache
if [ -e auto/config ]
then
rm -f .build/config
fi
2007-09-23 08:05:18 +00:00
;;
--stage)
rm -rf .build
2007-09-23 08:05:18 +00:00
;;
--source)
rm -f source*.iso
rm -f source*.img
2007-09-23 08:05:18 +00:00
rm -f source*.tar
rm -f source*.tar.gz
2011-06-12 07:21:28 +00:00
rm -f source*.list
rm -f source-selection.txt
2007-09-23 08:05:18 +00:00
rm -rf source
rm -f .build/source*
2007-09-23 08:05:18 +00:00
;;
-h|--help)
Help
;;
-u|--usage)
Usage
;;
-v|--version)
2012-07-18 19:38:58 +00:00
echo "${VERSION}"
exit 0
;;
2007-09-23 08:05:18 +00:00
*)
Usage
exit 1
2007-09-23 08:05:18 +00:00
;;
esac
done