From e7f41bbb607f4ac545c3ba3875d40c2c5a12b988 Mon Sep 17 00:00:00 2001 From: langfingaz Date: Fri, 11 Jun 2021 14:20:12 +0200 Subject: [PATCH] tmp --- build-archiso.sh | 55 ++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/build-archiso.sh b/build-archiso.sh index e725414..63436b8 100755 --- a/build-archiso.sh +++ b/build-archiso.sh @@ -2,35 +2,50 @@ # # https://wiki.archlinux.org/index.php/Archiso#Prepare_a_custom_profile # -# Arch installer with some additional packages: -# -> TODO: set custom welcome message in /etc/motd -# -> de-p1st-installer -# -> [de-p1st] repository enabled in pacman.conf -# -> german keyboard -# -> nano with syntax highlighting -# -> git -# -> screen with long scrollback history configured +# TODO: set custom welcome message in /etc/motd # BUILD_DIR=./archlive -PKGS=('git' 'de-p1st-keyboard' 'de-p1st-nano' 'de-p1st-screen' 'de-p1st-pacman' 'de-p1st-systemd' 'de-p1st-installer') -PACMAN_CFG_ADDITION='pkg/de-p1st-pacman/pacman.d/de-p1st' # will be used to extend the builder's pacman.conf +PKGS=() +PKGS+=('de-p1st-keyboard') # german keyboard +PKGS+=('de-p1st-nano') # syntax hilighting in nano +PKGS+=('de-p1st-screen') # longer scrollback history in screen +PKGS+=('de-p1st-pacman') # [de-p1st] mirror enabled +PKGS+=('de-p1st-installer') # de-p1st-installer script ################################ -if [ "$1" = "clean" ] ; then - sudo rm -r "${BUILD_DIR}" || exit $? -elif [ -d "${BUILD_DIR}" ] ; then - echo "Build dir does already exist and may not be empty!" - echo "Run '$0 clean' to start a clean ISO build." - exit 1 +function isEmptyDir() { + if [ -n "$(find "$DIR_TO_CHECK" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then + # "Empty directory" + return 0 + else + # echo "Not empty or NOT a directory" + return 1 + fi +} + + +if [ -d "${BUILD_DIR}" ]; then + if ! isEmptyDir "${BUILD_DIR}"; then + if [ "$1" = "clean" ]; then + sudo rm -r "${BUILD_DIR}" || exit $? + mkdir -p "${BUILD_DIR}" || exit $? + else + echo "BUILD_DIR not empty"; + echo "Run '$0 clean' to start a clean ISO build." + exit 1; + fi + fi # else: BUILD_DIR exists and is empty :) +elif ! mkdir -p "${BUILD_DIR}"; then + echo "Could not create BUILD_DIR"; + exit 1; fi -mkdir "$BUILD_DIR" || exit $? # The releng profile is used to create the official monthly installation ISO PROFILE=/usr/share/archiso/configs/releng/ -if [ ! -d "${PROFILE}" ] ; then +if [ ! -d "${PROFILE}" ]; then echo "Installing dependency 'archiso' with sudo ..." sudo pacman -S --needed archiso || exit $? fi @@ -39,10 +54,10 @@ cp -r "$PROFILE" "$BUILD_DIR"/profile || exit $? # extend the builder's pacman.conf (add de-p1st mirrors) # https://wiki.archlinux.org/index.php/Archiso#Custom_local_repository -cat "${PACMAN_CFG_ADDITION}" >> "$BUILD_DIR"/profile/pacman.conf || exit $? +cat "pkg/de-p1st-pacman/pacman.d/de-p1st" >>"$BUILD_DIR"/profile/pacman.conf || exit $? for PKG in "${PKGS[@]}"; do - echo "${PKG}" >> "${BUILD_DIR}"/profile/packages.x86_64 + echo "${PKG}" >>"${BUILD_DIR}"/profile/packages.x86_64 done ###