Remove container architecture from quantal64 rootfs folder when building it

This commit is contained in:
Fabio Rehm 2013-04-04 22:02:20 -03:00
parent 4ea3395872
commit 666482304d
2 changed files with 19 additions and 19 deletions

View file

@ -15,8 +15,8 @@ suggest_flush()
cleanup() cleanup()
{ {
rm -rf $cache/partial-$arch rm -rf $cache/partial
rm -rf $cache/rootfs-$arch rm -rf $cache/rootfs
} }
write_sourceslist() write_sourceslist()
@ -40,18 +40,18 @@ download_ubuntu()
trap cleanup EXIT SIGHUP SIGINT SIGTERM trap cleanup EXIT SIGHUP SIGINT SIGTERM
# check the mini ubuntu was not already downloaded # check the mini ubuntu was not already downloaded
mkdir -p "$cache/partial-$arch" mkdir -p "$cache/partial"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to create '$cache/partial-$arch' directory" echo "Failed to create '$cache/partial' directory"
return 1 return 1
fi fi
# download a mini ubuntu into a cache # download a mini ubuntu into a cache
echo "Downloading ubuntu $release minimal ..." echo "Downloading ubuntu $release minimal ..."
if [ -n "$(which qemu-debootstrap)" ]; then if [ -n "$(which qemu-debootstrap)" ]; then
qemu-debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial-$arch $MIRROR qemu-debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial $MIRROR
else else
debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial-$arch $MIRROR debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial $MIRROR
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -62,27 +62,27 @@ download_ubuntu()
# Serge isn't sure whether we should avoid doing this when # Serge isn't sure whether we should avoid doing this when
# $release == `distro-info -d` # $release == `distro-info -d`
echo "Installing updates" echo "Installing updates"
> $cache/partial-$arch/etc/apt/sources.list > $cache/partial/etc/apt/sources.list
write_sourceslist $cache/partial-$arch/ $arch write_sourceslist $cache/partial/ $arch
chroot "$1/partial-${arch}" apt-get update chroot "$1/partial" apt-get update
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to update the apt cache" echo "Failed to update the apt cache"
return 1 return 1
fi fi
cat > "$1/partial-${arch}"/usr/sbin/policy-rc.d << EOF cat > "$1/partial"/usr/sbin/policy-rc.d << EOF
#!/bin/sh #!/bin/sh
exit 101 exit 101
EOF EOF
chmod +x "$1/partial-${arch}"/usr/sbin/policy-rc.d chmod +x "$1/partial"/usr/sbin/policy-rc.d
lxc-unshare -s MOUNT -- chroot "$1/partial-${arch}" apt-get dist-upgrade -y || { suggest_flush; false; } lxc-unshare -s MOUNT -- chroot "$1/partial" apt-get dist-upgrade -y || { suggest_flush; false; }
rm -f "$1/partial-${arch}"/usr/sbin/policy-rc.d rm -f "$1/partial"/usr/sbin/policy-rc.d
chroot "$1/partial-${arch}" apt-get clean chroot "$1/partial" apt-get clean
mv "$1/partial-$arch" "$1/rootfs-$arch" mv "$1/partial" "$1/rootfs"
trap EXIT trap EXIT
trap SIGINT trap SIGINT
trap SIGTERM trap SIGTERM
@ -95,14 +95,14 @@ declare cache=`readlink -f .` \
arch=amd64 \ arch=amd64 \
release=quantal release=quantal
if [ -d "${cache}/rootfs-${arch}" ]; then if [ -d "${cache}/rootfs" ]; then
echo 'The rootfs cache has been downloaded already, please remove it if you want to update' echo 'The rootfs cache has been built already, please remove it if you want to update'
exit 1 exit 1
fi fi
download_ubuntu $cache $arch $release download_ubuntu $cache $arch $release
rootfs="${cache}/rootfs-${arch}" rootfs="${cache}/rootfs"
echo "installing puppet" echo "installing puppet"
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb -O "${rootfs}/tmp/puppetlabs-release-${release}.deb" wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb -O "${rootfs}/tmp/puppetlabs-release-${release}.deb"

View file

@ -10,7 +10,7 @@ namespace :boxes do
sh 'mkdir -p boxes/output' sh 'mkdir -p boxes/output'
sh 'cd boxes/quantal64 && sudo ./download-ubuntu' sh 'cd boxes/quantal64 && sudo ./download-ubuntu'
sh 'rm -f boxes/quantal64/rootfs.tar.gz' sh 'rm -f boxes/quantal64/rootfs.tar.gz'
sh 'cd boxes/quantal64 && sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs-amd64/*' sh 'cd boxes/quantal64 && sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*'
sh "cd boxes/quantal64 && sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz && tar -czf ../output/lxc-quantal64.box ./* --exclude=rootfs-amd64 --exclude=download-ubuntu" sh "cd boxes/quantal64 && sudo chown #{ENV['USER']}:#{ENV['USER']} rootfs.tar.gz && tar -czf ../output/lxc-quantal64.box ./* --exclude=rootfs-amd64 --exclude=download-ubuntu"
sh 'cd boxes/quantal64 && sudo rm -rf rootfs-amd64' sh 'cd boxes/quantal64 && sudo rm -rf rootfs-amd64'
end end