diff --git a/usr/bin/archboot-aarch64-create-container.sh b/usr/bin/archboot-aarch64-create-container.sh index 030ac0038..f3b001ecb 100755 --- a/usr/bin/archboot-aarch64-create-container.sh +++ b/usr/bin/archboot-aarch64-create-container.sh @@ -9,6 +9,7 @@ _root_check echo "Starting container creation ..." [[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then + _cachedir_check _create_pacman_conf "${1}" _prepare_pacman "${1}" || exit 1 _pacman_parameters "${1}" diff --git a/usr/bin/archboot-riscv64-create-container.sh b/usr/bin/archboot-riscv64-create-container.sh index 8741f9005..1ff247b24 100755 --- a/usr/bin/archboot-riscv64-create-container.sh +++ b/usr/bin/archboot-riscv64-create-container.sh @@ -9,6 +9,7 @@ _root_check echo "Starting container creation ..." [[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") if [[ "${_RUNNING_ARCH}" == "riscv64" ]]; then + _cachedir_check _create_pacman_conf "${1}" _prepare_pacman "${1}" || exit 1 _pacman_parameters "${1}" diff --git a/usr/bin/archboot-x86_64-create-container.sh b/usr/bin/archboot-x86_64-create-container.sh index 18b7bbb94..8eebc77ec 100755 --- a/usr/bin/archboot-x86_64-create-container.sh +++ b/usr/bin/archboot-x86_64-create-container.sh @@ -7,6 +7,7 @@ _ARCHBOOT="archboot" _parameters "$@" _root_check _x86_64_check +_cachedir_check echo "Starting container creation ..." [[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") _create_pacman_conf "${1}" diff --git a/usr/lib/archboot/common.sh b/usr/lib/archboot/common.sh index 3414d9362..4644a65e5 100644 --- a/usr/lib/archboot/common.sh +++ b/usr/lib/archboot/common.sh @@ -141,6 +141,7 @@ _pacman_parameters() { _PACMAN_CACHEDIR="--cachedir ${_CACHEDIR}" _PACMAN_DB="--dbpath ${1}/blankdb" fi + [[ -d "${1}"/blankdb ]] || mkdir "${1}"/blankdb # defaults used on every pacman call _PACMAN_DEFAULTS="--config ${_PACMAN_CONF} ${_PACMAN_CACHEDIR} --ignore systemd-resolvconf --noconfirm" } @@ -162,3 +163,10 @@ _riscv64_disable_graphics() { #shellcheck disable=SC2001 [[ "$(echo "${_CONTAINER_ARCH}" | sed -e 's#\r##g')" == "riscv64" ]] && _GRAPHICAL_PACKAGES="" } + +_cachedir_check() { + if grep -q ^CacheDir /etc/pacman.conf; then + echo "Error: CacheDir is set in /etc/pacman.conf. Aborting ..." + exit 1 + fi +} diff --git a/usr/lib/archboot/container.sh b/usr/lib/archboot/container.sh index 6b5fc4701..e3a06768e 100644 --- a/usr/lib/archboot/container.sh +++ b/usr/lib/archboot/container.sh @@ -144,13 +144,12 @@ _umount_special() { _install_base_packages() { _PACMAN_OPTIONS="${_PACKAGES} ${_PACMAN_DEFAULTS}" - [[ -d "${1}"/blankdb ]] || mkdir "${1}"/blankdb if [[ "${2}" == "use_binfmt" ]]; then echo "Downloading ${_PACKAGES} to ${1} ..." ${_PACMAN} -Syw ${_PACMAN_OPTIONS} --dbpath /blankdb >/dev/null 2>&1 || exit 1 fi echo "Installing packages ${_PACKAGES} to ${1} ..." - ${_PACMAN} -Sy ${_PACMAN_OPTIONS} >/dev/null 2>&1 || exit 1 + ${_PACMAN} -Sy ${_PACMAN_OPTIONS} >/dev/null 2>&1 || exit 1 } _install_archboot() { @@ -163,7 +162,6 @@ _install_archboot() { [[ "${_RUNNING_ARCH}" == "riscv64" ]] && _GRAPHICAL_PACKAGES="" fi [[ "${_CLEANUP_CACHE}" == "1" ]] && _GRAPHICAL_PACKAGES="" - [[ -d "${1}"/blankdb ]] || mkdir "${1}"/blankdb _pacman_key #shellcheck disable=SC2086 if grep -qw archboot /etc/hostname; then diff --git a/usr/lib/archboot/repository.sh b/usr/lib/archboot/repository.sh index 3f1f83efc..08609f85a 100644 --- a/usr/lib/archboot/repository.sh +++ b/usr/lib/archboot/repository.sh @@ -11,16 +11,8 @@ _usage () { exit 0 } -_cachedir_check() { - if grep -q ^CacheDir /etc/pacman.conf; then - echo "Error: CacheDir set in /etc/pacman.conf. Aborting ..." - exit 1 - fi -} - _download_packages() { _PACMAN_OPTIONS="${_PACKAGES} ${_ARCHBOOT} ${_GRAPHICAL_PACKAGES} ${_PACMAN_DEFAULTS}" - [[ -d "${1}"/blankdb ]] || mkdir "${1}"/blankdb if [[ "${2}" == "use_binfmt" ]]; then _copy_gpg_key _riscv64_disable_graphics