Skip to content

Commit e6f2567

Browse files
authored
Merge pull request #49 from sorenisanerd/dev
Merge dev branch
2 parents eefe3dd + 5260ed6 commit e6f2567

File tree

14 files changed

+102
-16
lines changed

14 files changed

+102
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
/*.acast
1212
mkosi.local
1313
mkosi.local.conf
14+
/*.log

mkosi.bios.finalize

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
kver=$(basename ${BUILDROOT}/usr/lib/modules/*)
4+
initrd=$(basename $(jq -C .Initrds[0] < ${MKOSI_CONFIG} -r))
5+
6+
# Use IMAGE_VERSION for kernel's filename. Blame sd-sysupdate.
7+
mv ${BUILDROOT}/boot/mangos/${kver}/vmlinuz ${BUILDROOT}/boot/mangos-${IMAGE_VERSION}.vmlinuz
8+
9+
# Combine microcode and initrd and call it a day
10+
cat ${BUILDROOT}/boot/mangos/microcode.initrd ${BUILDROOT}/boot/mangos/${initrd} > ${BUILDROOT}/boot/mangos-${IMAGE_VERSION}.initrd
11+
12+
# There's so much extra stuff in /boot we don't need.
13+
rm -rf ${BUILDROOT}/boot/mangos/microcode.initrd ${BUILDROOT}/boot/mangos/${initrd} ${BUILDROOT}/boot/vmlinuz-* ${BUILDROOT}/boot/mangos/${kver}
14+
15+
# Menuentries in grub.cfg have with the kernel version in their id by default.
16+
# Since our entries often use the same kernel (but different roothash), we put
17+
# the IMAGE_VERSION in the menuentry id instead.
18+
# Also accomodate the renamed kernel and initrd.
19+
# Finally, add \${kernel_args} to the linux line.
20+
sed -e 's/menuentry.*"/menuentry "mangos-'${IMAGE_VERSION}'"/g' \
21+
-e 's@^[ ]*linux [^ ]*@ linux /mangos-'${IMAGE_VERSION}'.vmlinuz@g' \
22+
-e 's@^[ ]*linux .*@& ${kernel_args}@' \
23+
-e 's@^[ ]*initrd .*@ initrd /mangos-'${IMAGE_VERSION}'.initrd@' \
24+
-i ${BUILDROOT}/efi/grub/grub.cfg
25+
26+
cp ${BUILDROOT}/efi/grub/grub.cfg ${OUTPUTDIR}/${IMAGE_ID}_${IMAGE_VERSION}.grub.cfg
27+

mkosi.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Bootable=yes
5454
Bootloader=systemd-boot
5555
KernelModulesInitrd=yes
5656

57+
# 2025-06-01 00:00:00
58+
SourceDateEpoch=1757490000
59+
5760
[Validation]
5861
Checksum=yes
5962
SecureBoot=yes
@@ -72,3 +75,4 @@ Ephemeral=yes
7275
RAM=4G
7376
CPUs=2
7477
VSock=yes
78+
RuntimeScratch=no
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Partition]
2+
Type=swap
3+
Format=swap
4+
SizeMinBytes=4G
5+
SizeMaxBytes=4G
6+
FactoryReset=on
7+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Partition]
2+
Type=tmp
3+
Format=xfs
4+
SizeMinBytes=5G
5+
FactoryReset=on
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Partition]
2+
Type=var
3+
Format=xfs
4+
SizeMinBytes=2G
5+
FactoryReset=on
6+
MakeDirectories=/log/journal /tmp /lib/extensions /lib/extensions.available

mkosi.images/debug/mkosi.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Output]
2+
Overlay=true
3+
Format=sysext
4+
5+
[Config]
6+
Dependencies=base
7+
8+
[Content]
9+
BaseTrees=%O/base_%v
10+
Packages=strace

mkosi.images/docker/mkosi.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ PostInstallationScripts=%D/resources/augment-os-release
1212
[Output]
1313
Format=sysext
1414
Overlay=yes
15+
16+
[Validation]
17+
Checksum=yes

mkosi.images/initrd/mkosi.extra/usr/lib/mangos/mangos-install

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#!/bin/sh
22

3-
DOWNLOAD_URL="$(systemd-creds cat mangos_install_source 2> /dev/null)"
4-
5-
if [ -z "${KERNEL_CMDLINE}" ]
6-
then
7-
KERNEL_CMDLINE="$(cat /proc/cmdline)"
8-
fi
9-
3+
install_source="$(systemd-creds cat mangos_install_source 2> /dev/null)"
104
install_target="$(systemd-creds cat mangos_install_target 2> /dev/null)"
115

126
while [ $# -gt 0 ]
@@ -22,7 +16,7 @@ do
2216
exit 0
2317
;;
2418
-s)
25-
DOWNLOAD_URL="$2"
19+
install_source="$2"
2620
shift 2
2721
;;
2822
-n|--dry-run)
@@ -38,7 +32,7 @@ done
3832

3933
if [ -z "${install_target}" ]
4034
then
41-
target="$(sed -e 's%.*mangos_install_target=\([a-z0-9/:.-]\+\).*%\1%' /proc/cmdline)"
35+
target="$(sed -e 's%.*mangos_install_target=\([^ ]\+\).*%\1%' /proc/cmdline)"
4236
if [ -n "${target}" ]
4337
then
4438
install_target="${target}"
@@ -49,22 +43,31 @@ install_target="${install_target:-ask}"
4943

5044
if [ "${install_target}" = "ask" ]
5145
then
52-
if ! lsblk -p -o TYPE,NAME,VENDOR,MODEL,SERIAL -l | grep ^disk | cut -f2- -d' ' | sed -e 's/ \+/ /g' | while read bdev info; do /bin/echo -e "$bdev\0$info\0" ; done | tr -d '\n' | xargs -0 whiptail --menu "Install target" 15 50 0 2> /tmp/mangos_install_target
46+
if ! lsblk -p -o TYPE,NAME,SIZE,VENDOR,MODEL,SERIAL -l | grep ^disk | cut -f2- -d' ' | sed -e 's/ \+/ /g' | while read bdev info; do /bin/echo -e "$bdev\x00$info\x00" ; done | tr -d '\n' | xargs -0 whiptail --menu "Install target" 15 50 0 2> /tmp/mangos_install_target
5347
then
5448
echo "Install cancelled"
5549
exit 1
5650
fi
5751
install_target="$(cat /tmp/mangos_install_target ; rm /tmp/mangos_install_target)"
5852
fi
5953

60-
if [ -z "${DOWNLOAD_URL}" ]
54+
if [ -z "${install_source}" ]
55+
then
56+
source="$(sed -e 's%.*mangos_install_source=\([^ ]\+\).*%\1%' /proc/cmdline)"
57+
if [ -n "${source}" ]
58+
then
59+
install_source="${source}"
60+
fi
61+
fi
62+
63+
if [ -z "${install_source}" ]
6164
then
6265
. /etc/os-release
6366

64-
DOWNLOAD_URL="${MANGOS_GITHUB_URL}/releases/download/v${IMAGE_VERSION}/mangos_${IMAGE_VERSION}.raw.zst"
67+
install_source="${MANGOS_GITHUB_URL}/releases/download/v${IMAGE_VERSION}/mangos_${IMAGE_VERSION}.raw.zst"
6568
fi
6669

67-
$echo /usr/lib/systemd/systemd-pull --force --verify=no --roothash=no --verity=no --direct raw "${DOWNLOAD_URL}" "$install_target"
70+
$echo /usr/lib/systemd/systemd-pull --force --verify=no --roothash=no --verity=no --direct raw "${install_source}" "$install_target"
6871

6972
$echo sgdisk -p "${install_target}"
7073
$echo sgdisk -v "${install_target}"
@@ -83,8 +86,17 @@ sync ; sync
8386

8487
mount "${install_target}5" /mnt
8588
mount "${install_target}1" /mnt/boot
89+
90+
# Add ip= kernel arg to grub config
91+
ip_arg="$(grep -oE 'ip=[^ ]+' /proc/cmdline)"
92+
nameserver_arg="$(grep -oE 'nameserver=[^ ]+' /proc/cmdline)"
93+
94+
sed -e "s%^.*linux .*%& ${ip_arg} ${nameserver_arg}%g" -i /mnt/boot/grub/grub.cfg
95+
8696
touch /dev/shm/entry-token
8797
mount -o bind /dev/shm/entry-token /mnt/etc/kernel/entry-token
8898
bootctl install --root=/mnt --variables=yes
8999
umount /mnt/etc/kernel/entry-token
100+
umount /mnt/boot
101+
umount /mnt
90102
sync ; sync

mkosi.images/initrd/mkosi.extra/usr/lib/systemd/system-generators/mangos-installer-generator

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ then
2222
exit 0
2323
fi
2424

25-
unit="$(systemd-escape ${target}).device"
25+
unit="$(systemd-escape ${target#/}).device"
2626

2727
mkdir -p "${outdir}/mangos-install.service.d"
2828

0 commit comments

Comments
 (0)