arch/build-archiso.sh

69 lines
1.9 KiB
Bash
Raw Normal View History

2021-04-28 17:21:39 +02:00
#!/bin/bash
#
# https://wiki.archlinux.org/index.php/Archiso#Prepare_a_custom_profile
#
2021-06-11 14:20:12 +02:00
# TODO: set custom welcome message in /etc/motd
2021-04-28 17:21:39 +02:00
#
BUILD_DIR=./archlive
2021-06-11 14:20:12 +02:00
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
2021-04-28 17:21:39 +02:00
################################
2021-06-11 14:20:12 +02:00
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;
2021-04-28 17:21:39 +02:00
fi
2021-04-29 12:09:36 +02:00
2021-04-28 17:21:39 +02:00
# The releng profile is used to create the official monthly installation ISO
PROFILE=/usr/share/archiso/configs/releng/
2021-06-11 14:20:12 +02:00
if [ ! -d "${PROFILE}" ]; then
2021-04-28 17:21:39 +02:00
echo "Installing dependency 'archiso' with sudo ..."
2021-05-24 15:09:45 +02:00
sudo pacman -S --needed archiso || exit $?
2021-04-28 17:21:39 +02:00
fi
2021-05-24 15:09:45 +02:00
cp -r "$PROFILE" "$BUILD_DIR"/profile || exit $?
2021-04-28 17:21:39 +02:00
2021-04-29 20:25:30 +02:00
# extend the builder's pacman.conf (add de-p1st mirrors)
2021-04-28 17:21:39 +02:00
# https://wiki.archlinux.org/index.php/Archiso#Custom_local_repository
2021-06-11 14:20:12 +02:00
cat "pkg/de-p1st-pacman/pacman.d/de-p1st" >>"$BUILD_DIR"/profile/pacman.conf || exit $?
2021-04-28 17:21:39 +02:00
for PKG in "${PKGS[@]}"; do
2021-06-11 14:20:12 +02:00
echo "${PKG}" >>"${BUILD_DIR}"/profile/packages.x86_64
2021-04-28 17:21:39 +02:00
done
###
2021-05-24 15:09:45 +02:00
mkdir "${BUILD_DIR}/work_dir" && mkdir "${BUILD_DIR}/out_dir" || exit $?
2021-04-28 17:21:39 +02:00
echo "running 'sudo mkarchiso' ..."
2021-05-24 15:09:45 +02:00
sudo mkarchiso -v -w "${BUILD_DIR}/work_dir" -o "${BUILD_DIR}/out_dir" "${BUILD_DIR}/profile" || exit $?