#!/bin/sh umask 022 set -e if [ "$(id -u)" != "0" ]; then echo "Please run this script as root" 1>&2 exit 1 fi if [ ! "$rocket" ]; then echo 'Please set the $rocket variable' 1>&2 exit 1 fi echo "Changing ownership of $rocket to root" chown -R 0.0 "$rocket" echo "Creating device nodes" mkdir -p "$rocket/dev" if cut -d' ' -f2 /proc/mounts | grep "$rocket/dev" > /dev/null; then umount -R "$rocket/dev" fi mknod -m 600 "$rocket/dev/console" c 5 1 2> /dev/null || true mknod -m 666 "$rocket/dev/null" c 1 3 2> /dev/null || true echo "Creating directories" install -dm750 "$rocket/root" install -dm1777 "$rocket/tmp" mkdir -p "$rocket/etc" "$rocket/usr/pkg" "$rocket/usr/sat" if [ "$(uname -m)" == "x86_64" ]; then ln -sf lib "$rocket/lib64" ln -sf lib "$rocket/usr/lib64" fi echo "Creating temporary symlinks" mkdir -p "$rocket/usr/pkg/tmp-coreutils/bin" ln -sf ../../../../tools/bin/sh "$rocket/usr/pkg/tmp-coreutils/bin/sh" ln -sf ../../../../tools/bin/pwd "$rocket/usr/pkg/tmp-coreutils/bin/pwd" mkdir -p "$rocket/usr/pkg/tmp-bash/bin" ln -sf ../../../../tools/bin/bash "$rocket/usr/pkg/tmp-bash/bin/bash" mkdir -p "$rocket/usr/pkg/tmp-ca-certificates/etc/ssl" ln -sf ../../../../../tools/lib/ssl/certs "$rocket/usr/pkg/tmp-ca-certificates/etc/ssl/certs" mkdir -p "$rocket/usr/pkg/tmp-gcc/usr/lib" ln -sf ../../../../../tools/lib/libgcc_s.so "$rocket/usr/pkg/tmp-gcc/usr/lib/libgcc_s.so" ln -sf ../../../../../tools/lib/libgcc_s.so.1 "$rocket/usr/pkg/tmp-gcc/usr/lib/libgcc_s.so.1" ln -sf ../../../../../tools/lib/libstdc++.so "$rocket/usr/pkg/tmp-gcc/usr/lib/libstdc++.so" ln -sf ../../../../../tools/lib/libstdc++.so.6 "$rocket/usr/pkg/tmp-gcc/usr/lib/libstdc++.so.6" echo "Creating users and groups" echo 'root:x:0:0:root:/root:/bin/sh' > "$rocket/etc/passwd" echo 'root:x:0:' > "$rocket/etc/group"