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:
parent
6be747cf6a
commit
7e17847377
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@ base_rpms
|
|||||||
keys
|
keys
|
||||||
appmenus
|
appmenus
|
||||||
build_timestamp
|
build_timestamp
|
||||||
|
*.iso
|
||||||
|
*.fs
|
||||||
|
2
Makefile
2
Makefile
@ -16,7 +16,7 @@ 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) && \
|
@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) && \
|
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; \
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ fi
|
|||||||
|
|
||||||
rpmbuild --target noarch \
|
rpmbuild --target noarch \
|
||||||
--define "template_name $NAME" \
|
--define "template_name $NAME" \
|
||||||
|
--define "DIST $DIST" \
|
||||||
--define "_topdir $PWD/rpmbuild" \
|
--define "_topdir $PWD/rpmbuild" \
|
||||||
--define "_tmppath $PWD/rpmbuild/tmp" \
|
--define "_tmppath $PWD/rpmbuild/tmp" \
|
||||||
-bb templates.spec
|
-bb templates.spec
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
IMG=$1
|
export IMG=$1
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -16,13 +16,9 @@ if ! [ -f $IMG ]; then
|
|||||||
fi
|
fi
|
||||||
ls -als $IMG
|
ls -als $IMG
|
||||||
mount -o loop $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
INSTALLDIR=`pwd`/mnt/
|
export 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
|
|
||||||
|
|
||||||
# Make sure that rpm database has right format (for rpm version in template, not host)
|
scripts_"${DIST}"/09_cleanup.sh
|
||||||
echo "--> Rebuilding rpm database..."
|
|
||||||
chroot `pwd`/mnt /bin/rpm --rebuilddb 2> /dev/null
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -1,31 +1,28 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
IMG=$1
|
export IMG=$1
|
||||||
PKGLISTFILE=$2
|
|
||||||
|
|
||||||
RETCODE=0
|
RETCODE=0
|
||||||
|
|
||||||
: ${DIST=fc14}
|
: ${DIST=fc14}
|
||||||
|
|
||||||
if ! [ $# -eq 2 ]; then
|
if ! [ $# -eq 1 ]; then
|
||||||
echo "usage $0 <img_file_name> <package_list>"
|
echo "usage $0 <img_file_name>"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$VERBOSE" == "1" ]; then
|
if [ "$VERBOSE" == "1" ]; then
|
||||||
YUM_OPTS="$YUM_OPTS -q"
|
export YUM_OPTS="$YUM_OPTS -q"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
||||||
INSTALLDIR=`pwd`/mnt/
|
export INSTALLDIR=`pwd`/mnt/
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "-> Preparing instalation of $DIST template..."
|
echo "-> Preparing instalation of $DIST template..."
|
||||||
rm -f keys base_rpms
|
scripts_"${DIST}"/00_prepare.sh
|
||||||
ln -sf keys_$DIST keys
|
|
||||||
ln -sf base_rpms_$DIST base_rpms
|
|
||||||
|
|
||||||
echo "-> Initializing empty image..."
|
echo "-> Initializing empty image..."
|
||||||
truncate -s 10G $IMG || exit 1
|
truncate -s 10G $IMG || exit 1
|
||||||
@ -36,29 +33,18 @@ else
|
|||||||
mkdir -p mnt
|
mkdir -p mnt
|
||||||
mount -o loop $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
|
|
||||||
INSTALLDIR=`pwd`/mnt/
|
export INSTALLDIR=`pwd`/mnt/
|
||||||
|
|
||||||
echo "-> Initializing RPM database..."
|
scripts_"${DIST}"/01_install_core.sh
|
||||||
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/
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mount -t proc proc mnt/proc
|
export PKGGROUPS=$(cat scripts_"${DIST}/packages.list")
|
||||||
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
|
|
||||||
|
|
||||||
umount mnt/proc mnt
|
echo "-> Installing package groups..."
|
||||||
|
scripts_"${DIST}"/02_install_groups.sh
|
||||||
|
|
||||||
|
echo "-> Unmounting fedorized_image..."
|
||||||
|
sudo umount $INSTALLDIR
|
||||||
|
|
||||||
exit $RETCODE
|
exit $RETCODE
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
CLEANIMG=$1
|
export CLEANIMG=$1
|
||||||
NAME=$2
|
export NAME=$2
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -39,26 +39,22 @@ function cleanup() {
|
|||||||
|
|
||||||
trap cleanup ERR
|
trap cleanup ERR
|
||||||
|
|
||||||
IMG=qubeized_images/$NAME-root.img
|
export IMG=qubeized_images/$NAME-root.img
|
||||||
echo "--> Copying $CLEANIMG to $IMG..."
|
echo "--> Copying $CLEANIMG to $IMG..."
|
||||||
|
echo "--> cp could fail with a sparse file error"
|
||||||
cp $CLEANIMG $IMG || exit 1
|
cp $CLEANIMG $IMG || exit 1
|
||||||
|
|
||||||
echo "--> Mouting $IMG"
|
echo "--> Mouting $IMG"
|
||||||
|
|
||||||
mkdir -p mnt
|
mkdir -p mnt
|
||||||
mount -o loop $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
mount -t proc proc mnt/proc
|
export INSTALLDIR=mnt
|
||||||
|
|
||||||
echo "--> Installing RPMs..."
|
scripts_"${DIST}"/04_install_qubes.sh
|
||||||
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
|
|
||||||
|
|
||||||
echo "--> Copying the Apps Menu shortcuts..."
|
echo "--> Copying the Apps Menu shortcuts..."
|
||||||
APPSORIG=qubeized_images/$NAME-apps.orig
|
export APPSORIG=qubeized_images/$NAME-apps.orig
|
||||||
APPSTEMPL=qubeized_images/$NAME-apps.templates
|
export APPSTEMPL=qubeized_images/$NAME-apps.templates
|
||||||
mkdir -p $APPSORIG
|
mkdir -p $APPSORIG
|
||||||
cp -r $(pwd)/mnt/usr/share/applications/* $APPSORIG
|
cp -r $(pwd)/mnt/usr/share/applications/* $APPSORIG
|
||||||
|
|
||||||
@ -87,7 +83,7 @@ if ! [ -r mnt/etc/sysconfig/i18n ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "--> Unmounting $IMG"
|
echo "--> Unmounting $IMG"
|
||||||
umount mnt/proc mnt
|
umount mnt
|
||||||
|
|
||||||
echo "Qubeized image stored at: $IMG"
|
echo "Qubeized image stored at: $IMG"
|
||||||
|
|
||||||
|
@ -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}/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 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.templates
|
||||||
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps
|
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps
|
||||||
|
1
yum_repo_qubes/.gitignore
vendored
1
yum_repo_qubes/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
fc*
|
fc*
|
||||||
|
archlinux*
|
||||||
|
Loading…
Reference in New Issue
Block a user