2022-08-04 20:56:02 +00:00
|
|
|
#!/bin/bash
|
2022-05-10 20:53:09 +00:00
|
|
|
set -e
|
2022-08-04 20:56:02 +00:00
|
|
|
cd "$(dirname "$(realpath -s "$BASH_SOURCE")")"
|
|
|
|
source shell
|
|
|
|
source "env-$1"
|
|
|
|
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
# export OPUS_OUTPUT="/media/zram"
|
|
|
|
export OPUS_IMAGEDIR_BASE="$OPUS_OUTPUT/$1/base"
|
|
|
|
export OPUS_IMAGEDIR_FINAL="$OPUS_OUTPUT/$1/final"
|
2022-05-23 05:24:47 +00:00
|
|
|
export OPUS_PACKAGES=""
|
2022-08-04 20:56:02 +00:00
|
|
|
export OPUS_PACKAGES_INTERACTIVE=""
|
2022-05-23 05:24:47 +00:00
|
|
|
export OPUS_PACKAGES_DL=""
|
|
|
|
export OPUS_PACKAGES_REMOVE=""
|
|
|
|
|
|
|
|
# Base
|
2022-08-04 20:56:02 +00:00
|
|
|
if [ -d "$OPUS_IMAGEDIR_BASE-tmp" ]; then
|
|
|
|
rm -f -r "$OPUS_IMAGEDIR_BASE-tmp"
|
|
|
|
fi
|
2022-05-23 05:24:47 +00:00
|
|
|
|
2022-08-04 20:56:02 +00:00
|
|
|
if ! [ -d "$OPUS_IMAGEDIR_BASE" ]; then
|
|
|
|
mkdir -p "$OPUS_IMAGEDIR_BASE-tmp"
|
|
|
|
make-base "$OPUS_IMAGEDIR_BASE-tmp" # Base image
|
|
|
|
source apply-mod "$OPUS_HOME/input/sources" "$OPUS_IMAGEDIR_BASE-tmp"
|
|
|
|
mv "$OPUS_IMAGEDIR_BASE-tmp" "$OPUS_IMAGEDIR_BASE"
|
|
|
|
fi
|
2022-05-23 05:24:47 +00:00
|
|
|
|
2022-08-04 20:56:02 +00:00
|
|
|
if [ -d "$OPUS_IMAGEDIR_FINAL-tmp" ]; then
|
|
|
|
rm -f -r "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
fi
|
2022-05-23 05:24:47 +00:00
|
|
|
|
2022-08-04 20:56:02 +00:00
|
|
|
if ! [ -d "$OPUS_IMAGEDIR_FINAL" ]; then
|
|
|
|
echo "Copying base image ..."
|
|
|
|
cp -a "$OPUS_IMAGEDIR_BASE" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
# Hardware
|
|
|
|
source apply-mod "$OPUS_HOME/mods/kernel" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
source apply-mod "$OPUS_HOME/mods/firmware-free" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
source apply-mod "$OPUS_HOME/mods/firmware-proprietary" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
source apply-mod "$OPUS_HOME/mods/grub" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
|
|
|
|
# Graphical
|
|
|
|
source apply-mod "$OPUS_HOME/mods/packages-graphical" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
|
|
|
|
# Overrides
|
|
|
|
source apply-mod "$OPUS_HOME/mods/hostname" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
source apply-mod "$OPUS_HOME/mods/user-config" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
|
|
|
|
# Raw image
|
|
|
|
# source apply-mod "$OPUS_HOME/input/image-raw" "$OPUS_IMAGEDIR"
|
|
|
|
|
|
|
|
# Packages
|
|
|
|
source apply-mod "$OPUS_HOME/mods/fast-dpkg" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
source apply-mod "$OPUS_HOME/mods/packages-apply" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
|
|
|
|
# Extra
|
|
|
|
source apply-mod "$OPUS_HOME/mods/oobe" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
source apply-mod "$OPUS_HOME/mods/clean-logs" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
mv "$OPUS_IMAGEDIR_FINAL-tmp" "$OPUS_IMAGEDIR_FINAL"
|
|
|
|
fi
|
2022-05-24 22:19:32 +00:00
|
|
|
|
2022-08-04 20:56:02 +00:00
|
|
|
echo ""
|
|
|
|
echo "Done."
|
|
|
|
#make-image-gz "$OPUS_IMAGEDIR" "$OPUS_OUTPUT/${OPUS_NAME}-${OPUS_DIST}-${OPUS_ARCH}_$(date "+%Y.%m.%d-%H.%M.%S").tar.gz" # tar.gz image
|
|
|
|
)
|
|
|
|
if [ $? != 0 ]; then
|
2022-05-10 20:53:09 +00:00
|
|
|
set +e
|
2022-08-04 20:56:02 +00:00
|
|
|
echo "Script execution ended due to error. Cleaning up..."
|
2022-05-23 05:24:47 +00:00
|
|
|
fchroot-end "$OPUS_IMAGEDIR"
|
2022-08-04 20:56:02 +00:00
|
|
|
echo "Script execution ended due to error."
|
|
|
|
exit 1
|
2022-05-10 20:53:09 +00:00
|
|
|
fi
|