Fork of PureOS make-live.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
5.3 KiB

#!/bin/bash -e
# some fancy colors
if [ $(tty -s) ]; then
RED=$(tput setaf 1)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
else
RED=
BRIGHT=
NORMAL=
fi
if [ -z "$FLAVOR" ]; then
FLAVOR="gnome-live"
echo "Using default flavor: $FLAVOR"
else
echo "Using flavor: $FLAVOR"
fi
if [ -z "$SUITE" ]; then
SUITE="amber"
echo "Using default suite: $SUITE"
else
echo "Using suite: $SUITE"
fi
UI_TYPE=$(echo $FLAVOR | cut -f1 -d-)
IMAGE_TYPE=${FLAVOR#*-}
if [ "$IMAGE_TYPE" = "$FLAVOR" ]; then
IMAGE_TYPE="live"
echo "Using default image type: $IMAGE_TYPE"
else
echo "Using image type: $IMAGE_TYPE"
fi
CURRENT_DATE=$(date +%Y%m%d)
export SOURCE_DATE_EPOCH=$(date +%s)
# repository URL
PUREOS_REPO="http://mirror.puresauce.org/pureos/"
# current architecture
arch=$(dpkg --print-architecture)
# options
lb_opts=""
dist_reltag=""
case "$SUITE" in
byzantium)
dist_version="10"
lb_opts="$lb_opts --security true --updates true"
dist_reltag="~devel"
;;
amber)
dist_version="9.0"
lb_opts="$lb_opts --security true --updates true"
;;
*)
echo "WARNING: Suite $SUITE is unknown" >&2
dist_version="0.0"
;;
esac
VERSION_FULL="${dist_version}${dist_reltag}"
# live-build doesn't work if --parent-debian-distribution is unknown of
# debian-cd => we have to put a symlink so that it deals with Tanglu like jessie/sid
if [ ! -e "/usr/share/live/build/data/debian-cd/$SUITE" ]; then
if [ -w /usr/share/live/build/data/debian-cd ]; then
ln -sf sid "/usr/share/live/build/data/debian-cd/$SUITE"
else
echo "ERROR: Run this first:"
echo "ln -sf sid /usr/share/live/build/data/debian-cd/$SUITE"
exit 1
fi
fi
# create some directories which we will need later
mkdir -p config/package-lists
mkdir -p config/includes.chroot
# FIXME: should be fixed in the live-build autodetection
case "$arch" in
amd64)
kernel_flavour="amd64"
;;
arm64)
kernel_flavour="arm64"
;;
i386)
kernel_flavour="686-pae"
;;
*)
echo "WARNING: configuration not tested on arch $arch" >&2
;;
esac
rm -rf config/includes.chroot
mkdir -p config/includes.chroot
case "$IMAGE_TYPE" in
"live"|"LIVE")
case "$UI_TYPE" in
"gnome"|"GNOME")
FLAVOR=gnome-live
FLAVOR_PRETTY="GNOME Live"
# create package config for GNOME
cat > config/package-lists/desktop.list.chroot <<EOF
pureos-gnome
linux-image-$kernel_flavour
calamares
adwaita-qt
grub-pc
EOF
;;
"plasma")
FLAVOR=plasma-live
FLAVOR_PRETTY="KDE Plasma Live"
# create package config for KDE Plasma
cat > config/package-lists/desktop.list.chroot <<EOF
pureos-plasma
linux-image-$kernel_flavour
calamares
grub-pc
EOF
;;
esac
rm -f config/hooks/normal/004-setup-oem.hook.chroot
rm -rf config/includes.chroot
rm -rf config/bootloaders/isolinux
cp -r config/bootloaders/isolinux.live/ config/bootloaders/isolinux
;;
"oem")
case "$UI_TYPE" in
"gnome"|"GNOME")
FLAVOR=gnome-oem
FLAVOR_PRETTY="GNOME OEM"
# create package config for GNOME (OEM)
cat > config/package-lists/desktop.list.chroot <<EOF
pureos-gnome
linux-image-$kernel_flavour
calamares-pureos-oem
adwaita-qt
grub-pc
EOF
;;
"plasma")
FLAVOR=plasma-oem
FLAVOR_PRETTY="KDE Plasma OEM"
echo "Can not create a OEM installer image for KDE Plasma at time."
exit 1
;;
esac
# add OEM extra files
cp -r config/includes.chroot.oem/home config/includes.chroot/home
# fix permissions
chmod go+rX config/includes.chroot/home
rm -f config/hooks/normal/004-setup-oem.hook.chroot
cp config/hooks.oem/004-setup-oem.hook.chroot config/hooks/normal/
rm -rf config/bootloaders/isolinux/
cp -r config/bootloaders/isolinux.oem config/bootloaders/isolinux
;;
esac
# include the live tools
cat > config/package-lists/live.list.chroot <<EOF
casper
EOF
# Configure bootloader
sed -e s/@VERSION@/"$VERSION_FULL"/g config/bootloaders/splash.svg.in > config/bootloaders/splash.svg
mv -f config/bootloaders/splash.svg config/bootloaders/isolinux/
# Update GRUB EFI menu for our flavor
sed -e s/@FLAVOR@/"$FLAVOR"/g config/bootloaders/grub-efi.cfg.in > config/bootloaders/isolinux/grub-efi.cfg
IMAGE_FILENAME=pureos-${VERSION_FULL}-${FLAVOR}_${CURRENT_DATE}
lb config noauto \
--distribution "$SUITE" \
--mode pureos \
--binary-images iso-hybrid \
--archive-areas "main" \
--mirror-bootstrap $PUREOS_REPO \
--mirror-binary $PUREOS_REPO \
--mirror-debian-installer $PUREOS_REPO \
--parent-mirror-bootstrap $PUREOS_REPO \
--parent-mirror-binary $PUREOS_REPO \
--parent-mirror-binary-security $PUREOS_REPO \
--parent-mirror-debian-installer $PUREOS_REPO \
--parent-mirror-chroot-security $PUREOS_REPO \
--memtest "memtest86+" \
--apt-source-archives false \
--debian-installer false \
--win32-loader false \
--keyring-packages pureos-archive-keyring \
--bootloader syslinux \
--firmware-binary true \
--firmware-chroot true \
--initsystem systemd \
--initramfs casper \
--tasksel apt \
--iso-application "PureOS GNU/Linux" \
--iso-publisher "Purism" \
--iso-volume "PureOS $dist_version $FLAVOR_PRETTY" \
--image-name $IMAGE_FILENAME \
--linux-flavours $kernel_flavour \
$lb_opts \
"${@}"