template_builder: made make scripts OS independent.

An important note is that each OS script need to setup itself its own chroot environment (like creating /proc...).
This commit is contained in:
Olivier Medoc 2013-01-25 09:03:51 +01:00 committed by Marek Marczykowski
parent 6be747cf6a
commit 7e17847377
13 changed files with 32 additions and 50 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ base_rpms
keys
appmenus
build_timestamp
*.iso
*.fs

View File

@ -16,7 +16,7 @@ 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 clean_images/packages.list && \
sudo -E ./fedorize_image fedorized_images/$(TEMPLATE_NAME).img && \
sudo -E ./qubeize_image fedorized_images/$(TEMPLATE_NAME).img $(TEMPLATE_NAME) && \
./build_template_rpm $(TEMPLATE_NAME) || exit 1; \

View File

@ -8,6 +8,7 @@ fi
rpmbuild --target noarch \
--define "template_name $NAME" \
--define "DIST $DIST" \
--define "_topdir $PWD/rpmbuild" \
--define "_tmppath $PWD/rpmbuild/tmp" \
-bb templates.spec

View File

@ -1,6 +1,6 @@
#!/bin/sh
IMG=$1
export IMG=$1
set -e
@ -16,13 +16,9 @@ if ! [ -f $IMG ]; then
fi
ls -als $IMG
mount -o loop $IMG mnt || exit 1
INSTALLDIR=`pwd`/mnt/
rm -f $INSTALLDIR/var/lib/rpm/__db.00* $INSTALLDIR/var/lib/rpm/.rpm.lock
yum -c $PWD/yum.conf $YUM_OPTS clean packages --installroot=$INSTALLDIR
export INSTALLDIR=`pwd`/mnt/
# Make sure that rpm database has right format (for rpm version in template, not host)
echo "--> Rebuilding rpm database..."
chroot `pwd`/mnt /bin/rpm --rebuilddb 2> /dev/null
scripts_"${DIST}"/09_cleanup.sh
echo "--> Compacting image file..."
dd if=/dev/zero of=mnt/fillme bs=1M > /dev/null 2>&1 || true

View File

@ -1,31 +1,28 @@
#!/bin/sh
IMG=$1
PKGLISTFILE=$2
export IMG=$1
RETCODE=0
: ${DIST=fc14}
if ! [ $# -eq 2 ]; then
echo "usage $0 <img_file_name> <package_list>"
if ! [ $# -eq 1 ]; then
echo "usage $0 <img_file_name>"
exit
fi
if [ "$VERBOSE" == "1" ]; then
YUM_OPTS="$YUM_OPTS -q"
export YUM_OPTS="$YUM_OPTS -q"
fi
if [ -f $IMG ]; then
echo "-> Image file already exists, assuming *update*..."
mount -o loop $IMG mnt || exit 1
INSTALLDIR=`pwd`/mnt/
export INSTALLDIR=`pwd`/mnt/
else
echo "-> Preparing instalation of $DIST template..."
rm -f keys base_rpms
ln -sf keys_$DIST keys
ln -sf base_rpms_$DIST base_rpms
scripts_"${DIST}"/00_prepare.sh
echo "-> Initializing empty image..."
truncate -s 10G $IMG || exit 1
@ -36,29 +33,18 @@ else
mkdir -p mnt
mount -o loop $IMG mnt || exit 1
INSTALLDIR=`pwd`/mnt/
export INSTALLDIR=`pwd`/mnt/
echo "-> Initializing RPM database..."
rpm --initdb --root=$INSTALLDIR
rpm --import --root=$INSTALLDIR keys/*
echo "-> Installing core RPM packages..."
rpm -i --root=$INSTALLDIR base_rpms/*.rpm || exit 1
cp clean_images/network $INSTALLDIR/etc/sysconfig
cp clean_images/resolv.conf $INSTALLDIR/etc
cp -a /dev/null /dev/zero /dev/random /dev/urandom $INSTALLDIR/dev/
scripts_"${DIST}"/01_install_core.sh
fi
mount -t proc proc mnt/proc
PKGGROUPS=$(cat $PKGLISTFILE)
export YUM0=$PWD/yum_repo_qubes
echo "-> Installing package groups..."
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 update -c $PWD/yum.conf $YUM_OPTS -y --installroot=$INSTALLDIR || RETCODE=1
export PKGGROUPS=$(cat scripts_"${DIST}/packages.list")
umount mnt/proc mnt
echo "-> Installing package groups..."
scripts_"${DIST}"/02_install_groups.sh
echo "-> Unmounting fedorized_image..."
sudo umount $INSTALLDIR
exit $RETCODE

View File

@ -1,7 +1,7 @@
#!/bin/sh
CLEANIMG=$1
NAME=$2
export CLEANIMG=$1
export NAME=$2
set -e
@ -39,26 +39,22 @@ function cleanup() {
trap cleanup ERR
IMG=qubeized_images/$NAME-root.img
export IMG=qubeized_images/$NAME-root.img
echo "--> Copying $CLEANIMG to $IMG..."
echo "--> cp could fail with a sparse file error"
cp $CLEANIMG $IMG || exit 1
echo "--> Mouting $IMG"
mkdir -p mnt
mount -o loop $IMG mnt || exit 1
mount -t proc proc mnt/proc
export INSTALLDIR=mnt
echo "--> Installing RPMs..."
export YUM0=$PWD/yum_repo_qubes
yum install -c $PWD/yum.conf $YUM_OPTS -y --installroot=$(pwd)/mnt @qubes-vm
echo "--> Installing 3rd party apps"
./add_3rd_party_software.sh
scripts_"${DIST}"/04_install_qubes.sh
echo "--> Copying the Apps Menu shortcuts..."
APPSORIG=qubeized_images/$NAME-apps.orig
APPSTEMPL=qubeized_images/$NAME-apps.templates
export APPSORIG=qubeized_images/$NAME-apps.orig
export APPSTEMPL=qubeized_images/$NAME-apps.templates
mkdir -p $APPSORIG
cp -r $(pwd)/mnt/usr/share/applications/* $APPSORIG
@ -87,7 +83,7 @@ if ! [ -r mnt/etc/sysconfig/i18n ]; then
fi
echo "--> Unmounting $IMG"
umount mnt/proc mnt
umount mnt
echo "Qubeized image stored at: $IMG"

View File

@ -44,7 +44,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 clean_images/clean-volatile.img.tar $RPM_BUILD_ROOT/%{dest_dir}/clean-volatile.img.tar
cp scripts_%{DIST}/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

View File

@ -1 +1,2 @@
fc*
archlinux*