From add64aa2e4b9911b43cc3fd27742bf1359499564 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sat, 16 Feb 2013 16:00:50 +0100 Subject: [PATCH] Support different versions of the same distribution Split $DIST to distribution name and version (builder_setup script) and search for scripts first $DIST-specific, but then for given distribution. Also move out some Fedora-specific things to scripts_fc17. --- Makefile | 6 ++--- build_template_rpm | 4 ++++ builder_setup | 22 +++++++++++++++++++ cleanup_image | 4 +++- fedorize_image => prepare_image | 15 ++++++------- .../.gitignore | 0 qubeize_image | 4 +++- scripts_archlinux/02_install_groups.sh | 2 ++ scripts_fc17/00_prepare.sh | 2 ++ scripts_fc17/02_install_groups.sh | 7 ++++++ templates.spec | 2 +- 11 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 builder_setup rename fedorize_image => prepare_image (65%) rename {fedorized_images => prepared_images}/.gitignore (100%) diff --git a/Makefile b/Makefile index ffee2c0..3d919cf 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ ifndef DIST $(error "You must set DIST variable, e.g. DIST=fc14") endif +#TODO: build template name somehow smarter TEMPLATE_NAME := $${DIST/fc/fedora-}-x64 VERSION := $(shell cat version) TIMESTAMP := $(shell date -u +%Y%m%d%H%M) @@ -15,9 +16,8 @@ help: rpms: @echo $(TIMESTAMP) > build_timestamp @echo "Building template: $(TEMPLATE_NAME)" - @createrepo -q -g $$PWD/comps-qubes-template.xml yum_repo_qubes/$(DIST) -o yum_repo_qubes/$(DIST) && \ - sudo -E ./fedorize_image fedorized_images/$(TEMPLATE_NAME).img && \ - sudo -E ./qubeize_image fedorized_images/$(TEMPLATE_NAME).img $(TEMPLATE_NAME) && \ + sudo -E ./prepare_image prepared_images/$(TEMPLATE_NAME).img && \ + sudo -E ./qubeize_image prepared_images/$(TEMPLATE_NAME).img $(TEMPLATE_NAME) && \ ./build_template_rpm $(TEMPLATE_NAME) || exit 1; \ update-repo-installer: diff --git a/build_template_rpm b/build_template_rpm index c98a1c9..d17e75b 100755 --- a/build_template_rpm +++ b/build_template_rpm @@ -6,9 +6,13 @@ echo "usage $0 " exit 1 fi +. ./builder_setup + rpmbuild --target noarch \ --define "template_name $NAME" \ --define "DIST $DIST" \ + --define "DISTRIBUTION $DISTRIBUTION" \ + --define "VERSION $VERSION" \ --define "_topdir $PWD/rpmbuild" \ --define "_tmppath $PWD/rpmbuild/tmp" \ -bb templates.spec diff --git a/builder_setup b/builder_setup new file mode 100644 index 0000000..949225b --- /dev/null +++ b/builder_setup @@ -0,0 +1,22 @@ +#!/bin/bash + +# Setup env variables + +case "$DIST" in + fc*) + DISTRIBUTION=fedora + VERSION=${DIST/fc/} + ;; + *) + DISTRIBUTION="$DIST" + VERSION= + ;; +esac + +if [ -d "scripts_$DIST" ]; then + SCRIPTSDIR="scripts_$DIST" +else + SCRIPTSDIR="scripts_$DISTRIBUTION" +fi + +export SCRIPTSDIR diff --git a/cleanup_image b/cleanup_image index 2673513..522d9d4 100755 --- a/cleanup_image +++ b/cleanup_image @@ -2,6 +2,8 @@ export IMG=$1 +. ./builder_setup + set -e if ! [ $# -eq 1 ]; then @@ -18,7 +20,7 @@ ls -als $IMG mount -o loop $IMG mnt || exit 1 export INSTALLDIR=`pwd`/mnt/ -scripts_"${DIST}"/09_cleanup.sh +$SCRIPTSDIR/09_cleanup.sh echo "--> Compacting image file..." dd if=/dev/zero of=mnt/fillme bs=1M > /dev/null 2>&1 || true diff --git a/fedorize_image b/prepare_image similarity index 65% rename from fedorize_image rename to prepare_image index 7292725..b9e8a89 100755 --- a/fedorize_image +++ b/prepare_image @@ -6,6 +6,8 @@ RETCODE=0 : ${DIST=fc14} +. ./builder_setup + if ! [ $# -eq 1 ]; then echo "usage $0 " exit @@ -15,15 +17,15 @@ if [ "$VERBOSE" == "1" ]; then export YUM_OPTS="$YUM_OPTS -q" fi +echo "-> Preparing instalation of $DIST template..." +$SCRIPTSDIR/00_prepare.sh + if [ -f $IMG ]; then echo "-> Image file already exists, assuming *update*..." mount -o loop $IMG mnt || exit 1 export INSTALLDIR=`pwd`/mnt/ else - echo "-> Preparing instalation of $DIST template..." - scripts_"${DIST}"/00_prepare.sh - echo "-> Initializing empty image..." truncate -s 10G $IMG || exit 1 @@ -35,14 +37,11 @@ else export INSTALLDIR=`pwd`/mnt/ - scripts_"${DIST}"/01_install_core.sh + $SCRIPTSDIR/01_install_core.sh fi -PKGLISTFILE=$(shell [ -r scripts_"${DIST}/packages_$(DIST).list" ] && echo scripts_"${DIST}/packages_$(DIST).list" || echo scripts_"${DIST}/packages.list") -export PKGGROUPS=$(cat $PKGLISTFILE) - echo "-> Installing package groups..." -scripts_"${DIST}"/02_install_groups.sh +$SCRIPTSDIR/02_install_groups.sh echo "-> Unmounting fedorized_image..." sudo umount $INSTALLDIR diff --git a/fedorized_images/.gitignore b/prepared_images/.gitignore similarity index 100% rename from fedorized_images/.gitignore rename to prepared_images/.gitignore diff --git a/qubeize_image b/qubeize_image index 1966699..19cd98c 100755 --- a/qubeize_image +++ b/qubeize_image @@ -3,6 +3,8 @@ export CLEANIMG=$1 export NAME=$2 +. ./builder_setup + set -e if [ $# -eq 0 ]; then @@ -50,7 +52,7 @@ mkdir -p mnt mount -o loop $IMG mnt || exit 1 export INSTALLDIR=mnt -scripts_"${DIST}"/04_install_qubes.sh +$SCRIPTSDIR/04_install_qubes.sh echo "--> Copying the Apps Menu shortcuts..." export APPSORIG=qubeized_images/$NAME-apps.orig diff --git a/scripts_archlinux/02_install_groups.sh b/scripts_archlinux/02_install_groups.sh index 3d5b132..4d9640a 100755 --- a/scripts_archlinux/02_install_groups.sh +++ b/scripts_archlinux/02_install_groups.sh @@ -3,6 +3,8 @@ echo "Mounting archlinux install system into archlinux_dvd..." sudo mount root-image.fs archlinux_dvd +PKGGROUPS=`cat $SCRIPTSDIR/packages.list` + echo "-> Installing archlinux package groups..." echo "-> Selected packages:" echo "$PKGGROUPS" diff --git a/scripts_fc17/00_prepare.sh b/scripts_fc17/00_prepare.sh index a6634bd..e2349bf 100755 --- a/scripts_fc17/00_prepare.sh +++ b/scripts_fc17/00_prepare.sh @@ -3,3 +3,5 @@ rm -f keys base_rpms ln -sf keys_$DIST keys ln -sf base_rpms_$DIST base_rpms + +createrepo -q -g $PWD/comps-qubes-template.xml yum_repo_qubes/$DIST -o yum_repo_qubes/$DIST diff --git a/scripts_fc17/02_install_groups.sh b/scripts_fc17/02_install_groups.sh index 86ceade..14ffa7f 100755 --- a/scripts_fc17/02_install_groups.sh +++ b/scripts_fc17/02_install_groups.sh @@ -2,6 +2,13 @@ echo "--> Preparing environment..." mount -t proc proc mnt/proc +if [ -r "$SCRIPTSDIR/packages_${DIST}.list" ]; then + PKGLISTFILE="$SCRIPTSDIR/packages_${DIST}.list" +else + PKGLISTFILE="$SCRIPTSDIR/packages.list" +fi +export PKGGROUPS=$(cat $PKGLISTFILE) + export YUM0=$PWD/yum_repo_qubes yum clean all -c $PWD/yum.conf $YUM_OPTS -y --installroot=$PWD/mnt yum install -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR $PKGGROUPS || RETCODE=1 diff --git a/templates.spec b/templates.spec index 514a393..2754f16 100644 --- a/templates.spec +++ b/templates.spec @@ -45,7 +45,7 @@ touch $RPM_BUILD_ROOT/%{dest_dir}/root.img # we will create the real file in %po touch $RPM_BUILD_ROOT/%{dest_dir}/private.img # we will create the real file in %post touch $RPM_BUILD_ROOT/%{dest_dir}/volatile.img # we will create the real file in %post -cp scripts_%{DIST}/clean-volatile.img.tar $RPM_BUILD_ROOT/%{dest_dir}/clean-volatile.img.tar +cp $SCRIPTSDIR/clean-volatile.img.tar $RPM_BUILD_ROOT/%{dest_dir}/clean-volatile.img.tar mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps.templates mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps