Bug#698347: debootstrap: New variant based on PRoot
Package: debootstrap
Version: 1.0.46
Severity: wishlist
I patched debootstrap in order to add a new variant base on PRoot.
If you don't know PRoot, it's a user space implementation of chroot,
mount --bind and binfmt_misc based on PTrace. It's a really useful
tool for playing with rootfs while staying in user mode (non-root).
For instance we use it to test software in different distributions
environment (debian, ubuntu, fedora, slackware, ...) without the need
to run a full virtual machine.
For this reason, I patched debootstrap so it can create a rootfs using
PRoot. This rootfs is then used for validating software in debian
environment. Be careful that this new rootfs will not have the normal
rights (root:root for /bin for instance) and should only be used for
testing (with chroot or PRoot).
For more information about the usage of PRoot, you can look at two
article that I wrote about it:
* http://ivoire.dinauz.org/blog/post/2012/04/16/PRoot-sorcery
* http://ivoire.dinauz.org/blog/post/2012/05/04/Making-VLC-at-home
This patch only works for sid. I will modify the other target when needed.
Rgds
>From 65a171af12f3f8749a778a6074fa0eb2c44d94b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Duraffort?= <remi.duraffort@st.com>
Date: Thu, 17 Jan 2013 09:58:44 +0100
Subject: [PATCH] Add a new variant based on PRoot
With this new variant, a non-root user can create a debian/ubuntu rootfs.
This is really usefull for testing. For instance, one can now create rootfs for
different versions of debian and ubuntu and run the test suite of a software
inside each rootfs.
More information on PRoot at http://proot.me and the link to documentation and
tutorials.
---
debootstrap | 14 ++++++++++----
functions | 6 ++++++
scripts/sid | 10 +++++++---
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/debootstrap b/debootstrap
index f336164..613b41e 100755
--- a/debootstrap
+++ b/debootstrap
@@ -99,7 +99,7 @@ usage()
archive
--variant=X use variant X of the bootstrap scripts
(currently supported variants: buildd, fakechroot,
- scratchbox, minbase)
+ scratchbox, minbase, proot)
--keyring=K check Release files against keyring K
--no-check-gpg avoid checking Release file signatures
--no-resolve-deps don't try to resolve dependencies automatically
@@ -450,6 +450,8 @@ elif doing_variant scratchbox; then
done
[ "x$SB2_TARGET" != "x" ] || error 1 SBOXTARGETREQ "No scratchbox target configured for $TARGET"
CHROOT_CMD="sb2 -eR -t $SB2_TARGET"
+elif doing_variant proot; then
+ CHROOT_CMD="proot -v -1 -0 -b /dev -b /sys -b /proc -b /tmp $TARGET"
else
CHROOT_CMD="chroot $TARGET"
fi
@@ -466,10 +468,12 @@ export ARCH SUITE TARGET CHROOT_CMD SHA_SIZE DEBOOTSTRAP_CHECKSUM_FIELD
if am_doing_phase first_stage second_stage; then
if in_path id && [ `id -u` -ne 0 ]; then
- error 1 NEEDROOT "debootstrap can only run as root"
+ if ! doing_variant proot; then
+ error 1 NEEDROOT "debootstrap can only run as root"
+ fi
fi
# Ensure that we can create working devices and executables on the target.
- if ! check_sane_mount "$TARGET"; then
+ if ! doing_variant proot && ! check_sane_mount "$TARGET"; then
error 1 NOEXEC "Cannot install into target '$TARGET' mounted with noexec or nodev"
fi
fi
@@ -619,7 +623,9 @@ if am_doing_phase first_stage; then
if ! am_doing_phase second_stage; then
cp "$0" "$TARGET/debootstrap/debootstrap"
cp $DEBOOTSTRAP_DIR/functions "$TARGET/debootstrap/functions"
- cp $DEBOOTSTRAP_DIR/devices.tar.gz "$TARGET/debootstrap/devices.tar.gz"
+ if ! doing_variant proot; then
+ cp $DEBOOTSTRAP_DIR/devices.tar.gz "$TARGET/debootstrap/devices.tar.gz"
+ fi
cp $SCRIPT "$TARGET/debootstrap/suite-script"
echo "$ARCH" >"$TARGET/debootstrap/arch"
echo "$SUITE" >"$TARGET/debootstrap/suite"
diff --git a/functions b/functions
index c1e938e..eba40c1 100644
--- a/functions
+++ b/functions
@@ -1036,6 +1036,12 @@ setup_devices () {
return 0
fi
+ if doing_variant proot; then
+ # No need to do anything fo the /dev directory in the target
+ # filesystem. PRoot will mirror the host /dev to be the target /dev.
+ return 0
+ fi
+
case "$HOST_OS" in
kfreebsd*)
in_target mount -t devfs devfs /dev ;;
diff --git a/scripts/sid b/scripts/sid
index 893d5d5..e34870f 100644
--- a/scripts/sid
+++ b/scripts/sid
@@ -1,7 +1,7 @@
mirror_style release
download_style apt
finddebs_style from-indices
-variants - buildd fakechroot minbase scratchbox
+variants - buildd fakechroot minbase scratchbox proot
keyring /usr/share/keyrings/debian-archive-keyring.gpg
if doing_variant fakechroot; then
@@ -22,7 +22,7 @@ work_out_debs () {
#required="$required $(get_debs Priority: important)"
# ^^ should be getting debconf here somehow maybe
base="$(get_debs Priority: important)"
- elif doing_variant buildd || doing_variant scratchbox; then
+ elif doing_variant buildd || doing_variant scratchbox || doing_variant proot; then
base="apt build-essential"
elif doing_variant minbase; then
base="apt"
@@ -44,7 +44,9 @@ first_stage_install () {
setup_etc
if [ ! -e "$TARGET/etc/fstab" ]; then
echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
- chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
+ if ! doing_variant proot; then
+ chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
+ fi
fi
x_feign_install () {
@@ -81,6 +83,8 @@ second_stage_install () {
setup_proc_fakechroot
elif doing_variant scratchbox; then
true
+ elif doing_variant proot; then
+ true
else
setup_proc
in_target /sbin/ldconfig
--
1.8.0.3
Reply to: