aboutsummaryrefslogtreecommitdiff
path: root/sub/layout
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-05-04 00:10:26 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-05-04 00:10:26 +0000
commit7bb2006007c1996f33758e41db070252d4d3607f (patch)
tree3dc03d4f6a8867742961a3dea9ecc96c52d00a10 /sub/layout
parent1202c964c4e91083a3c60b41b9c11e220bfa759d (diff)
downloadlh-bootstrap-7bb2006007c1996f33758e41db070252d4d3607f.tar.xz
Make a lean and mean version, as a basis for filling an initramfs
Diffstat (limited to 'sub/layout')
-rw-r--r--sub/layout/Makefile7
-rwxr-xr-xsub/layout/configure-localoptions20
-rwxr-xr-xsub/layout/copylayout53
-rw-r--r--sub/layout/permissions21
4 files changed, 9 insertions, 92 deletions
diff --git a/sub/layout/Makefile b/sub/layout/Makefile
index ce9ebd5..ed63328 100644
--- a/sub/layout/Makefile
+++ b/sub/layout/Makefile
@@ -1,12 +1,7 @@
$(OUTPUT)/tmp/.lh_layout_copied: $(OUTPUT)/tmp/.lh_prepared layout | $(OUTPUT)/build-build/.lh_skarnet_installed
exec sub/layout/copylayout $(OUTPUT)
- exec sub/layout/configure-localoptions $(OUTPUT) $(COUNTRY_CODE) $(LOCAL_IP) $(ROUTER_IP)
exec setuidgid $(NORMALUSER) s6-touch $@
-$(OUTPUT)/tmp/.lh_layout_s6rcdb_made: $(OUTPUT)/tmp/.lh_layout_copied | $(OUTPUT)/build-build/.lh_skarnet_installed
- stamp=$$(s6-clock) && s6-rc-compile -v2 -h sysfdh $(OUTPUT)/rootfs/etc/s6-rc/compiled-$$stamp $(OUTPUT)/rootfs/etc/s6-rc/source-base && s6-ln -s compiled-$$stamp $(OUTPUT)/rootfs/etc/s6-rc/compiled.new && s6-rename $(OUTPUT)/rootfs/etc/s6-rc/compiled.new $(OUTPUT)/rootfs/etc/s6-rc/compiled
- exec setuidgid $(NORMALUSER) s6-touch $@
-
-$(OUTPUT)/tmp/.lh_layout_installed: $(OUTPUT)/tmp/.lh_layout_copied $(OUTPUT)/tmp/.lh_layout_s6rcdb_made | $(OUTPUT)/build-build/.lh_skarnet_installed
+$(OUTPUT)/tmp/.lh_layout_installed: $(OUTPUT)/tmp/.lh_layout_copied | $(OUTPUT)/build-build/.lh_skarnet_installed
exec setuidgid $(NORMALUSER) s6-touch $@
diff --git a/sub/layout/configure-localoptions b/sub/layout/configure-localoptions
deleted file mode 100755
index 451fcce..0000000
--- a/sub/layout/configure-localoptions
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh -e
-
-output="$1"
-countrycode="$2"
-localip="$3"
-routerip="$4"
-
-case "$countrycode" in
- fr) timezone=Europe/Paris ;;
- uk) timezone=Europe/London ;;
- rs) timezone=Europe/Belgrade ;;
- cn) timezone=Asia/Shanghai ;;
- vn) timezone=Asia/Saigon ;;
- *) echo "invalid countrycode: please choose fr, uk, rs, cn or vn" 1>&2 ; exit 100 ;;
-esac
-
-echo "$countrycode" > $output/rootfs/etc/s6-linux-init/env-stage2/COUNTRY_CODE
-echo "$localip" > $output/rootfs/etc/s6-linux-init/env-stage2/ETH0_IP4
-echo "$routerip" > $output/rootfs/etc/s6-linux-init/env-stage2/DEFAULT_ROUTER_IP4
-echo ":$timezone" > $output/rootfs/etc/s6-linux-init/env/TZ
diff --git a/sub/layout/copylayout b/sub/layout/copylayout
index 82b303e..32b991d 100755
--- a/sub/layout/copylayout
+++ b/sub/layout/copylayout
@@ -1,64 +1,17 @@
#!/bin/sh -e
-# TODO: need comments
-
output="$1"
-
-case "$QEMU_ARCH" in
- x86_64) disk=sda ; partition=sda ; netmodule=e1000 ; console=ttyS0 ;;
- x86) disk=sda ; partition=sda ; netmodule=e1000 ; console=ttyS0 ;;
- arm) disk=mmcblk0 ; partition=mmcblk0p ; netmodule=virtio_net ; console=ttyAMA0 ;;
- aarch64) disk=mmcblk0 ; partition=mmcblk0p ; netmodule=virtio_net ; console=ttyAMA0 ;;
-esac
-
-if $USE_VIRTIO_DISK ; then
- disk=vda
- partition=vda
-fi
-
-if $USE_VIRTIO_NETWORK ; then
- netmodule=virtio_net
-fi
-
s6-hiercopy layout/rootfs $output/rootfs
find "$output/rootfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;
-s6-hiercopy layout/rwfs $output/rwfs
-find "$output/rwfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;
-s6-hiercopy layout/userfs $output/userfs
-find "$output/userfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;
-s6-hiercopy layout/stagingfs $output/stagingfs
-find "$output/stagingfs" -type f -name .empty -size 0c -exec s6-rmrf {} \;
-if $USE_GRAPHIC ; then
- console=tty1
- echo "load-essential-modules" >> $output/rootfs/etc/s6-rc/source-base/ok-local/contents
-fi
-
-timeout=${S6RC_TIMEOUT}
buildtime=$(s6-clock)
hostarch=$(s6-echo $TRIPLE | cut -f1 -d-)
-sed -i -e "s/%%HOSTNAME%%/lh-$hostarch/g" $output/rootfs/etc/s6-rc/source-base/00/up $output/rootfs/etc/s6-linux-init/run-image/service/s6-linux-init-early-getty/run $output/rootfs/etc/motd $output/rootfs/etc/issue.net $output/rootfs/root/.execline-shell $output/userfs/home/guest/.execline-shell
-sed -i -e "s/%%CONSOLE%%/$console/g" $output/rootfs/etc/s6-linux-init/run-image/service/s6-linux-init-early-getty/run
-sed -i -e "s/%%NETMODULE%%/$netmodule/g" $output/rootfs/etc/s6-rc/source-base/init-eth0/up
-sed -i -e "s/%%RCTIMEOUT%%/$timeout/g" -e "s/%%BUILDTIME%%/$buildtime/g" $output/rootfs/etc/rc.init
-
-
-if $USE_DHCP ; then
- eth0_service=udhcpc-eth0-pipeline
-else
- eth0_service=static-eth0
-fi
-# echo ${eth0_service} > $output/rootfs/etc/s6-rc/source-base/activate-eth0/contents
-
-for i in $output/rootfs/etc/s6-rc/source-base/mount-*/* ; do
- sed -i -e "s/%%DISK%%/$disk/g" -e "s/%%PARTITION%%/$partition/g" $i
-done
-
-chown -R root.root $output/rootfs $output/rwfs $output/userfs
+sed -i -e "s/%%HOSTNAME%%/lh-$hostarch/g" $output/rootfs/run/service/s6-linux-init-early-getty/run $output/rootfs/etc/motd $output/rootfs/etc/issue.net $output/rootfs/root/.execline-shell
+sed -i -e "s/%%CONSOLE%%/$console/g" $output/rootfs/run/service/s6-linux-init-early-getty/run
-s6-mkfifo -m 0600 -- $output/rootfs/etc/s6-linux-init/run-image/service/s6-svscan-log/fifo || s6-true
+s6-mkfifo -m 0600 $output/rootfs/run/service/s6-svscan-log/fifo
while read file user group perms ; do
if s6-test -n "$file" -a "$file" != "#" ; then
diff --git a/sub/layout/permissions b/sub/layout/permissions
index 459355e..d940583 100644
--- a/sub/layout/permissions
+++ b/sub/layout/permissions
@@ -1,18 +1,7 @@
rootfs/etc/shadow 0 0 0600
-rootfs/etc/s6-linux-init/run-image/uncaught-logs 98 98 2700
+rootfs/run/uncaught-logs 98 98 2700
-rwfs/var/tmp 0 0 1777
-rwfs/var/log/devd 100 61 2700
-rwfs/var/log/dnscache 114 64 2700
-rwfs/var/log/fdholder 135 76 2700
-rwfs/var/log/fdholder-tmp 135 76 2700
-rwfs/var/log/klogd 102 61 2700
-rwfs/var/log/ntpclient 106 62 2700
-rwfs/var/log/sshd-4 138 61 2700
-rwfs/var/log/syslogd 104 61 2700
-# rwfs/var/log/udhcpc-eth0 139 78 2700
-
-userfs/home/guest 1000 100 2755
-userfs/home/guest/.execline-shell 1000 100 0755
-userfs/home/guest/.execline-loginshell 1000 100 0755
-userfs/home/guest/.ssh 1000 100 2700
+rootfs/tmp 0 0 1777
+rootfs/var/log/klogd 102 61 2700
+rootfs/var/log/ntpclient 106 62 2700
+rootfs/var/log/sshd-4 138 61 2700