dot

packages and services management
Log | Files | Refs | README

commit ee926595f17f3c85af6aeac44611680984628332
parent 18dcff5cb5fad88449a13b5ff1819a70940b2b5d
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu, 30 Aug 2018 00:59:17 +0200

pack: simpler and saner pack-chroot script

Diffstat:
Mbin/pack-chroot | 62+++++++++++++++++++++++++++++---------------------------------
1 file changed, 29 insertions(+), 33 deletions(-)

diff --git a/bin/pack-chroot b/bin/pack-chroot @@ -1,43 +1,39 @@ #!/bin/sh -e -# -# New empty directory tree -# -! umount -R /mnt/pack -rm -rf /mnt/pack -mkdir -p /mnt/pack +mkdir -p /mnt/pack/bin +mkdir -p /mnt/pack/dev +mkdir -p /mnt/pack/etc cd /mnt/pack -mkdir -p etc/pack bin dev -# -# Resources used for bootstraping -# pack-add busybox/cur -pack-add dash/cur -cp "$(readlink -f "$(command -v cc)")" bin/cc -cp "$(readlink -f "$(command -v as)")" bin/as -cp "$(readlink -f "$(command -v ld)")" bin/ld -# -# Tools used -# -cp -r /etc/pack/* etc/pack -cp -r /opt/dash/cur/* . -ln -s dash bin/sh -cp /opt/busybox/cur/bin/busybox bin -for cmd in add build cvs del get git tar up -do cp "$(command -v "pack-$cmd")" bin -done +cp -L "$(command -v cc)" bin +cp -L "$(command -v as)" bin +cp -L "$(command -v ld)" bin +cp -L "$(command -v busybox)" bin +cp -L "$(command -v pack-add)" bin +cp -L "$(command -v pack-build)" bin +cp -L "$(command -v pack-cvs)" bin +cp -L "$(command -v pack-del)" bin +cp -L "$(command -v pack-get)" bin +cp -L "$(command -v pack-git)" bin +cp -L "$(command -v pack-tar)" bin +cp -L "$(command -v pack-up)" bin +cp -L "$(command -v pack-chroot)" bin -# -# Minimal config -# echo root:x:0:0:root:/root:/bin/bash >etc/passwd echo nameserver 87.98.175.85 >etc/resolv.conf -# -# Mount, start, stop, unmount -# -mount -t devtmpfs devtmpfs dev -PATH=/bin chroot /mnt/pack /bin/sh -c '/bin/busybox --install -s /bin && exec ash' -umount -R /mnt/pack/dev +cp -r /etc/pack etc + +trap ' + set -e + umount /mnt/pack/dev + rm -rf /mnt/pack/dev /mnt/pack/bin /mnt/pack/ +' EXIT + +PATH=/bin chroot /mnt/pack /bin/busybox sh -c ' + /bin/busybox --install -s /bin + mount -t devtmpfs devtmpfs dev + exec "$0" "$@" +' "$@"