diff options
Diffstat (limited to 'sub/layout/copylayout')
-rwxr-xr-x | sub/layout/copylayout | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/sub/layout/copylayout b/sub/layout/copylayout new file mode 100755 index 0000000..59dd0e0 --- /dev/null +++ b/sub/layout/copylayout @@ -0,0 +1,70 @@ +#!/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/initramfs $output/initramfs +find "$output/initramfs" -type f -name .empty -size 0c -exec s6-rmrf {} \; +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/initramfs/init $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/initramfs $output/rootfs $output/rwfs $output/userfs + +s6-mkfifo -m 0600 -- $output/rootfs/etc/s6-linux-init/run-image/service/s6-svscan-log/fifo || s6-true + +while read file user group perms ; do + if s6-test -n "$file" -a "$file" != "#" ; then + $output/build-build/command/s6-chown -u $user -g $group -- $output/$file + $output/build-build/command/s6-chmod $perms $output/$file + fi +done < sub/layout/permissions |