summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/parted-usb.sh43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/parted-usb.sh b/src/parted-usb.sh
index cfd2ad1..41c2814 100755
--- a/src/parted-usb.sh
+++ b/src/parted-usb.sh
@@ -16,7 +16,9 @@ MiB()
16. samizdat-paths.sh || die 'samizdat-paths.sh not found' 16. samizdat-paths.sh || die 'samizdat-paths.sh not found'
17 17
18samizdat_linux_dir=/boot 18samizdat_linux_dir=/boot
19
19: ${GPG_INPUT_DIR:=/cdrom/gnupghome} 20: ${GPG_INPUT_DIR:=/cdrom/gnupghome}
21: ${GRUB_CONFIG:=grub.cfg}
20 22
21if [[ $UID != 0 ]] 23if [[ $UID != 0 ]]
22then 24then
@@ -66,14 +68,11 @@ make_target_bootable()
66 mkfs.btrfs --mixed "$kdev"p2 68 mkfs.btrfs --mixed "$kdev"p2
67 mkdir -p "$mnt" 69 mkdir -p "$mnt"
68 mount "$kdev"p2 "$mnt" 70 mount "$kdev"p2 "$mnt"
69 rsync -aL --info=STATS "$samizdat_linux_dir"/vmlinuz${version} "$samizdat_linux_dir"/initrd.img${version} "$mnt"/linux/
70 71
71 boot_dir=$mnt/boot 72 mkdir -p "$mnt"/boot/grub
72 mkdir -p "$boot_dir"/grub 73 cp -aL "$GRUB_CONFIG" "$mnt"/boot/grub
73 cp -a grub.cfg "$boot_dir"/grub
74 74
75 # grub-install -v -d "$samizdat_grub_efi_dir"/grub/i386-pc --boot-directory "$mnt"/boot "$dev" 75 eatmydata -- grub-install -v --boot-directory "$mnt"/boot "$dev"
76 eatmydata -- grub-install -v --boot-directory "$boot_dir" "$dev"
77 sync 76 sync
78} 77}
79 78
@@ -84,19 +83,44 @@ release_target()
84 losetup -d "$dev" 83 losetup -d "$dev"
85} 84}
86 85
87add_keys() 86with_target()
88{ 87{
89 local mnt dev target="$1" 88 local mnt dev target="$1"
89 shift
90
90 mnt=$target.mnt 91 mnt=$target.mnt
91 mkdir -p "$mnt" 92 mkdir -p "$mnt"
92 losetup -f "$target" -o $(MiB $start_keys) 93 losetup -f "$target" -o $(MiB $start_keys)
93 dev=$(losetup -j "$target" -O NAME --noheadings) 94 dev=$(losetup -j "$target" -O NAME --noheadings)
94 mount "$dev" "$mnt" 95 mount "$dev" "$mnt"
95 rsync -a --info=STATS "$GPG_INPUT_DIR"/ "$mnt"/gnupghome/ 96 "$@"
96 umount "$mnt" 97 umount "$mnt"
97 losetup -d "$dev" 98 losetup -d "$dev"
98} 99}
99 100
101add_keys()
102{
103 rsync -a --info=STATS "$GPG_INPUT_DIR"/ "$mnt"/gnupghome/
104}
105
106add_initrd()
107{
108 rsync -aL --info=STATS "$samizdat_linux_dir"/vmlinuz${version} "$samizdat_linux_dir"/initrd.img${version} "$mnt"/linux/
109}
110
111add_grub_cfg()
112{
113 mkdir -p "$mnt"/boot/grub
114 cp -aL "$GRUB_CONFIG" "$mnt"/boot/grub
115}
116
117add_all()
118{
119 add_keys
120 add_initrd
121 add_grub_cfg
122}
123
100set -e 124set -e
101 125
102if [ ! -e "$target" ] 126if [ ! -e "$target" ]
@@ -108,7 +132,8 @@ then
108fi 132fi
109 133
110cp --reflink=always "$target" "$target".keyed 134cp --reflink=always "$target" "$target".keyed
111add_keys "$target".keyed 135
136with_target "$target".keyed add_all
112 137
113qemu-system-x86_64 -enable-kvm -smp 2 -m 512 -k en-us -vga qxl -drive file="$target".keyed,format=raw 138qemu-system-x86_64 -enable-kvm -smp 2 -m 512 -k en-us -vga qxl -drive file="$target".keyed,format=raw
114 139