aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfunctions.sh57
1 files changed, 28 insertions, 29 deletions
diff --git a/functions.sh b/functions.sh
index 5d331e4..72c5fae 100755
--- a/functions.sh
+++ b/functions.sh
@@ -24,7 +24,7 @@ function timestamp() {
date "+[%H:%M:%S]"
}
-function exit(){
+function cleanExit(){
if [ 0 -ne ${#} ]; then
if [ 0 -ne ${1} ]; then
warning "unmounting all mounted files before exit"
@@ -34,7 +34,6 @@ function exit(){
fi
fi
- unset exit
exit $@
}
@@ -97,7 +96,7 @@ function createchroot() {
installpkg "distribution-gpg-keys" "--setopt=install_weak_deps=False"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't install distribution-gpg-keys : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
@@ -107,7 +106,7 @@ function createchroot() {
installpkg "qemu-user-static" "--setopt=install_weak_deps=False"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't install qemu-user-static : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
# Starting qemu service if not started
@@ -118,14 +117,14 @@ function createchroot() {
/usr/bin/systemctl start systemd-binfmt.service
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't start qemu-user-static : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
# else
# title "Restarting systemd-binfmt.service"
# /usr/bin/systemctl restart systemd-binfmt.service
# if [ ${?} -ne 0 ]; then
# error "line ${LINENO} can't start qemu-user-static : exiting"
-# exit ${ERR_1}
+# cleanExit ${ERR_1}
# fi
fi
return 0
@@ -178,7 +177,7 @@ function enableextrarepos() {
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate nonfree repositories : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
if [ ${TAINTED} -eq 1 ]; then
@@ -191,7 +190,7 @@ function enableextrarepos() {
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate tainted repositories : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
return 0
@@ -220,7 +219,7 @@ function addurpmimedia() {
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't add medias from ${MIRROR} : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
if [ ${NONFREE} -eq 1 ]; then
title "activating non-free repos"
@@ -228,7 +227,7 @@ function addurpmimedia() {
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate medias nonfree : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
if [ ${TAINTED} -eq 1 ]; then
@@ -237,7 +236,7 @@ function addurpmimedia() {
err=${?}
if [ ${err} -ne 0 ]; then
error "line ${LINENO} error ${err} - can't activate medias tainted : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
return 0
@@ -248,7 +247,7 @@ function updateurpmmirror() {
/sbin/urpmi.update -a --urpmi-root "${BUILD_PATH}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't update mirrors : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
return 0
}
@@ -263,10 +262,10 @@ function installbasesystem() {
/usr/bin/mkdir -p "${BUILD_PATH}/usr/bin" "${BUILD_PATH}/usr/lib/binfmt.d"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't create ${BUILD_PATH} : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
else
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
else
print_info "Build path exists"
@@ -289,7 +288,7 @@ function installbasesystem() {
installpkg "shadow-utils basesystem-minimal"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error installing shadow-utils or basesystem-minimal : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
if [ ${INSTALL_METHOD} = "urpmi" ]; then
installpkg "urpmi locales"
@@ -319,7 +318,7 @@ function preparechroot() {
cp --preserve=mode "${CONFIG_PATH}/second_stage_install.sh" "${BUILD_PATH}/second_stage_install.sh"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error copying ${CONFIG_PATH}/second_stage_install.sh : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
print_info "configuring second_stage_install.sh for ${INSTALL_METHOD}"
if [ ${INSTALL_METHOD} = "urpmi" ]; then
@@ -350,7 +349,7 @@ function preparechroot() {
postPrepareChroot
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error in postPrepareChroot function."
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
return 0
}
@@ -368,19 +367,19 @@ function mountdevsysproc(){
# fi
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BUILD_PATH}/dev : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
MOUNTED_DEV=true
/usr/bin/mount -B /sys "${BUILD_PATH}/sys"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BUILD_PATH}/sys : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
MOUNTED_SYS=true
/usr/bin/mount -B /proc "${BUILD_PATH}/proc"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BUILD_PATH}/proc : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
MOUNTED_PROC=true
return 0
@@ -422,7 +421,7 @@ function jumpchroot() {
/usr/bin/cp -v --preserve=mode /etc/resolv.conf "${BUILD_PATH}/etc/"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error copying ${BUILD_PATH}/etc/resolv.conf : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
print_info "chrooting to ${BUILD_PATH}"
@@ -455,7 +454,7 @@ function createImageWrap() {
preImgCreation
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
createimage
@@ -479,7 +478,7 @@ function createimage() {
/usr/bin/rm -f "${INSTALL_PATH}/${IMAGE}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error can't remove previous image at ${INSTALL_PATH}/${IMAGE} : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
fi
@@ -488,7 +487,7 @@ function createimage() {
/usr/bin/truncate -s ${IMAGE_SIZE}G "${INSTALL_PATH}/${IMAGE}"
if [ ${?} -ne 0 ]; then
error "line ${LINENO} can't make image at ${INSTALL_PATH}/${IMAGE} : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
/usr/bin/chown ${USER}:${USER} "${INSTALL_PATH}/${IMAGE}"
@@ -592,7 +591,7 @@ function formatpartitions() {
error "line ${LINENO} error formating ${BOOTP} : exiting"
# /usr/sbin/losetup -d "${DEVICE}"
udisksctl unmount -b ${BOOTP}
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
# BOOT_UUID=$(/usr/sbin/blkid -s UUID -o value UUID "${BOOTP}")
# print_info "Boot UUID: ${BOOT_UUID}"
@@ -606,7 +605,7 @@ function formatpartitions() {
error "line ${LINENO} error formating ${ROOTP} : exiting"
# /usr/sbin/losetup -d "${DEVICE}"
# udisksctl unmount -b ${ROOTP}
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
ROOT_UUID=$(echo "${FSINFO}" | grep 'Filesystem UUID' | sed 's/Filesystem UUID: //')
# ROOT_UUID=$(/usr/sbin/blkid -s UUID -o value UUID "${ROOTP}")
@@ -661,7 +660,7 @@ function copyingsystem() {
copyingCustomSystem
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error in the process ${CONFIG_PATH}/specialFunctions.sh ."
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
copyingcommon
@@ -679,7 +678,7 @@ function mountPartitions() {
ROOT=$(/usr/bin/udisksctl mount -b ${ROOTP} | sed -e 's/^.* at //' -e 's/\.$//' )
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${ROOTP} : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
MOUNTED_ROOT=true
print_info "Root partition mount in ${ROOT}"
@@ -689,7 +688,7 @@ function mountPartitions() {
BOOT=$(/usr/bin/udisksctl mount -b ${BOOTP} | sed -e 's/^.* at //' -e 's/\.$//' )
if [ ${?} -ne 0 ]; then
error "line ${LINENO} error mounting ${BOOTP} : exiting"
- exit ${ERR_1}
+ cleanExit ${ERR_1}
fi
print_info "boot partition mount in ${BOOT}"
MOUNTED_BOOT=true