Skip to content

Commit

Permalink
Add arch-chroot creation without unshare and with killing child proce…
Browse files Browse the repository at this point in the history
…sses
  • Loading branch information
sgtpep committed Dec 26, 2014
1 parent 65fd2a4 commit b3ea4c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install-packages() {
[curl]=curl
[objdump]=binutils
[haveged]=haveged
[lsof]=lsof
)

if ! which ${!packages[@]} &>/dev/null; then
Expand Down Expand Up @@ -142,8 +143,14 @@ run-actions() {
}

chroot-cmd() {
if [[ ! -x /tmp/arch-drive/bin/arch-chroot ]]; then
mkdir -p /tmp/arch-drive/bin
cp $mnt_dir/bin/arch-chroot /tmp/arch-drive/bin/arch-chroot
sed -i "s/^\(.*\) unshare --fork --pid \(chroot .*\)$/\1 \2\n\npids=\`lsof -t -f -- \"\$chrootdir\"\`\n[[ \! \$pids ]] || kill \$pids/" /tmp/arch-drive/bin/arch-chroot
fi

[[ $arch =~ ^i[0-9]86$ ]] || objdump -f $mnt_dir/bin/chroot | grep -q "\-x86-64" || local linux_cmd=linux32
sudo ${linux_cmd:-} $mnt_dir/bin/arch-chroot $mnt_dir "$@"
sudo ${linux_cmd:-} /tmp/arch-drive/bin/arch-chroot $mnt_dir "$@"
}

chroot-bash() {
Expand Down

0 comments on commit b3ea4c5

Please sign in to comment.