Browse Source

Merge #114: Add support for Debian guests using LXC

ad0a871 make-base-vm: fix init.lxc path (Nicolas Vigier)
e3c2e8d Add support for Debian guests using LXC (Joseph Bisch)
pull/13/merge
Devrandom 4 years ago
parent
commit
99bc6e832e
No account linked to committer's email address
2 changed files with 21 additions and 8 deletions
  1. 18
    6
      bin/make-base-vm
  2. 3
    2
      target-bin/bootstrap-fixup.in

+ 18
- 6
bin/make-base-vm View File

@@ -81,17 +81,14 @@ if [ $# != 0 ] ; then
done
fi

if [ $DISTRO = "debian" -a $LXC = "1" ]; then
echo "There is no support for Debian guests using LXC currently. Please use KVM or another distro for now."
exit 1
fi

if [ $DISTRO = "ubuntu" ]; then
MIRROR=$MIRROR_BASE/archive.ubuntu.com/ubuntu
SECURITY_MIRROR=$MIRROR_BASE/security.ubuntu.com/ubuntu
components=main,universe
elif [ $DISTRO = "debian" ]; then
MIRROR=$MIRROR_BASE/ftp.debian.org/debian
SECURITY_MIRROR=$MIRROR_BASE/security.debian.org/
components=main,contrib
fi

mkdir -p var
@@ -144,6 +141,9 @@ fi

if [ $LXC = "1" ]; then
addpkg=$addpkg,lxc
if [ $DISTRO = "debian" ]; then
addpkg=$addpkg,sudo
fi
else
# Lack of comma after KERNEL_PKG is not a typo
addpkg=$addpkg,${KERNEL_PKG}${GRUB_PKG},openssh-server
@@ -185,7 +185,19 @@ if [ $LXC = "1" ]; then
echo "sudo will preserve (some) env flags"
preserve_env=yes # if you would want to set false then unset this variable
fi
env -i LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 DEBOOTSTRAP_DIR="$DEBOOTSTRAP_DIR" sudo ${preserve_env+--preserve-env} debootstrap --arch=$ARCH --include=$addpkg --exclude=$removepkg --components=main,universe $SUITE $OUT-bootstrap $MIRROR
env -i LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 DEBOOTSTRAP_DIR="$DEBOOTSTRAP_DIR" sudo ${preserve_env+--preserve-env} debootstrap --arch=$ARCH --include=$addpkg --exclude=$removepkg --components=$components $SUITE $OUT-bootstrap $MIRROR
# Fix lxc issue
if [ -f $OUT-bootstrap/usr/lib/lxc/lxc-init ]
then
sudo cp $OUT-bootstrap/usr/lib/lxc/lxc-init $OUT-bootstrap/usr/sbin/init.lxc
else
if [ $ARCH = "amd64" ]
then
sudo cp $OUT-bootstrap/usr/lib/x86_64-linux-gnu/lxc/lxc-init $OUT-bootstrap/usr/sbin/init.lxc
else
sudo cp $OUT-bootstrap/usr/lib/i386-linux-gnu/lxc/lxc-init $OUT-bootstrap/usr/sbin/init.lxc
fi
fi
dd if=/dev/zero of=$OUT-lxc bs=1M count=1 seek=10240
/sbin/mkfs.ext4 -F $OUT-lxc
t=`mktemp -d gitian.XXXXXXXX`

+ 3
- 2
target-bin/bootstrap-fixup.in View File

@@ -16,13 +16,14 @@ elif [ $DISTRIB_NAME = "Debian" ]; then
# grub-legacy conflicts grub-pc dependencies
# No grub-legacy on Ubuntu, just on Debian
# Work around bcron-run conflict due to cron being removed
apt-get purge -y grub-legacy bcron-run &> /dev/null
# Needed for KVM, but apparently errors out for LXC, so the true ignores the error
apt-get purge -y grub-legacy bcron-run &> /dev/null || true
fi
echo '127.0.1.1 gitian' >> /etc/hosts

# If LXC
if grep /lxc/gitian /proc/1/cgroup > /dev/null; then
adduser --disabled-password --gecos ubuntu --quiet ubuntu || true
adduser --disabled-password --gecos ${DISTRIB_NAME,,} --quiet ${DISTRIB_NAME,,} || true
apt-get remove -y rsyslog || true
dpkg-divert --local --rename --add /sbin/initctl
ln -sf /bin/true /sbin/initctl

Loading…
Cancel
Save