diff options
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | user.mk | 32 |
2 files changed, 50 insertions, 3 deletions
@@ -48,16 +48,31 @@ else | |||
48 | ln -sf /var/cache/kiki/config/tor/hostname ${instdir}/etc/hostname | 48 | ln -sf /var/cache/kiki/config/tor/hostname ${instdir}/etc/hostname |
49 | endif | 49 | endif |
50 | 50 | ||
51 | include user.mk | ||
52 | |||
51 | .PHONY: rootfs | 53 | .PHONY: rootfs |
52 | rootfs: | 54 | rootfs: |
53 | make -C fsmgr | 55 | : git submodule update |
54 | make -C fsmgr install | 56 | $(MAKE) -C fsmgr |
55 | make -C rootfs | 57 | $(MAKE) -C fsmgr install |
58 | $(MAKE) -C rootfs | ||
56 | sudo ln -sf "$$PWD"/rootfs/samizdat.btrfs /srv/nbd/samizdat.btrfs | 59 | sudo ln -sf "$$PWD"/rootfs/samizdat.btrfs /srv/nbd/samizdat.btrfs |
57 | 60 | ||
58 | boot: rootfs | 61 | boot: rootfs |
59 | sudo qemu.sh | 62 | sudo qemu.sh |
60 | 63 | ||
64 | reuse_child := $(shell 2>/dev/null read child < reused-child && echo --reuse_child=$$child; true) | ||
65 | |||
66 | isotest: install | ||
67 | initrd.sh | ||
68 | xorriso-usb.sh $(reuse_child) --bootloader --out samizdat.iso | ||
69 | USE_ISO=y SLOW_BOOT=y qemu.sh | ||
70 | |||
71 | isotest-nonet: install | ||
72 | initrd.sh | ||
73 | xorriso-usb.sh $(reuse_child) --out samizdat-nonet.iso | ||
74 | USE_ISO=y SLOW_BOOT=y NO_NET=y qemu.sh samizdat-nonet.iso | ||
75 | |||
61 | install: ${bin_programs} samizdat-paths.sh ${compiled_programs} | 76 | install: ${bin_programs} samizdat-paths.sh ${compiled_programs} |
62 | install -p ${bin_programs} ${instdir}${samizdat_bindir} | 77 | install -p ${bin_programs} ${instdir}${samizdat_bindir} |
63 | mkdir -p ${instdir}${samizdat_initrd_files_dir} | 78 | mkdir -p ${instdir}${samizdat_initrd_files_dir} |
@@ -0,0 +1,32 @@ | |||
1 | user_username = u | ||
2 | user_home_path := $(shell getent passwd "$(user_username)" | (IFS=: read _ _ _ _ _ homedir _; echo $$homedir)) | ||
3 | user_home_btrfs = $(user_home_path).btrfs | ||
4 | user_home_bytes = 10GiB | ||
5 | user_home_force_replace = | ||
6 | |||
7 | user_exists = getent passwd "$(user_username)" >/dev/null | ||
8 | |||
9 | is_btrfs = df ~$(user_username) -t btrfs >/dev/null | ||
10 | |||
11 | user-account: | ||
12 | [ "$(user_username)" ] | ||
13 | $(user_exists) || sudo useradd "$(user_username)" -G sudo -m -p '' -s /bin/bash | ||
14 | $(is_btrfs) || $(MAKE) mount-user-btrfs-home >/dev/null 2>&1 || $(MAKE) user-btrfs-home | ||
15 | |||
16 | remove_user_home_btrfs = sudo mv -b "$(user_home_btrfs)" "$(user_home_btrfs)"~"$$(date -Is)" | ||
17 | |||
18 | user-btrfs-home: | ||
19 | [ "$(user_home_path)" ] | ||
20 | [ ! -e "$(user_home_btrfs)" ] || $(if $(user_home_force_replace),$(remove_user_home_btrfs),false) | ||
21 | [ ! -e "$(user_home_btrfs)" ] | ||
22 | ! mountpoint -q "$(user_home_path)" || sudo umount "$(user_home_path)" | ||
23 | [ ! -e "$(user_home_path)" ] || sudo rmdir "$(user_home_path)" || sudo mv -b "$(user_home_path)" "$(user_home_path)"~"$$(date -Is)" | ||
24 | [ -e "$(user_home_btrfs)" ] || sudo fallocate -l "$(user_home_bytes)" "$(user_home_btrfs)" | ||
25 | sudo mkdir "$(user_home_path)" | ||
26 | sudo mkfs.btrfs "$(user_home_btrfs)" | ||
27 | sudo mount -t btrfs "$(user_home_btrfs)" "$(user_home_path)" | ||
28 | sudo rsync -a /etc/skel/ "$(user_home_path)"/ | ||
29 | sudo chown -R "$(user_username):" "$(user_home_path)" | ||
30 | |||
31 | mount-user-btrfs-home: | ||
32 | mountpoint -q "$(user_home_path)" || sudo mount -t btrfs "$(user_home_btrfs)" "$(user_home_path)" | ||