From 9f7f1dd31587e45244c002423d47ca994ce09b8f Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Thu, 25 Apr 2013 17:54:54 +0200 Subject: [PATCH 01/33] Add Debian wheezy/sid base box templates Refactor boxes rake task Create common directory for common installation scripts Move Debian/Ubuntu common installation scripts --- boxes/common/install-babushka | 15 + boxes/{ubuntu => common}/install-chef | 0 boxes/{ubuntu => common}/install-puppet | 0 boxes/debian/download | 157 +++++++++ boxes/debian/lxc-template | 424 ++++++++++++++++++++++++ boxes/debian/metadata.json.template | 9 + tasks/boxes.rake | 92 +++-- 7 files changed, 677 insertions(+), 20 deletions(-) create mode 100755 boxes/common/install-babushka rename boxes/{ubuntu => common}/install-chef (100%) rename boxes/{ubuntu => common}/install-puppet (100%) create mode 100755 boxes/debian/download create mode 100755 boxes/debian/lxc-template create mode 100644 boxes/debian/metadata.json.template diff --git a/boxes/common/install-babushka b/boxes/common/install-babushka new file mode 100755 index 0000000..839631c --- /dev/null +++ b/boxes/common/install-babushka @@ -0,0 +1,15 @@ +#!/bin/bash + +cache=`readlink -f .` +rootfs="${cache}/rootfs" + +echo "installing babushka" +cat > $rootfs/tmp/install-babushka.sh << EOF +#!/bin/sh +curl -L https://babushka.me/up | sudo bash + +EOF +chmod +x $rootfs/tmp/install-babushka.sh +chroot $rootfs /tmp/install-babushka.sh + +rm -rf $rootfs/tmp/* diff --git a/boxes/ubuntu/install-chef b/boxes/common/install-chef similarity index 100% rename from boxes/ubuntu/install-chef rename to boxes/common/install-chef diff --git a/boxes/ubuntu/install-puppet b/boxes/common/install-puppet similarity index 100% rename from boxes/ubuntu/install-puppet rename to boxes/common/install-puppet diff --git a/boxes/debian/download b/boxes/debian/download new file mode 100755 index 0000000..27769aa --- /dev/null +++ b/boxes/debian/download @@ -0,0 +1,157 @@ +#!/bin/bash +# -*- mode:shell-mode;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*- +# vim: ft=shell syn=shell fileencoding=utf-8 sw=2 ts=2 ai eol et si +# +# This is the code extracted from /usr/share/lxc/templates/lxc-debian +# that comes with Ubuntu 12.10 which is responsible for downloading the +# rootfs files / packages + +set -e + +suggest_flush() +{ + echo < ${rootfs}/etc/apt/sources.list +# ${release} +#------------------------------------------------------------------------------ +deb ${MIRROR} ${release} main contrib non-free +EOF + else + cat < ${rootfs}/etc/apt/sources.list +# ${release} +#------------------------------------------------------------------------------ +deb ${MIRROR} ${release} main contrib non-free + +# ${release} security +#------------------------------------------------------------------------------ +deb ${SECURITY_MIRROR} ${release}/updates main contrib non-free + +# ${release} updates +#------------------------------------------------------------------------------ +deb ${MIRROR} ${release}-updates main contrib non-free + +# ${release} proposed updates +#------------------------------------------------------------------------------ +deb ${MIRROR} ${release}-proposed-updates main contrib non-free +EOF + fi +} + +download_debian() +{ + cache=$1 + arch=$2 + release=$3 + + packages=\ +sudo,\ +ifupdown,\ +locales,\ +localepurge,\ +libui-dialog-perl,\ +dialog,\ +isc-dhcp-client,\ +netbase,\ +net-tools,\ +iproute,\ +openssh-server,\ +vim,\ +jed,\ +jed-extra,\ +ssh,\ +curl,\ +wget,\ +bash-completion,\ +manpages,\ +man-db,\ +psmisc,\ +bind9-host,\ +telnet,\ +mtr-tiny + + if [ ! -z "${ADDITIONAL_PACKAGES}" ]; then + packages=${ADDITIONAL_PACKAGES},${packages} + fi + + echo "installing packages: ${packages}" + + trap cleanup EXIT SIGHUP SIGINT SIGTERM + # check the mini debian was not already downloaded + partial=${cache}/partial-${release}-${arch} + mkdir -p ${partial} + if [ $? -ne 0 ]; then + echo "Failed to create '${partial}' directory" + return 1 + fi + + # download a mini debian into a cache + echo "Downloading debian ${release} minimal ..." + debootstrap \ + --variant=minbase \ + --verbose \ + --components=main,contrib,non-free \ + --arch=${arch} \ + --include=${packages} ${release} ${partial} ${MIRROR} + + if [ $? -ne 0 ]; then + echo 'Failed to download the rootfs, aborting.' + return 1 + fi + + echo 'Installing updates' + write_sourceslist ${partial} ${arch} ${release} + + chroot ${partial} apt-get update + if [ $? -ne 0 ]; then + echo 'Failed to update the apt cache' + return 1 + fi + + lxc-unshare -s MOUNT -- chroot ${partial} \ + apt-get dist-upgrade -y || { suggest_flush; false; } + + chroot ${partial} apt-get clean + + mv ${partial} ${cache}/rootfs + trap EXIT + trap SIGINT + trap SIGTERM + trap SIGHUP + echo 'Download complete' + return 0 +} + +declare cache=`readlink -f .` \ + arch=$1 \ + release=$2 + +if [ -d ${cache}/rootfs-${release}-${arch} ]; then + echo < $rootfs/etc/inittab +id:3:initdefault: +si::sysinit:/etc/init.d/rcS +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin +1:2345:respawn:/sbin/getty 38400 console +#c1:12345:respawn:/sbin/getty 38400 tty1 linux +c2:12345:respawn:/sbin/getty 38400 tty2 linux +c3:12345:respawn:/sbin/getty 38400 tty3 linux +c4:12345:respawn:/sbin/getty 38400 tty4 linux +EOF + echo '/etc/inittab created' + + # disable selinux in debian + mkdir -p $rootfs/selinux + echo 0 > $rootfs/selinux/enforce + echo 'selinux disabled' + + # configure the network using the dhcp + cat < $rootfs/etc/network/interfaces +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +# The loopback network interface +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + echo 'network configured (dhcp on eth0)' + + + # set the hostname + cat < $rootfs/etc/hostname +$hostname +EOF + echo "/etc/hostname created (${hostname})" + + # set dhcp hostname + cat <> $rootfs/etc/dhcp/dhclient.conf +send host-name "$hostname"; +EOF + echo 'dhcp hostname set' + + if [ -z "${LANG}" ]; then + # set default locale + cat < $rootfs/etc/locale.gen +${LANG} UTF-8 +EOF + echo "default locale set to ${LANG} UTF-8" + chroot $rootfs locale-gen ${LANG} > /dev/null 2>&1 + chroot $rootfs update-locale LANG=${LANG} + echo 'update-locale done' + fi + + # set proxy if any + if [ ! -z "${HTTP_PROXY}" ]; then + cat < $rootfs/etc/apt/apt.conf.d/10proxy +Acquire::http::Proxy "${HTTP_PROXY}"; +Acquire::ftp::Proxy "${HTTP_PROXY}"; +Acquire::ftp::Timeout "15"; +Acquire::ftp::Passive "true"; +Acquire::ftp::Proxy::Passive "true"; +EOF + echo "Apt default proxy set to ${HTTP_PROXY}" + cat <> $rootfs/etc/environment +HTTP_PROXY=${HTTP_PROXY} +HTTPS_PROXY=${HTTP_PROXY} +FTP_PROXY=${HTTP_PROXY} +EOF + echo "proxy ${HTTP_PROXY} added to /etc/environment" + fi + + # recommends are as of now still abused in many packages + cat < $rootfs/etc/apt/apt.conf.d/90recommends +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; +EOF + echo '/etc/apt/apt.conf.d/90recommends created' + + # set default release + cat < $rootfs/etc/apt/apt.conf.d/30release +DPkg::Default-Release "${release}"; +APT::Default-Release "${release}"; +EOF + echo '/etc/apt/apt.conf.d/30release created' + + + # set minimal hosts + cat < $rootfs/etc/hosts +127.0.0.1 localhost +127.0.1.1 $hostname.vagrantup.com $hostname + +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +EOF + + # remove pointless services in a container + for service in checkroot \ + umountfs \ + hwclock.sh \ + hwclockfirst.sh \ + mountall.sh ; do + chroot $rootfs /usr/sbin/update-rc.d -f $service remove > /dev/null 2>&1 + echo "service ${service} removed from init" + done + + # suppress log level output for udev + #sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf + + echo "root:vagrant" | chroot $rootfs chpasswd + + if ! (grep -q vagrant $rootfs/etc/passwd); then + chroot $rootfs useradd --create-home -s /bin/bash vagrant + echo "vagrant:vagrant" | chroot $rootfs chpasswd + chroot $rootfs adduser vagrant sudo >/dev/null 2>&1 || true + chroot $rootfs cp /etc/sudoers /etc/sudoers.orig >/dev/null 2>&1 || true + chroot $rootfs sed -i -e \ + 's/%sudo\s\+ALL=(ALL:ALL)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' \ + /etc/sudoers >/dev/null 2>&1 || true + fi + + return 0 +} + +cleanup() +{ + rm -rf ${cache}/partial-${SUITE}-${arch} + rm -rf ${cache}/rootfs-${SUITE}-${arch} +} + +extract_rootfs() +{ + tarball=$1 + arch=$2 + rootfs=$3 + + echo "Extracting $tarball ..." + mkdir -p $(dirname $rootfs) + # Make sure the rootfs does not exist before extracting + rm -rf $rootfs + (cd `dirname $rootfs` && tar xfz $tarball) + return 0 +} + +install_debian() +{ + rootfs=$1 + release=$2 + tarball=$3 + mkdir -p /var/lock/subsys/ + + ( + flock -x 200 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi + + extract_rootfs $tarball $arch $rootfs + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi + + return 0 + + ) 200>/var/lock/subsys/lxc + + return $? +} + +copy_configuration() +{ + path=$1 + rootfs=$2 + name=$3 + arch=$4 + release=$5 + + cat <> $path/fstab +none $rootfs/dev/pts devpts defaults 0 0 +none $rootfs/proc proc defaults 0 0 +none $rootfs/sys sysfs defaults 0 0 +none $rootfs/dev/shm tmpfs defaults 0 0 +EOF + + cat <> $path/config +lxc.tty = 4 +lxc.pts = 1024 +lxc.rootfs = ${rootfs} +lxc.cgroup.devices.deny = a +# /dev/null and zero +lxc.cgroup.devices.allow = c 1:3 rwm +lxc.cgroup.devices.allow = c 1:5 rwm +# consoles +lxc.cgroup.devices.allow = c 5:1 rwm +lxc.cgroup.devices.allow = c 5:0 rwm +lxc.cgroup.devices.allow = c 4:0 rwm +lxc.cgroup.devices.allow = c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow = c 1:9 rwm +lxc.cgroup.devices.allow = c 1:8 rwm +lxc.cgroup.devices.allow = c 136:* rwm +lxc.cgroup.devices.allow = c 5:2 rwm +# rtc +lxc.cgroup.devices.allow = c 254:0 rwm + +# mounts point +#lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +#lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 +#lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 +lxc.mount = ${path}/fstab + +lxc.utsname = ${name} + +# networking + +lxc.network.type = veth +lxc.network.flags = up +# Bridged network +#lxc.network.link = br42 +lxc.network.name = eth0 +lxc.network.veth.pair = veth${name##vagrant-} +# It is fine to be commented out +#lxc.network.ipv4 = 10.1.1.1/24 +#lxc.network.hwaddr = 00:12:34:56:78:9A +lxc.network.hwaddr = \ +00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//') + +# Limits + +# Set max memory +lxc.cgroup.memory.limit_in_bytes = 1024M + +# Scheduler, works like this: You assign to vm0 the value of 10 and to vm1 +# the value of 20. This means: in each CPU Second vm1 will get the double +# amount of CPU cycles as vm0. Per default all values are set to 1024. +#lxc.cgroup.cpu.shares = 512 + +# CPUs +# assign first CPU to this container: +#lxc.cgroup.cpuset.cpus = 0 +# assign the first, the second and the last CPU +#lxc.cgroup.cpuset.cpus = 0-1,3 +# assign the first and the last CPU +#lxc.cgroup.cpuset.cpus = 0,3 + +EOF + + if [ $? -ne 0 ]; then + echo 'failed to add configuration' + return 1 + fi + +} + + +add_ssh_key() +{ + user=$1 + + if [ -n "$auth_key" -a -f "$auth_key" ]; then + u_path="/home/${user}/.ssh" + root_u_path="$rootfs/$u_path" + + mkdir -p $root_u_path + cp $auth_key "$root_u_path/authorized_keys" + chroot $rootfs chown -R ${user}: "$u_path" + + echo "Inserted SSH public key from $auth_key into /home/${user}/.ssh/authorized_keys" + fi +} + +usage() +{ + cat <] [ -S | --auth-key ] +release: the debian release (e.g. wheezy): defaults to host release on debian, otherwise uses latest stable +arch: the container architecture (e.g. amd64): defaults to host arch +auth-key: SSH Public key file to inject into container +EOF + return 0 +} + +options=$(getopt -o a:b:hp:r:xn:Fd:C -l arch:,help,path:,release:,name:,flush-cache,auth-key:,debug:,tarball: -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +release=wheezy # Default to the last Debian stable release + +arch=$(uname -m) + +# Code taken from debootstrap +if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then + arch=`/usr/bin/dpkg --print-architecture` +elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then + arch=`/usr/bin/udpkg --print-architecture` +else + arch=$(uname -m) + if [ "$arch" = "i686" ]; then + arch="i386" + elif [ "$arch" = "x86_64" ]; then + arch="amd64" + elif [ "$arch" = "armv7l" ]; then + arch="armel" + fi +fi + +debug=0 +hostarch=$arch +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -T|--tarball) tarball=$2; shift 2;; + -r|--release) release=$2; shift 2;; + -S|--auth-key) auth_key=$2; shift 2;; + -a|--arch) arch=$2; shift 2;; + -d|--debug) debug=1; shift 1;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ $debug -eq 1 ]; then + set -x +fi + + +if [ "$arch" == "i686" ]; then + arch=i386 +fi + +if [ $hostarch = "i386" -a $arch = "amd64" ]; then + echo "can't create amd64 container on i386" + exit 1 +fi + +if [ -z "$path" ]; then + echo "'path' parameter is required" + exit 1 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This script should be run as 'root'" + exit 1 +fi + +# detect rootfs +config="$path/config" +if grep -q '^lxc.rootfs' $config 2>/dev/null ; then + rootfs=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'` +else + rootfs=$path/rootfs +fi + +install_debian $rootfs $release $tarball +if [ $? -ne 0 ]; then + echo "failed to install debian $release" + exit 1 +fi + +configure_debian $rootfs "vagrant-debian-${release}" $release +if [ $? -ne 0 ]; then + echo "failed to configure debian $release for a container" + exit 1 +fi + +copy_configuration $path $rootfs $name $arch $release +if [ $? -ne 0 ]; then + echo "failed write configuration file" + exit 1 +fi + +add_ssh_key vagrant + +echo "" +echo "##" +echo "# The default user is 'vagrant' with password 'vagrant'!" +echo "# Use the 'sudo' command to run tasks as root in the container." +echo "##" +echo "" diff --git a/boxes/debian/metadata.json.template b/boxes/debian/metadata.json.template new file mode 100644 index 0000000..70f414b --- /dev/null +++ b/boxes/debian/metadata.json.template @@ -0,0 +1,9 @@ +{ + "provider": "lxc", + "version": "2", + + "template-opts": { + "--arch": "ARCH", + "--release": "RELEASE" + } +} diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 4753b7e..2521536 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -1,19 +1,22 @@ require 'rake/tasklib' -class BuildUbuntuBoxTask < ::Rake::TaskLib +class BuildGenericBoxTask < ::Rake::TaskLib include ::Rake::DSL attr_reader :name - def initialize(name, release, arch, opts = {}) - @name = name - @release = release.to_s - @arch = arch.to_s - @install_chef = opts.fetch(:chef, true) - @install_puppet = opts.fetch(:puppet, true) - @file = opts[:file] || default_box_file + def initialize(name, distrib, release, arch, opts = {}) + @name = name + @distrib = distrib + @release = release.to_s + @arch = arch.to_s + @install_chef = opts.fetch(:chef, true) + @install_puppet = opts.fetch(:puppet, true) + @install_babushka = opts.fetch(:babushka, true) + @file = opts[:file] || default_box_file - desc "Build an Ubuntu #{release} #{arch} box" unless ::Rake.application.last_comment + desc "Build an #{distrib.upcase} #{release} #{arch} box" unless + ::Rake.application.last_comment task name do RakeFileUtils.send(:verbose, true) do run_task @@ -28,27 +31,41 @@ class BuildUbuntuBoxTask < ::Rake::TaskLib end if Dir.exists?('boxes/temp') - puts "There is a partially built box under #{File.expand_path('./boxes/temp')}, please remove it before building a new box" + puts 'There is a partially built box under ' + + File.expand_path('./boxes/temp') + + ', please remove it before building a new box' exit 1 end sh 'mkdir -p boxes/temp/' Dir.chdir 'boxes/temp' do - sh "sudo ../ubuntu/download #{@arch} #{@release}" - sh "sudo ../ubuntu/install-puppet" if @install_puppet - sh "sudo ../ubuntu/install-chef" if @install_chef + sh "sudo ../#{@distrib}/download #{@arch} #{@release}" + [ :puppet, :chef, :babushka ].each do |cfg_engine| + break unless instance_variable_get :"@install_#{cfg_engine}" + script_name = "install-#{cfg_engine}" + install_path = File.join '..', @distrib, script_name + unless File.readable? install_path + install_path = File.join '..', 'common', script_name + end + if File.readable? install_path + sh "sudo #{install_path}" + else + STDERR.puts "cannot execute #{install_path} (not found?)" + end + end sh 'sudo rm -f rootfs.tar.gz' sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*' sh 'sudo rm -rf rootfs' sh "sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz" - sh "cp ../ubuntu/lxc-template ." - metadata = File.read('../ubuntu/metadata.json.template') + sh "cp ../#{@distrib}/lxc-template ." + metadata = File.read("../#{@distrib}/metadata.json.template") metadata.gsub!('ARCH', @arch) metadata.gsub!('RELEASE', @release) File.open('metadata.json', 'w') { |f| f.print metadata } sh "tar -czf tmp-package.box ./*" end + sh 'mkdir -p boxes/output' sh "cp boxes/temp/tmp-package.box boxes/output/#{@file}" sh "rm -rf boxes/temp" end @@ -59,21 +76,56 @@ class BuildUbuntuBoxTask < ::Rake::TaskLib end end +class BuildDebianBoxTask < BuildGenericBoxTask + def initialize(name, release, arch, opts = {}) + super(name, 'debian', release, arch, opts) + end +end + +class BuildUbuntuBoxTask < BuildGenericBoxTask + def initialize(name, release, arch, opts = {}) + super(name, 'ubuntu', release, arch, opts) + end +end + +chef = ENV['CHEF'] != '0' +puppet = ENV['PUPPET'] != '0' +babushka = ENV['BABUSKA'] != '0' + namespace :boxes do namespace :ubuntu do namespace :build do - chef = ENV['CHEF'] != '0' - puppet = ENV['PUPPET'] != '0' desc 'Build an Ubuntu Precise 64 bits box' - BuildUbuntuBoxTask.new(:precise64, :precise, 'amd64', chef: chef, puppet: puppet) + BuildUbuntuBoxTask. + new(:precise64, + :precise, 'amd64', chef: chef, puppet: puppet, babushka: babushka) desc 'Build an Ubuntu Quantal 64 bits box' - BuildUbuntuBoxTask.new(:quantal64, :quantal, 'amd64', chef: chef, puppet: puppet) + BuildUbuntuBoxTask. + new(:quantal64, + :quantal, 'amd64', chef: chef, puppet: puppet, babushka: babushka) # FIXME: Find out how to install chef on raring desc 'Build an Ubuntu Raring 64 bits box' - BuildUbuntuBoxTask.new(:raring64, :raring, 'amd64', chef: false, puppet: puppet) + BuildUbuntuBoxTask. + new(:raring64, + :raring, 'amd64', chef: false, puppet: puppet, babushka: babushka) + end + end + + namespace :debian do + namespace :build do + + desc 'Build an Debian Wheezy 64 bits box' + BuildDebianBoxTask. + new(:wheezy64, + :wheezy, 'amd64', chef: chef, puppet: puppet, babushka: babushka) + + desc 'Build an Debian Sid/unstable 64 bits box' + BuildDebianBoxTask. + new(:sid64, + :sid, 'amd64', chef: chef, puppet: puppet, babushka: babushka) end end end From 7f338da734cd8e964a21d0f54fceaf086b57ceaa Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Mon, 29 Apr 2013 11:12:42 +0200 Subject: [PATCH 02/33] Add ping package to test networking after build --- boxes/debian/download | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boxes/debian/download b/boxes/debian/download index 27769aa..a3dc66c 100755 --- a/boxes/debian/download +++ b/boxes/debian/download @@ -89,7 +89,8 @@ man-db,\ psmisc,\ bind9-host,\ telnet,\ -mtr-tiny +mtr-tiny,\ +ping if [ ! -z "${ADDITIONAL_PACKAGES}" ]; then packages=${ADDITIONAL_PACKAGES},${packages} From 14afc0b8141598d04553d72b44949cd62947a33a Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Mon, 29 Apr 2013 11:12:55 +0200 Subject: [PATCH 03/33] Fix $LANG support --- boxes/debian/lxc-template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index b5fbbe0..823f7e2 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -73,7 +73,7 @@ send host-name "$hostname"; EOF echo 'dhcp hostname set' - if [ -z "${LANG}" ]; then + if [ ! -z "${LANG}" ]; then # set default locale cat < $rootfs/etc/locale.gen ${LANG} UTF-8 From a5fd5478596464f49c0a224283abf8a872a7de5f Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Mon, 29 Apr 2013 15:25:48 +0200 Subject: [PATCH 04/33] Non interactive babushka install --- boxes/common/install-babushka | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxes/common/install-babushka b/boxes/common/install-babushka index 839631c..112ff1c 100755 --- a/boxes/common/install-babushka +++ b/boxes/common/install-babushka @@ -6,7 +6,7 @@ rootfs="${cache}/rootfs" echo "installing babushka" cat > $rootfs/tmp/install-babushka.sh << EOF #!/bin/sh -curl -L https://babushka.me/up | sudo bash +curl -L https://babushka.me/up/hard | sudo bash EOF chmod +x $rootfs/tmp/install-babushka.sh From 14bd12e4cebfb16459bb68eb8cbf175e495eac40 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Mon, 29 Apr 2013 15:26:06 +0200 Subject: [PATCH 05/33] Wrong package name for ping tool --- boxes/debian/download | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxes/debian/download b/boxes/debian/download index a3dc66c..95be6d4 100755 --- a/boxes/debian/download +++ b/boxes/debian/download @@ -90,7 +90,7 @@ psmisc,\ bind9-host,\ telnet,\ mtr-tiny,\ -ping +iputils-ping if [ ! -z "${ADDITIONAL_PACKAGES}" ]; then packages=${ADDITIONAL_PACKAGES},${packages} From 624eb05afe2c36f59e731855139f1e5a0d312f5b Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Mon, 29 Apr 2013 16:16:39 +0200 Subject: [PATCH 06/33] Fix bug bypassing following configuration engine --- tasks/boxes.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 2521536..775265c 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -41,7 +41,7 @@ class BuildGenericBoxTask < ::Rake::TaskLib Dir.chdir 'boxes/temp' do sh "sudo ../#{@distrib}/download #{@arch} #{@release}" [ :puppet, :chef, :babushka ].each do |cfg_engine| - break unless instance_variable_get :"@install_#{cfg_engine}" + next unless instance_variable_get :"@install_#{cfg_engine}" script_name = "install-#{cfg_engine}" install_path = File.join '..', @distrib, script_name unless File.readable? install_path From 4487ac57516a5dfbf05ce84afa35ec6bfea9df71 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Mon, 29 Apr 2013 16:17:46 +0200 Subject: [PATCH 07/33] Add CA certificates (needed for curl/wget configuration engine download after downloading) --- boxes/debian/download | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boxes/debian/download b/boxes/debian/download index 95be6d4..ba9cce6 100755 --- a/boxes/debian/download +++ b/boxes/debian/download @@ -90,8 +90,9 @@ psmisc,\ bind9-host,\ telnet,\ mtr-tiny,\ -iputils-ping - +iputils-ping,\ +ca-certificates + if [ ! -z "${ADDITIONAL_PACKAGES}" ]; then packages=${ADDITIONAL_PACKAGES},${packages} fi From f27bbbb5992dcb76316dd5de68154759e0c0eefd Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 15:44:42 +0200 Subject: [PATCH 08/33] Fix silent install of Babushka --- boxes/common/install-babushka | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxes/common/install-babushka b/boxes/common/install-babushka index 112ff1c..23a7455 100755 --- a/boxes/common/install-babushka +++ b/boxes/common/install-babushka @@ -6,7 +6,7 @@ rootfs="${cache}/rootfs" echo "installing babushka" cat > $rootfs/tmp/install-babushka.sh << EOF #!/bin/sh -curl -L https://babushka.me/up/hard | sudo bash +curl -L https://babushka.me/up | sudo bash < /dev/null EOF chmod +x $rootfs/tmp/install-babushka.sh From c5a316f1ae8e8529294e48dd435b9d0bf775b12e Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 15:45:27 +0200 Subject: [PATCH 09/33] Make possible to symlink boxes/temp --- tasks/boxes.rake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 775265c..c9fc162 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -30,22 +30,23 @@ class BuildGenericBoxTask < ::Rake::TaskLib exit 1 end - if Dir.exists?('boxes/temp') + if Dir.entries('boxes/temp').size > 2 puts 'There is a partially built box under ' + File.expand_path('./boxes/temp') + ', please remove it before building a new box' exit 1 end + pwd = Dir.pwd sh 'mkdir -p boxes/temp/' Dir.chdir 'boxes/temp' do - sh "sudo ../#{@distrib}/download #{@arch} #{@release}" + sh "sudo #{pwd}/boxes/#{@distrib}/download #{@arch} #{@release}" [ :puppet, :chef, :babushka ].each do |cfg_engine| next unless instance_variable_get :"@install_#{cfg_engine}" script_name = "install-#{cfg_engine}" - install_path = File.join '..', @distrib, script_name + install_path = File.join pwd, 'boxes', @distrib, script_name unless File.readable? install_path - install_path = File.join '..', 'common', script_name + install_path = File.join pwd, 'boxes', 'common', script_name end if File.readable? install_path sh "sudo #{install_path}" @@ -57,8 +58,8 @@ class BuildGenericBoxTask < ::Rake::TaskLib sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*' sh 'sudo rm -rf rootfs' sh "sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz" - sh "cp ../#{@distrib}/lxc-template ." - metadata = File.read("../#{@distrib}/metadata.json.template") + sh "cp #{pwd}/boxes/#{@distrib}/lxc-template ." + metadata = File.read("#{pwd}/boxes/#{@distrib}/metadata.json.template") metadata.gsub!('ARCH', @arch) metadata.gsub!('RELEASE', @release) File.open('metadata.json', 'w') { |f| f.print metadata } From 224f73e0ff3bb9d75f6323fd237324f12d9734f8 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 16:35:23 +0200 Subject: [PATCH 10/33] Support unstable release name for sid --- boxes/debian/download | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxes/debian/download b/boxes/debian/download index ba9cce6..0703394 100755 --- a/boxes/debian/download +++ b/boxes/debian/download @@ -32,7 +32,7 @@ write_sourceslist() SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/debian-security} - if [ 'sid' == "${release}" ]; then + if [ 'sid' == "${release}" -o 'unstable' == "${release}" ]; then cat < ${rootfs}/etc/apt/sources.list # ${release} #------------------------------------------------------------------------------ From 199012e0451f6d2d1d9c0f881b3f11f030e59989 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 16:36:09 +0200 Subject: [PATCH 11/33] Fix interface name 'vethXXXX' too long (>15) --- boxes/debian/lxc-template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index 823f7e2..e593add 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -256,7 +256,8 @@ lxc.network.flags = up # Bridged network #lxc.network.link = br42 lxc.network.name = eth0 -lxc.network.veth.pair = veth${name##vagrant-} +# Fix interface name 'vethXXXX' too long (>15) +lxc.network.veth.pair = veth${name#*-} # It is fine to be commented out #lxc.network.ipv4 = 10.1.1.1/24 #lxc.network.hwaddr = 00:12:34:56:78:9A From 6736d34a9937a323e899e05e7173c556a4e3d865 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 17:14:30 +0200 Subject: [PATCH 12/33] Remove veth name definition --- boxes/debian/lxc-template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index e593add..e46788d 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -256,9 +256,9 @@ lxc.network.flags = up # Bridged network #lxc.network.link = br42 lxc.network.name = eth0 -# Fix interface name 'vethXXXX' too long (>15) -lxc.network.veth.pair = veth${name#*-} # It is fine to be commented out +# Warn: interface name 'vethXXXX' too long (>15) +#lxc.network.veth.pair = veth${name#*-} #lxc.network.ipv4 = 10.1.1.1/24 #lxc.network.hwaddr = 00:12:34:56:78:9A lxc.network.hwaddr = \ From 4707068d25256515f46d778adb994ccbd44d7b29 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 17:35:21 +0200 Subject: [PATCH 13/33] commenting LXC networking options (configured by vagrant) --- boxes/debian/lxc-template | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index e46788d..ab5cab3 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -251,17 +251,17 @@ lxc.utsname = ${name} # networking -lxc.network.type = veth -lxc.network.flags = up +#lxc.network.type = veth +#lxc.network.flags = up # Bridged network #lxc.network.link = br42 -lxc.network.name = eth0 +#lxc.network.name = eth0 # It is fine to be commented out # Warn: interface name 'vethXXXX' too long (>15) #lxc.network.veth.pair = veth${name#*-} #lxc.network.ipv4 = 10.1.1.1/24 #lxc.network.hwaddr = 00:12:34:56:78:9A -lxc.network.hwaddr = \ +#lxc.network.hwaddr = \ 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//') # Limits From d0fb7ef750db691604722663db8346fc850e3ff7 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Tue, 30 Apr 2013 18:17:09 +0200 Subject: [PATCH 14/33] remove localepurge --- boxes/debian/download | 1 - 1 file changed, 1 deletion(-) diff --git a/boxes/debian/download b/boxes/debian/download index 0703394..43e5b94 100755 --- a/boxes/debian/download +++ b/boxes/debian/download @@ -69,7 +69,6 @@ download_debian() sudo,\ ifupdown,\ locales,\ -localepurge,\ libui-dialog-perl,\ dialog,\ isc-dhcp-client,\ From 4759adf143b31487211db4e44a0022e370eaecd3 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 1 May 2013 18:30:16 -0300 Subject: [PATCH 15/33] Minor clean up for debian base boxes scripts --- boxes/debian/download | 14 ++++++-------- boxes/debian/lxc-template | 6 ++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/boxes/debian/download b/boxes/debian/download index 43e5b94..fd6f95a 100755 --- a/boxes/debian/download +++ b/boxes/debian/download @@ -1,7 +1,5 @@ #!/bin/bash -# -*- mode:shell-mode;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*- -# vim: ft=shell syn=shell fileencoding=utf-8 sw=2 ts=2 ai eol et si -# + # This is the code extracted from /usr/share/lxc/templates/lxc-debian # that comes with Ubuntu 12.10 which is responsible for downloading the # rootfs files / packages @@ -27,7 +25,7 @@ write_sourceslist() rootfs=$1 arch=$2 release=$3 - + MIRROR=${MIRROR:-http://ftp.debian.org/debian} SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/debian-security} @@ -64,7 +62,7 @@ download_debian() cache=$1 arch=$2 release=$3 - + packages=\ sudo,\ ifupdown,\ @@ -97,7 +95,7 @@ ca-certificates fi echo "installing packages: ${packages}" - + trap cleanup EXIT SIGHUP SIGINT SIGTERM # check the mini debian was not already downloaded partial=${cache}/partial-${release}-${arch} @@ -106,7 +104,7 @@ ca-certificates echo "Failed to create '${partial}' directory" return 1 fi - + # download a mini debian into a cache echo "Downloading debian ${release} minimal ..." debootstrap \ @@ -115,7 +113,7 @@ ca-certificates --components=main,contrib,non-free \ --arch=${arch} \ --include=${packages} ${release} ${partial} ${MIRROR} - + if [ $? -ne 0 ]; then echo 'Failed to download the rootfs, aborting.' return 1 diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index ab5cab3..2168760 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode:shell-mode;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*- -# vim: ft=shell syn=shell fileencoding=utf-8 sw=2 ts=2 ai eol et si # This is a modified version of /usr/share/lxc/templates/lxc-debian # that comes with Ubuntu 12.10 changed to suit vagrant-lxc needs @@ -139,7 +137,7 @@ EOF chroot $rootfs /usr/sbin/update-rc.d -f $service remove > /dev/null 2>&1 echo "service ${service} removed from init" done - + # suppress log level output for udev #sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf @@ -276,7 +274,7 @@ lxc.cgroup.memory.limit_in_bytes = 1024M # CPUs # assign first CPU to this container: -#lxc.cgroup.cpuset.cpus = 0 +#lxc.cgroup.cpuset.cpus = 0 # assign the first, the second and the last CPU #lxc.cgroup.cpuset.cpus = 0-1,3 # assign the first and the last CPU From 06a0d66616bc755b25848d0ade3274a58289decb Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 1 May 2013 22:01:59 -0300 Subject: [PATCH 16/33] "Merge" in code from debian lxc template that comes with Ubuntu 13.04 --- boxes/debian/lxc-template | 150 +++++++------------------------------- 1 file changed, 26 insertions(+), 124 deletions(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index 2168760..0e7cc28 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -1,7 +1,7 @@ #!/bin/bash # This is a modified version of /usr/share/lxc/templates/lxc-debian -# that comes with Ubuntu 12.10 changed to suit vagrant-lxc needs +# that comes with Ubuntu 13.04 changed to suit vagrant-lxc needs set -e @@ -18,6 +18,14 @@ configure_debian() hostname=$2 release=$3 + # squeeze only has /dev/tty and /dev/tty0 by default, + # therefore creating missing device nodes for tty1-4. + for tty in $(seq 1 4); do + if [ ! -e $rootfs/dev/tty$tty ]; then + mknod $rootfs/dev/tty$tty c 4 $tty + fi + done + # configure the inittab cat < $rootfs/etc/inittab id:3:initdefault: @@ -32,45 +40,33 @@ l6:6:wait:/etc/init.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin 1:2345:respawn:/sbin/getty 38400 console -#c1:12345:respawn:/sbin/getty 38400 tty1 linux +c1:12345:respawn:/sbin/getty 38400 tty1 linux c2:12345:respawn:/sbin/getty 38400 tty2 linux c3:12345:respawn:/sbin/getty 38400 tty3 linux c4:12345:respawn:/sbin/getty 38400 tty4 linux +p6::ctrlaltdel:/sbin/init 6 +p0::powerfail:/sbin/init 0 EOF - echo '/etc/inittab created' # disable selinux in debian mkdir -p $rootfs/selinux echo 0 > $rootfs/selinux/enforce - echo 'selinux disabled' # configure the network using the dhcp cat < $rootfs/etc/network/interfaces -# This file describes the network interfaces available on your system -# and how to activate them. For more information, see interfaces(5). - -# The loopback network interface auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp EOF - echo 'network configured (dhcp on eth0)' - # set the hostname cat < $rootfs/etc/hostname $hostname EOF - echo "/etc/hostname created (${hostname})" - - # set dhcp hostname - cat <> $rootfs/etc/dhcp/dhclient.conf -send host-name "$hostname"; -EOF - echo 'dhcp hostname set' + # reconfigure some services if [ ! -z "${LANG}" ]; then # set default locale cat < $rootfs/etc/locale.gen @@ -82,64 +78,11 @@ EOF echo 'update-locale done' fi - # set proxy if any - if [ ! -z "${HTTP_PROXY}" ]; then - cat < $rootfs/etc/apt/apt.conf.d/10proxy -Acquire::http::Proxy "${HTTP_PROXY}"; -Acquire::ftp::Proxy "${HTTP_PROXY}"; -Acquire::ftp::Timeout "15"; -Acquire::ftp::Passive "true"; -Acquire::ftp::Proxy::Passive "true"; -EOF - echo "Apt default proxy set to ${HTTP_PROXY}" - cat <> $rootfs/etc/environment -HTTP_PROXY=${HTTP_PROXY} -HTTPS_PROXY=${HTTP_PROXY} -FTP_PROXY=${HTTP_PROXY} -EOF - echo "proxy ${HTTP_PROXY} added to /etc/environment" - fi - - # recommends are as of now still abused in many packages - cat < $rootfs/etc/apt/apt.conf.d/90recommends -APT::Install-Recommends "0"; -APT::Install-Suggests "0"; -EOF - echo '/etc/apt/apt.conf.d/90recommends created' - - # set default release - cat < $rootfs/etc/apt/apt.conf.d/30release -DPkg::Default-Release "${release}"; -APT::Default-Release "${release}"; -EOF - echo '/etc/apt/apt.conf.d/30release created' - - - # set minimal hosts - cat < $rootfs/etc/hosts -127.0.0.1 localhost -127.0.1.1 $hostname.vagrantup.com $hostname - -# The following lines are desirable for IPv6 capable hosts -::1 ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters -EOF - # remove pointless services in a container - for service in checkroot \ - umountfs \ - hwclock.sh \ - hwclockfirst.sh \ - mountall.sh ; do - chroot $rootfs /usr/sbin/update-rc.d -f $service remove > /dev/null 2>&1 - echo "service ${service} removed from init" - done - - # suppress log level output for udev - #sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf + chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove echo "root:vagrant" | chroot $rootfs chpasswd @@ -209,19 +152,16 @@ copy_configuration() rootfs=$2 name=$3 arch=$4 - release=$5 - - cat <> $path/fstab -none $rootfs/dev/pts devpts defaults 0 0 -none $rootfs/proc proc defaults 0 0 -none $rootfs/sys sysfs defaults 0 0 -none $rootfs/dev/shm tmpfs defaults 0 0 -EOF + grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config cat <> $path/config lxc.tty = 4 lxc.pts = 1024 -lxc.rootfs = ${rootfs} +lxc.utsname = ${name} + +# When using LXC with apparmor, uncomment the next line to run unconfined: +#lxc.aa_profile = unconfined + lxc.cgroup.devices.deny = a # /dev/null and zero lxc.cgroup.devices.allow = c 1:3 rwm @@ -240,46 +180,8 @@ lxc.cgroup.devices.allow = c 5:2 rwm lxc.cgroup.devices.allow = c 254:0 rwm # mounts point -#lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 -#lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 -#lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 -lxc.mount = ${path}/fstab - -lxc.utsname = ${name} - -# networking - -#lxc.network.type = veth -#lxc.network.flags = up -# Bridged network -#lxc.network.link = br42 -#lxc.network.name = eth0 -# It is fine to be commented out -# Warn: interface name 'vethXXXX' too long (>15) -#lxc.network.veth.pair = veth${name#*-} -#lxc.network.ipv4 = 10.1.1.1/24 -#lxc.network.hwaddr = 00:12:34:56:78:9A -#lxc.network.hwaddr = \ -00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//') - -# Limits - -# Set max memory -lxc.cgroup.memory.limit_in_bytes = 1024M - -# Scheduler, works like this: You assign to vm0 the value of 10 and to vm1 -# the value of 20. This means: in each CPU Second vm1 will get the double -# amount of CPU cycles as vm0. Per default all values are set to 1024. -#lxc.cgroup.cpu.shares = 512 - -# CPUs -# assign first CPU to this container: -#lxc.cgroup.cpuset.cpus = 0 -# assign the first, the second and the last CPU -#lxc.cgroup.cpuset.cpus = 0-1,3 -# assign the first and the last CPU -#lxc.cgroup.cpuset.cpus = 0,3 - +lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0 +lxc.mount.entry = sysfs sys sysfs defaults 0 0 EOF if [ $? -ne 0 ]; then @@ -407,7 +309,7 @@ if [ $? -ne 0 ]; then exit 1 fi -copy_configuration $path $rootfs $name $arch $release +copy_configuration $path $rootfs $name if [ $? -ne 0 ]; then echo "failed write configuration file" exit 1 From 37cf1e4e315e15f74a8a5ab6cc5aa6ddc5330dc6 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 1 May 2013 22:22:58 -0300 Subject: [PATCH 17/33] Disable `/tmp` cleanup on start for base debian boxes References #68 --- boxes/debian/lxc-template | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index 0e7cc28..1d7b6c2 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -208,6 +208,13 @@ add_ssh_key() fi } +disable_tmp_cleanup() { + rootfs=$1 + chroot $rootfs /usr/sbin/update-rc.d -f checkroot-bootclean.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f mountall-bootclean.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f mountnfs-bootclean.sh remove +} + usage() { cat < Date: Thu, 2 May 2013 00:41:13 -0300 Subject: [PATCH 18/33] Disable cfg engines by default when building base boxes --- README.md | 11 ++++++++--- tasks/boxes.rake | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 593379c..2c5ca82 100644 --- a/README.md +++ b/README.md @@ -72,13 +72,18 @@ can use the [same Vagrant VirtualBox machine I use for development](#using-virtu *Please note that I'm currently using only the quantal x86_64 on a daily basis, and I've only done some basic testing with the others* -You can also build a clean box by providing `CHEF=0` and `PUPPET=0` to the available -[rake tasks](tasks/boxes.rake). For example: +There is a set of [rake tasks](tasks/boxes.rake) that you can use to build base +boxes as needed. By default it won't include any provisioning tool and you can +pick the one you want by providing some environment variables. + +For example: ``` -CHEF=0 PUPPET=0 rake boxes:ubuntu:build:precise64 +CHEF=1 rake boxes:ubuntu:build:precise64 ``` +Will build a Ubuntu Precise x86_64 box with chef pre-installed. + ### Storing container's rootfs on a separate partition Before the 0.3.0 version of this plugin, there used to be a support for specifying diff --git a/tasks/boxes.rake b/tasks/boxes.rake index c9fc162..bdb0242 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -89,9 +89,9 @@ class BuildUbuntuBoxTask < BuildGenericBoxTask end end -chef = ENV['CHEF'] != '0' -puppet = ENV['PUPPET'] != '0' -babushka = ENV['BABUSKA'] != '0' +chef = ENV['CHEF'] == '1' +puppet = ENV['PUPPET'] == '1' +babushka = ENV['BABUSHKA'] == '1' namespace :boxes do namespace :ubuntu do From acc5f055b76f1289cb119e77542019ebfc157649 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Thu, 2 May 2013 00:41:48 -0300 Subject: [PATCH 19/33] Add note about soon to come Debian base boxes --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2c5ca82..9aaf332 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ can use the [same Vagrant VirtualBox machine I use for development](#using-virtu | [lxc-raring-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-raring-amd64-2013-04-21.box) | Ubuntu 13.04 Raring x86_64 (Puppet 3.1.1) | | [lxc-quantal-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-04-21.box) | Ubuntu 12.10 Quantal x86_64 (Puppet 3.1.1 & Chef 11.4.0) | | [lxc-precise-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-precise-amd64-2013-04-21.box) | Ubuntu 12.04 Precise x86_64 (Puppet 3.1.1 & Chef 11.4.0) | +| *SOON* | Debian Wheezy | +| *SOON* | Debian Sid | *Please note that I'm currently using only the quantal x86_64 on a daily basis, and I've only done some basic testing with the others* From 5cda7ded90c09d20a12e25a1b7d835e440a9fa76 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Thu, 2 May 2013 00:45:08 -0300 Subject: [PATCH 20/33] Update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cbcb3c..47ec336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.?.?](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.3...master) (unreleased) + +FEATURES: + + - Support for building Debian boxes (tks to @Val) + - Support for installing babushka on base boxes (tks to @Val) + ## [0.3.3](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.2...v0.3.3) (April 23, 2013) BUG FIXES: From f6be69286e88c3516883f094eb60245124e440ae Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Thu, 2 May 2013 07:52:25 +0200 Subject: [PATCH 21/33] Create boxes/temp directory if none (regression fix) --- tasks/boxes.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/boxes.rake b/tasks/boxes.rake index bdb0242..950cf19 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -30,6 +30,7 @@ class BuildGenericBoxTask < ::Rake::TaskLib exit 1 end + FileUtils.mkdir_p 'boxes/temp' unless File.exist? 'base/temp' if Dir.entries('boxes/temp').size > 2 puts 'There is a partially built box under ' + File.expand_path('./boxes/temp') + From 32ff85596830d909773fd3816c8b83356ce041b9 Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Thu, 2 May 2013 14:29:27 +0200 Subject: [PATCH 22/33] Avoid trouble when using lxc-console --- boxes/debian/lxc-template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index 1d7b6c2..d4eb8d9 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -40,7 +40,7 @@ l6:6:wait:/etc/init.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin 1:2345:respawn:/sbin/getty 38400 console -c1:12345:respawn:/sbin/getty 38400 tty1 linux +#c1:12345:respawn:/sbin/getty 38400 tty1 linux c2:12345:respawn:/sbin/getty 38400 tty2 linux c3:12345:respawn:/sbin/getty 38400 tty3 linux c4:12345:respawn:/sbin/getty 38400 tty4 linux From f141443564eda1fb6fab188cf7df9c9f1465afee Mon Sep 17 00:00:00 2001 From: Laurent Vallar Date: Fri, 3 May 2013 14:33:50 +0200 Subject: [PATCH 23/33] Copy default lxc.cgroup.devices.allow from ubuntu template --- boxes/debian/lxc-template | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index d4eb8d9..3b0f8fc 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -151,7 +151,6 @@ copy_configuration() path=$1 rootfs=$2 name=$3 - arch=$4 grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config cat <> $path/config @@ -163,6 +162,9 @@ lxc.utsname = ${name} #lxc.aa_profile = unconfined lxc.cgroup.devices.deny = a +# Allow any mknod (but not using the node) +lxc.cgroup.devices.allow = c *:* m +lxc.cgroup.devices.allow = b *:* m # /dev/null and zero lxc.cgroup.devices.allow = c 1:3 rwm lxc.cgroup.devices.allow = c 1:5 rwm @@ -178,6 +180,16 @@ lxc.cgroup.devices.allow = c 136:* rwm lxc.cgroup.devices.allow = c 5:2 rwm # rtc lxc.cgroup.devices.allow = c 254:0 rwm +#fuse +lxc.cgroup.devices.allow = c 10:229 rwm +#tun +lxc.cgroup.devices.allow = c 10:200 rwm +#full +lxc.cgroup.devices.allow = c 1:7 rwm +#hpet +lxc.cgroup.devices.allow = c 10:228 rwm +#kvm +lxc.cgroup.devices.allow = c 10:232 rwm # mounts point lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0 From f07179e582b756ce5568369d24afc2c514973a38 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 10:57:12 -0300 Subject: [PATCH 24/33] Clean up box packaging rake task --- boxes/common/cleanup | 7 +++ tasks/boxes.rake | 107 ++++++++++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 36 deletions(-) create mode 100755 boxes/common/cleanup diff --git a/boxes/common/cleanup b/boxes/common/cleanup new file mode 100755 index 0000000..bfa6653 --- /dev/null +++ b/boxes/common/cleanup @@ -0,0 +1,7 @@ +#!/bin/bash + +cache=`readlink -f .` +rootfs="${cache}/rootfs" + +rm -rf $rootfs/tmp/* +chroot $rootfs apt-get clean diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 950cf19..f007980 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -14,56 +14,48 @@ class BuildGenericBoxTask < ::Rake::TaskLib @install_puppet = opts.fetch(:puppet, true) @install_babushka = opts.fetch(:babushka, true) @file = opts[:file] || default_box_file + @scripts_path = Pathname(Dir.pwd).join('boxes') desc "Build an #{distrib.upcase} #{release} #{arch} box" unless ::Rake.application.last_comment task name do RakeFileUtils.send(:verbose, true) do - run_task + build end end end - def run_task - if File.exists?("./boxes/output/#{@file}") - puts 'Box has been built already!' - exit 1 + def default_box_file + require 'time' + "lxc-#{@release}-#{@arch}-#{Date.today}.box" + end + + def run(script_name, *args) + unless (script = @scripts_path.join(@distrib, script_name)).readable? + script = @scripts_path.join('common', script_name) end - FileUtils.mkdir_p 'boxes/temp' unless File.exist? 'base/temp' - if Dir.entries('boxes/temp').size > 2 - puts 'There is a partially built box under ' + - File.expand_path('./boxes/temp') + - ', please remove it before building a new box' + if script.readable? + sh "sudo #{script} #{args.join(' ')}" + else + STDERR.puts "cannot execute #{install_path} (not found?)" exit 1 end + end + + def build + check_if_box_has_been_built! + + FileUtils.mkdir_p 'boxes/temp' unless File.exist? 'base/temp' + check_for_partially_built_box! pwd = Dir.pwd sh 'mkdir -p boxes/temp/' Dir.chdir 'boxes/temp' do - sh "sudo #{pwd}/boxes/#{@distrib}/download #{@arch} #{@release}" - [ :puppet, :chef, :babushka ].each do |cfg_engine| - next unless instance_variable_get :"@install_#{cfg_engine}" - script_name = "install-#{cfg_engine}" - install_path = File.join pwd, 'boxes', @distrib, script_name - unless File.readable? install_path - install_path = File.join pwd, 'boxes', 'common', script_name - end - if File.readable? install_path - sh "sudo #{install_path}" - else - STDERR.puts "cannot execute #{install_path} (not found?)" - end - end - sh 'sudo rm -f rootfs.tar.gz' - sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*' - sh 'sudo rm -rf rootfs' - sh "sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz" - sh "cp #{pwd}/boxes/#{@distrib}/lxc-template ." - metadata = File.read("#{pwd}/boxes/#{@distrib}/metadata.json.template") - metadata.gsub!('ARCH', @arch) - metadata.gsub!('RELEASE', @release) - File.open('metadata.json', 'w') { |f| f.print metadata } + download + install_cfg_engines + prepare_package_contents pwd + cleanup sh "tar -czf tmp-package.box ./*" end @@ -72,9 +64,52 @@ class BuildGenericBoxTask < ::Rake::TaskLib sh "rm -rf boxes/temp" end - def default_box_file - require 'time' - "lxc-#{@release}-#{@arch}-#{Date.today}.box" + def check_if_box_has_been_built! + return unless File.exists?("./boxes/output/#{@file}") + + puts 'Box has been built already!' + exit 1 + end + + def check_for_partially_built_box! + return unless Dir.entries('boxes/temp').size > 2 + + puts 'There is a partially built box under ' + + File.expand_path('./boxes/temp') + + ', please remove it before building a new box' + exit 1 + end + + def download + run 'download', @arch, @release + end + + def install_cfg_engines + [ :puppet, :chef, :babushka ].each do |cfg_engine| + next unless instance_variable_get :"@install_#{cfg_engine}" + script_name = "install-#{cfg_engine}" + run script_name + end + end + + def prepare_package_contents(pwd) + sh 'sudo rm -f rootfs.tar.gz' + sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*' + sh "sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz" + sh "cp #{pwd}/boxes/#{@distrib}/lxc-template ." + compile_metadata(pwd) + end + + def compile_metadata(pwd) + metadata = File.read("#{pwd}/boxes/#{@distrib}/metadata.json.template") + metadata.gsub!('ARCH', @arch) + metadata.gsub!('RELEASE', @release) + File.open('metadata.json', 'w') { |f| f.print metadata } + end + + def cleanup + run 'cleanup' + sh 'sudo rm -rf rootfs' end end From cb665ecdd57e52920ba7d1101b0e85474f7b6a2d Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 11:03:43 -0300 Subject: [PATCH 25/33] Add squeeze box Closes #63 --- README.md | 5 +++-- tasks/boxes.rake | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9aaf332..4d64377 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,9 @@ can use the [same Vagrant VirtualBox machine I use for development](#using-virtu | [lxc-raring-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-raring-amd64-2013-04-21.box) | Ubuntu 13.04 Raring x86_64 (Puppet 3.1.1) | | [lxc-quantal-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-04-21.box) | Ubuntu 12.10 Quantal x86_64 (Puppet 3.1.1 & Chef 11.4.0) | | [lxc-precise-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-precise-amd64-2013-04-21.box) | Ubuntu 12.04 Precise x86_64 (Puppet 3.1.1 & Chef 11.4.0) | -| *SOON* | Debian Wheezy | -| *SOON* | Debian Sid | +| *[SOON](tasks/boxes.rake#157)* | Debian Squeeze | +| *[SOON](tasks/boxes.rake#162)* | Debian Wheezy | +| *[SOON](tasks/boxes.rake#167)* | Debian Sid | *Please note that I'm currently using only the quantal x86_64 on a daily basis, and I've only done some basic testing with the others* diff --git a/tasks/boxes.rake b/tasks/boxes.rake index f007980..0424ed5 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -151,13 +151,18 @@ namespace :boxes do end end + # FIXME: Find out how to install chef on debian boxes namespace :debian do namespace :build do + desc 'Build an Debian Squeeze 64 bits box' + BuildDebianBoxTask. + new(:squeeze64, + :squeeze, 'amd64', chef: false, puppet: puppet, babushka: babushka) desc 'Build an Debian Wheezy 64 bits box' BuildDebianBoxTask. new(:wheezy64, - :wheezy, 'amd64', chef: chef, puppet: puppet, babushka: babushka) + :wheezy, 'amd64', chef: false, puppet: puppet, babushka: babushka) desc 'Build an Debian Sid/unstable 64 bits box' BuildDebianBoxTask. From 72b06dfa69cf0f96bffad7fa6753d3bcaf1eba57 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 11:07:39 -0300 Subject: [PATCH 26/33] Disable chef installation on sid base box --- tasks/boxes.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 0424ed5..7e00a0c 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -167,7 +167,7 @@ namespace :boxes do desc 'Build an Debian Sid/unstable 64 bits box' BuildDebianBoxTask. new(:sid64, - :sid, 'amd64', chef: chef, puppet: puppet, babushka: babushka) + :sid, 'amd64', chef: false, puppet: puppet, babushka: babushka) end end end From 2df893e4f4cd88896ced12146abd919dd59140f5 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 11:09:57 -0300 Subject: [PATCH 27/33] Remove extra parameter for ubuntu lxc-template function --- boxes/ubuntu/lxc-template | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/boxes/ubuntu/lxc-template b/boxes/ubuntu/lxc-template index 4199e19..0905687 100755 --- a/boxes/ubuntu/lxc-template +++ b/boxes/ubuntu/lxc-template @@ -202,7 +202,6 @@ copy_configuration() rootfs=$2 name=$3 arch=$4 - release=$5 if [ $arch = "i386" ]; then arch="i686" @@ -551,7 +550,7 @@ if [ $? -ne 0 ]; then exit 1 fi -copy_configuration $path $rootfs $name $arch $release +copy_configuration $path $rootfs $name $arch if [ $? -ne 0 ]; then echo "failed write configuration file" exit 1 From 53484d3caf985076f5ec24faa73ab8f483d2c976 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 11:11:49 -0300 Subject: [PATCH 28/33] Add tasks for building all boxes --- tasks/boxes.rake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 7e00a0c..e38aa4d 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -148,6 +148,9 @@ namespace :boxes do BuildUbuntuBoxTask. new(:raring64, :raring, 'amd64', chef: false, puppet: puppet, babushka: babushka) + + desc 'Build all Ubuntu boxes' + task :all => %w( precise64 quantal64 raring64 ) end end @@ -168,6 +171,20 @@ namespace :boxes do BuildDebianBoxTask. new(:sid64, :sid, 'amd64', chef: false, puppet: puppet, babushka: babushka) + + desc 'Build all Debian boxes' + task :all => %w( squeeze64 wheezy64 sid64 ) end end + + task :enable_puppet do + ENV['PUPPET'] = '1' + end + + task :enable_chef do + ENV['CHEF'] = '1' + end + + desc 'Build all base boxes for release' + task :build_all => %w( enable_puppet enable_chef ubuntu:build:all debian:build:all ) end From 878b701b6540fba5d00fa35415983b77800abcab Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 11:27:54 -0300 Subject: [PATCH 29/33] Use debian release as hostname when creating debian boxes --- boxes/debian/lxc-template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boxes/debian/lxc-template b/boxes/debian/lxc-template index 3b0f8fc..ea46245 100755 --- a/boxes/debian/lxc-template +++ b/boxes/debian/lxc-template @@ -16,7 +16,7 @@ configure_debian() { rootfs=$1 hostname=$2 - release=$3 + release=$2 # squeeze only has /dev/tty and /dev/tty0 by default, # therefore creating missing device nodes for tty1-4. @@ -322,7 +322,7 @@ if [ $? -ne 0 ]; then exit 1 fi -configure_debian $rootfs "vagrant-debian-${release}" $release +configure_debian $rootfs $release if [ $? -ne 0 ]; then echo "failed to configure debian $release for a container" exit 1 From 495c6f6b3e0115e11dd4e8703e4f43a611ed8cc1 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 12:46:52 -0300 Subject: [PATCH 30/33] Fix task to build base boxes --- tasks/boxes.rake | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tasks/boxes.rake b/tasks/boxes.rake index e38aa4d..456452a 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -177,14 +177,6 @@ namespace :boxes do end end - task :enable_puppet do - ENV['PUPPET'] = '1' - end - - task :enable_chef do - ENV['CHEF'] = '1' - end - desc 'Build all base boxes for release' - task :build_all => %w( enable_puppet enable_chef ubuntu:build:all debian:build:all ) + task :build_all => %w( ubuntu:build:all debian:build:all ) end From 0e066e7a1cfe21f058df476c4f9021c5580e7698 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 5 May 2013 12:54:01 -0300 Subject: [PATCH 31/33] Fix ubuntu lxc template --- boxes/ubuntu/lxc-template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boxes/ubuntu/lxc-template b/boxes/ubuntu/lxc-template index 0905687..e88c523 100755 --- a/boxes/ubuntu/lxc-template +++ b/boxes/ubuntu/lxc-template @@ -36,8 +36,8 @@ fi configure_ubuntu() { rootfs=$1 - release=$3 - hostname='quantal64' + release=$2 + hostname=$2 # configure the network using the dhcp cat < $rootfs/etc/network/interfaces From 9a731ec9897a9b6248f0483fcd47c060a93c5a7e Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Mon, 6 May 2013 10:42:30 -0300 Subject: [PATCH 32/33] Proper base box cleanup --- CHANGELOG.md | 6 +++++- tasks/boxes.rake | 9 +++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ec336..e1612ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ -## [0.?.?](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.3...master) (unreleased) +## [0.?.?](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.3...master) FEATURES: - Support for building Debian boxes (tks to @Val) - Support for installing babushka on base boxes (tks to @Val) +IMPROVEMENTS: + + - Clean up base boxes files after they've been configured, resulting in smaller packages + ## [0.3.3](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.2...v0.3.3) (April 23, 2013) BUG FIXES: diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 456452a..ce53851 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -1,3 +1,4 @@ +require 'pathname' require 'rake/tasklib' class BuildGenericBoxTask < ::Rake::TaskLib @@ -55,7 +56,7 @@ class BuildGenericBoxTask < ::Rake::TaskLib download install_cfg_engines prepare_package_contents pwd - cleanup + sh 'sudo rm -rf rootfs' sh "tar -czf tmp-package.box ./*" end @@ -93,6 +94,7 @@ class BuildGenericBoxTask < ::Rake::TaskLib end def prepare_package_contents(pwd) + run 'cleanup' sh 'sudo rm -f rootfs.tar.gz' sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*' sh "sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz" @@ -106,11 +108,6 @@ class BuildGenericBoxTask < ::Rake::TaskLib metadata.gsub!('RELEASE', @release) File.open('metadata.json', 'w') { |f| f.print metadata } end - - def cleanup - run 'cleanup' - sh 'sudo rm -rf rootfs' - end end class BuildDebianBoxTask < BuildGenericBoxTask From 7d5f64b14c6b4871023dfa73cbca77a09e314a3b Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Mon, 6 May 2013 12:22:39 -0300 Subject: [PATCH 33/33] Update debian boxes info on readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4d64377..5143437 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,9 @@ can use the [same Vagrant VirtualBox machine I use for development](#using-virtu | [lxc-raring-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-raring-amd64-2013-04-21.box) | Ubuntu 13.04 Raring x86_64 (Puppet 3.1.1) | | [lxc-quantal-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-04-21.box) | Ubuntu 12.10 Quantal x86_64 (Puppet 3.1.1 & Chef 11.4.0) | | [lxc-precise-amd64-2013-04-21.box](http://dl.dropbox.com/u/13510779/lxc-precise-amd64-2013-04-21.box) | Ubuntu 12.04 Precise x86_64 (Puppet 3.1.1 & Chef 11.4.0) | -| *[SOON](tasks/boxes.rake#157)* | Debian Squeeze | -| *[SOON](tasks/boxes.rake#162)* | Debian Wheezy | -| *[SOON](tasks/boxes.rake#167)* | Debian Sid | +| *[SOON](tasks/boxes.rake#167)* | Debian Sid (Puppet 3.1.1) | +| *[SOON](tasks/boxes.rake#162)* | Debian Wheezy (Puppet 3.1.1) | +| *[SOON](tasks/boxes.rake#157)* | Debian Squeeze (Puppet 3.1.1) | *Please note that I'm currently using only the quantal x86_64 on a daily basis, and I've only done some basic testing with the others*