builder: Replace centos-6.sh with a single script.

Just use:

  ./centos.sh 6

Note that you don't need to be root.
This commit is contained in:
Richard W.M. Jones
2013-11-05 14:08:01 +00:00
parent af9e9299bf
commit 2f3fb2420e
6 changed files with 121 additions and 139 deletions

View File

@@ -23,8 +23,7 @@ EXTRA_DIST = \
README \
index \
index.asc \
centos-6.ks \
centos-6.sh \
centos.sh \
centos-6.xz.sig \
debian.preseed \
debian.sh \

View File

@@ -1,40 +0,0 @@
# virt-builder
# Copyright (C) 2013 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
part /boot --fstype=ext4 --size=512 --asprimary
part swap --size=1024 --asprimary
part / --fstype=ext4 --size=1024 --grow --asprimary
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end

View File

@@ -1,78 +0,0 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
set -e
set -x
# Some configuration.
export http_proxy=http://cache.home.annexia.org:3128
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
# We rebuild this every time there is a new 6.x release, and bump
# the revision in the index.
tree=http://mirror.bytemark.co.uk/centos/6.4/os/x86_64/
# Currently you have to run this script as root.
if [ `id -u` -ne 0 ]; then
echo "You have to run this script as root."
exit 1
fi
# Make sure it's being run from the correct directory.
if [ ! -f centos-6.ks ]; then
echo "You are running this script from the wrong directory."
exit 1
fi
pwd=`pwd`
virsh undefine tmpc6 ||:
rm -f centos-6 centos-6.old
virt-install \
--name=tmpc6 \
--ram 2048 \
--cpu=host --vcpus=2 \
--os-type=linux --os-variant=fedora18 \
--initrd-inject=$pwd/centos-6.ks \
--extra-args="ks=file:/centos-6.ks console=tty0 console=ttyS0,115200 proxy=$http_proxy" \
--disk $pwd/centos-6,size=6 \
--location=$tree \
--nographics \
--noreboot
# The virt-install command should exit after complete installation.
# Remove the guest, we don't want it to be defined in libvirt.
virsh undefine tmpc6
# Sysprep (removes logfiles and so on).
# Note this also touches /.autorelabel so the further installation
# changes that we make will be labelled properly at first boot.
virt-sysprep -a centos-6
# Sparsify.
mv centos-6 centos-6.old
virt-sparsify centos-6.old centos-6
rm centos-6.old
# Compress.
rm -f centos-6.xz
xz --best --block-size=16777216 centos-6
# Result:
ls -lh centos-6.xz

101
builder/website/centos.sh Executable file
View File

@@ -0,0 +1,101 @@
#!/bin/bash -
# virt-builder
# Copyright (C) 2013 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
unset CDPATH
export LANG=C
set -e
set -x
if [ $# -ne 1 ]; then
echo "$0 VERSION"
exit 1
fi
version=$1
output=fedora-$version
tmpname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8)
# We rebuild this every time there is a new 6.x release, and bump
# the revision in the index.
tree=http://mirror.bytemark.co.uk/centos/$version/os/x86_64/
rm -f $output $output.old $output.xz
# Generate the kickstart to a temporary file.
ks=$(mktemp)
cat > $ks <<'EOF'
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw builder
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
part /boot --fstype=ext4 --size=512 --asprimary
part swap --size=1024 --asprimary
part / --fstype=ext4 --size=1024 --grow --asprimary
# Halt the system once configuration has finished.
poweroff
%packages
@core
%end
EOF
# Clean up function.
cleanup ()
{
rm -f $ks
virsh undefine $tmpname ||:
}
trap cleanup INT QUIT TERM EXIT ERR
virt-install \
--name=$tmpname \
--ram=2048 \
--cpu=host --vcpus=2 \
--os-type=linux --os-variant=rhel$version \
--initrd-inject=$ks \
--extra-args="ks=file:/`basename $ks` console=tty0 console=ttyS0,115200 proxy=$http_proxy" \
--disk $(pwd)/$output,size=6 \
--location=$tree \
--nographics \
--noreboot
# Sysprep (removes logfiles and so on).
# Note this also touches /.autorelabel so the further installation
# changes that we make will be labelled properly at first boot.
virt-sysprep -a $output
# Sparsify.
mv $output $output.old
virt-sparsify $output.old $output
rm $output.old
# Compress.
xz --best --block-size=16777216 $output
# Result:
ls -lh $output.xz

View File

@@ -14,9 +14,9 @@ notes=CentOS 6.4
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs git tree:
libguestfs.git/builder/website/centos-6.ks
libguestfs.git/builder/website/centos-6.sh
found in the libguestfs source tree:
builder/website/centos.sh
Note that `virt-builder centos-6' will always install the latest
6.x release.

View File

@@ -17,9 +17,9 @@ notes=CentOS 6.4
This CentOS image contains only unmodified @Core group packages.
It is thus very minimal. The kickstart and install script can be
found in the libguestfs git tree:
libguestfs.git/builder/website/centos-6.ks
libguestfs.git/builder/website/centos-6.sh
found in the libguestfs source tree:
builder/website/centos.sh
Note that `virt-builder centos-6' will always install the latest
6.x release.
@@ -207,17 +207,17 @@ notes=Ubuntu 13.10 (Saucy).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
iQIcBAEBAgAGBQJSeP5LAAoJEJFzj3Pht2igO5QP/2jjVb8W15AWxvuATDc/kOXE
8Dvg4hFbvvBnv/U9QQ1/2BNQDykATcVIE/lWg7VzpF2HLuEwbVdwAgEO73xKpeRT
U6zGNxkTi0mfr3aKT4rfQtqNlMkc1IMVCQSBJEIHLd1hjh2gozBCM9KM4f5YHK2P
i/6GX8j7AeWzVkOb60PKKQrGk1ycXm0UbZuS0MPBqnc9v56fzEyaWVvvrCQEOq7a
zTJULgOcfCBHQLF8re2upQV5NbYwruplaCYpsTcvNHvQ/vsoUIf0dNbqvarpwFUQ
FHDesMZQBW6OWzsIBkeMYfIJ4GXO0A0ZlVuzBW07eHbmr0ev1b4c37npHrsuytbI
TF6SUF7wyIxZlKbyf4W+RaX1hAsMOKXU8ptsMBmBPn7UnWrLbCDAPpS27ruZOA4q
oPGeuKLUGPnimjNEatkJH8rmWlg71hsCy1hMGAOTXAUpCgPXHv/WHa0n4GTbtJ1y
VzUElr0wAGPOqrClJse6po1h7f6XEdB4mLZ8OYHKNDjJl57QirUcmnmYmRMsctN4
tKYgnEcv+PhNMEV/GIQXLrtCYX/Ty81AV4hwlfzL3fjqdxX9f+Fem5PcxeMaS0ik
xfnpMsRuprkoNyTAhDr6AX9AcY4fEW8NSfG5YUjt+s27IFLIjl7HfWCbRqcqGwv9
VvLm+Omd+GUA6rd4fuee
=Gv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