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.
This commit is contained in:
Marek Marczykowski 2013-02-16 16:00:50 +01:00
parent 746cb149c9
commit add64aa2e4
11 changed files with 54 additions and 14 deletions

View File

@ -2,6 +2,7 @@ ifndef DIST
$(error "You must set DIST variable, e.g. DIST=fc14") $(error "You must set DIST variable, e.g. DIST=fc14")
endif endif
#TODO: build template name somehow smarter
TEMPLATE_NAME := $${DIST/fc/fedora-}-x64 TEMPLATE_NAME := $${DIST/fc/fedora-}-x64
VERSION := $(shell cat version) VERSION := $(shell cat version)
TIMESTAMP := $(shell date -u +%Y%m%d%H%M) TIMESTAMP := $(shell date -u +%Y%m%d%H%M)
@ -15,9 +16,8 @@ help:
rpms: rpms:
@echo $(TIMESTAMP) > build_timestamp @echo $(TIMESTAMP) > build_timestamp
@echo "Building template: $(TEMPLATE_NAME)" @echo "Building template: $(TEMPLATE_NAME)"
@createrepo -q -g $$PWD/comps-qubes-template.xml yum_repo_qubes/$(DIST) -o yum_repo_qubes/$(DIST) && \ sudo -E ./prepare_image prepared_images/$(TEMPLATE_NAME).img && \
sudo -E ./fedorize_image fedorized_images/$(TEMPLATE_NAME).img && \ sudo -E ./qubeize_image prepared_images/$(TEMPLATE_NAME).img $(TEMPLATE_NAME) && \
sudo -E ./qubeize_image fedorized_images/$(TEMPLATE_NAME).img $(TEMPLATE_NAME) && \
./build_template_rpm $(TEMPLATE_NAME) || exit 1; \ ./build_template_rpm $(TEMPLATE_NAME) || exit 1; \
update-repo-installer: update-repo-installer:

View File

@ -6,9 +6,13 @@ echo "usage $0 <template_name>"
exit 1 exit 1
fi fi
. ./builder_setup
rpmbuild --target noarch \ rpmbuild --target noarch \
--define "template_name $NAME" \ --define "template_name $NAME" \
--define "DIST $DIST" \ --define "DIST $DIST" \
--define "DISTRIBUTION $DISTRIBUTION" \
--define "VERSION $VERSION" \
--define "_topdir $PWD/rpmbuild" \ --define "_topdir $PWD/rpmbuild" \
--define "_tmppath $PWD/rpmbuild/tmp" \ --define "_tmppath $PWD/rpmbuild/tmp" \
-bb templates.spec -bb templates.spec

22
builder_setup Normal file
View File

@ -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

View File

@ -2,6 +2,8 @@
export IMG=$1 export IMG=$1
. ./builder_setup
set -e set -e
if ! [ $# -eq 1 ]; then if ! [ $# -eq 1 ]; then
@ -18,7 +20,7 @@ ls -als $IMG
mount -o loop $IMG mnt || exit 1 mount -o loop $IMG mnt || exit 1
export INSTALLDIR=`pwd`/mnt/ export INSTALLDIR=`pwd`/mnt/
scripts_"${DIST}"/09_cleanup.sh $SCRIPTSDIR/09_cleanup.sh
echo "--> Compacting image file..." echo "--> Compacting image file..."
dd if=/dev/zero of=mnt/fillme bs=1M > /dev/null 2>&1 || true dd if=/dev/zero of=mnt/fillme bs=1M > /dev/null 2>&1 || true

View File

@ -6,6 +6,8 @@ RETCODE=0
: ${DIST=fc14} : ${DIST=fc14}
. ./builder_setup
if ! [ $# -eq 1 ]; then if ! [ $# -eq 1 ]; then
echo "usage $0 <img_file_name>" echo "usage $0 <img_file_name>"
exit exit
@ -15,15 +17,15 @@ if [ "$VERBOSE" == "1" ]; then
export YUM_OPTS="$YUM_OPTS -q" export YUM_OPTS="$YUM_OPTS -q"
fi fi
echo "-> Preparing instalation of $DIST template..."
$SCRIPTSDIR/00_prepare.sh
if [ -f $IMG ]; then if [ -f $IMG ]; then
echo "-> Image file already exists, assuming *update*..." echo "-> Image file already exists, assuming *update*..."
mount -o loop $IMG mnt || exit 1 mount -o loop $IMG mnt || exit 1
export INSTALLDIR=`pwd`/mnt/ export INSTALLDIR=`pwd`/mnt/
else else
echo "-> Preparing instalation of $DIST template..."
scripts_"${DIST}"/00_prepare.sh
echo "-> Initializing empty image..." echo "-> Initializing empty image..."
truncate -s 10G $IMG || exit 1 truncate -s 10G $IMG || exit 1
@ -35,14 +37,11 @@ else
export INSTALLDIR=`pwd`/mnt/ export INSTALLDIR=`pwd`/mnt/
scripts_"${DIST}"/01_install_core.sh $SCRIPTSDIR/01_install_core.sh
fi 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..." echo "-> Installing package groups..."
scripts_"${DIST}"/02_install_groups.sh $SCRIPTSDIR/02_install_groups.sh
echo "-> Unmounting fedorized_image..." echo "-> Unmounting fedorized_image..."
sudo umount $INSTALLDIR sudo umount $INSTALLDIR

View File

@ -3,6 +3,8 @@
export CLEANIMG=$1 export CLEANIMG=$1
export NAME=$2 export NAME=$2
. ./builder_setup
set -e set -e
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@ -50,7 +52,7 @@ mkdir -p mnt
mount -o loop $IMG mnt || exit 1 mount -o loop $IMG mnt || exit 1
export INSTALLDIR=mnt export INSTALLDIR=mnt
scripts_"${DIST}"/04_install_qubes.sh $SCRIPTSDIR/04_install_qubes.sh
echo "--> Copying the Apps Menu shortcuts..." echo "--> Copying the Apps Menu shortcuts..."
export APPSORIG=qubeized_images/$NAME-apps.orig export APPSORIG=qubeized_images/$NAME-apps.orig

View File

@ -3,6 +3,8 @@
echo "Mounting archlinux install system into archlinux_dvd..." echo "Mounting archlinux install system into archlinux_dvd..."
sudo mount root-image.fs archlinux_dvd sudo mount root-image.fs archlinux_dvd
PKGGROUPS=`cat $SCRIPTSDIR/packages.list`
echo "-> Installing archlinux package groups..." echo "-> Installing archlinux package groups..."
echo "-> Selected packages:" echo "-> Selected packages:"
echo "$PKGGROUPS" echo "$PKGGROUPS"

View File

@ -3,3 +3,5 @@
rm -f keys base_rpms rm -f keys base_rpms
ln -sf keys_$DIST keys ln -sf keys_$DIST keys
ln -sf base_rpms_$DIST base_rpms ln -sf base_rpms_$DIST base_rpms
createrepo -q -g $PWD/comps-qubes-template.xml yum_repo_qubes/$DIST -o yum_repo_qubes/$DIST

View File

@ -2,6 +2,13 @@
echo "--> Preparing environment..." echo "--> Preparing environment..."
mount -t proc proc mnt/proc 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 export YUM0=$PWD/yum_repo_qubes
yum clean all -c $PWD/yum.conf $YUM_OPTS -y --installroot=$PWD/mnt 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 yum install -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR $PKGGROUPS || RETCODE=1

View File

@ -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}/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 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.templates
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps