-
Notifications
You must be signed in to change notification settings - Fork 9
/
functions.sh
executable file
·170 lines (154 loc) · 4.67 KB
/
functions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
check_and_source_constants()
{
if [ -e constants ]
then
. ./constants
else
echo "Please copy the file \"constants.example\" to \"constants\" and adopt the settings to your build environment."
exit
fi
}
init_build()
{
START=$(date)
TODAY=$(date +%Y-%m-%d)
}
configure_cd()
{
ISO_SUFFIX="_bootcd"
SYSTEM_SUFFIX=" Boot-CD"
# mv config/chroot_local-packageslists/lernstick_squeeze.list config/chroot_local-packageslists/lernstick_squeeze
# mv config/chroot_local-packageslists/bootcd config/chroot_local-packageslists/bootcd.list
}
configure()
{
echo ""
}
get_version_number()
{
echo $1 | sed 's/.*_\(.*\)_.*/\1/' | sed 's/%3a/:/'
}
cache_cleanup()
{
echo "removing deprecated packages from cache"
for DIR in cache/packages.*
do
echo "checking directory ${DIR}"
for FILE in ${DIR}/*
do
BASE_NAME=$(basename ${FILE})
PACKAGE_NAME=$(echo ${BASE_NAME} | sed 's/_.*//')
VERSIONS=$(ls ${DIR}/${PACKAGE_NAME}_*)
COUNTER=$(echo ${VERSIONS} | wc -w)
if [ ${COUNTER} -gt 1 ]
then
PACKAGE_VERSION="$(get_version_number ${BASE_NAME})"
for VERSION in ${VERSIONS}
do
OTHER_VERSION="$(get_version_number ${VERSION})"
if dpkg --compare-versions "${PACKAGE_VERSION}" lt "${OTHER_VERSION}"
then
echo "removing deprecated cache file ${FILE} (newer version ${OTHER_VERSION} found)"
rm ${FILE}
break
fi
done
fi
done
done
}
build_image()
{
# update time stamp in bootloaders
# ISOLINUX/SYSLINUX
BOOTLOGO="config/bootloaders/isolinux/bootlogo"
BOOTLOGO_DIR="${BOOTLOGO}.dir"
cp templates/xmlboot.config ${BOOTLOGO_DIR}
sed -i "s|<version its:translate=\"no\">.*</version>|<version its:translate=\"no\">(Version ${TODAY})</version>|1" \
${BOOTLOGO_DIR}/xmlboot.config
gfxboot --archive ${BOOTLOGO_DIR} --pack-archive ${BOOTLOGO}
cp ${BOOTLOGO} ${BOOTLOGO}.orig
# GRUB
GRUB_THEME_DIR="config/includes.binary/boot/grub/themes/lernstick"
cp templates/theme.txt ${GRUB_THEME_DIR}
sed -i "s|title-text.*|title-text: \"Lernstick Debian 12 (Version ${TODAY})\"|1" \
${GRUB_THEME_DIR}/theme.txt
# update configuration
rm -f config/binary
rm -f config/bootstrap
rm -f config/build
rm -f config/chroot
rm -f config/common
rm -f config/source
lb clean
lb config \
--apt-indices false \
--apt-recommends true \
--architectures amd64 \
--archive-areas "main contrib non-free non-free-firmware" \
--bootloaders "syslinux,grub-efi" \
--chroot-squashfs-compression-level 22 \
--chroot-squashfs-compression-type zstd \
--debootstrap-options "--include=ca-certificates,openssl" \
--distribution bookworm \
--firmware-chroot false \
--iso-volume "lernstick${ISO_SUFFIX} ${TODAY}" \
--linux-packages linux-image-6.10.11+bpo \
--mirror-binary ${MIRROR_SYSTEM} \
--mirror-binary-security ${MIRROR_SECURITY_SYSTEM} \
--mirror-bootstrap ${MIRROR_BUILD} \
--security true \
--source ${SOURCE} \
--updates true \
--verbose
#--linux-packages linux-image-6.1.0-0.deb11.7 \
# let's hope that we are no longer encountering machines that just freeze with isohybrid images:
# https://lists.debian.org/debian-live/2011/08/msg00144.html
# if this is still a problem we need to change back from the default of "iso-hybrid" to plain "iso"
# --binary-images iso \
# build image (and produce a log file)
lb build 2>&1 | tee logfile.txt
ISO_FILE="live-image-amd64.hybrid.iso"
if [ -f ${ISO_FILE} ]
then
PREFIX="lernstick_debian12${ISO_SUFFIX}_${TODAY}"
IMAGE="${PREFIX}.iso"
mv ${ISO_FILE} ${IMAGE}
# we must update the zsync file because we renamed the iso file
echo "Updating zsync file..." | tee -a logfile.txt
rm *.zsync
zsyncmake -C ${IMAGE} -u ${IMAGE}
echo "Creating MD5 for iso..." | tee -a logfile.txt
md5sum ${IMAGE} > ${IMAGE}.md5
if [ "${SOURCE}" = "true" ]
then
# debian live sources
mv live-image-source.live.tar ${PREFIX}-source.live.tar
# debian sources
DEBIAN_TAR="${PREFIX}-source.debian.tar"
mv live-image-source.debian.tar ${DEBIAN_TAR}
md5sum ${DEBIAN_TAR} > ${DEBIAN_TAR}.md5
fi
# move files from tmpfs to harddisk
if [ -d "${BUILD_DIR}" ]
then
mv ${PREFIX}* "${BUILD_DIR}"
fi
else
echo "Error: ISO file was not build" | tee -a logfile.txt
fi
cache_cleanup
# When installing firmware-b43legacy-installer downloads.openwrt.org is
# sometimes down. Building doesn't fail in this situation but we would
# have produced an image without support for some legacy broadcom cards.
# Therefore we must check via eyeballs what happened...
grep downloads.openwrt.org logfile.txt
echo "Start: ${START}" | tee -a logfile.txt
echo "Stop : $(date)" | tee -a logfile.txt
if [ -d "${BUILD_DIR}" ]
then
mv logfile.txt "${BUILD_DIR}"
fi
# hello, wake up!!! :-)
#eject
}