portable-svc/build-rootfs.sh

36 lines
808 B
Bash
Raw Normal View History

source $stdenv/setup
set -o pipefail
# basic file system layout
mkdir -p $out/etc $out/proc $out/sys $out/dev $out/run $out/tmp $out/var/tmp $out/var/lib $out/var/log
# empty files to mount over with host's version
touch $out/etc/resolv.conf $out/etc/machine-id
# required for portable services
cp ${osRelease} $out/etc/os-release
# units must be copied to /etc/…
mkdir -p $out/etc/systemd/system
units=($units)
unitNames=($unitNames)
for ((n = 0; n < ${#units[*]}; n++)); do
unit=${units[$n]}
unitName=${unitNames[$n]}
cp $unit $out/etc/systemd/system/$unitName
done
# symlinks
objects=($objects)
targets=($targets)
for ((n = 0; n < ${#objects[*]}; n++)); do
object=${objects[$n]}
target=${targets[$n]}
mkdir -p $(dirname $out/$target)
ln -s $object $out/$target
done