78 lines
2.5 KiB
Bash
Executable File
78 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
cd "$(dirname "$(realpath -s "$BASH_SOURCE")")"
|
|
source shell
|
|
source "env-$1"
|
|
source "env-proprietary"
|
|
set +e
|
|
|
|
(
|
|
set -e
|
|
# export OPUS_OUTPUT="/media/zram"
|
|
export OPUS_IMAGEDIR_BASE="$OPUS_OUTPUT/$1/base"
|
|
export OPUS_IMAGEDIR_FINAL="$OPUS_OUTPUT/$1/final-proprietary"
|
|
export OPUS_PACKAGES=""
|
|
export OPUS_PACKAGES_INTERACTIVE=""
|
|
export OPUS_PACKAGES_DL=""
|
|
export OPUS_PACKAGES_REMOVE=""
|
|
|
|
# Base
|
|
if [ -d "$OPUS_IMAGEDIR_BASE-tmp" ]; then
|
|
rm -f -r "$OPUS_IMAGEDIR_BASE-tmp"
|
|
fi
|
|
|
|
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
|
|
|
|
if [ -d "$OPUS_IMAGEDIR_FINAL-tmp" ]; then
|
|
rm -f -r "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
fi
|
|
|
|
if ! [ -d "$OPUS_IMAGEDIR_FINAL" ]; then
|
|
echo "Copying base image ..."
|
|
cp -a "$OPUS_IMAGEDIR_BASE" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
echo "$OPUS_SOURCES" > "$OPUS_IMAGEDIR_FINAL-tmp/etc/apt/sources.list"
|
|
|
|
# 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/mods/image-raw" "$OPUS_IMAGEDIR_FINAL-tmp"
|
|
|
|
# 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"
|
|
|
|
# make-image-raw "$OPUS_IMAGEDIR_FINAL" "$OPUS_HOME/${OPUS_NAME}-${OPUS_DIST}-${OPUS_ARCH}_$(date "+%Y.%m.%d-%H.%M.%S").img"
|
|
# 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
|
|
fi
|
|
|
|
echo ""
|
|
echo "Done."
|
|
)
|
|
if [ $? != 0 ]; then
|
|
set +e
|
|
echo "Script execution ended due to error. Cleaning up..."
|
|
fchroot-end "$OPUS_IMAGEDIR"
|
|
echo "Script execution ended due to error."
|
|
exit 1
|
|
fi |