diff --git a/bin/make-base-vm b/bin/make-base-vm index ceedc43..c1920f3 100755 --- a/bin/make-base-vm +++ b/bin/make-base-vm @@ -20,10 +20,10 @@ usage() { --vbox use VirtualBox instead of kvm The MIRROR_HOST environment variable can be used to change the - apt-cacher host. It should be something that the target VM can - resolve. It may be set to 127.0.0.1, in which case it will be - changed to 10.0.2.2 on the guest. 10.0.2.2 is the host IP as visible - from the guest under qemu networking. + apt-cacher host. It should be something that both the host and the + target VM can reach. It may be set to 127.0.0.1, in which case it will be + changed to 10.0.2.2 on the guest (or GITIAN_HOST_IP if it is defined) + 10.0.2.2 is the host IP as visible from the guest under qemu networking. EOF } @@ -104,6 +104,7 @@ if [ -e $OUT.qcow2 ]; then exit 1 fi +libexec/config-bootstrap-fixup rm -rf $OUT sudo vmbuilder kvm ubuntu --rootsize 10240 --arch=$ARCH --suite=$SUITE --addpkg=$addpkg --removepkg=$removepkg --ssh-key=var/id_dsa.pub --ssh-user-key=var/id_dsa.pub --mirror=$MIRROR --security-mirror=$SECURITY_MIRROR --dest=$OUT --flavour=$FLAVOUR --firstboot=`pwd`/target-bin/bootstrap-fixup mv $OUT/*.qcow2 $OUT.qcow2 diff --git a/etc/lxc.config.in b/etc/lxc.config.in index b4c02e5..5397170 100644 --- a/etc/lxc.config.in +++ b/etc/lxc.config.in @@ -26,7 +26,9 @@ lxc.mount.entry=sysfs ROOTFS/sys sysfs defaults 0 0 # Container with network virtualized using a pre-configured bridge named br0 and # veth pair virtual network devices # On the host, run: ifconfig br0 up 10.0.2.2 +# Alternatively, you can use another IP range for the bridge interface, in this case set +# the environment variables GITIAN_HOST_IP and LXC_GUEST_IP appropriately. lxc.network.type = veth lxc.network.flags = up lxc.network.link = br0 -lxc.network.ipv4 = 10.0.2.5/24 +lxc.network.ipv4 = GUESTIP/24 diff --git a/libexec/config-bootstrap-fixup b/libexec/config-bootstrap-fixup new file mode 100755 index 0000000..61d69b0 --- /dev/null +++ b/libexec/config-bootstrap-fixup @@ -0,0 +1,15 @@ +#!/bin/bash + +wd=`pwd` + +# Default host IP is 10.0.2.2 +if [ -z "$GITIAN_HOST_IP" ]; then + GITIAN_HOST_IP=10.0.2.2 +fi + +# Default to host IP if the MIRROR_HOST is not set, or set to 127.0.0.1 +if [ -z "$MIRROR_HOST" ] || [ "$MIRROR_HOST" == "127.0.0.1" ]; then + MIRROR_HOST=$GITIAN_HOST_IP +fi + +sed "s;HOSTIP;$MIRROR_HOST;g" < target-bin/bootstrap-fixup.in > target-bin/bootstrap-fixup diff --git a/libexec/config-lxc b/libexec/config-lxc index bc401af..fa6cac0 100755 --- a/libexec/config-lxc +++ b/libexec/config-lxc @@ -1,4 +1,9 @@ #!/bin/bash wd=`pwd` -sed "s;ROOTFS;$wd/target-$LXC_SUITE-$LXC_ARCH;;s;ARCH;$LXC_ARCH;g" < etc/lxc.config.in > var/lxc.config + +if [ -z "$LXC_GUEST_IP" ]; then + LXC_GUEST_IP=10.0.2.5 +fi + +sed "s;ROOTFS;$wd/target-$LXC_SUITE-$LXC_ARCH;;s;ARCH;$LXC_ARCH;g;;s;GUESTIP;$LXC_GUEST_IP;g" < etc/lxc.config.in > var/lxc.config diff --git a/libexec/make-clean-vm b/libexec/make-clean-vm index e6400c1..68b7b8a 100755 --- a/libexec/make-clean-vm +++ b/libexec/make-clean-vm @@ -60,6 +60,7 @@ case $VMSW in ;; LXC) cp -a $BASE $OUT + libexec/config-bootstrap-fixup on-target -u root bash < target-bin/bootstrap-fixup ;; VBOX) diff --git a/target-bin/bootstrap-fixup b/target-bin/bootstrap-fixup deleted file mode 100755 index 6662f31..0000000 --- a/target-bin/bootstrap-fixup +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -set -e - -. /etc/lsb-release - -echo "deb http://10.0.2.2:3142/archive.ubuntu.com/ubuntu $DISTRIB_CODENAME main universe" > $1/etc/apt/sources.list -echo "deb http://10.0.2.2:3142/archive.ubuntu.com/ubuntu $DISTRIB_CODENAME-updates main universe" >> $1/etc/apt/sources.list diff --git a/target-bin/bootstrap-fixup.in b/target-bin/bootstrap-fixup.in new file mode 100755 index 0000000..1908417 --- /dev/null +++ b/target-bin/bootstrap-fixup.in @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +. /etc/lsb-release + +echo "deb http://HOSTIP:3142/archive.ubuntu.com/ubuntu $DISTRIB_CODENAME main universe" > $1/etc/apt/sources.list +echo "deb http://HOSTIP:3142/archive.ubuntu.com/ubuntu $DISTRIB_CODENAME-updates main universe" >> $1/etc/apt/sources.list