mklni: Add cleanup args
This commit is contained in:
parent
6ef4d5dcbc
commit
6c4d6008e3
39
mklni
39
mklni
|
@ -70,6 +70,10 @@ build)
|
||||||
chroot_into
|
chroot_into
|
||||||
break 2 ;;
|
break 2 ;;
|
||||||
|
|
||||||
|
-r | -c | --cleanraw | --cleanup)
|
||||||
|
run_makelni "$opt"
|
||||||
|
break ;;
|
||||||
|
|
||||||
-h | -help | --help)
|
-h | -help | --help)
|
||||||
usage ;;
|
usage ;;
|
||||||
|
|
||||||
|
@ -96,6 +100,12 @@ usage() {
|
||||||
# Make image
|
# Make image
|
||||||
$0 build path/to/lnibuild
|
$0 build path/to/lnibuild
|
||||||
|
|
||||||
|
# Clean raw images
|
||||||
|
$0 -r or --cleanraw
|
||||||
|
|
||||||
|
# Clean build chroots
|
||||||
|
$0 -c or --cleanup
|
||||||
|
|
||||||
# Chroot into
|
# Chroot into
|
||||||
$0 chroot
|
$0 chroot
|
||||||
EOF
|
EOF
|
||||||
|
@ -328,6 +338,35 @@ build()
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_makelni()
|
||||||
|
{
|
||||||
|
[ ! -d "$CHROOTDIR" ] && {
|
||||||
|
log "Chroot not installed" error
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Running makelni $1"
|
||||||
|
|
||||||
|
prepare_chroot || {
|
||||||
|
log "Failed to setup chroot" error
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
chroot "$CHROOTDIR" /bin/bash -c "cd /makelni && ./makelni $1"
|
||||||
|
local exitcode=$?
|
||||||
|
|
||||||
|
detach_chroot || {
|
||||||
|
log "Failed to detach chroot" error
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "$exitcode" -eq "0" ] || {
|
||||||
|
log "Failed to build image" error
|
||||||
|
}
|
||||||
|
|
||||||
|
return "$exitcode"
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
if [ "$(id -u)" != "0" ]; then
|
||||||
log "$0 must be run as root"
|
log "$0 must be run as root"
|
||||||
exit 3
|
exit 3
|
||||||
|
|
Loading…
Reference in a new issue