command: add new build flag '--keep-builddir'

The working directory contains the files of a target OS system to build
and it's the source to create partitions and OS image. With the flag
'--keep-builddir' won't remove the working directory after the target OS
image is built such that one can traverse the file system in the build
machine. By default, the working directory will be removed.

Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: I00e8488797535410fde6dbd01249ecb8ebc1ae56
This commit is contained in:
Dongjin Kim
2021-04-14 19:30:12 +09:00
parent 7b24cbbaec
commit 28d4caa447
2 changed files with 15 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
boot_mnt=${WORKDIR}/boot
rootfs_mnt=${WORKDIR}/rootfs
boot_mnt=${build_dir}/boot
rootfs_mnt=${build_dir}/rootfs
fixups_dir=/host/fixups
do_unmount() {
@@ -30,7 +30,12 @@ cleanup() {
fi
umount -f ${boot_mnt} ${rootfs_mnt} 2>/dev/null
rm -rf ${boot_mnt} ${rootfs_mnt}
if [ "x${opt_keep_builddir}" != "xtrue" ]; then
rm -rf ${boot_mnt} ${rootfs_mnt}
fi
if [ "$(ls ${build_dir} | wc -l)" = "0" ]; then
rm -rf ${build_dir}
fi
}
trap_ctrlc() {

View File

@@ -8,6 +8,8 @@ usage() {
echo " --help: this help message"
echo " --output=<path>: output directory for image files."
echo " --live: enforce to build live boot system image."
echo " --keep-builddir: prevent removing temporary directory"
echo " after building an image."
exit 1
}
@@ -22,7 +24,6 @@ RUN_MENU=true
DEFAULT_CONFIG=${WORKDIR}/.config
download_dir="/var/cache/odroid-stamper/downloads"
out_dir=${WORKDIR}
for opt in "$@"; do
case $opt in
@@ -35,9 +36,14 @@ for opt in "$@"; do
--no-live) opt_livesystem=false;;
--live) opt_livesystem=true;;
--keep-builddir)
opt_keep_builddir=true;;
esac
done
[ "x${out_dir}" = "x" ] && out_dir=${WORKDIR}
build_dir="${out_dir}/BUILD"
. ${TOPDIR}/menu
. ${TOPDIR}/default
. ${TOPDIR}/functions