psss / rpms / libguestfs

Forked from rpms/libguestfs 5 years ago
Clone
Blob Blame History Raw
From 401de624d1bbd3a2b5bd0a7bad17f6f17c986a5d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 5 Nov 2013 14:08:01 +0000
Subject: [PATCH] builder: Replace centos-6.sh with a single script.

Just use:

  ./centos.sh 6

Note that you don't need to be root.

(cherry picked from commit 2f3fb2420e7f2ccc19fdc863ecc7b7ce29dd6aa1)
---
 builder/website/Makefile.am |   3 +-
 builder/website/centos-6.ks |  40 ------------------
 builder/website/centos-6.sh |  78 ----------------------------------
 builder/website/centos.sh   | 101 ++++++++++++++++++++++++++++++++++++++++++++
 builder/website/index       |   6 +--
 builder/website/index.asc   |  32 +++++++-------
 6 files changed, 121 insertions(+), 139 deletions(-)
 delete mode 100644 builder/website/centos-6.ks
 delete mode 100755 builder/website/centos-6.sh
 create mode 100755 builder/website/centos.sh

diff --git a/builder/website/Makefile.am b/builder/website/Makefile.am
index a662176..cdf263a 100644
--- a/builder/website/Makefile.am
+++ b/builder/website/Makefile.am
@@ -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 \
diff --git a/builder/website/centos-6.ks b/builder/website/centos-6.ks
deleted file mode 100644
index 55e2e86..0000000
--- a/builder/website/centos-6.ks
+++ /dev/null
@@ -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
diff --git a/builder/website/centos-6.sh b/builder/website/centos-6.sh
deleted file mode 100755
index 611ba90..0000000
--- a/builder/website/centos-6.sh
+++ /dev/null
@@ -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
diff --git a/builder/website/centos.sh b/builder/website/centos.sh
new file mode 100755
index 0000000..ce7abb6
--- /dev/null
+++ b/builder/website/centos.sh
@@ -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
diff --git a/builder/website/index b/builder/website/index
index 494c177..49b964c 100644
--- a/builder/website/index
+++ b/builder/website/index
@@ -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.
diff --git a/builder/website/index.asc b/builder/website/index.asc
index 35f6281..6711df7 100644
--- a/builder/website/index.asc
+++ b/builder/website/index.asc
@@ -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+F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