diff options
-rwxr-xr-x | src/parted-usb.sh | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/parted-usb.sh b/src/parted-usb.sh index 41c2814..6841166 100755 --- a/src/parted-usb.sh +++ b/src/parted-usb.sh | |||
@@ -13,31 +13,6 @@ MiB() | |||
13 | KiB $(KiB "$1") | 13 | KiB $(KiB "$1") |
14 | } | 14 | } |
15 | 15 | ||
16 | . samizdat-paths.sh || die 'samizdat-paths.sh not found' | ||
17 | |||
18 | samizdat_linux_dir=/boot | ||
19 | |||
20 | : ${GPG_INPUT_DIR:=/cdrom/gnupghome} | ||
21 | : ${GRUB_CONFIG:=grub.cfg} | ||
22 | |||
23 | if [[ $UID != 0 ]] | ||
24 | then | ||
25 | exit 1 | ||
26 | fi | ||
27 | |||
28 | for d in "$samizdat_linux_dir" "$GPG_INPUT_DIR" | ||
29 | do | ||
30 | if ! test -d "$d" | ||
31 | then | ||
32 | exit 1 | ||
33 | fi | ||
34 | done | ||
35 | |||
36 | start_keys=64 # megs | ||
37 | end_keys=256 # megs | ||
38 | |||
39 | target=fallacy.img.tmp | ||
40 | |||
41 | initialize_target() | 16 | initialize_target() |
42 | { | 17 | { |
43 | rm -f "$target" | 18 | rm -f "$target" |
@@ -56,7 +31,6 @@ partition_target() | |||
56 | 31 | ||
57 | make_target_bootable() | 32 | make_target_bootable() |
58 | { | 33 | { |
59 | version=${1:+-$1} | ||
60 | losetup -f "$target" | 34 | losetup -f "$target" |
61 | dev=$(losetup -j "$target" -O NAME --noheadings) | 35 | dev=$(losetup -j "$target" -O NAME --noheadings) |
62 | 36 | ||
@@ -121,18 +95,42 @@ add_all() | |||
121 | add_grub_cfg | 95 | add_grub_cfg |
122 | } | 96 | } |
123 | 97 | ||
98 | sanity_checks() | ||
99 | { | ||
100 | [[ $UID = 0 ]] || die "You are not root." | ||
101 | for d in "$samizdat_linux_dir" "$GPG_INPUT_DIR" | ||
102 | do | ||
103 | [ -d "$d" ] || die "Not a directory: $d" | ||
104 | done | ||
105 | } | ||
106 | |||
107 | |||
108 | |||
109 | |||
110 | . samizdat-paths.sh || die 'samizdat-paths.sh not found' | ||
111 | samizdat_linux_dir=/boot | ||
112 | : ${GPG_INPUT_DIR:=/cdrom/gnupghome} | ||
113 | : ${GRUB_CONFIG:=grub.cfg} | ||
114 | start_keys=64 # megs | ||
115 | end_keys=256 # megs | ||
116 | target=fallacy.img.tmp | ||
117 | |||
118 | sanity_checks | ||
124 | set -e | 119 | set -e |
125 | 120 | ||
126 | if [ ! -e "$target" ] | 121 | if [ ! -e "$target" ] |
127 | then | 122 | then |
128 | initialize_target | 123 | initialize_target |
129 | partition_target | 124 | partition_target |
130 | make_target_bootable ${1:4.9.0-0.bpo.2-amd64} | 125 | make_target_bootable |
131 | release_target | 126 | release_target |
132 | fi | 127 | fi |
133 | 128 | ||
129 | if [ "$1" ] | ||
130 | then | ||
131 | version=-$1 | ||
132 | fi | ||
134 | cp --reflink=always "$target" "$target".keyed | 133 | cp --reflink=always "$target" "$target".keyed |
135 | |||
136 | with_target "$target".keyed add_all | 134 | with_target "$target".keyed add_all |
137 | 135 | ||
138 | qemu-system-x86_64 -enable-kvm -smp 2 -m 512 -k en-us -vga qxl -drive file="$target".keyed,format=raw | 136 | qemu-system-x86_64 -enable-kvm -smp 2 -m 512 -k en-us -vga qxl -drive file="$target".keyed,format=raw |