summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-04-29 14:36:26 -0400
committerAndrew Cady <d@jerkface.net>2016-04-29 14:36:30 -0400
commit153d299a41b9be4e15dab1ca29bb93a74bd2445d (patch)
tree96fbfbe7c64f0b3f02f3d755e2b129917785bb98
parent5f41fb879ca830e5ad3345878e59072f3d6573bc (diff)
fix paths (in progress)
-rw-r--r--Makefile23
-rwxr-xr-xinitramfs-tools/hooks/samizdat6
-rw-r--r--notes.txt176
-rw-r--r--notes/btrfs-test.sh282
-rw-r--r--notes/xorriso-patch.sh11
-rw-r--r--samizdat-paths.sh7
-rw-r--r--src/btrfs-functions.sh (renamed from btrfs-functions.sh)0
-rw-r--r--src/btrfs-receive-root.sh (renamed from btrfs-receive-root.sh)0
-rw-r--r--src/btrfs-send-root.sh (renamed from btrfs-send-root.sh)5
-rwxr-xr-xsrc/grub-efi.sh (renamed from grub-efi.sh)6
-rwxr-xr-xsrc/initrd.sh (renamed from initrd.sh)4
-rw-r--r--src/initrd/common.sh (renamed from old-school/common.sh)0
-rwxr-xr-xsrc/initrd/grok-block (renamed from old-school/grok-block)0
-rwxr-xr-xsrc/initrd/halt.montecarlo (renamed from old-school/halt.montecarlo)0
-rwxr-xr-xsrc/initrd/init (renamed from old-school/init)0
-rw-r--r--src/initrd/init.functions (renamed from old-school/init.functions)0
-rwxr-xr-xsrc/initrd/init.shutdown (renamed from old-school/init.shutdown)0
-rw-r--r--src/initrd/loop-layer.sh (renamed from loop-layer.sh)0
-rw-r--r--src/initrd/lvm-create.sh (renamed from old-school/lvm-create.sh)0
-rw-r--r--src/initrd/lvm.conf (renamed from old-school/lvm.conf)0
-rw-r--r--src/initrd/mdadm-dup.sh (renamed from old-school/mdadm-dup.sh)0
-rwxr-xr-xsrc/initrd/menu-select (renamed from old-school/menu-select)0
-rwxr-xr-xsrc/initrd/samizdat-cdrom-copy (renamed from old-school/samizdat-cdrom-copy)0
-rwxr-xr-xsrc/initrd/samizdat-eject.sh (renamed from samizdat-eject.sh)0
-rwxr-xr-xsrc/initrd/squashfs-size (renamed from old-school/squashfs-size)0
-rwxr-xr-xsrc/initrd/umountall.sh (renamed from old-school/umountall.sh)0
-rwxr-xr-xsrc/initrd/vol_id (renamed from old-school/vol_id)0
-rwxr-xr-xsrc/keygen.sh (renamed from keygen.sh)0
-rwxr-xr-xsrc/patchroot.sh (renamed from patchroot.sh)0
-rwxr-xr-xsrc/qemu.sh (renamed from qemu.sh)14
-rw-r--r--src/samizdat-paths.sh5
-rw-r--r--src/var.sh (renamed from var.sh)0
-rwxr-xr-xsrc/xorriso-layer.sh (renamed from xorriso-layer.sh)0
-rw-r--r--[-rwxr-xr-x]src/xorriso-usb.sh (renamed from xorriso-usb.sh)20
-rwxr-xr-xsrc/xorriso.sh (renamed from xorriso.sh)0
-rwxr-xr-xsrc/xorriso.test-efi.sh (renamed from xorriso.test-efi.sh)0
-rw-r--r--update-initramfs.conf30
37 files changed, 358 insertions, 231 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..767f5f3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,23 @@
1PACKAGE=samizdat-rhizome
2prefix=/usr/local
3exec_prefix=${prefix}
4bindir=${exec_prefix}/bin
5libdir=${exec_prefix}/lib
6includedir=${prefix}/include
7datarootdir=${prefix}/share
8datadir=${datarootdir}
9mandir=${datarootdir}/man
10infodir=${datarootdir}/info
11docdir=${datarootdir}/doc/${PACKAGE}
12sysconfdir=$(prefix)/etc
13libexecdir=$(exec_prefix)/libexec
14
15
16bin_programs=xorriso-usb.sh btrfs-functions.sh btrfs-receive-root.sh btrfs-send-root.sh var.sh
17data_files=
18libexec_programs=grub-efi.sh keygen.sh initrd.sh
19
20install:
21 install ${bin_programs} ${bindir}
22 install ${libexec_programs} ${libexecdir}
23 install ${data_files} ${datadir}/${PACKAGE}
diff --git a/initramfs-tools/hooks/samizdat b/initramfs-tools/hooks/samizdat
index d9d5b5d..eb4497f 100755
--- a/initramfs-tools/hooks/samizdat
+++ b/initramfs-tools/hooks/samizdat
@@ -5,8 +5,9 @@
5CopyExec() { copy_exec "$@" || exit 1; } 5CopyExec() { copy_exec "$@" || exit 1; }
6 6
7. /usr/share/initramfs-tools/hook-functions 7. /usr/share/initramfs-tools/hook-functions
8. samizdat-paths.sh
8 9
9repo_execs=$(echo ./old-school/* loop-layer.sh samizdat-eject.sh) 10repo_execs=$(echo "${samizdat_initrd_files_dir}"/*)
10 11
11path_execs='mountpoint openvt rsync gpg2 gpg-agent pinentry-curses truncate cryptsetup mkfs.btrfs btrfs fsck.hfsplus' 12path_execs='mountpoint openvt rsync gpg2 gpg-agent pinentry-curses truncate cryptsetup mkfs.btrfs btrfs fsck.hfsplus'
12 13
@@ -22,6 +23,7 @@ graft_paths="
22absolute_path_copies='/lib/terminfo/l/linux' 23absolute_path_copies='/lib/terminfo/l/linux'
23 24
24samizdat_execs='wait_for_files samizdat-pinentry dynmenu src/samizdat-password-agent src/samizdat-gpg-agent' 25samizdat_execs='wait_for_files samizdat-pinentry dynmenu src/samizdat-password-agent src/samizdat-gpg-agent'
26for c in $samizdat_execs; do CopyExec ${samizdat_execs_dir}/$c /bin; done
25modules='loop xts dm-crypt hfs hfsplus' 27modules='loop xts dm-crypt hfs hfsplus'
26modules_dirs='kernel/drivers/net/ethernet kernel/fs/nls' 28modules_dirs='kernel/drivers/net/ethernet kernel/fs/nls'
27 29
@@ -31,8 +33,6 @@ modules_dirs='kernel/drivers/net/ethernet kernel/fs/nls'
31for f in $repo_execs; do CopyExec "$f" /bin; done 33for f in $repo_execs; do CopyExec "$f" /bin; done
32for c in $path_execs; do CopyExec "$(which $c)" /bin; done 34for c in $path_execs; do CopyExec "$(which $c)" /bin; done
33for f in $absolute_path_copies; do CopyExec "$f" "$f"; done 35for f in $absolute_path_copies; do CopyExec "$f" "$f"; done
34samizdat_execs_dir=/home/d/src/samizdat # TODO
35for c in $samizdat_execs; do CopyExec ${samizdat_execs_dir}/$c /bin; done
36for m in $modules; do force_load "$m" || exit 1; done 36for m in $modules; do force_load "$m" || exit 1; done
37for dir in $modules_dirs; do copy_modules_dir "$dir" || exit 1; done 37for dir in $modules_dirs; do copy_modules_dir "$dir" || exit 1; done
38 38
diff --git a/notes.txt b/notes.txt
deleted file mode 100644
index 1e4f296..0000000
--- a/notes.txt
+++ /dev/null
@@ -1,176 +0,0 @@
1initramfs-tools launches, as pid 1, a script called /init which is used to call
2all of the various configured scripts which are installed into
3'/etc/initramfs-tools/scripts'.
4
5Some of this scripts are executed in subshells, thus they cannot contain the
6final 'pivot_root' (or actually 'switch_root' now), but some of the scripts are
7sourced from the pid1 'sh' process.
8
9There is an environment variable called 'BOOT' which is set to 'local' by
10default and which can be overriden on the kernel command line. The pid1 process
11will source a file named with the value of the 'BOOT' variable:
12
13 # Always load local and nfs (since these might be needed for /etc or
14 # /usr, irrespective of the boot script used to mount the rootfs).
15 . /scripts/local
16 . /scripts/nfs
17 . /scripts/${BOOT}
18
19The BOOT script is used to define functions that will be called within pid1;
20particularly (from '/scripts/local', for example):
21
22
23 mountroot()
24 {
25 local_mount_root
26 }
27
28 mount_top()
29 {
30 # Note, also called directly in case it's overridden.
31 local_top
32 }
33
34 mount_premount()
35 {
36 # Note, also called directly in case it's overridden.
37 local_premount
38 }
39
40 mount_bottom()
41 {
42 # Note, also called directly in case it's overridden.
43 local_bottom
44 }
45
46
47Thus, it should be possible to add a script '/script/samizdat' which overrides
48one of these functions, and then add a BOOT=samizdat parameter.
49
50(Note: the 'local' versions of these scripts merely call 'run_scripts' on
51directories named like '/scripts/local-premount' etc. -- 'run_scripts' runs
52scripts in new processes, it does not source them from pid 1. But see below.)
53
54Almost certainly, the samizdat script should simply define the function 'mountroot'.
55
56Note: if it was desired not to have to set a kernel parameter, it would also be
57possible to 'trick' the system into executing code as pid1 through any script
58called with 'run_scripts' (such as a file placed in '/scripts/local-bottom').
59
60A script called with 'run_scripts' will run in a separate process, but after
61each script is called, pid1 will source the file '/conf/param.conf'.
62
63Thus, to overwrite the mountroot() function, something like this should suffice:
64
65 cat > /conf/mountroot-override <<EOF
66
67 mountroot()
68 {
69 # ...
70 }
71 EOF
72
73 echo '. /conf/mountroot-override' >> /conf/param.conf
74
75Or even just:
76
77 echo BOOT=samizdat >> /conf/mountroot-override
78
79
80
81
82
83
84This is probably the approach to take:
85
86 Create two scripts:
87
88 /etc/initramfs-tools/scripts/local-bottom/samizdat
89 /etc/initramfs-tools/scripts/samizdat
90
91 The first script just does:
92
93 echo BOOT=samizdat >> /conf/param.conf
94
95 The second script calls out to the existing samizdat initrd code. It can even
96 'exec' the original samizdat 'init', although it probably shouldn't.
97
98
99
100
101
102
103Another idea:
104
105
106 The first script waits for a samizdat read-only ISO, then configures the rest
107 of the boot process:
108
109 * Find the btrfs seed filesystem on the ISO
110 * Mount it as a loop device
111 * Add a ramfs to it, making it read-write
112 * Chroot into this system and run code to interact with the user and determine what to do:
113 * Find existing encrypted LUKS partitions
114 * Find existing encrypted GPG keys
115 * Allow the user to decrypt GPG keys -- saving the password in order to restart GPG agent
116 * Allow the user to create a new LUKS partition or choose an existing one
117 * If successful:
118
119 echo BOOT=samizdat >> /conf/param.conf
120 echo SAMIZDAT_LUKS_DEV=... >> /conf/param.conf # unencrypted dm dev
121 echo SAMIZDAT_GPG_ID=... >> /conf/param.conf # record the user we've authenticated as
122
123 The second script does the rest of the work:
124
125 * ...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141grepping for param.conf:
142
143/usr/share/initramfs-tools/scripts/local-top/cryptroot: # Apparently ROOT is already set in /conf/param.conf for
144/usr/share/initramfs-tools/scripts/local-top/cryptroot: if [ -f /conf/param.conf ] && grep -q "^ROOT=" /conf/param.conf; then
145/usr/share/initramfs-tools/scripts/local-top/cryptroot: NEWROOT=$(sed -n 's/^ROOT=//p' /conf/param.conf)
146/usr/share/initramfs-tools/scripts/local-top/cryptroot: echo "ROOT=$NEWROOT" >>/conf/param.conf
147/usr/share/initramfs-tools/hook-functions: echo "[ -e /conf/param.conf ] && . /conf/param.conf" >> ${initdir}/ORDER
148/usr/share/initramfs-tools/hook-functions: if [ -e /conf/param.conf ]; then
149/usr/share/initramfs-tools/hook-functions: . /conf/param.conf
150
151Relevant instances of 'run_scripts':
152
153 Definition:
154
155 /usr/share/initramfs-tools/scripts/functions:run_scripts()
156
157 Uses in pid1:
158
159 /usr/share/initramfs-tools/init:run_scripts /scripts/init-top
160 /usr/share/initramfs-tools/init:run_scripts /scripts/init-premount
161 /usr/share/initramfs-tools/init:run_scripts /scripts/init-bottom
162
163 Uses in 'local':
164
165 /usr/share/initramfs-tools/scripts/local: run_scripts /scripts/local-top
166 /usr/share/initramfs-tools/scripts/local: run_scripts /scripts/local-block "$@"
167 /usr/share/initramfs-tools/scripts/local: run_scripts /scripts/local-premount
168 /usr/share/initramfs-tools/scripts/local: run_scripts /scripts/local-bottom
169
170 Note that 'local' is unconditionally executed in init:
171
172
173
174 Panic hooks:
175
176 /usr/share/initramfs-tools/scripts/functions: run_scripts /scripts/panic
diff --git a/notes/btrfs-test.sh b/notes/btrfs-test.sh
new file mode 100644
index 0000000..62cab9a
--- /dev/null
+++ b/notes/btrfs-test.sh
@@ -0,0 +1,282 @@
1#!/bin/sh
2
3. ./var.sh
4. ./btrfs-functions.sh
5
6create_image()
7{
8 $(ARGS_NE megs filename)
9 [ ! -e "$filename" ] || return
10 truncate -s "$megs"M "$filename"
11}
12
13make_seed_fs()
14{
15 $(ARGS_NE input_dir img)
16 local mountpoint dev seed_subvol root_subvol
17
18 mountpoint=$img.mnt
19 mkdir "$mountpoint" || die 'mkdir failed'
20 dev=$(lodev "$img") || die 'lodev failed'
21 mkfs.btrfs "$dev" || die 'mkfs failed'
22 mount "$dev" "$mountpoint" || die 'mount failed'
23
24 seed_subvol=$mountpoint/SEED
25 root_subvol=$mountpoint/ROOT
26 btrfs subvolume create "$root_subvol" || die
27 rsync -aP "$input_dir"/ "$root_subvol"/ || die 'rsync failed'
28 btrfs subvolume snapshot -r "$root_subvol" "$seed_subvol" || die
29 btrfs_subvolume_set_default "$root_subvol" || die
30
31 umount "$mountpoint" || die 'umount failed'
32 rmdir "$mountpoint"
33 btrfstune -S 1 "$dev" || die 'btrfstune failed'
34 unlodev "$dev"
35}
36
37btrfs_subvolume_set_default()
38{
39 $(ARGS_NE path)
40 local subvol_id
41 subvol_id=$(btrfs_show_subvolume_id "$path") || return
42 btrfs subvolume set-default "$subvol_id" "$path"
43}
44
45loop_is_attached()
46{
47 [ "$(losetup -l "$1" -O BACK-FILE -n 2>/dev/null)" ]
48}
49
50lodev() { lodev_helper false "$@"; }
51lodev_readonly() { lodev_helper true "$@"; }
52
53lodev_helper()
54{
55 $(ARGS_NE readonly img)
56 local link b dev opt_ro
57 link=$img.b
58 if $readonly; then
59 opt_ro=-r
60 else
61 opt_ro=
62 fi
63 if [ -L "$link" ]; then
64 b="$(readlink "$link")"
65 loop_is_attached "$b" || losetup $opt_ro "$b" "$img" || return
66 else
67 dev=$(unused_dev) || return
68 losetup $opt_ro "$dev" "$img" || return
69 ln -sf "$dev" "$img".b || return
70 fi >/dev/null
71 printf '%s\n' $link
72}
73
74unused_dev()
75{
76 local do_not_use f d no
77 do_not_use=$(for f in *.b; do [ -L "$f" ] || continue; readlink $f; done)
78 for n in $(seq 10 20); do
79 d=/dev/loop$n
80 for no in $do_not_use; do
81 [ "$d" != "$no" ] || continue 2
82 done
83 echo $d
84 return
85 done
86}
87
88unlodev()
89{
90 $(ARGS_NE link)
91 [ -L "$link" ] || return
92 losetup -d "$(readlink "$link")" # && rm -f "$link"
93}
94
95plant_seed()
96{
97 $(ARGS_NE seed_img overlay_img mountpoint)
98 local overlay_dev seed_dev
99
100 overlay_dev=$(lodev "$overlay_img") || die 'lodev failed'
101 seed_dev=$(lodev_readonly "$seed_img") || die 'lodev failed'
102
103 mount "$seed_dev" "$mountpoint" || die 'mount failed'
104
105 btrfs device add "$overlay_dev" "$mountpoint" || die 'btrfs-device-add failed'
106 mount -o rw,remount "$mountpoint" || die 'remount failed'
107 btrfs device delete "$seed_dev" "$mountpoint" || die 'btrfs-device-delete failed'
108
109 unlodev "$seed_dev"
110
111 umount "$mountpoint"
112 unlodev "$overlay_dev"
113}
114
115generate_seed_helper()
116{
117 $(ARGS_NE seed_layer keep_old_seeds size seed_img snapshot_mountpoint overlay_img_output)
118 local mountpoint overlay_dev seed_dev snapshot_default
119 mountpoint=${overlay_img_output}.mnt
120
121 mountpoint -q "$snapshot_mountpoint" || die
122 [ -d "$mountpoint" ] || mkdir "$mountpoint" || die
123
124 filemaker "$overlay_img_output" create_image "$size" || die
125
126 overlay_dev=$(lodev "$overlay_img_output") || die
127 seed_dev=$(lodev_read_only "$seed_img") || die
128
129 mount -o subvol=/ "$seed_dev" "$mountpoint" || die
130 btrfs device add "$overlay_dev" "$mountpoint" || die
131 mount -o rw,remount "$mountpoint" || die
132
133 snapshot_default=$(btrfs_show_default_path "$snapshot_mountpoint") || die
134
135 push_simple "$snapshot_mountpoint"/SEED_NEW "$snapshot_mountpoint"/SEED "$snapshot_default" "$mountpoint"
136
137 if $keep_old_seeds; then
138 sex mv -T --backup=numbered "$mountpoint"/SEED_NEW "$mountpoint"/SEED || die
139 else
140 btrfs subvolume delete "$mountpoint"/SEED || die
141 sex mv "$mountpoint"/SEED_NEW "$mountpoint"/SEED || die
142 fi
143
144 if ! $seed_layer; then
145 btrfs device remove "$seed_dev" "$mountpoint" || die
146 fi
147
148 umount "$mountpoint" || die
149 rmdir "$mountpoint"
150
151 btrfstune -S 1 "$overlay_img_output" || die 'btrfstune failed'
152}
153
154generate_seed_overlay() # NB. uses non-local variables set in <..>_helper
155{
156 generate_seed_helper true true "$@"
157}
158
159regenerate_toplevel_seed()
160{
161 generate_seed_helper false true "$@"
162}
163
164regenerate_from_master()
165{
166 regenerate_toplevel_seed 256 seed.img master overlay.img
167 remove_image seed.img || die
168 mv overlay.img seed.img || die
169 mv overlay.img.b seed.img.b || die
170}
171
172plant_seed_mount()
173{
174 plant_seed "$1" "$2" "$3"
175 mount "$(lodev "$2")" "$3"
176}
177
178plant_seed_mount_rootvol()
179{
180 plant_seed "$1" "$2" "$3"
181 mount -o subvol=/ "$(lodev "$2")" "$3"
182}
183
184remove_image()
185{
186 unlodev "$1.b"
187 rm -f "$1" "$1.b"
188}
189
190IMAGES='master.img slave.img seed.img overlay.img'
191MNTPOINTS='master slave/mnt slave seed.img.mnt overlay.img.mnt'
192
193mounter()
194{
195 $(ARGS_NE mp)
196 shift
197 mountpoint -q "$mp" && return
198 mkdir "$mp" 2>/dev/null
199 "$@" "$mp"
200}
201
202filemaker()
203{
204 $(ARGS_NE f)
205 shift
206 [ -f "$f" ] && return
207 ! [ -e "$f" ] || return
208 "$@" "$f"
209}
210
211in_dir()
212{
213 (set -e
214 cd "$1"
215 shift
216 "$@")
217}
218
219pull()
220{
221 $(ARGS_NE mnt src dst)
222 local src_subvol
223 src_subvol=$(btrfs_show_default_path "$src") || die
224
225 die 'unimplemented'
226}
227
228push_slave()
229{
230 local mnt img img_dev
231 mnt=slave/mnt
232 img=slave.img
233 mkdir "$mnt" 2>/dev/null
234 img_dev=$(lodev "$img") || die
235 mounter "$mnt" mount -o subvol=/ "$img_dev" || die
236
237 push "$mnt" slave master
238 umount "$mnt"
239 losetup -D
240}
241
242main()
243{
244 local img
245
246 mkdir inp
247 touch inp/file.txt
248
249 for img in $IMAGES; do
250 filemaker $img create_image 256 || die # Note: btrfs kernel task hangs if image is too small!
251 done
252
253 make_seed_fs inp seed.img || die
254
255 mounter slave plant_seed_mount seed.img slave.img
256 mounter master plant_seed_mount_rootvol seed.img master.img
257}
258
259cleanup()
260{
261 local img m
262
263 for img in $IMAGES; do
264 remove_image "$img"
265 done
266 for m in $MNTPOINTS; do
267 umount "$m" 2>/dev/null
268 rmdir "$m" 2>/dev/null
269 done
270 losetup -D 2>/dev/null
271 true
272}
273
274case "$1" in
275 clean|cleanup) cleanup ;;
276 testclean) main; cleanup ;;
277 cleantest) cleanup; main ;;
278 push) push_slave ;;
279 regen) regenerate_from_master ;;
280 '') main ;;
281 *) die "Unknown command: $1" ;;
282esac
diff --git a/notes/xorriso-patch.sh b/notes/xorriso-patch.sh
new file mode 100644
index 0000000..47a9934
--- /dev/null
+++ b/notes/xorriso-patch.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2exit
3# This kept the ISO bootable:
4
5xorriso -drive_class clear_list all \
6 -indev debian-live-8.4.0-amd64-standard.iso \
7 -outdev test3.iso \
8 -rm_r live install pool -- \
9 -pathspecs on \
10 -add live=isolinux/live/ isolinux/pxelinux.* isolinux/*.cfg -- \
11 -boot_image isolinux patch
diff --git a/samizdat-paths.sh b/samizdat-paths.sh
new file mode 100644
index 0000000..e417849
--- /dev/null
+++ b/samizdat-paths.sh
@@ -0,0 +1,7 @@
1samizdat_initrd_files_dir=/home/d/sami/src/initrd
2samizdat_execs_dir=/home/d/src/samizdat
3samizdat_child_dir=/home/d/sami/child
4samizdat_isolinux_dir=/home/d/sami/isolinux
5samizdat_grub_efi_dir=/home/d/sami/grub-efi
6samizdat_iso_dir=/home/d/sami
7PATH=${libexecdir}/${PACKAGE}/bin:${PATH}
diff --git a/btrfs-functions.sh b/src/btrfs-functions.sh
index b83b94d..b83b94d 100644
--- a/btrfs-functions.sh
+++ b/src/btrfs-functions.sh
diff --git a/btrfs-receive-root.sh b/src/btrfs-receive-root.sh
index f553c2c..f553c2c 100644
--- a/btrfs-receive-root.sh
+++ b/src/btrfs-receive-root.sh
diff --git a/btrfs-send-root.sh b/src/btrfs-send-root.sh
index 25e60f2..8a3a513 100644
--- a/btrfs-send-root.sh
+++ b/src/btrfs-send-root.sh
@@ -1,6 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2. ./var.sh 2. samizdat-paths.sh
3. ./btrfs-functions.sh 3. var.sh
4. btrfs-functions.sh
4 5
5rootfs_uuid () 6rootfs_uuid ()
6{ 7{
diff --git a/grub-efi.sh b/src/grub-efi.sh
index 76ee34a..e2d50f6 100755
--- a/grub-efi.sh
+++ b/src/grub-efi.sh
@@ -1,4 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2. samizdat-paths.sh
3
2grub_config() 4grub_config()
3{ 5{
4 cat <<EOF 6 cat <<EOF
@@ -29,8 +31,8 @@ boot
29EOF 31EOF
30} 32}
31 33
32real_destdir=grub-efi 34real_destdir=$samizdat_grub_efi_dir
33destdir=grub-efi.tmp 35destdir=$real_destdir.tmp
34 36
35set -e 37set -e
36rm -r "${destdir}" 2>/dev/null || true 38rm -r "${destdir}" 2>/dev/null || true
diff --git a/initrd.sh b/src/initrd.sh
index 252763b..8cc8ea1 100755
--- a/initrd.sh
+++ b/src/initrd.sh
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2 2
3initrd=isolinux/linux/initrd.img 3initrd=${samizdat_isolinux_dir}/linux/initrd.img
4vmlinuz=isolinux/linux/vmlinuz 4vmlinuz=${samizdat_isolinux_dir}/linux/vmlinuz
5 5
6version=$(uname -r) 6version=$(uname -r)
7version=4.5.0-0.bpo.1-amd64 7version=4.5.0-0.bpo.1-amd64
diff --git a/old-school/common.sh b/src/initrd/common.sh
index 4aa8528..4aa8528 100644
--- a/old-school/common.sh
+++ b/src/initrd/common.sh
diff --git a/old-school/grok-block b/src/initrd/grok-block
index 75d5120..75d5120 100755
--- a/old-school/grok-block
+++ b/src/initrd/grok-block
diff --git a/old-school/halt.montecarlo b/src/initrd/halt.montecarlo
index 67dac17..67dac17 100755
--- a/old-school/halt.montecarlo
+++ b/src/initrd/halt.montecarlo
diff --git a/old-school/init b/src/initrd/init
index 3b62c0a..3b62c0a 100755
--- a/old-school/init
+++ b/src/initrd/init
diff --git a/old-school/init.functions b/src/initrd/init.functions
index 7209b04..7209b04 100644
--- a/old-school/init.functions
+++ b/src/initrd/init.functions
diff --git a/old-school/init.shutdown b/src/initrd/init.shutdown
index 6bfce84..6bfce84 100755
--- a/old-school/init.shutdown
+++ b/src/initrd/init.shutdown
diff --git a/loop-layer.sh b/src/initrd/loop-layer.sh
index 7e08e12..7e08e12 100644
--- a/loop-layer.sh
+++ b/src/initrd/loop-layer.sh
diff --git a/old-school/lvm-create.sh b/src/initrd/lvm-create.sh
index d4a8bdf..d4a8bdf 100644
--- a/old-school/lvm-create.sh
+++ b/src/initrd/lvm-create.sh
diff --git a/old-school/lvm.conf b/src/initrd/lvm.conf
index 0c1289f..0c1289f 100644
--- a/old-school/lvm.conf
+++ b/src/initrd/lvm.conf
diff --git a/old-school/mdadm-dup.sh b/src/initrd/mdadm-dup.sh
index 70163a5..70163a5 100644
--- a/old-school/mdadm-dup.sh
+++ b/src/initrd/mdadm-dup.sh
diff --git a/old-school/menu-select b/src/initrd/menu-select
index f059052..f059052 100755
--- a/old-school/menu-select
+++ b/src/initrd/menu-select
diff --git a/old-school/samizdat-cdrom-copy b/src/initrd/samizdat-cdrom-copy
index d4920b9..d4920b9 100755
--- a/old-school/samizdat-cdrom-copy
+++ b/src/initrd/samizdat-cdrom-copy
diff --git a/samizdat-eject.sh b/src/initrd/samizdat-eject.sh
index d95a49d..d95a49d 100755
--- a/samizdat-eject.sh
+++ b/src/initrd/samizdat-eject.sh
diff --git a/old-school/squashfs-size b/src/initrd/squashfs-size
index 74b67d7..74b67d7 100755
--- a/old-school/squashfs-size
+++ b/src/initrd/squashfs-size
diff --git a/old-school/umountall.sh b/src/initrd/umountall.sh
index bf89838..bf89838 100755
--- a/old-school/umountall.sh
+++ b/src/initrd/umountall.sh
diff --git a/old-school/vol_id b/src/initrd/vol_id
index 5cd24a1..5cd24a1 100755
--- a/old-school/vol_id
+++ b/src/initrd/vol_id
diff --git a/keygen.sh b/src/keygen.sh
index 716359b..716359b 100755
--- a/keygen.sh
+++ b/src/keygen.sh
diff --git a/patchroot.sh b/src/patchroot.sh
index 738beac..738beac 100755
--- a/patchroot.sh
+++ b/src/patchroot.sh
diff --git a/qemu.sh b/src/qemu.sh
index 5553e7b..dfed521 100755
--- a/qemu.sh
+++ b/src/qemu.sh
@@ -1,25 +1,27 @@
1#!/bin/sh 1#!/bin/sh
2 2
3. samizdat-path.sh
4
3# iso=debian-live-8.4.0-amd64-gnome-desktop.iso 5# iso=debian-live-8.4.0-amd64-gnome-desktop.iso
4# iso=debian-live-8.4.0-amd64-standard.iso 6# iso=debian-live-8.4.0-amd64-standard.iso
5# iso=debian-live-8.4.0-amd64-standard.btrfs.iso 7# iso=debian-live-8.4.0-amd64-standard.btrfs.iso
6iso=samizdat.iso 8iso=${samizdat_iso_dir}/samizdat.iso
7disk=debian-live-8.4.0-amd64-standard.btrfs.disk 9disk=${samizdat_iso_dir}/debian-live-8.4.0-amd64-standard.btrfs.disk
8layered=${iso%.iso}.layered.iso 10layered=${samizdat_iso_dir}/${iso%.iso}.layered.iso
9 11
10[ -f "$layered" ] && iso=$layered 12[ -f "$layered" ] && iso=$layered
11 13
12[ "$1" ] && iso=$1 14[ "$1" ] && iso=$1
13 15
14./initrd.sh || { echo "./initrd.sh failed" >&2; exit 1; }; 16initrd.sh || { echo "initrd.sh failed" >&2; exit 1; };
15 17
16NET='tap,vlan=0,ifname=tap0,script=no,downscript=no' 18NET='tap,vlan=0,ifname=tap0,script=no,downscript=no'
17 19
18# To test local pxe boot server: 20# To test local pxe boot server:
19# NET='user,tftp=isolinux,bootfile=/pxelinux.0' 21# NET='user,tftp=isolinux,bootfile=/pxelinux.0'
20 22
21initrd=isolinux/linux/initrd.img 23initrd=${samizdat_isolinux_dir}/linux/initrd.img
22kernel=isolinux/linux/vmlinuz 24kernel=${samizdat_isolinux_dir}/linux/vmlinuz
23kcmdline='boot=samizdat components quiet splash' 25kcmdline='boot=samizdat components quiet splash'
24 26
25sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 640 -k en-us \ 27sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 640 -k en-us \
diff --git a/src/samizdat-paths.sh b/src/samizdat-paths.sh
new file mode 100644
index 0000000..c437c5b
--- /dev/null
+++ b/src/samizdat-paths.sh
@@ -0,0 +1,5 @@
1samizdat_initrd_files_dir=/home/d/sami/src/initrd
2samizdat_execs_dir=/home/d/src/samizdat
3samizdat_child_dir=./child
4samizdat_isolinux_dir=/home/d/sami/isolinux
5PATH=${libexecdir}/${PACKAGE}/bin:${PATH}
diff --git a/var.sh b/src/var.sh
index d0c7df5..d0c7df5 100644
--- a/var.sh
+++ b/src/var.sh
diff --git a/xorriso-layer.sh b/src/xorriso-layer.sh
index 7ce4776..7ce4776 100755
--- a/xorriso-layer.sh
+++ b/src/xorriso-layer.sh
diff --git a/xorriso-usb.sh b/src/xorriso-usb.sh
index 3f7df8e..61fcda0 100755..100644
--- a/xorriso-usb.sh
+++ b/src/xorriso-usb.sh
@@ -1,12 +1,14 @@
1#!/bin/bash 1#!/bin/bash
2 2
3. samizdat-paths.sh || exit 1
4
3outdev= 5outdev=
4volid=SamizdatLive 6volid=SamizdatLive
5gpg_iso_path=gnupghome 7gpg_iso_path=gnupghome
6gnupghome= 8gnupghome=
7secrets=secrets 9child_dir=$samizdat_child_dir
8child_dir=./child 10vmlinuz_dir=$samizdat_isolinux_dir
9vmlinuz_dir=isolinux/linux 11efi_dir=$samizdat_grub_efi_dir
10 12
11die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } 13die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; }
12 14
@@ -104,7 +106,7 @@ generate_keys()
104 kiki init || die 'kiki init failed' 106 kiki init || die 'kiki init failed'
105 gnupghome=/root/.gnupg 107 gnupghome=/root/.gnupg
106 else 108 else
107 ./keygen.sh "$child_dir" || die "keygen.sh failed" 109 keygen.sh "$child_dir" || die "keygen.sh failed"
108 gnupghome=$child_dir/root/.gnupg 110 gnupghome=$child_dir/root/.gnupg
109 trap 'umount "$child_dir"; rmdir "$child_dir"' EXIT 111 trap 'umount "$child_dir"; rmdir "$child_dir"' EXIT
110 fi 112 fi
@@ -113,9 +115,7 @@ generate_keys()
113 115
114[ "$(id -u)" = 0 ] || die "you are not root." 116[ "$(id -u)" = 0 ] || die "you are not root."
115 117
116if [ grub-efi.sh -nt grub-efi ]; then 118grub-efi.sh || die "grub-efi.sh failed"
117 ./grub-efi.sh || die "grub-efi.sh failed"
118fi
119 119
120choose_outdev 120choose_outdev
121 121
@@ -137,7 +137,7 @@ if [ "$QUICK_TEST" ]; then
137fi 137fi
138 138
139if [ "$REPLACE_INITRD" ]; then 139if [ "$REPLACE_INITRD" ]; then
140 ./initrd.sh 140 initrd.sh
141fi 141fi
142 142
143(set -x 143(set -x
@@ -168,9 +168,9 @@ xorriso \
168 -as mkisofs -graft-points \ 168 -as mkisofs -graft-points \
169 -b grub/i386-pc/eltorito.img \ 169 -b grub/i386-pc/eltorito.img \
170 -no-emul-boot -boot-info-table \ 170 -no-emul-boot -boot-info-table \
171 --embedded-boot grub-efi/embedded.img \ 171 --embedded-boot "${efi_dir}"/embedded.img \
172 --protective-msdos-label \ 172 --protective-msdos-label \
173 grub=grub-efi/grub 173 grub="${efi_dir}"/grub
174) || die "xorriso exited $?" 174) || die "xorriso exited $?"
175 175
176case "$outdev" in 176case "$outdev" in
diff --git a/xorriso.sh b/src/xorriso.sh
index 5068d4b..5068d4b 100755
--- a/xorriso.sh
+++ b/src/xorriso.sh
diff --git a/xorriso.test-efi.sh b/src/xorriso.test-efi.sh
index 3591528..3591528 100755
--- a/xorriso.test-efi.sh
+++ b/src/xorriso.test-efi.sh
diff --git a/update-initramfs.conf b/update-initramfs.conf
deleted file mode 100644
index ce86f30..0000000
--- a/update-initramfs.conf
+++ /dev/null
@@ -1,30 +0,0 @@
1#
2# Configuration file for update-initramfs(8)
3#
4
5#
6# update_initramfs [ yes | all | no ]
7#
8# Default is yes
9# If set to all update-initramfs will update all initramfs
10# If set to no disables any update to initramfs beside kernel upgrade
11
12update_initramfs=yes
13
14#
15# backup_initramfs [ yes | no ]
16#
17# Default is no
18# If set to no leaves no .bak backup files.
19
20backup_initramfs=no
21
22if [ "$SAMIZDAT_UPDATE_INITRAMFS_ROOT" ]; then
23 STATEDIR="$SAMIZDAT_UPDATE_INITRAMFS_ROOT"/var/lib/initramfs-tools
24 BOOTDIR="$SAMIZDAT_UPDATE_INITRAMFS_ROOT"/boot
25 test -d "$SAMIZDAT_UPDATE_INITRAMFS_ROOT" || {
26 echo "$0: Error: not a directory: ${SAMIZDAT_UPDATE_INITRAMFS_ROOT}" >&2
27 exit 1
28 }
29 mkdir -p "$STATEDIR" "$BOOTDIR"
30fi