2022-03-19 14:34:36 -01:00
#!/bin/bash
# Rebuild an ISO image for a given timestamp
#
# Copyright 2021-2022 Holger Levsen <holger@layer-acht.org>
2024-03-05 14:57:25 -01:00
# Copyright 2021-2024 Roland Clobus <rclobus@rclobus.nl>
# Copyright 2024 Emanuele Rocca <ema@debian.org>
2022-03-19 14:34:36 -01:00
# released under the GPLv2
# Environment variables:
# http_proxy: The proxy that is used by live-build and wget
# https_proxy: The proxy that is used by git
# SNAPSHOT_TIMESTAMP: The timestamp to rebuild (format: YYYYMMDD'T'HHMMSS'Z')
2023-01-28 16:08:13 -01:00
# This script can be run as root, but root rights are only required for a few commands.
# You are advised to configure the user with 'visudo' instead.
2022-03-19 14:34:36 -01:00
# Required entries in the sudoers file:
# Defaults env_keep += "SOURCE_DATE_EPOCH"
# Defaults env_keep += "LIVE_BUILD"
# thisuser ALL=(root) NOPASSWD: /usr/bin/lb build
# thisuser ALL=(root) NOPASSWD: /usr/bin/lb clean --purge
# Coding convention: enforced by 'shfmt'
DEBUG = false
set -e
set -o pipefail # see eg http://petereisentraut.blogspot.com/2010/11/pipefail.html
output_echo( ) {
set +x
echo "###########################################################################################"
echo
echo -e " $( date -u) - $1 "
echo
if $DEBUG ; then
set -x
fi
}
cleanup( ) {
output_echo " Generating summary.txt $1 "
cat <<EOF >summary.txt
Configuration: ${ CONFIGURATION }
Debian version: ${ DEBIAN_VERSION }
2022-07-24 19:26:08 +00:00
Use latest snapshot: ${ BUILD_LATEST_DESC }
2022-11-12 10:46:45 -01:00
Installer origin: ${ INSTALLER_ORIGIN }
2022-03-19 14:34:36 -01:00
Snapshot timestamp: ${ SNAPSHOT_TIMESTAMP }
Snapshot epoch: ${ SOURCE_DATE_EPOCH }
Live-build override: ${ LIVE_BUILD_OVERRIDE }
Live-build path: ${ LIVE_BUILD }
Build result: ${ BUILD_RESULT }
Alternative timestamp: ${ PROPOSED_SNAPSHOT_TIMESTAMP }
Checksum: ${ SHA256SUM }
2023-07-12 14:07:38 +00:00
Script commandline: ${ REBUILD_COMMANDLINE }
Script hash: ${ REBUILD_SHA256SUM }
2022-03-19 14:34:36 -01:00
EOF
2022-07-24 19:26:08 +00:00
touch summary.txt -d@${ SOURCE_DATE_EPOCH }
2022-03-19 14:34:36 -01:00
}
2023-07-12 14:07:38 +00:00
show_help( ) {
echo "--help, --usage: This help text"
2024-03-05 14:57:25 -01:00
echo "--architecture: Optional, specifies the architecture (e.g. for cross-building)"
2023-07-12 14:07:38 +00:00
echo "--configuration: Mandatory, specifies the configuration (desktop environment)"
echo "--debian-version: Mandatory, e.g. trixie, sid"
echo "--debian-version-number: The version number, e.g. 13.0.1"
echo "--debug: Enable debugging output"
echo "--disk-info: Override the default content for the file .disk/info"
echo "--generate-source: Enable the building of a source image"
echo "--installer-origin:"
echo " 'git' (default): rebuild the installer from git"
echo " 'archive': take the installer from the Debian archive"
echo "--timestamp:"
echo " 'archive' (default): fetches the timestamp from the Debian archive"
echo " 'snapshot': fetches the latest timestamp from the snapshot server"
echo " A timestamp (format: YYYYMMDD'T'HHMMSS'Z'): a specific timestamp on the snapshot server"
}
2022-03-19 14:34:36 -01:00
parse_commandline_arguments( ) {
2023-07-12 14:07:38 +00:00
# In alphabetical order
2024-03-05 14:57:25 -01:00
local LONGOPTS = "architecture:,configuration:,debian-version:,debian-version-number:,debug,disk-info,generate-source,help,installer-origin:,timestamp:,usage"
2023-07-12 14:07:38 +00:00
local ARGUMENTS
local ERR = 0
# Add an extra -- to mark the last option
ARGUMENTS = " $( getopt --shell sh --name " ${ BASH_SOURCE } " --longoptions $LONGOPTS -- -- " ${ @ } " ) " || ERR = $?
REBUILD_COMMANDLINE = " ${ @ } "
if [ $ERR -eq 1 ] ; then
output_echo "Error: invalid argument(s)"
exit 1
elif [ $ERR -ne 0 ] ; then
output_echo "Error: getopt failure"
exit 1
fi
eval set -- " ${ ARGUMENTS } "
while true; do
local ARG = " ${ 1 } "
# In alphabetical order
case " ${ ARG } " in
2024-03-05 14:57:25 -01:00
--architecture)
shift
ARCHITECTURE = $1
shift
; ;
2023-07-12 14:07:38 +00:00
--configuration)
shift
CONFIGURATION = $1
shift
; ;
--debian-version)
shift
DEBIAN_VERSION = $1
shift
; ;
--debian-version-number)
shift
DEBIAN_VERSION_NUMBER = $1
shift
; ;
--debug)
shift
DEBUG = true
; ;
--disk-info)
shift
DISK_INFO = " ${ 1 } "
2023-07-15 17:27:59 +00:00
shift
2023-07-12 14:07:38 +00:00
; ;
--generate-source)
shift
GENERATE_SOURCE = "--source true"
; ;
--help| --usage)
show_help
exit 0
; ;
--installer-origin)
shift
INSTALLER_ORIGIN = $1
shift
; ;
--timestamp)
shift
TIMESTAMP = $1
shift
; ;
--)
# The last option
break
; ;
*)
# An earlier version of this script had 2 mandatory arguments and 2 optional arguments
CONFIGURATION = $1
shift
DEBIAN_VERSION = $1
shift
if [ " ${ 1 } " != "--" ]
then
TIMESTAMP = $1
shift
if [ " ${ 1 } " != "--" ]
then
INSTALLER_ORIGIN = $1
shift
fi
fi
; ;
esac
done
case ${ CONFIGURATION } in
2022-03-19 14:34:36 -01:00
"smallest-build" )
2023-01-28 19:52:52 -01:00
INSTALLER = "none"
PACKAGES = ""
2022-03-19 14:34:36 -01:00
; ;
"cinnamon" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-cinnamon spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
"gnome" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-gnome spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
"kde" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-kde spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
"lxde" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-lxde spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
"lxqt" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-lxqt spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
"mate" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-mate spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
"standard" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
PACKAGES = "live-task-standard"
2022-03-19 14:34:36 -01:00
; ;
"xfce" )
2023-01-28 19:52:52 -01:00
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-xfce spice-vdagent"
2022-03-19 14:34:36 -01:00
; ;
2024-01-12 20:45:00 -01:00
"debian-junior" )
INSTALLER = "live"
2024-01-12 20:22:05 -01:00
PACKAGES = "live-task-debian-junior spice-vdagent"
2024-01-12 20:45:00 -01:00
; ;
2023-07-12 14:07:38 +00:00
"" )
output_echo "Error: Missing --configuration"
exit 1
; ;
2022-03-19 14:34:36 -01:00
*)
2023-07-12 14:07:38 +00:00
output_echo " Error: Unknown value for --configuration: ${ CONFIGURATION } "
2022-03-19 14:34:36 -01:00
exit 1
; ;
esac
# Use 'stable', 'testing' or 'unstable' or code names like 'sid'
2023-07-12 14:07:38 +00:00
if [ -z " ${ DEBIAN_VERSION } " ] ; then
output_echo "Error: Missing --debian-version"
2022-03-19 14:34:36 -01:00
exit 2
fi
2023-03-11 22:16:04 -01:00
case " $DEBIAN_VERSION " in
"bullseye" )
2023-03-14 18:28:32 -01:00
FIRMWARE_ARCHIVE_AREA = "non-free contrib"
2023-03-11 22:16:04 -01:00
; ;
*)
FIRMWARE_ARCHIVE_AREA = "non-free-firmware"
; ;
esac
2022-03-19 14:34:36 -01:00
2024-03-05 14:57:25 -01:00
if command -v dpkg >/dev/null; then
HOST_ARCH = " $( dpkg --print-architecture) "
else
HOST_ARCH = " $( uname -m) "
fi
# Use host architecture as default, if no architecture is provided
if [ -z " ${ ARCHITECTURE } " ] ; then
ARCHITECTURE = ${ HOST_ARCH }
fi
if [ " ${ ARCHITECTURE } " != " ${ HOST_ARCH } " ] ; then
output_echo " Cross-building ${ ARCHITECTURE } image on ${ HOST_ARCH } "
case " ${ ARCHITECTURE } " in
"amd64" )
QEMU_STATIC_EXECUTABLE = qemu-x86_64-static
; ;
"i386" )
QEMU_STATIC_EXECUTABLE = qemu-i386-static
; ;
"arm64" )
QEMU_STATIC_EXECUTABLE = qemu-aarch64-static
; ;
*)
output_echo " Error: Unknown architecture ${ ARCHITECTURE } "
exit 5
; ;
esac
ARCHITECTURE_OPTIONS = " --bootstrap-qemu-arch ${ ARCHITECTURE } --bootstrap-qemu-static /usr/bin/ ${ QEMU_STATIC_EXECUTABLE } "
fi
2023-01-28 19:52:52 -01:00
BUILD_LATEST = "archive"
BUILD_LATEST_DESC = "yes, from the main Debian archive"
2023-07-12 14:07:38 +00:00
if [ ! -z " ${ TIMESTAMP } " ] ; then
case " ${ TIMESTAMP } " in
2022-07-24 19:26:08 +00:00
"archive" )
2023-01-28 19:52:52 -01:00
BUILD_LATEST = "archive"
BUILD_LATEST_DESC = "yes, from the main Debian archive"
2022-07-24 19:26:08 +00:00
; ;
"snapshot" )
2023-01-28 19:52:52 -01:00
BUILD_LATEST = "snapshot"
BUILD_LATEST_DESC = "yes, from the snapshot server"
2022-07-24 19:26:08 +00:00
; ;
*)
2023-07-12 14:07:38 +00:00
SNAPSHOT_TIMESTAMP = ${ TIMESTAMP }
2022-07-24 19:26:08 +00:00
BUILD_LATEST = "no"
BUILD_LATEST_DESC = "no"
; ;
esac
2022-03-19 14:34:36 -01:00
fi
2022-11-12 10:46:45 -01:00
2023-07-12 14:07:38 +00:00
case " ${ INSTALLER_ORIGIN } " in
"git" | "" )
INSTALLER_ORIGIN = "git"
; ;
"archive" )
INSTALLER_ORIGIN = " ${ DEBIAN_VERSION } "
; ;
*)
output_echo " Error: Unknown value ' ${ INSTALLER_ORIGIN } ' for --installer-origin "
exit 4
; ;
esac
if [ -z " ${ DEBIAN_VERSION_NUMBER } " ]
then
DEBIAN_VERSION_NUMBER = ${ DEBIAN_VERSION }
fi
local CONFIGURATION_SHORT = $( echo ${ CONFIGURATION } | cut -c1-2)
if [ " ${ CONFIGURATION_SHORT } " = = "lx" ]
then
# Differentiate between lxqt and lxde
CONFIGURATION_SHORT = $( echo ${ CONFIGURATION } | cut -c1,3)
2024-01-12 20:45:00 -01:00
elif [ " ${ CONFIGURATION } " = = "debian-junior" ]
then
CONFIGURATION_SHORT = "jr"
2023-07-12 14:07:38 +00:00
fi
2024-03-05 14:57:25 -01:00
ISO_VOLUME = " d-live ${ DEBIAN_VERSION_NUMBER } ${ CONFIGURATION_SHORT } ${ ARCHITECTURE } "
2023-07-12 14:07:38 +00:00
# Tracing this generator script
REBUILD_SHA256SUM = $( sha256sum ${ BASH_SOURCE } | cut -f1 -d" " )
2024-03-05 14:57:25 -01:00
echo " ARCHITECTURE = ${ ARCHITECTURE } "
2024-03-13 19:55:10 -01:00
echo " CONFIGURATION = ${ CONFIGURATION } "
echo " DEBIAN_VERSION = ${ DEBIAN_VERSION } "
echo " DEBIAN_VERSION_NUMBER = ${ DEBIAN_VERSION_NUMBER } "
echo " TIMESTAMP = ${ TIMESTAMP } "
echo " SNAPSHOT_TIMESTAMP = ${ SNAPSHOT_TIMESTAMP } "
echo " BUILD_LATEST = ${ BUILD_LATEST } "
echo " BUILD_LATEST_DESC = ${ BUILD_LATEST_DESC } "
echo " INSTALLER_ORIGIN = ${ INSTALLER_ORIGIN } "
echo " ISO_VOLUME = ${ ISO_VOLUME } "
echo " DISK_INFO = ${ DISK_INFO } "
2022-03-19 14:34:36 -01:00
}
2022-07-24 19:26:08 +00:00
get_snapshot_from_archive( ) {
wget ${ WGET_OPTIONS } http://deb.debian.org/debian/dists/${ DEBIAN_VERSION } /InRelease --output-document latest
#
# Extract the timestamp from the InRelease file
#
# Input:
# ...
# Date: Sat, 23 Jul 2022 14:33:45 UTC
# ...
# Output:
# 20220723T143345Z
#
2023-01-28 19:52:52 -01:00
SNAPSHOT_TIMESTAMP = $( cat latest | awk '/^Date:/ { print substr($0, 7) }' | xargs -I this_date date --utc --date "this_date" +%Y%m%dT%H%M%SZ)
2022-07-24 19:26:08 +00:00
rm latest
}
2024-10-31 12:58:36 -01:00
get_snapshot_from_snapshot_debian_org( ) {
# Pick the snapshot closest to 'now'
wget ${ WGET_OPTIONS } http://snapshot.debian.org/archive/debian/$( date --utc +%Y%m%dT%H%M%SZ) /dists/${ DEBIAN_VERSION } /InRelease --output-document latest
#
# Extract the timestamp from the InRelease file
#
# Input:
# ...
# Date: Sat, 23 Jul 2022 14:33:45 UTC
# ...
# Output:
# 20220723T143345Z
#
SNAPSHOT_TIMESTAMP = $( cat latest | awk '/^Date:/ { print substr($0, 7) }' | xargs -I this_date date --utc --date "this_date" +%Y%m%dT%H%M%SZ)
rm latest
}
2022-03-19 14:34:36 -01:00
#
# main: follow https://wiki.debian.org/ReproducibleInstalls/LiveImages
#
# Cleanup if something goes wrong
trap cleanup INT TERM EXIT
parse_commandline_arguments " $@ "
if $DEBUG ; then
2023-01-28 19:52:52 -01:00
WGET_OPTIONS =
GIT_OPTIONS =
2022-03-19 14:34:36 -01:00
else
2023-01-28 19:52:52 -01:00
WGET_OPTIONS = --quiet
GIT_OPTIONS = --quiet
2022-03-19 14:34:36 -01:00
fi
# No log required
WGET_OPTIONS = " ${ WGET_OPTIONS } --output-file /dev/null --timestamping "
if [ ! -z " ${ LIVE_BUILD } " ] ; then
2023-01-28 19:52:52 -01:00
LIVE_BUILD_OVERRIDE = 1
2022-03-19 14:34:36 -01:00
else
2023-01-28 19:52:52 -01:00
LIVE_BUILD_OVERRIDE = 0
2022-03-19 14:34:36 -01:00
export LIVE_BUILD = ${ PWD } /live-build
fi
2023-01-28 16:08:13 -01:00
# Prepend sudo for the commands that require it (when not running as root)
if [ " ${ EUID :- $( id -u) } " -ne 0 ] ; then
SUDO = sudo
fi
2022-03-19 14:34:36 -01:00
# Use a fresh git clone
if [ ! -d ${ LIVE_BUILD } -a ${ LIVE_BUILD_OVERRIDE } -eq 0 ] ; then
git clone https://salsa.debian.org/live-team/live-build.git ${ LIVE_BUILD } --single-branch --no-tags
fi
2023-01-28 19:52:52 -01:00
LB_OUTPUT = lb_output.txt
2022-03-19 14:34:36 -01:00
rm -f ${ LB_OUTPUT }
2022-07-24 19:26:08 +00:00
case ${ BUILD_LATEST } in
"archive" )
# Use the timestamp of the current Debian archive
get_snapshot_from_archive
2023-01-28 19:52:52 -01:00
MIRROR = http://deb.debian.org/debian/
2022-07-24 19:26:08 +00:00
; ;
"snapshot" )
2022-03-19 14:34:36 -01:00
# Use the timestamp of the latest mirror snapshot
2024-10-31 12:58:36 -01:00
get_snapshot_from_snapshot_debian_org
MIRROR = http://snapshot.debian.org/archive/debian/${ SNAPSHOT_TIMESTAMP }
2022-07-24 19:26:08 +00:00
; ;
"no" )
# The value of SNAPSHOT_TIMESTAMP was provided on the command line
2024-10-31 12:58:36 -01:00
MIRROR = http://snapshot.debian.org/archive/debian/${ SNAPSHOT_TIMESTAMP }
2022-07-24 19:26:08 +00:00
; ;
*)
echo "E: A new option to BUILD_LATEST has been added"
exit 1
; ;
esac
2022-03-19 14:34:36 -01:00
# Convert SNAPSHOT_TIMESTAMP to Unix time (insert suitable formatting first)
export SOURCE_DATE_EPOCH = $( date -d $( echo ${ SNAPSHOT_TIMESTAMP } | awk '{ printf "%s-%s-%sT%s:%s:%sZ", substr($0,1,4), substr($0,5,2), substr($0,7,2), substr($0,10,2), substr($0,12,2), substr($0,14,2) }' ) +%s)
output_echo " Info: using the snapshot from ${ SOURCE_DATE_EPOCH } ( ${ SNAPSHOT_TIMESTAMP } ) "
# Use the code from the actual timestamp
# Report the versions that were actually used
if [ ${ LIVE_BUILD_OVERRIDE } -eq 0 ] ; then
pushd ${ LIVE_BUILD } >/dev/null
git pull ${ GIT_OPTIONS }
git checkout $( git rev-list -n 1 --min-age= ${ SOURCE_DATE_EPOCH } HEAD) ${ GIT_OPTIONS }
git clean -Xdf ${ GIT_OPTIONS }
output_echo " Info: using live-build from git version $( git log -n 1 --pretty= format:%H_%aI) "
popd >/dev/null
else
output_echo " Info: using local live-build: $( lb --version) "
fi
# If the configuration folder already exists, re-create from scratch
if [ -d config ] ; then
2023-01-28 16:08:13 -01:00
${ SUDO } lb clean --purge
2022-03-19 14:34:36 -01:00
rm -fr config
rm -fr .build
fi
# Configuration for the live image:
# - For /etc/apt/sources.list: Use the mirror from ${MIRROR}, no security, no updates
2023-07-12 14:07:38 +00:00
# - The debian-installer is built from its git repository, if configured
2022-03-19 14:34:36 -01:00
# - Don't cache the downloaded content
2023-07-12 14:07:38 +00:00
# - Access to non-free-firmware
# - Use an ISO volume label similar to live-wrapper
# - Generate a source image, if configured
2022-03-19 14:34:36 -01:00
# - To reduce some network traffic a proxy is implicitly used
output_echo "Running lb config."
lb config \
2022-05-02 18:04:47 +00:00
--mirror-bootstrap ${ MIRROR } \
--mirror-binary ${ MIRROR } \
2022-03-19 14:34:36 -01:00
--security false \
--updates false \
--distribution ${ DEBIAN_VERSION } \
--debian-installer ${ INSTALLER } \
2022-11-12 10:46:45 -01:00
--debian-installer-distribution ${ INSTALLER_ORIGIN } \
2022-03-19 14:34:36 -01:00
--cache-packages false \
2023-03-11 22:16:04 -01:00
--archive-areas " main ${ FIRMWARE_ARCHIVE_AREA } " \
2023-07-12 14:07:38 +00:00
--iso-volume " ${ ISO_VOLUME } " \
2024-03-05 14:57:25 -01:00
--architecture ${ ARCHITECTURE } \
${ ARCHITECTURE_OPTIONS } \
2023-07-12 14:07:38 +00:00
${ GENERATE_SOURCE } \
2022-03-19 14:34:36 -01:00
2>& 1 | tee $LB_OUTPUT
# Insider knowledge of live-build:
# Add '-o Acquire::Check-Valid-Until=false', to allow for rebuilds of older timestamps
sed -i -e '/^APT_OPTIONS=/s/--yes/--yes -o Acquire::Check-Valid-Until=false/' config/common
if [ ! -z " ${ PACKAGES } " ] ; then
echo " ${ PACKAGES } " >config/package-lists/desktop.list.chroot
fi
2023-07-12 14:07:38 +00:00
# Set meta information about the image
mkdir config/includes.binary/.disk
cat << EOF > config/includes.binary/.disk/generator
This image was generated by $( basename ${ BASH_SOURCE } )
Script commandline: ${ REBUILD_COMMANDLINE }
Script hash: ${ REBUILD_SHA256SUM }
EOF
2023-07-15 17:27:59 +00:00
ISO8601_TIMESTAMP = $( date --utc -d@${ SOURCE_DATE_EPOCH } +%Y-%m-%dT%H:%M:%SZ)
2023-07-12 14:07:38 +00:00
if [ -z " ${ DISK_INFO } " ]
then
2023-07-15 17:27:59 +00:00
DISK_INFO = " Auto-generated Debian GNU/Linux Live ${ DEBIAN_VERSION_NUMBER } ${ CONFIGURATION } "
2023-07-12 14:07:38 +00:00
fi
2023-07-15 17:27:59 +00:00
echo -n " ${ DISK_INFO } ${ ISO8601_TIMESTAMP } " > config/includes.binary/.disk/info
2023-07-12 14:07:38 +00:00
2022-03-19 14:34:36 -01:00
# Add additional hooks, that work around known issues regarding reproducibility
cp -a ${ LIVE_BUILD } /examples/hooks/reproducible/* config/hooks/normal
2023-12-02 12:59:19 -01:00
# The hook script needs to be escaped once
# The replaced file needs to be escaped twice
cat << EOFHOOK > config/hooks/live/5000-no-password-for-calamares.hook.chroot
#!/bin/sh
set -e
# With live-config < 11.0.4 a password is required for running e.g. Calamares
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1037295
# Don't run if live-config is not installed
if [ ! -e /usr/lib/live/config/1080-policykit ] ;
then
exit 0
fi
# Don't run if the version of 1080-policykit is sufficiently new
if grep -q "/usr/share/polkit-1/rules.d" /usr/lib/live/config/1080-policykit;
then
exit 0
fi
# Completely replace the content to match the content of 11.0.4
cat << EOFNE WCONTENT > /usr/lib/live/config/1080-policykit
#!/bin/sh
. /lib/live/config.sh
## live-config(7) - System Configuration Components
## Copyright (C) 2016-2023 The Debian Live team
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
#set -e
Cmdline ( )
{
# Reading kernel command line
for _PARAMETER in \\ \$ { LIVE_CONFIG_CMDLINE}
do
case "\\\${_PARAMETER}" in
live-config.noroot| noroot)
LIVE_CONFIG_NOROOT = "true"
; ;
live-config.username= *| username = *)
LIVE_USERNAME = "\\\${_PARAMETER#*username=}"
; ;
esac
done
}
Init ( )
{
# Disable root access, no matter what mechanism
case "\\\${LIVE_CONFIG_NOROOT}" in
true )
exit 0
; ;
esac
# Checking if package is installed
if ( ! pkg_is_installed "polkitd" &&
! pkg_is_installed "policykit-1" ) || \\ \\
component_was_executed "policykit"
then
exit 0
fi
echo -n " policykit"
}
Config ( )
{
# Configure PolicyKit in live session
mkdir -p /usr/share/polkit-1/rules.d
if [ -n "\\\${LIVE_USERNAME}" ]
then
cat > /usr/share/polkit-1/rules.d/sudo_on_live.rules << EOF
// Grant the live user access without a prompt
polkit.addRule( function ( action, subject) {
if ( subject.local &&
subject.active &&
subject.user = = = "\\\${LIVE_USERNAME}" &&
subject.isInGroup( "sudo" ) ) {
return polkit.Result.YES;
}
} ) ;
EOF
else
cat > /usr/share/polkit-1/rules.d/sudo_on_live.rules << EOF
// Grant the sudo users access without a prompt
polkit.addRule( function ( action, subject) {
if ( subject.local &&
subject.active &&
subject.isInGroup( "sudo" ) ) {
return polkit.Result.YES;
}
} ) ;
EOF
fi
# Creating state file
touch /var/lib/live/config/policykit
}
Cmdline
Init
Config
EOFNEWCONTENT
echo "P: \$(basename \$0) Bugfix hook has been applied"
EOFHOOK
2024-08-28 20:43:53 +00:00
if [ " ${ DEBIAN_VERSION } " = "bookworm" -a " ${ CONFIGURATION } " = "kde" ] ;
then
cat << EOFHOOK > config/hooks/live/5010-kde-icon-for-calamares.hook.chroot
#!/bin/sh
set -e
# Fix for #1057853: Missing Calamares icon for KDE on bookworm
if [ ! -e /etc/xdg/autostart/calamares-desktop-icon.desktop ] ;
then
exit 0
fi
sed -i -e '/X-GNOME-Autostart-Phase=/d' /etc/xdg/autostart/calamares-desktop-icon.desktop
echo "P: \$(basename \$0) Bugfix hook has been applied"
EOFHOOK
fi
2024-03-15 20:48:35 -01:00
# For oldstable and stable use the same boot splash screen as the Debian installer
2023-03-25 12:39:47 -01:00
case " $DEBIAN_VERSION " in
2025-01-07 07:53:48 -01:00
"bullseye" | "oldstable" )
2024-03-15 20:48:35 -01:00
mkdir -p config/bootloaders
wget --quiet https://salsa.debian.org/installer-team/debian-installer/-/raw/master/build/boot/artwork/11-homeworld/homeworld.svg -O config/bootloaders/splash.svg
2023-03-25 12:39:47 -01:00
mkdir -p config/bootloaders/grub-pc
2024-03-15 20:48:35 -01:00
# Use the old resolution of 640x480 for grub
2023-03-25 12:39:47 -01:00
ln -s ../../isolinux/splash.png config/bootloaders/grub-pc/splash.png
; ;
2025-01-07 07:53:48 -01:00
"bookworm" | "stable" )
2024-03-15 20:48:35 -01:00
mkdir -p config/bootloaders
wget --quiet https://salsa.debian.org/installer-team/debian-installer/-/raw/master/build/boot/artwork/12-emerald/emerald.svg -O config/bootloaders/splash.svg
2023-03-25 12:39:47 -01:00
; ;
2025-01-07 07:53:48 -01:00
"trixie" | "testing" )
# Trixie artwork: https://wiki.debian.org/DebianArt/Themes/Ceratopsian
mkdir -p config/bootloaders
wget --quiet https://raw.githubusercontent.com/pccouper/trixie/refs/heads/main/grub/grub.svg -O config/bootloaders/splash.svg
; ;
2023-03-25 12:39:47 -01:00
*)
# Use the default 'under construction' image
; ;
esac
2022-03-19 14:34:36 -01:00
# Build the image
output_echo "Running lb build."
set +e # We are interested in the result of 'lb build', so do not fail on errors
2023-01-28 16:08:13 -01:00
${ SUDO } lb build | tee -a $LB_OUTPUT
2023-01-28 19:52:52 -01:00
BUILD_RESULT = $?
2022-03-19 14:34:36 -01:00
set -e
if [ ${ BUILD_RESULT } -ne 0 ] ; then
# Find the snapshot that matches 1 second before the current snapshot
2024-10-31 12:58:36 -01:00
wget ${ WGET_OPTIONS } http://snapshot.debian.org/archive/debian/$( date --utc -d @$(( ${ SOURCE_DATE_EPOCH } - 1 )) +%Y%m%dT%H%M%SZ) /dists/${ DEBIAN_VERSION } /InRelease --output-document but_latest
PROPOSED_SNAPSHOT_TIMESTAMP = $( cat but_latest | awk '/^Date:/ { print substr($0, 7) }' | xargs -I this_date date --utc --date "this_date" +%Y%m%dT%H%M%SZ)
2022-03-19 14:34:36 -01:00
rm but_latest
output_echo " Warning: lb build failed with ${ BUILD_RESULT } . The latest snapshot might not be complete (yet). Try re-running the script with SNAPSHOT_TIMESTAMP= ${ PROPOSED_SNAPSHOT_TIMESTAMP } . "
# Occasionally the snapshot is not complete, you could use the previous snapshot instead of giving up
exit 99
fi
# Calculate the checksum
2024-03-05 14:57:25 -01:00
SHA256SUM = $( sha256sum live-image-${ ARCHITECTURE } .hybrid.iso | cut -f 1 -d " " )
2022-03-19 14:34:36 -01:00
2022-07-24 19:26:08 +00:00
if [ ${ BUILD_LATEST } = = "archive" ] ; then
2023-01-28 19:52:52 -01:00
SNAPSHOT_TIMESTAMP_OLD = ${ SNAPSHOT_TIMESTAMP }
2022-07-24 19:26:08 +00:00
get_snapshot_from_archive
if [ ${ SNAPSHOT_TIMESTAMP } != ${ SNAPSHOT_TIMESTAMP_OLD } ] ; then
output_echo "Warning: meanwhile the archive was updated. Try re-running the script."
2023-01-28 19:52:52 -01:00
PROPOSED_SNAPSHOT_TIMESTAMP = " ${ BUILD_LATEST } "
2022-07-24 19:26:08 +00:00
exit 99
fi
fi
2022-03-19 14:34:36 -01:00
cleanup success
# Turn off the trap
trap - INT TERM EXIT
# We reached the end, return with PASS
exit 0