blob: cd1e5017c93b190abef211bbc3dae804e28d1ab9 (
plain)
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
|
#!/bin/bash
mkdiskimg () {
# Prepare image file
cp /usr/lib/syslinux/bios/gptmbr.bin $1
truncate -s 64M $1
sgdisk -n 1:0:0 $1
sgdisk -t 1:ef00 $1
sgdisk -A 1:set:2 $1
loopdev="$(losetup --show -f $1)"
partprobe $loopdev
mkfs.fat -n SEDUTILPBA "${loopdev}p1"
syslinux -i "${loopdev}p1"
# Mount image and copy files
mount "${loopdev}p1" mnt
mkdir -p mnt/EFI/BOOT
cp /boot/$2 mnt/vmlinuz-linux
cp /boot/$3 mnt/linuxpba.img
cp /usr/lib/linuxpba/syslinux.cfg mnt/syslinux.cfg
if [[ -e /boot/intel-ucode.img ]]
then
cp /boot/intel-ucode.img mnt/intel-ucode.img
else
sed -i 's/\/intel-ucode.img,//' mnt/syslinux.cfg
fi
cp mnt/syslinux.cfg mnt/EFI/BOOT/syslinux.cfg
cp /usr/lib/syslinux/efi64/syslinux.efi mnt/EFI/BOOT/BOOTX64.EFI
cp /usr/lib/syslinux/efi64/ldlinux.e64 mnt/EFI/BOOT
# Unmount image
umount mnt
losetup -d "$loopdev"
}
if [[ ! -e /usr/bin/extlinux ]]
then
echo "syslinux is not installed: nothing to do."
exit 1
fi
if [[ ! -e /usr/bin/gdisk ]]
then
echo "gptfdisk is not installed: nothing to do."
exit 1
fi
if [[ ! -e /usr/bin/partprobe ]]
then
echo "parted is not installed: nothing to do."
exit 1
fi
mklinuxpba-initramfs
kernel_release="$(uname -r)"
case "${kernel_release##*-}" in
"ARCH")
kernel_image="vmlinuz-linux"
;;
"lts")
kernel_image="vmlinuz-linux-lts"
;;
*)
echo "The currenly running kernel is not supported."
exit 1
;;
esac
mkdir -p "/tmp/linuxpbatemp/mnt"
pushd "/tmp/linuxpbatemp"
mkdiskimg linuxpba.diskimg $kernel_image linuxpba.img
mkdiskimg linuxpba-fallback.diskimg $kernel_image linuxpba-fallback.img
mv linuxpba.diskimg linuxpba-fallback.diskimg /boot
cd /tmp
rmdir -p linuxpbatemp/mnt
popd
|