mklni: Add cleanup args

This commit is contained in:
timoxa0 2024-11-02 23:12:32 +05:00
parent 4a5c854855
commit a564fd7787

39
mklni
View file

@ -70,6 +70,10 @@ build)
chroot_into
break 2 ;;
-r | -c | --cleanraw | --cleanup)
run_makelni "$opt"
break ;;
-h | -help | --help)
usage ;;
@ -96,6 +100,12 @@ usage() {
# Make image
$0 build path/to/lnibuild
# Clean raw images
$0 -r or --cleanraw
# Clean build chroots
$0 -c or --cleanup
# Chroot into
$0 chroot
EOF
@ -328,6 +338,35 @@ build()
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
log "$0 must be run as root"
exit 3