Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master cauldron by Karsten Behrmann (27cba7011fa20860d831ef55defe026c198c4a10)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Karsten Behrmann <scm AT mail.sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master cauldron by Karsten Behrmann (27cba7011fa20860d831ef55defe026c198c4a10)
  • Date: Fri, 15 Dec 2006 21:39:25 -0600

GIT changes to master cauldron by Karsten Behrmann
<BearPerson AT sourcemage.org>:

iso/generation-scripts/Makefile | 31 ++++++
iso/generation-scripts/README | 26 +++++
iso/generation-scripts/caster | 164 ++++++++++++++++++++++++++-----
iso/generation-scripts/config | 43 +++++++-
iso/generation-scripts/first_build | 9 +
iso/generation-scripts/misc | 1
iso/generation-scripts/mk-smgl-iso | 9 +
iso/generation-scripts/mkinitrd | 53 ++++++++--
iso/generation-scripts/mkiso | 191
++++++++++++++++++++++---------------
iso/generation-scripts/mkprep | 91 +++++++++++++++--
iso/generation-scripts/mkroot | 14 ++
11 files changed, 505 insertions(+), 127 deletions(-)

New commits:
commit 27cba7011fa20860d831ef55defe026c198c4a10
Author: Karsten Behrmann <BearPerson AT sourcemage.org>
Commit: Karsten Behrmann <BearPerson AT sourcemage.org>

Add some documentation and wrapper stuff for ISO generation,
and polish mkroot a bit.

mkroot and the last scripts are still to be documented, but it's
4:30 and I'm tired.

diff --git a/iso/generation-scripts/Makefile b/iso/generation-scripts/Makefile
new file mode 100644
index 0000000..ea2b29d
--- /dev/null
+++ b/iso/generation-scripts/Makefile
@@ -0,0 +1,31 @@
+#set this to e.g. /opt/old-root if you have an old chroot (recommended)
+SOURCE_ROOT=/
+
+DESTINATION_ROOT=/opt/chroot
+
+all: iso
+
+sanitize_source:
+ if [ "${SOURCE_ROOT}" != "/" ] ;then \
+ ./sanitize_chroot ${SOURCE_ROOT} \
+ fi
+
+${DESTINATION_ROOT}: sanitize_source
+ ./mkroot ${SOURCE_ROOT} ${DESTINATION_ROOT}
+
+sanitize_dest: ${DESTINATION_ROOT}
+ ./sanitize_chroot ${DESTINATION_ROOT}
+
+target_copy_files: sanitize_dest
+ ./mkprep ${DESTINATION_ROOT}/root/p4
+ touch target_copy_files
+
+target_create_tarballs: target_copy_files sanitize_dest
+ chroot ${DESTINATION_ROOT} bash -c "cd /root/p4/generation-scripts ;
./first_build"
+ touch target_create_tarballs
+
+iso: target_create_tarballs sanitize_dest
+ chroot ${DESTINATION_ROOT} bash -c "cd /root/p4/generation-scripts ;
./mk-smgl-iso"
+ @echo "phew, we're done. look for the ISO in ${DESTINATION_ROOT}"
+
+.PHONY: sanitize_source sanitize_dest iso
diff --git a/iso/generation-scripts/README b/iso/generation-scripts/README
index 98b275b..cd74519 100644
--- a/iso/generation-scripts/README
+++ b/iso/generation-scripts/README
@@ -1 +1,27 @@
Scripts we use for creating an ISO
+
+To be used from outside the chroot:
+- Makefile: in theory, a "make iso" should let your box rumble for a day,
+ and crank out a fully-built .iso in the end, no manual work
needed
+- config: a bunch of configuration for the ISO
+- mkprep: resolves template stuff in the iso configuration files and copies
+ them into the chroot. Use this to update/install the iso
generation
+ scripts into the chroot
+- mkroot: creates a new chroot
+
+To be used inside the chroot:
+- first_build: build all tarballs needed for the iso
+- mk-smgl-iso: create a .iso from existing tarballs
+- mkinitrd: create only an initrd image
+ (usually called via mk-smgl-iso)
+- mkiso: create a .iso from existing tarballs and initrd image
+ (usually called via mk-smgl-iso)
+
+
+Old cruft, not to be used at all:
+- autoupdate.sh: attempt to update the spells inside the chroot and generate
a
+ new .iso - probably not working too well
+- lint-packages.sh: run inside the chroot to try and find unsatisfied
+ dependencies from spells unpacked to the iso. Might come
in
+ useful every once in a while, but not part of the regular
+ procedure. Should actually work.
diff --git a/iso/generation-scripts/caster b/iso/generation-scripts/caster
index 9401a62..c4124e8 100755
--- a/iso/generation-scripts/caster
+++ b/iso/generation-scripts/caster
@@ -1,58 +1,90 @@
#!/bin/bash
-# Handy little wrapper script for creating cache tarballs
+# This script wraps around cast. It tries to be a little "smarter"
+# to ensure we get good cache tarballs. Technically, we should be
+# able to use cast instead, but this does nice stuff like prevent
+# optional dependencies from automatically turning themselves on.

-# If anything is needed to be run before every cast
-function prepare_cast()
-{
-# rm $(find /etc -not -type d | grep -v -f ~/etcexcluded)
- true
-}

+# This function is called before every cast. It is commonly used for
+# spell-specific workarounds.
function pre_workaround()
{
-# The place for workarounds needed before a spell so it casts nicely.
+
+# this used to be a hack to ensure /etc was clean. This technique was
+# neccessary so spells installed their /etc files properly, as otherwise
+# many refused to overwrite existing files, resulting in those files not
+# getting tracked and not getting included in the binary tarball.
+# rm $(find /etc -not -type d | grep -v -f ~/etcexcluded)
+
case $1 in
+
+ # autoconf fails to find a C++ compiler, even if those spells don't
+ # actually need one. So, we install g++ so they're happy.
+ # TODO: audit this list
"irssi"|"grub"|"lshw"|"parted"|"syslinux"|"syslog-ng"|"uptimed")
- cast g++ # The ole autoconf workaround
+ cast g++
;;
+
+ # this attempts to make the linux build use the settings we want
+ # for the ISO kernel.
"linux")
cp $STATE_DIR/linux.p $DEPENDS_CONFIG/linux.p
cp $STATE_DIR/config-$KVERSION /etc/sorcery/local/kernel.config
rm -f /usr/src/linux-*/.spell-config.p
- ;; #We want to use our preset kernel version and config
+ ;;
+
+ # This directory is protected by sorcery, and thus won't be reaped
+ # automatically. However, we'll want openssh to install all its
+ # /etc files, as otherwise e.g. sshd.conf is missing from the tarball.
"openssh")
rm -rf /etc/ssh
- ;; # The dir is protected by sorcery, it won't reap it by itself
+ ;;
esac
+
true
}

+# If neccessary, undo changes from pre_workaround here, or do other funky
stuff
function post_workaround()
{
true
}

-# Attempts to fetch an install log, either from sorcery or from the cache.
+# This function is part of our spell tracking procedures. It attempts to
+# produce an install log for the given spell on stdout, so that we can
+# notice changes in the files a spell installs (usually bad, unless we're
+# updating)
# Needs the sorcery environment and codex_set_current_spell done before it
function try_get_install_log() {
local rclog=/tmp/install_log_rc.$$
local rc
{
+ # First, get from sorcery, if the spell is currently installed
gaze install $SPELL ||
+ # Next, try finding it in the tarball
tar -xjOf ${INSTALL_CACHE}/${SPELL}-${VERSION}-${HOST}.tar${EXTENSION} \
--occurrence ${INSTALL_LOGS#/}/$SPELL-$VERSION ||
- # try without leading / first
+ # try again with a leading /, for some reason the file sometimes has it
tar -xjOf ${INSTALL_CACHE}/${SPELL}-${VERSION}-${HOST}.tar${EXTENSION} \
--occurrence $INSTALL_LOGS/$SPELL-$VERSION
+
+ # Preserve exit code (this is a subshell, so setting variables won't
work)
echo $? >$rclog
- # This is a subshell. We can't just set a variable.
- # Exit code of a pipe is the exit code of the last command, here: "sort".
+
+ # Ignore tablet, don't include gaze install's "does not exist" message
} 2>/dev/null | grep -v "$TABLET_PATH" | grep -v "does not exist" | sort
+
+ # And grab exit code again
rc=$(cat $rclog)
rm -f $rclog
return $rc
}

+# This function is part of the spell tracking procedure.
+# It will try to remove directory names from the files listed on stdin.
+# We're not interested in directories that don't get installed again,
+# as they are created by extracting the tarball anyway for the files
+# they contain
function filter_dirs() {
local line
while read line ;do
@@ -61,95 +93,160 @@ function filter_dirs() {
done
}

+# Phew. This function is interesting.
+# Attempt to work out if a spell's tarball is out of date and a new version
+# is in the grimoire.
+# As the spell isn't neccessarily installed, we need to fiddle our stuff from
+# the cache tarball (its filename gets passed as $1)
function needs_updating() {
local TMPTABDIR=/tmp/tabletstuff.$$
mkdir -p $TMPTABDIR
- tar -C $TMPTABDIR -xjf "$1" --occurrence \
- 'var/state/sorcery/tablet/*/*/updated' \
- 'var/state/sorcery/tablet/*/*/patchlevel' \
- 'var/state/sorcery/tablet/*/*/security_patch'
+
+ # Try to extract the relevant fields from the tablet saved in the tarball.
+ # As we do not know the exact tablet paths, we put * and rely on tar to
work it out.
+ tar -C $TMPTABDIR -xjf "$1" --occurrence \
+ 'var/state/sorcery/tablet/*/*/updated' \
+ 'var/state/sorcery/tablet/*/*/patchlevel' \
+ 'var/state/sorcery/tablet/*/*/security_patch'
+
CACHE_UPDATED=$(cat $TMPTABDIR/var/state/sorcery/tablet/*/*/updated)
CACHE_PATCHLEVEL=$(cat $TMPTABDIR/var/state/sorcery/tablet/*/*/patchlevel)
CACHE_SECPATCH=$(cat
$TMPTABDIR/var/state/sorcery/tablet/*/*/security_patch)
+
rm -rf $TMPTABDIR
+
+ # If any of those have increased, we need to update.
+ # NOTE: this construction might contain bugs.
[[ ${UPDATED:-0} > ${CACHE_UPDATED:-0} ]] && return 0
[[ ${PATCHLEVEL:-0} > ${CACHE_PATCHLEVEL:-0} ]] && return 0
[[ ${SECURITY_PATCH:-0} > ${CACHE_SECPATCH:-0} ]] && return 0
return 1
}

+
+# ---- execution of script starts here ----
+
if [ "$1" == "-c" ] ;then
RECAST="-c"
shift
fi
+
+# Make sure dirs we need actually exist
mkdir -p ~/broken-logs
-mkdir -p /tmp # Just to be sure
+mkdir -p /tmp
+
+# Load sorcery and our config
. /etc/sorcery/config
. ${0%/*}/config

-# sanity check
+# make sure we actually have a list of spells to keep,
+# or things will go horribly boom.
if ! [ -e $STATE_DIR/list.reqd ] ;then
${0%/*}/listparse
fi

+# Some report files for fancy spell listings
SUCCESS_LIST=/tmp/spell.success.$$
FAIL_LIST=/tmp/spell.fail.$$
CHANGE_LIST=/tmp/spell.change.$$
rm -f $SUCCESS_LIST $FAIL_LIST $CHANGE_LIST
+
+# Main loop, cast each spell from the command line
for spell in "$@" ; do
+
+ # grab everything we need to know about the spell from sorcery
codex_set_current_spell_by_name $spell
cachefile=${INSTALL_CACHE}/${SPELL}-${VERSION}-${HOST}.tar${EXTENSION}

+ # Generate a new tarball if we don't have one yet, have -c specified,
+ # or have an outdated one
if ! test -e $cachefile || [ $RECAST ] || needs_updating $cachefile ;then

+ # Grab old install log if one exists, so we can check for changes
rm -f /tmp/old-install-log /tmp/tmp-install-log
try_get_install_log >/tmp/tmp-install-log || rm /tmp/tmp-install-log

- prepare_cast
+ # Do hacks needed to get this thing to work
pre_workaround $spell
+ # Cast all spells needed to cast $spell, but NOT $spell itself
+ # (this allows cast to extract caches for those spells )
cast --deps $spell
+
+ # Remove caches, so we notice if ARCHIVE=off
rm -f $cachefile
+
+ # Compile the spell itself
cast -c $spell
+
rc=$?
+ # Do post_workaround, no matter what happened
post_workaround $spell
- if ! test -e $cachefile ;then # ARCHIVE=off
+
+ # Test if we did not get a cache file
+ if ! test -e $cachefile ;then
+
+ # If the cast was successful, and there is an install log,
+ # we'll just make the tarball ourselves (ARCHIVE=off)
if [[ $rc == 0 ]] && gaze install $spell >/dev/null ;then
message "Forcing generation of cache"
pushd / >/dev/null
- # This is how current sorcery makes caches (not quite intentional)
+ # This mimicks sorcery's current behavior of making caches.
gaze install-full $spell | sed 's:^/::' |
tar --no-recursion -cjPf $cachefile -T -
popd >/dev/null
fi
fi

+ # If we had an old install log, filter out dirs (we can only do this
+ # once the spell is installed and we're sure the dirs actually exist)
[ -e /tmp/tmp-install-log ] &&
cat /tmp/tmp-install-log | filter_dirs >/tmp/old-install-log
- # filter_dirs only once all the dirs referenced exist

+ # Grab new install log, to compare it against the old one
gaze install $spell >/tmp/tmp-install-log &&
+ # This ">file && cat file |" hack ensures that if gaze install fails,
+ # the commands after it don't get executed.
cat /tmp/tmp-install-log | filter_dirs >/tmp/new-install-log &&
- # again, preserving exit status from gaze install
+
+ # Do we have an old install log, and does it differ from the current one?
if [ -e /tmp/old-install-log ] &&
- ! diff /tmp/old-install-log /tmp/new-install-log >/dev/null ;then
+ ! cmp -s /tmp/old-install-log /tmp/new-install-log ;then
+
message "OOPS... Spell ${SPELL_COLOR}${SPELL}${DEFAULT_COLOR} \
install log suddenly changed..."
+
+ # Save old and new install log, in case we want to see what changed
datestr=$(date +%s)
cp /tmp/old-install-log ~/broken-logs/${SPELL}-${datestr}-pre
cp /tmp/new-install-log ~/broken-logs/${SPELL}-${datestr}-post
echo "$SPELL" >>$CHANGE_LIST
+
elif [[ $rc == 0 ]] ;then
+ # Yay, everything went sweet
echo "$SPELL" >>$SUCCESS_LIST
else
echo "$SPELL" >>$FAIL_LIST
fi ||
- echo "$SPELL" >>$FAIL_LIST # when the gaze install failed
+ # hmm... we just cast a spell, but gaze install $spell fails...
strange.
+ echo "$SPELL" >>$FAIL_LIST
+
rm -f /tmp/new-install-log

+
+ # Now, we finished what we came here for (casting one spell).
+ # We clean up after ourselves and dispel all spells not strictly needed,
+ # so the next spell gets a clean environment.
+
+ # This little thingy grabs all installed spells, compares them against
+ # the 'minimum' spells that actually should stay around all the time,
+ # and gives us all the "superfluous" spells that aren't needed.
SUP_SPELLS=$(
{ cat /var/state/sorcery/packages | cut -d: -f1
cat $STATE_DIR/list.reqd $STATE_DIR/list.reqd ; } |
sort | uniq -u)
+
+ # Quick sanity check: If we're supposed to dispel more than 10 spells,
+ # something is very probably very wrong. Bail.
if [ $( echo "$SUP_SPELLS" | wc -l ) -gt 10 ] ;then
message "${QUERY_COLOR}Whoops! Cleanup wants me to dispel the
following\
spells:${DEFAULT_COLOR}${SPELL_COLOR}"
@@ -159,12 +256,17 @@ spells:${DEFAULT_COLOR}${SPELL_COLOR}"
exit 3
fi
fi
+
+ # If we have spells to dispel, do so.
+ # Leave the /var/state/sorcery/depends entries around, though.
+ # We'll need them for dependency management on the ISO.
if [ -n "$SUP_SPELLS" ] ;then
dispel --no-reap-depends $SUP_SPELLS
fi
fi
done

+# Print pretty cleanse --fix like result
if [ -s $SUCCESS_LIST ] ;then
message "${MESSAGE_COLOR}Spells installed successfully:"
message "------------------------------${SPELL_COLOR}"
@@ -184,6 +286,10 @@ if [ -s $FAIL_LIST ] ;then
message "$DEFAULT_COLOR"
fi

+# This is a hack.
+# When ISOGEN_LOGFILE is set, we write a report there,
+# for the benefit of automated scripts that call this and
+# may want to send report mails.
if [[ $ISOGEN_LOGFILE ]] ;then
{
echo "===== begin caster report ====="
@@ -195,6 +301,6 @@ if [[ $ISOGEN_LOGFILE ]] ;then
column -c 72 $FAIL_LIST
echo "===== end caster report ====="
} >$ISOGEN_LOGFILE
-fi #If we put the redirection here bash tries to apply it even when if is
false
+fi

rm -f $SUCCESS_LIST $FAIL_LIST $CHANGE_LIST
diff --git a/iso/generation-scripts/config b/iso/generation-scripts/config
index 1b6f7bd..08e046b 100755
--- a/iso/generation-scripts/config
+++ b/iso/generation-scripts/config
@@ -1,46 +1,77 @@
#!/bin/bash
+# This file is the main configuration hub for the ISO generation stuff.
+# It should remain in sync with version control. For local changes,
+# create a file /etc/smgl-isogen.conf and overwrite values there.

+# Read local changes
[ -e /etc/smgl-isogen.conf ] && . /etc/smgl-isogen.conf

+# Find out what dir the scripts are in
SCRIPTDIR=${0%/*}
if [[ "${SCRIPTDIR:0:1}" != "/" ]] ;then
SCRIPTDIR=$(pwd)/$SCRIPTDIR # turn into absolute path
fi
+
# all paths should be absolute
CACHE_DIR=/var/cache/sorcery
STATE_DIR=$SCRIPTDIR/../data
SKELETON=$SCRIPTDIR/../skeleton

ISO_BRANCH=${ISO_BRANCH:-devel}
-# Don't worry, that echo runs in a subshell
+
+# Ask sorcery what architecture we're running
+# This is used for finding out what name our tarballs have
ARCH=${ARCH:-$(. /etc/sorcery/config ; echo $HOST)}
+
+# Try to figure out what architecture we are
+# TODO: This is a hack
ISO_ARCH=${ISO_ARCH:-$(uname -m)}
-# FIXME: this is a brutal hack, but the best I could come up with
-# on short notice...
[[ $ISO_ARCH == ppc ]] || [[ $ISO_ARCH == x86_64 ]] || ISO_ARCH=i486
+
+# Sorcery version, Grimoire version, Kernel version
SVERSION=${SVERSION:-test}
GVERSION=${GVERSION:-test}
KVERSION=${KVERSION:-"2.6"}

-# "local" helper variables
+
+# Now, we try to figure out what kernel version we are building for.
+# 1. Find kernel config file
kconf=../data/config-$KVERSION.$ISO_ARCH
[[ -e $kconf ]] || kconf=../data/config-$KVERSION
+# 2. Extract kernel version that we have a config for
def_kv=$(sed -n 's/^# Linux kernel version: //p' $kconf)

+# 3. Set kernel version (unless already set by /etc/smgl-isogen.conf)
KERNEL_VERSION=${KERNEL_VERSION:-$def_kv}
+
+# 4. Figure out kernel major version and patches (for linux.p)
if [[ $KERNEL_VERSION == *.*.*.* ]] ;then
KERNEL_MVERSION=${KERNEL_MVERSION:-${KERNEL_VERSION%.*}}
KERNEL_PATCHES=${KERNEL_PATCHES:-"patch-$KERNEL_VERSION"}
else
KERNEL_MVERSION=${KERNEL_MVERSION:-$KERNEL_VERSION}
- # leave KERNEL_PATCHES unset if unset, otherwise don't change.
fi
+
+# What version should we display on the ISO menus and the .iso filename?
+# NOTE: change this for testing/stable ISOs
ISO_VERSION=${ISO_VERSION:-$ISO_BRANCH-$(cat $STATE_DIR/internal_version)}
+
+# The exact filename we'll crank out

ISO_FILENAME="smgl-${ISO_VERSION%%-*}-$ISO_ARCH-$KERNEL_VERSION-nptl-${ISO_VERSION#*-}.iso"
+
+# Try to keep on going during ISO generation even when steps fail?
+# Helpful for debugging, disable in test branch
IGNORE_FATAL=${IGNORE_FATAL:-yes}

+# What should the dirs used for initrd and ISO be called?
+# The ISO source dir will not be removed at the end of generation,
+# so you have an easy way to see what's on the ISO, for debugging
INITRDROOT=${INITRDROOT:-/theinitrd}
-ISO_DIR=${ISO_DIR:-/iso-root} # kept around for easy debugging
+ISO_DIR=${ISO_DIR:-/iso-root}

+# Where to put dynamically-generated files on the ISO.
+# Do not change this value, as the installer relies on it being this way.
ISO_STATE_DIR=$ISO_DIR/var/lib/smgl.install
+
+# Finally, source some useful helper functions
. $SCRIPTDIR/misc
diff --git a/iso/generation-scripts/first_build
b/iso/generation-scripts/first_build
index cc6161a..c00dab0 100755
--- a/iso/generation-scripts/first_build
+++ b/iso/generation-scripts/first_build
@@ -1,4 +1,13 @@
#!/bin/bash
+# This script attempts to automatically build all tarballs we need for the
ISO
+
+# First, grab configuration, fwiw
. ${0%/*}/config
+
+# Generate lists of spells we need tarballs of,
+# and of spells that shouldn't get dispelled
${0%/*}/listparse
+
+# First cast all critical spells (for the sake of paranoia),
+# then create all tarballs we need
${0%/*}/caster -c $( cat $STATE_DIR/list.reqd $STATE_DIR/list.all )
diff --git a/iso/generation-scripts/misc b/iso/generation-scripts/misc
index 74a1d08..bc98b40 100755
--- a/iso/generation-scripts/misc
+++ b/iso/generation-scripts/misc
@@ -1,4 +1,5 @@
#!/bin/bash
+# Some little helpers

output_warning()
{
diff --git a/iso/generation-scripts/mk-smgl-iso
b/iso/generation-scripts/mk-smgl-iso
index f13fd93..fcc93e3 100755
--- a/iso/generation-scripts/mk-smgl-iso
+++ b/iso/generation-scripts/mk-smgl-iso
@@ -1,8 +1,17 @@
#!/bin/bash
+# This is a little wrapper script to generate an ISO from inside a chroot
+# with existing tarballs.
+
+# Grab config
. ${0%/*}/config
+
+# Cast all spells we said we'd need
echo "checking for spells required for the generation process..."
while read -u 3 spell ; do
gaze installed $spell || cast $spell
done 3<$STATE_DIR/smgl.genspells
+
+# Make initrd image
./mkinitrd
+# Make iso image
./mkiso
diff --git a/iso/generation-scripts/mkinitrd b/iso/generation-scripts/mkinitrd
index a43eebd..670b483 100755
--- a/iso/generation-scripts/mkinitrd
+++ b/iso/generation-scripts/mkinitrd
@@ -1,10 +1,12 @@
#!/bin/bash
+# This script will crank out an initrd image for the ISO to use.

#---------------------------------------------------------------------
## @param full path of binary to check
## @Stdout libraries with full path
## echos all libs that the given file is linked against (not ld-linux)
#---------------------------------------------------------------------
+# Used to implicitly install linked-against-libs to the initrd with a binary
function libscan() {
ldd "$1" 2> /dev/null |
cut -d'>' -f2 |
@@ -19,8 +21,12 @@ function libscan() {
function install_prog() {
local prog progpath
for prog in $* ;do
+ # find executable
+ # TODO: check if we can use type -p here and avoid dependency on which
progpath=$( which $prog ) &&
+ # install executable
cp --parents -f $progpath $INITRDROOT &&
+ # install needed libs
cp --parents -f $( libscan $progpath ) $INITRDROOT
done
}
@@ -35,15 +41,20 @@ function install_prog() {
#---------------------------------------------------------------------
function mk_initrd_file() {
local initrd_size tmp_file tmp_mountdir
+
+ # Measure size of the initrd files, add 20% for e2fs overhead and safety
initrd_size=$(du -ks ${INITRDROOT} | cut -d$'\t' -f1)
- initrd_size="$(( initrd_size / 5 + initrd_size ))" # add 20% to allow for
e2fs
+ initrd_size="$(( initrd_size / 5 + initrd_size ))"
+
tmp_file="/tmp/initrd.$$"
tmp_mountdir="/tmp/initrdmpoint.$$"

rm -rf $tmp_file $tmp_mountdir
+ # Create initrd file and filesystem
dd if=/dev/zero of=$tmp_file bs=1024 count=$initrd_size
mke2fs -q -b 1024 -i 1024 -F $tmp_file

+ # Copy stuff into image
mkdir -p $tmp_mountdir
mount $tmp_file $tmp_mountdir -o loop
cp -a $1/* $tmp_mountdir
@@ -51,66 +62,92 @@ function mk_initrd_file() {

gzip -c $tmp_file >$2

- # Store size for inclusion in bootloader configs
+ # We'll need the unpacked size for the bootloader config,
+ # as it'll want to know how much memory to allocate for the initrd
echo "${initrd_size}" >${2%.gz}.size

rm -rf $tmp_file $tmp_mountdir
echo "initrd is compressed $(du -ks $2 | cut -d$'\t' -f1)K, uncompressed
${initrd_size}K."
}

+
+# ---- actual script starts here ----
+
+# grab config
. ${0%/*}/config
OLDWD=$(pwd)

rm -rf $INITRDROOT
mkdir -p $INITRDROOT

+# Create all dirs we need on the initrd
while read line ; do
mkdir -p ${INITRDROOT}/${line}
done <${STATE_DIR}/initrd.dirs

+# Copy files onto the initrd that we need.
+# Locating in and extracting from tarballs would be a pain,
+# so we just use the current system (chroot)
while read line ; do
+
+ # If it has a leading /, treat it as a single file
if [[ ${line:0:1} == '/' ]] ;then
cp -a --parents ${line} ${INITRDROOT}
+
+ # Otherwise, it's a binary, find it and install its libs too
else
install_prog $line
fi
done <${STATE_DIR}/initrd.files
+
+# Copy the dynamic loader over
cp --parents /lib/ld-2.* $INITRDROOT
-# the ld-linux symlink is made by ldconfig later

+# Create a static /dev
pushd $INITRDROOT/dev >/dev/null
$SKELETON/sbin/MAKEDEV generic-nopty
popd >/dev/null

+# Add kernel modules that are supposed to be on the iso
+mkdir -p ${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
pushd /lib/modules/${KERNEL_VERSION}/kernel >/dev/null
- mkdir -p ${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
while read line ; do
cp -pr --parents ./${line}
${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
-# 2>/dev/null #no error if what we're copying isn't in the kernel
- # remove this when you're making an official ISO - we are.
done <${STATE_DIR}/initrd.kernel
popd >/dev/null
+
+# Copy module listing and other files the kernel needs, omit dirs though
cp -dp --parents /lib/modules/$KERNEL_VERSION/* $INITRDROOT 2>/dev/null
-# modules.*map etc. ; /dev/null to omit "is a directory" warning for modules/

+# Finally, copy everything from the skeleton on top
cp -af ${SKELETON}/initrd/* ${INITRDROOT}

+# This is a dusty old hook. If needed, you can write a .patch file
+# that will get applied to the initrd before generation
[ -e ${STATE_DIR}/initrd.patch ] &&
patch -d ${INITRDROOT} -p0 <${STATE_DIR}/initrd.patch

+# Set up linker caches and symlinks
cp /sbin/ldconfig ${INITRDROOT}
chroot ${INITRDROOT} /ldconfig
rm ${INITRDROOT}/ldconfig

-# Backwards-compatible with 2.4 with .old files
+# create module dependencies. For whatever it's worth,
+# we're 2.4-compatible here and copy depmod.old too, if we have it
cp /sbin/depmod /sbin/depmod.old ${INITRDROOT}
chroot ${INITRDROOT} /depmod ${KERNEL_VERSION}
rm -f ${INITRDROOT}/depmod ${INITRDROOT}/depmod.old

+# Another dusty hook... If needed, you can add a script that will get run
+# just before the initrd is generated. You could as well just add code here,
+# though.
[ -x ${STATE_DIR}/initrd.command ] &&
. ${STATE_DIR}/initrd.command

+
# The initrd is complete now.

mk_initrd_file $INITRDROOT $STATE_DIR/initrd.gz
+
+
rm -rf ${INITRDROOT}
diff --git a/iso/generation-scripts/mkiso b/iso/generation-scripts/mkiso
index d116df6..85b9313 100755
--- a/iso/generation-scripts/mkiso
+++ b/iso/generation-scripts/mkiso
@@ -1,4 +1,10 @@
#!/bin/bash
+# This file generates the actual .iso file.
+# It's a bit lengthy, but manageable.
+
+
+# Let's start with a little trick. The iso.packages file actually is a
+# bash script, here we define the functions called from there.

#=====================================================================
## BEGIN of functions called from iso.packages
@@ -6,7 +12,7 @@

#---------------------------------------------------------------------
## @param file pattern to include by default
-## Adds the given pattern to the list of default includes
+## Makes the given pattern be copied to the iso, overriding default_exclude
#---------------------------------------------------------------------
function add_default_include() {
DEF_INCLUDE[${#DEF_INCLUDE[*]}]="$1"
@@ -14,7 +20,7 @@ function add_default_include() {

#---------------------------------------------------------------------
## @param file pattern to exclude by default
-## Adds the given pattern to the list of default excludes
+## Makes the given pattern be not included on the iso, unless overridden
#---------------------------------------------------------------------
function add_default_exclude() {
DEF_EXCLUDE[${#DEF_EXCLUDE[*]}]="$1"
@@ -25,8 +31,7 @@ function add_default_exclude() {
## @Description
## This is the main unpacking function to use when installing stuff
## onto the ISO. Specify the spell name and the spell will be
-## automatically unpacked to the ISO with default excludes and
-## includes honored.
+## automatically unpacked to the ISO. Dependency tracking is not done.
#---------------------------------------------------------------------
function unpack() {
begin_unpack "$1"
@@ -36,17 +41,20 @@ function unpack() {
#---------------------------------------------------------------------
## @param spell to unpack
## @Description
-## This function unpacks the given spell to a temporary location to
-## prepare for its installation.
+## This function prepares a spell to be installed
#---------------------------------------------------------------------
function begin_unpack() {
local file
+
+ # Clean up old unpack, if needed
if [ -e $UNPACK_DIR ] ;then
output_warning "An old unpack failed. Flushing the toilet."
rm -rf $UNPACK_DIR
fi
mkdir $UNPACK_DIR
- copy_fromver $1 ${UNPACK_DIR} &&
+
+ # Extract tarball to a temporary location
+ unpack_spell $1 ${UNPACK_DIR} &&
echo $1 >${TMP_DIR}/unpack_successful ||
echo "unpacking \"$1\" failed."
}
@@ -59,22 +67,29 @@ function begin_unpack() {
#---------------------------------------------------------------------
function end_unpack() {
local entry
+
+ # Copy files that should be copied in any case
for entry in "${DEF_INCLUDE[@]}" ;do
iso_include "$entry"
done
+ # Remove files that should not be copied
for entry in "${DEF_EXCLUDE[@]}" ;do
iso_exclude "$entry"
done

+ # Copy everything else, warn if there's nothing to copy
if [ -e ${TMP_DIR}/unpack_successful ] ;then
if ! cp -au ${UNPACK_DIR}/* ${ISO_DIR} 2>/dev/null ;then
echo -n "nothing to be done for "
cat ${TMP_DIR}/unpack_successful
fi
rm ${TMP_DIR}/unpack_successful
+
+ # Hmm, the unpack went boom. bad.
else
fatal_warning "The unpack failed. Can't install to ISO"
fi
+
rm -rf ${UNPACK_DIR}
}

@@ -116,17 +131,21 @@ function iso_exclude() {
## END of functions called from iso.packages
#=====================================================================

+
+# Okay, now some helper functions for installing and copying spells
+
#---------------------------------------------------------------------
## @param spell to unpack
## @param location to unpack to
## @Description
## Attempts to find and unpack the binary cache of the given spell
#---------------------------------------------------------------------
-function copy_fromver() {
+function unpack_spell() {
if [ -e $CACHE_DIR/$1-$(get_ver_from_codex $1)-$ARCH.tar.bz2 ] ;then
tar -xjf $CACHE_DIR/$1-$(get_ver_from_codex $1)-$ARCH.tar.bz2 -C $2
else
- copy_fromlog "$@"
+ fatal_warning "Unable to unpack $1: No tarball found"
+ return 1
fi
}

@@ -137,11 +156,12 @@ function copy_fromver() {
## Attempts to copy the binary cache of the given spell to the given
## location.
#---------------------------------------------------------------------
-function package_fromver() {
+function copy_spell_tarball() {
if [ -e $CACHE_DIR/$1-$(get_ver_from_codex $1)-$ARCH.tar.bz2 ] ;then
cp $CACHE_DIR/$1-$(get_ver_from_codex $1)-$ARCH.tar.bz2 $2
else
- package_fromlog "$@"
+ fatal_warning "Unable to copy tarball for $1: No tarball found"
+ return 1
fi
}

@@ -157,93 +177,75 @@ function get_ver_from_codex() {
)
}

-#---------------------------------------------------------------------
-## @param spell name
-## @param location to copy to
-## As a fallback to copy_fromver, copy all files mentioned in the
-## install log to the given location.
-#---------------------------------------------------------------------
-function copy_fromlog() {
- if gaze install $1 >/dev/null ;then
- output_warning "Using installed files for $1."
- gaze install $1 |
- xargs cp -dp --parents --target-directory $2 2>/dev/null
- # NOT -r !!! we don't want to copy all of /usr/share/man if our spell
- # happens to be the first one to create it
- else
- fatal_warning "No way to copy $1: no trace of it could be found."
- return 1
- fi
-}
-
-#---------------------------------------------------------------------
-## @param spell name
-## @param location to create the archive in
-## Fallback to package_fromver, create a binary cache from all files
-## mentioned in the install log.
-#---------------------------------------------------------------------
-function package_fromlog() {
- if gaze install $1 >/dev/null;then
- output_warning "Using installed files for $1."
- gaze install $1 |
- tar --no-recursion -cjf "$2/$1-ISO-$ARCH.tar.bz2" -T -
- else
- fatal_warning "No way to install $1: no trace of it could be found."
- return 1
- fi
-}

#---------------------------------------------------------------------
## @Description
-## This function is the chaos container for all the complicated code
-## needed to set up the environment and the variable files that the
-## installer wants generated.
-##
-## It copies the grimoire and sorcery packages and the linux sources
+## This function contains all the code for the dynamically-generated
+## files the installer needs.
##
-## It also generates the list of descriptions for the optional spell
-## list.
+## It also copies the grimoire and sorcery packages and the linux sources
##
-## Finally, it creates the packages and the conflicts file.
#---------------------------------------------------------------------
function create_statefiles() {
- cp ${STATE_DIR}/../../$GVERSION.tar.bz2 ${ISO_DIR}/var/lib/sorcery/codex
- cp ${STATE_DIR}/../../sorcery-$SVERSION.tar.bz2
${ISO_DIR}/var/cache/sorcery
+
+ # Copy codex and sorcery
+ cp ${STATE_DIR}/../../$GVERSION.tar.bz2 ${ISO_DIR}/var/lib/sorcery/codex/
+ cp ${STATE_DIR}/../../sorcery-$SVERSION.tar.bz2
${ISO_DIR}/var/cache/sorcery/
+
+ # Copy linux sources
pushd /var/spool/sorcery >/dev/null
cp $( summon -p source linux) ${ISO_DIR}/var/spool/sorcery
popd >/dev/null

+
+ # Generate spell descriptions and all the other goodies displayed in the
+ # optional spell menu, also track spell conflicts
echo "Pre-generating optional spell list..."
- (
+ ( # Subshell, so we don't mess up the caller's environment
. /etc/sorcery/config

+ # Get a list of all optional spells
cat ${STATE_DIR}/optional-list | sed -e 's/#.*$//' -e
's/[[:blank:]]*$//' |
grep -v '^$' >$TMP_DIR/optlist
+
+ # Write out data for the optional spell menu (grabbed from sorcery)
while read spell ; do
codex_set_current_spell_by_name $spell >/dev/null
echo "\"$spell\" \"$VERSION\" \"off\" \"$SHORT\""
done <$TMP_DIR/optlist >${ISO_STATE_DIR}/optionalSpellList
rm -f $TMP_DIR/optlist

+ # Tricky hack: We redefine an internal sorcery function, hoping that the
+ # CONFLICTS files are simple and just give us the conflicting spells
+ # nicely on stdout this way
function conflicts() { #redefinition
echo "$SPELL:$1"
}
+
+ # Generate spell list and conflicts list
while read spell ; do
+
+ # get spell data
codex_set_current_spell_by_name $spell >/dev/null
+
+ # Generate packages list, with a pretend install date of "right now".
echo "$SPELL:$(date +%Y%m%d):installed:$VERSION" \
>>$ISO_DIR/var/state/sorcery/packages
- # We cannot use the host system's /var/state/sorcery/packages,
- # as it does not have all the spells on the ISO installed at once

+ # Gather conflicts data, if possible
[ -x $SPELL_DIRECTORY/CONFLICTS ] &&
. $SPELL_DIRECTORY/CONFLICTS
>>$ISO_DIR/var/lib/smgl.install/conflicts

+ # The allspells file has been generated before we were called
done <$TMP_DIR/allspells
- # $TMP_DIR/allspells has been generated just before we copied cache files
)

+ # Add dependencies. Append, in case we want to "hardcode" some dependencies
+ # in the skeleton tree
cat $TMP_DIR/alldeps >>$ISO_DIR/var/state/sorcery/depends

+
+ # Generate listings for the NLS menus
echo "generating other pre-made lists..."
pushd $ISO_DIR >/dev/null

@@ -252,7 +254,7 @@ function create_statefiles() {
find usr/share/keymaps -type f -not -path '*/include/*' |
sed -e 's@^usr/share/keymaps/@@' -e 's@\.k\?map\.gz@@' |
sort |
- while read line ;do #SUBSHELL
+ while read line ;do
echo "${line##*/}" #keymap name
echo "${line%/*}" #path leading up to it, e.g. "qwerty"
done >>$ISO_STATE_DIR/keyMapList
@@ -273,51 +275,67 @@ function create_statefiles() {
find usr/share/zoneinfo -mindepth 1 -type d -printf '/%h:%f:Directory\n' \
>>$ISO_STATE_DIR/timeZoneList
find usr/share/zoneinfo -type f |
- while read line ;do #SUBSHELL
+ while read line ;do
echo "/${line%/*}:${line##*/}:$(TZ="$ISO_DIR/$line" date +%z)"
done >>$ISO_STATE_DIR/timeZoneList

popd >/dev/null
}

+
#---------------------------------------------------------------------
## @Description
-## This function creates a list of all spells that could get installed
-## by the ISO, as specified by install-list and optional-list.
+## This function runs through all spells that will have tarballs
+## on the iso, and includes their dependencies.
##
-## It also tracks dependencies and automatically adds dependencies to
-## the list too. It then prunes the depends file down to the parts
-## relevant for us and stores it.
+## It also prunes the depends file down to what we actually need
##
## The list of spells is stored in $TMP_DIR/allspells, all depends
## go into $TMP_DIR/alldeps
#---------------------------------------------------------------------
function generate_sufficient_spells_list() {
+
+ # Grab all spells
cat ${STATE_DIR}/optional-list ${STATE_DIR}/install-list |
filter_comments >$TMP_DIR/allspells
+
NUM_LINES=0
> $TMP_DIR/alldeps
+
+ # This loop will keep adding "dependencies of all spells in the list"
+ # to the list, so that we include multiple levels of dependencies.
+ # It terminates when the number of spells in the list no longer increases
+ # (as this means we didn't find any new dependencies)
while [ "$NUM_LINES" != "$(wc -l $TMP_DIR/allspells)" ] ;do
+
+ # Save new line count
NUM_LINES=$(wc -l $TMP_DIR/allspells)
- # When nothing here sees new spells, stop.
- # The last run will include their depends info
+
+ # Grab dependencies
local spell
while read spell ;do
grep "^$spell:[^:]*:on" /var/state/sorcery/depends
done <$TMP_DIR/allspells >$TMP_DIR/moredeps
+
+ # Parse depended-upon spells, remove the (FOO) construct for providers
cat $TMP_DIR/moredeps | cut -d: -f2 | sed 's/(.*$//' >$TMP_DIR/morespells
- # The sed kills (BOOTLOADER) etc.
+
+ # Add new dependency data, remove duplicates
mv $TMP_DIR/alldeps $TMP_DIR/olddeps
cat $TMP_DIR/olddeps $TMP_DIR/moredeps | sort -u >$TMP_DIR/alldeps
rm -f $TMP_DIR/olddeps $TMP_DIR/moredeps

+ # Add new spells to the list, remove duplicates
mv $TMP_DIR/allspells $TMP_DIR/oldspells
cat $TMP_DIR/oldspells $TMP_DIR/morespells | sort -u >$TMP_DIR/allspells
rm -f $TMP_DIR/oldspells $TMP_DIR/morespells

done # repeat until number of lines does not change anymore
+
+ # Result files are already where they belong.
}

+
#---------------------------------------------------------------------
## @stdin stream of text with comments
## @stdout same stream with comments, trailing whitespace and empty lines
stripped.
@@ -327,8 +345,13 @@ function filter_comments() {
sed -e 's/#.*$//' -e 's/[[:blank:]]*$//' | grep -v '^$'
}

+
+
+# ---- actual script starts here ----
+
. ${0%/*}/config

+# cleanup/setup
rm -rf ${ISO_DIR}
mkdir -p $ISO_DIR
TMP_DIR="/tmp/mkiso.$$"
@@ -340,12 +363,16 @@ declare -a DEF_EXCLUDE

echo "Creating ISO file structure..."

+# Create dirs
while read line ; do
mkdir -p ${ISO_DIR}/${line}
done <${STATE_DIR}/iso.dirs

+# Install (unpack) packages needed
. ${STATE_DIR}/iso.packages

+# Create static /dev, and the pipe init needs
+# (it normally creates it on bootup, but that's hard on a read-only iso9660
fs)
pushd $ISO_DIR/dev >/dev/null
$SKELETON/sbin/MAKEDEV generic-nopty md
mknod initctl p
@@ -356,41 +383,57 @@ cp ${STATE_DIR}/initrd.gz $ISO_DIR/boot/
echo "Copying cache tarballs..."

generate_sufficient_spells_list
+
+# Copy tarballs the installer will be able to install
while read spell ; do
- package_fromver $spell ${ISO_DIR}/var/cache/sorcery/
+ copy_spell_tarball $spell ${ISO_DIR}/var/cache/sorcery/
done <${TMP_DIR}/allspells

+
+# Finally, add the skeleton files on top (except for the initrd)
+# TODO: is a find construct with -prune cleaner?
pushd $SKELETON >/dev/null
cp -af --parents $(find * -maxdepth 0 ! -name initrd) $ISO_DIR
popd >/dev/null

+# Same dusty old hook as in mkiso, allow for a "patch file" for last-minute
mods
[ -e ${STATE_DIR}/iso.patch ] &&
patch -d $ISO_DIR -p0 ${STATE_DIR}/iso.patch

+# Create library caches and symlinks
cp /sbin/ldconfig ${ISO_DIR}
chroot ${ISO_DIR} /ldconfig
rm ${ISO_DIR}/ldconfig

+# Create module tables (and be compatible to 2.4 kernels, fwiw)
cp /sbin/depmod /sbin/depmod.old ${ISO_DIR}
chroot ${ISO_DIR} /depmod $KERNEL_VERSION
rm ${ISO_DIR}/depmod ${ISO_DIR}/depmod.old

-# symlinks would be pointing to ${INSTALL_ROOT} if we used that feature
-# have to run after ldconfig so everything finds its libs
+
+# Install sorcery
mkdir ${ISO_DIR}/tmpsorcery
tar -C ${ISO_DIR}/tmpsorcery -xjf
${STATE_DIR}/../../sorcery-$SVERSION.tar.bz2
chroot ${ISO_DIR} sh -c "cd /tmpsorcery/sorcery ; ./install"
rm -r ${ISO_DIR}/tmpsorcery

+
echo "Generating installer-related files"
create_statefiles

+
+# Command hook (this is actually used here)
+# This does some fixes, and puts the initrd size and grimoire version
+# into the bootloader config files
[ -e ${STATE_DIR}/iso.command ] &&
. ${STATE_DIR}/iso.command

rm -r ${TMP_DIR}

-# all ready
+# all systems ready
echo "generating ISO, outputting to /$ISO_FILENAME"
+
+
# ISO ends up in the / directory of the chroot
+# This last script calls mkisofs with the correct arguments for our arch.
. ${STATE_DIR}/iso.mkfscommand /$ISO_FILENAME $ISO_DIR
diff --git a/iso/generation-scripts/mkprep b/iso/generation-scripts/mkprep
index cc09240..c3092e9 100755
--- a/iso/generation-scripts/mkprep
+++ b/iso/generation-scripts/mkprep
@@ -1,12 +1,19 @@
#!/bin/bash
+# This script processes the template replacement system in the ISO
configuration
+# data and copies the iso scripts and data into the chroot
+
+# Pick up config
SCRIPTDIR=${0%/*}
. $SCRIPTDIR/config

+
if [ $# -lt 1 ] || [[ "$1" == "/" ]] ;then
echo "usage: $0 <path_to_p4_in_chroot>"
exit 1
fi

+
+# Sanity check - maybe we should change this pathname sometime...
if [[ ${1: -8} != "/root/p4" ]] ;then
echo "WARNING! The parameter of this script ($1) is supposed to be"
echo "the directory where the scripts should be copied to. The recommended"
@@ -18,42 +25,84 @@ if [[ ${1: -8} != "/root/p4" ]] ;then
[[ "$SANITY" == "y" ]] || exit 2
fi

+
+# We now get to the template processing functions.
+
+# This processes a "multifile" template. That is, given a filename (e.g.
+# data/config-2.6) and one or more suffixes (e.g. 'ppc'), it will choose
+# the "most specific" file that exists (that is, data/config-2.6.ppc if it
+# exists, otherwise data/config-2.6). This mechanism can be used if a
+# file differs radically between architectures.
+#
+# If under a certain architecture a file/path should _not_ exist, add a
+# symlink to "no/../op" as the file for that arch. An example for this
+# mechanism is the skeleton/isolinux dir on the ppc architecture.
function choose_multi()
{
local basicname foundname tempname
+
if [[ -z $1 ]] ;then
echo "choose_multi called on no file!"
return 1
fi # Things get really evil otherwise
+
basicname="$1"
tempname="$1"
shift
+
+ # We will now "build" the fully specialized filename,
+ # and keep the most specific file we find
while [ $# -gt 0 ] ;do
+ # Add next suffix
tempname="${tempname}.$1"
+ # Does it exist? (dead symlink counts as "exists")
[[ -L "$tempname" ]] || [[ -e "$tempname" ]] && foundname="$tempname"
- # Symlinks into nowhere need to be caught too
shift
done
+
+ # Did we find something?
if [[ "$foundname" ]] ;then
+ # Remove the base file/dir, if it exists
rm -rf "$basicname"
+ # Move us there
mv "$foundname" "$basicname"
fi
+
+ # Remove all other specializations
rm -rf "$basicname".*
+
+ # Are we the special "blow this away" symlink?
if [[ "$(readlink $basicname)" == "no/../op" ]] ;then
rm -f "$basicname"
fi
}

+
+# This function will scan a given file for 'templates', that is, special
+# strings that should be replaced (e.g. by the iso version), or lines that
+# should be removed/added only in specific architectures.
+# There once was a wiki page on this, but it got lost in our hd crash...
function process_templates()
{
local pattern
local line
- [[ -e "$1" ]] || return #Files not existing throws ugly errors here...
+
+ # Check if the file actually exists, if not, we get ugly errors here
+ [[ -e "$1" ]] || return
+
cp "$1" ${TMP_DIR}/tmp.template
+
+ # Apply each pattern replacement in data/smgl.patterns
while read line ; do
+ # We use eval so $VARIABLE expressions in the replacement work
eval pattern="$line"
+
sed -i "s/$pattern/g" ${TMP_DIR}/tmp.template
+
done <${STATE_DIR}/smgl.patterns
+
+ # Now, filter out the lines we don't want,
+ # remove the template markers on those that we do
cat ${TMP_DIR}/tmp.template |
grep -v "^__SMGL_TEMPLATE_NOT_${ISO_ARCH}__" |
grep -v "^__SMGL_TEMPLATE_NOT_${ISO_BRANCH}__" |
@@ -61,51 +110,73 @@ function process_templates()
sed "s/^__SMGL_TEMPLATE_ONLY_${ISO_ARCH}__//" |
sed "s/^__SMGL_TEMPLATE_ONLY_${ISO_BRANCH}__//" |
grep -v "^__SMGL_TEMPLATE_ONLY_[^_]*__" >"$1"
+ # we write the result to the file right ^^^^^ here
+
rm ${TMP_DIR}/tmp.template
}

+
+
+# ---- real script starts here ----
+
+# Clean up target dir
rm -rf $1
mkdir -p $1
+
+# Copy in our files
cp -a --no-preserve=ownership $SCRIPTDIR/../* $1

-# redefine
+# redefine from config to point to the to-be-created dirs
STATE_DIR=$1/data
SKELETON=$1/skeleton
SCRIPTS=$1/generation-scripts

+# Add changelog to skeleton
cp -a --no-preserve=ownership $SCRIPTDIR/../../ChangeLog $SKELETON
+
+# Add smgl-isogen.conf, if we have one
[[ -e /etc/smgl-isogen.conf ]] && cp /etc/smgl-isogen.conf $1/../../etc/
+
+# Create config for inside the chroot
{
+ # Fix ISO_VERSION to a nonchanging value (you get fun when it's defined
+ # dynamically via $(date) and it changes in the middle of generation)
echo "ISO_VERSION=$ISO_VERSION"
- # Set ISO version to version of copy
- # (avoiding different $(date)'s for templates->files and the .iso file)
+
cat $SCRIPTDIR/config
} >$SCRIPTS/config

+
+# As we would not have a chance to specify so otherwise,
+# process the list of multi-files / templated files for templates.
choose_multi $STATE_DIR/smgl.multi $ISO_ARCH
choose_multi $STATE_DIR/smgl.templated $ISO_ARCH
choose_multi $STATE_DIR/smgl.patterns $ISO_ARCH
process_templates $STATE_DIR/smgl.multi
process_templates $STATE_DIR/smgl.templated
+# Don't replace the patterns in the pattern replacement file though ;-)
+

+# Process multi files
while read line ;do
eval choose_multi $line
- # so $SKELETON etc. get a chance to expand
done <$STATE_DIR/smgl.multi

+
+# Process templates
while read line ;do
eval help="$line"
process_templates "$help"
done <$STATE_DIR/smgl.templated

-#if ! [ -e ${STATE_DIR}/linux-ISO.tar.bz2 ] ;then
-# echo "Missing a linux tarball for the ISO, generating one"
-# gaze install linux | tar --no-recursion -cjf
${STATE_DIR}/linux-ISO.tar.bz2 -T -
-#fi
+
+# Grab a new grimoire tarball if needed
if ! [ -e $1/../$GVERSION.tar.bz2 ] ;then
echo "Missing grimoire tarball, fetching..."
wget -O $1/../$GVERSION.tar.bz2
"http://codex.sourcemage.org/$GVERSION.tar.bz2";
fi
+
+# Ditto for sorcery
if ! [ -e $1/../sorcery-$SVERSION.tar.bz2 ] ;then
echo "Missing sorcery tarball, getting..."
wget -O $1/../sorcery-$SVERSION.tar.bz2
"http://download.sourcemage.org/sorcery/sorcery-$SVERSION.tar.bz2";
diff --git a/iso/generation-scripts/mkroot b/iso/generation-scripts/mkroot
index 5b77e31..6ecce50 100755
--- a/iso/generation-scripts/mkroot
+++ b/iso/generation-scripts/mkroot
@@ -22,8 +22,22 @@ pushd $1/new-root
mkdir -p proc dev sys tmp var/spool/sorcery
cd dev
$1/var/lib/sorcery/codex/*/smgl/init.d/MAKEDEV generic
+cd ..
+
+cp /etc/resolv.conf $1/new-root/etc/
+cp -a $SCRIPTDIR/../skeleton/etc/{nsswitch.conf,passwd,shadow,group}
$1/new-root/etc/
+
+cd tmp
+wget http://download.sourcemage.org/sorcery/sorcery-$SVERSION.tar.bz2
+tar -xjf sorcery-$SVERSION.tar.bz2
+
+chroot $1/new-root bash -c 'cd /tmp/sorcery ; ./install'
+
+rm -r sorcery*
+chroot $1/new-root scribe add $GVERSION

popd
+
mkdir -p $2
rmdir $2 &&
mv $1/new-root $2



  • [SM-Commit] GIT changes to master cauldron by Karsten Behrmann (27cba7011fa20860d831ef55defe026c198c4a10), Karsten Behrmann, 12/15/2006

Archive powered by MHonArc 2.6.24.

Top of Page