Giant directory of the old scripts.

Placed here for reference as to what remains to be done.

The orig/ subdir is the unmodified tools from anaconda.  The scratch/
subdir is a merge of orig in to a working area.  I delete blocks of
code from there as I rewrite them.
This commit is contained in:
David Cantrell 2008-10-04 18:52:23 -10:00
parent bbf732c9e1
commit 2aef98cb23
38 changed files with 7069 additions and 0 deletions

213
rewrite/orig/scripts/buildinstall Executable file
View File

@ -0,0 +1,213 @@
#!/bin/bash
#
# buildinstall
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
usage() {
echo "Usage: buildinstall --version <version> --product <product> --release <comment> [--output outputdir] [--discs <discstring>] <root>" >&2
exit 1
}
PRODUCTPATH="anaconda"
while [ $# -gt 0 ]; do
case $1 in
# general options affecting how we build things
--nogr)
NOGRSTR="--nogr"
shift
;;
--debug)
DEBUGSTR="--debug"
shift
;;
# release information
--version)
VERSION=$2
shift; shift
;;
--release)
RELEASESTR=$2
shift; shift
;;
--product)
PRODUCTSTR=$2
shift; shift
;;
--variant)
VARIANT=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
OUTPUT=$2
shift; shift
;;
--updates)
UPDATES=$2
shift; shift
;;
--mirrorlist)
MIRRORLIST="$MIRRORLIST $2"
shift; shift
;;
*)
if [ -z "$REPO" ]; then
REPO=$1
else
EXTRA_REPOS="$EXTRA_REPOS $1"
fi
shift
;;
esac
done
if [ -z "$PRODUCTSTR" ]; then
usage
fi
if [ -z "$VERSION" ]; then
usage
fi
if [ -z "$REPO" ]; then
usage
fi
if [ -z "$RELEASESTR" ]; then
usage
fi
if [ -z "$BUGURL" ]; then
BUGURL="your distribution provided bug reporting tool."
fi
if [[ "$REPO" =~ ^/ ]]; then
[ -n "$OUTPUT" ] || OUTPUT=$REPO
REPO="file://$REPO"
fi
if [ -z "$OUTPUT" ]; then
usage
fi
if [ ! -d "$OUTPUT" ]; then
mkdir -p $OUTPUT
fi
BUILDINSTDIR=$(mktemp -d ${TMPDIR:-/tmp}/buildinstall.tree.XXXXXX)
TREEDIR=$(mktemp -d ${TMPDIR:-/tmp}/treedir.XXXXXX)
CACHEDIR=$(mktemp -d ${TMPDIR:-/tmp}/yumcache.XXXXXX)
yumconf=$(mktemp ${TMPDIR:-/tmp}/yum.conf.XXXXXX)
cat > $yumconf <<EOF
[main]
cachedir=$CACHEDIR
keepcache=0
gpgcheck=0
plugins=0
reposdir=
tsflags=nodocs
[anacondarepo]
name=anaconda repo
baseurl=$REPO
enabled=1
EOF
n=1
for r in $EXTRA_REPOS; do
if [[ $r =~ ^/ ]]; then
r="file://$r"
fi
cat >> $yumconf <<EOF
[anaconda-extrarepo-$n]
name=anaconda extra repo $n
baseurl=$r
enabled=1
EOF
let n++
done
n=1
for l in $MIRRORLIST; do
cat >> $yumconf <<EOF
[anaconda-mirrorlistrepo-$n]
name=anaconda mirrorlist repo $n
mirrorlist=$l
enabled=1
EOF
let n++
done
echo "Running buildinstall..."
pushd $BUILDINSTDIR
BUILDARCH=`repoquery -c $yumconf --qf "%{ARCH}\n" anaconda`
yumdownloader -c $yumconf anaconda || exit 1
rpm2cpio anaconda*rpm | cpio --quiet -iumd './usr*'
rm -f anaconda*rpm
popd
UPD_INSTROOT=./upd-instroot
MK_IMAGES=./mk-images
MK_TREEINFO=./maketreeinfo.py
MK_STAMP=./makestamp.py
BUILDINSTALL=./buildinstall
for f in $UPD_INSTROOT $MK_IMAGES $MK_STAMP $MK_TREEINFO $BUILDINSTALL; do
if [ -n "$UPDATES" -a -f $UPDATES/usr/lib/anaconda-runtime/$f ]; then
cp -a $UPDATES/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
elif [ ! -f $f ]; then
cp -a $BUILDINSTDIR/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
else
cp -a $f* $BUILDINSTDIR/
fi
done
UPD_INSTROOT=$BUILDINSTDIR/upd-instroot
MK_IMAGES=$BUILDINSTDIR/mk-images
MK_TREEINFO=$BUILDINSTDIR/maketreeinfo.py
MK_STAMP=$BUILDINSTDIR/makestamp.py
BUILDINSTALL=$BUILDINSTDIR/buildinstall
if [ -n "$UPDATES" ]; then UPDATES="--updates $UPDATES"; fi
echo "Building images..."
$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH $UPDATES --imgdir $TREEDIR/install $yumconf
echo "Writing .treeinfo file..."
$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BUILDARCH --outfile=$OUTPUT/.treeinfo
# FIXME: need to update mk-images to take the yumconf
echo "Making images..."
$MK_IMAGES $DEBUGSTR $NOGRSTR --imgdir $TREEDIR/install --arch $BUILDARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" --output $OUTPUT $yumconf
echo "Writing .discinfo file"
$MK_STAMP --releasestr="$RELEASESTR" --arch=$BUILDARCH --discNum="ALL" --outfile=$OUTPUT/.discinfo
rm -rf $TREEDIR $BUILDINSTDIR
rm -f $yumconf

View File

@ -0,0 +1,120 @@
#!/bin/bash
# pulled right out of mkinitrd....
DSO_DEPS=""
LDSO=""
get_dso_deps() {
root="$1" ; shift
bin="$1" ; shift
DSO_DEPS=""
declare -a FILES
declare -a NAMES
# this is a hack, but the only better way requires binutils or elfutils
# be installed. i.e., we need readelf to find the interpretter.
if [ -z "$LDSO" ]; then
for ldso in $root/$LIBDIR/ld*.so* ; do
[ -L $ldso ] && continue
[ -x $ldso ] || continue
$ldso --verify $bin >/dev/null 2>&1 || continue
LDSO=$(echo $ldso |sed -e "s,$root,,")
done
fi
# I still hate shell.
declare -i n=0
while read NAME I0 FILE ADDR I1 ; do
[ "$FILE" == "not" ] && FILE="$FILE $ADDR"
NAMES[$n]="$NAME"
FILES[$n]="$FILE"
let n++
done << EOF
$(/usr/sbin/chroot $root env LD_TRACE_PRELINKING=1 LD_WARN= \
LD_TRACE_LOADED_OBJECTS=1 $LDSO $bin)
EOF
[ ${#FILES[*]} -eq 0 ] && return 1
# we don't want the name of the binary in the list
if [ "${FILES[0]}" == "$bin" ]; then
FILES[0]=""
NAMES[0]=""
[ ${#FILES[*]} -eq 1 ] && return 1
fi
declare -i n=0
while [ $n -lt ${#FILES[*]} ]; do
FILE="${FILES[$n]}"
if [ "$FILE" == "not found" ]; then
cat 1>&2 <<EOF
There are missing files on your system. The dynamic object $bin
requires ${NAMES[$n]} n order to properly function. mkinitrd cannot continue.
EOF
exit 1
fi
case "$FILE" in
/lib*)
TLIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'`
BASE=`basename "$FILE"`
# Prefer nosegneg libs over direct segment accesses on i686.
if [ -f "$TLIBDIR/i686/nosegneg/$BASE" ]; then
FILE="$TLIBDIR/i686/nosegneg/$BASE"
# Otherwise, prefer base libraries rather than their optimized
# variants.
elif [ -f "$TLIBDIR/$BASE" ]; then
FILE="$TLIBDIR/$BASE"
fi
;;
esac
dynamic="yes"
let n++
done
DSO_DEPS="${FILES[@]}"
for l in $(/usr/sbin/chroot $root find /$LIBDIR -maxdepth 1 -type l -name ld*.so*); do
[ "$(/usr/sbin/chroot $root readlink -f $l)" == "$LDSO" ] && DSO_DEPS="$DSO_DEPS $l"
done
[ -n "$DEBUG" ] && echo "DSO_DEPS for $bin are $DSO_DEPS"
}
instFile() {
FILE=$1
DESTROOT=$2
[ -n "$DEBUG" ] && echo "Installing $FILE"
if [ -e $DESTROOT/$FILE -o -L $DESTROOT/$FILE ]; then
return
elif [ ! -d $DESTROOT/`dirname $FILE` ]; then
mkdir -p $DESTROOT/`dirname $FILE`
fi
if [ -L $FILE ]; then
cp -al $FILE $DESTROOT/`dirname $FILE`
instFile ./`dirname $FILE`/`readlink $FILE` $DESTROOT
return
else
cp -aL $FILE $DESTROOT/`dirname $FILE`
fi
file $FILE | egrep -q ": (setuid )?ELF" && {
get_dso_deps $(pwd) "$FILE"
local DEPS="$DSO_DEPS"
for x in $DEPS ; do
instFile ./$x $DESTROOT
done
}
}
instDir() {
DIR=$1
DESTROOT=$2
[ -n "$DEBUG" ] && echo "Installing $DIR"
if [ -d $DESTROOT/$DIR -o -h $DESTROOT/$DIR ]; then
return
fi
cp -a --parents $DIR $DESTROOT/
}

View File

@ -0,0 +1,90 @@
#!/usr/bin/python
#
# makes a .discinfo file. if information isn't provided, prompts for it
#
# Copyright (C) 2002 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os,sys,string
import getopt
import time
def usage():
args = ""
for key in data:
args = "%s [--%s=%s]" %(args, key, key)
print("%s: %s" % (sys.argv[0], args))
sys.exit(1)
data = {"timestamp": None,
"releasestr": None,
"arch": None,
"discNum": None,
"outfile": None}
allDiscs = None
opts = []
for key in data.keys():
opts.append("%s=" % (key,))
opts.append("allDiscs")
(args, extra) = getopt.getopt(sys.argv[1:], '', opts)
if len(extra) > 0:
print("had extra args: %s" % extra)
usage()
for (str, arg) in args:
if str[2:] in data.keys():
data[str[2:]] = arg
elif str == "--allDiscs":
allDiscs = 1
else:
print("unknown str of ", str)
usage()
if data["timestamp"] is None:
sys.stderr.write("timestamp not specified; using the current time\n")
data["timestamp"] = time.time()
else:
data["timestamp"] = float(data["timestamp"])
if data["releasestr"] is None:
print("What should be the release name associated with this disc?\n")
data["releasestr"] = sys.stdin.readline()[:-1]
if data["arch"] is None:
print("What arch is this disc for?")
data["arch"] = sys.stdin.readline()[:-1]
if data["discNum"] is None and allDiscs is None:
sys.stderr.write("No disc number specified; assuming disc 1\n")
data["discNum"] = "1"
if data["outfile"] is None:
f = sys.stdout
else:
f = open(data["outfile"], "w")
f.write("%f\n" % data["timestamp"])
f.write("%s\n" % data["releasestr"])
f.write("%s\n" % data["arch"])
if allDiscs is None:
f.write("%s\n" % data["discNum"])
else:
f.write("0\n")

View File

@ -0,0 +1,113 @@
#!/usr/bin/python
#
# makes a .treeinfo file. if information isn't provided, emit some warnings.
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Will Woods <wwoods@redhat.com>
#
import os,sys,string
import getopt
import time
import ConfigParser
def usage():
args = ""
for key in data:
args = "%s [--%s=%s]" %(args, key, key)
print("%s: %s" % (sys.argv[0], args))
sys.exit(1)
# TODO: add composeid, images, etc.
# TODO: take releasestr as an option and break it up into family/variant/version?
data = {"timestamp": time.time(),
"family": None,
"variant": None,
"version": None,
"arch": None,
"discnum": None,
"totaldiscs": None,
"packagedir": None,
"outfile": None}
allDiscs = None
opts = []
for key in data.keys():
opts.append("%s=" % (key,))
opts.append("allDiscs")
(args, extra) = getopt.getopt(sys.argv[1:], '', opts)
if len(extra) > 0:
print("had extra args: %s" % extra)
usage()
for (str, arg) in args:
if str[2:] in data.keys():
data[str[2:]] = arg
elif str == "--allDiscs":
allDiscs = 1
else:
print("unknown str of ", str)
usage()
# Make sure timestamp is actually a float
if type(data["timestamp"]) != float:
data["timestamp"] = float(data["timestamp"])
if data["family"] is None:
sys.stderr.write("--family missing! This is probably bad!\n")
data["family"] = ""
if data["variant"] is None:
sys.stderr.write("--variant missing, but that's OK.\n")
data["variant"] = ""
if data["version"] is None:
sys.stderr.write("--version missing! This is probably bad!\n")
data["version"] = ""
if data["arch"] is None:
sys.stderr.write("--arch missing! This is probably bad!\n")
data["arch"] = ""
if data["discnum"] is None and allDiscs is None:
sys.stderr.write("--discnum missing; assuming disc 1\n")
data["discnum"] = "1"
if data["totaldiscs"] is None and allDiscs is None:
sys.stderr.write("--totaldiscs missing; assuming 1\n")
data["totaldiscs"] = "1"
if data["packagedir"] is None:
sys.stderr.write("--packagedir missing. This might cause some weirdness.\n")
data["packagedir"] = ""
if data["outfile"] is None:
f = sys.stdout
else:
f = open(data["outfile"], "w")
section='general'
c=ConfigParser.ConfigParser()
c.add_section(section)
for k,v in data.items():
if k != 'outfile':
c.set(section,k,v)
c.write(f)

965
rewrite/orig/scripts/mk-images Executable file
View File

@ -0,0 +1,965 @@
#!/bin/bash
#
# mk-images
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
LANG=C
PATH=$PATH:/sbin:/usr/sbin
IMAGEUUID=$(date +%Y%m%d%H%M).$(uname -i)
TMPDIR=${TMPDIR:-/tmp}
usage () {
echo "usage: mk-images <pkgsrc> <toplevel> <template> <imgdir> <buildarch> <productname> <version> [<productpath>]"
exit 0
}
DEBUG=""
BUILDARCH=`uname -m`
BOOTISO="boot.iso"
while [ $# -gt 0 ]; do
case $1 in
--debug)
DEBUG="--debug"
shift
;;
--noiso)
BOOTISO=""
shift
;;
--arch)
BUILDARCH=$2
shift; shift
;;
--imgdir)
IMGPATH=$2
shift; shift
;;
--product)
PRODUCT=$2
shift; shift
;;
--version)
VERSION=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
TOPDESTPATH=$2
shift; shift
;;
--nogr)
echo "*** DeprecationWarning: ignoring --nogr option." >&2
shift
;;
--mindir)
echo "*** DeprecationWarning: ignoring --mindir option." >&2
shift; shift
;;
--stg2dir)
echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
shift; shift
;;
*)
yumconf=$1
shift
;;
esac
done
if [ -z "$TOPDESTPATH" -o -z "$IMGPATH" -o -z "$PRODUCT" -o -z "$VERSION" ]; then usage; fi
TOPDIR=$(echo $0 | sed "s,/[^/]*$,,")
if [ $TOPDIR = $0 ]; then
$TOPDIR="."
fi
TOPDIR=$(cd $TOPDIR; pwd)
# modules that are needed. this is the generic "needed for every arch" stuff
COMMONMODS="fat vfat nfs sunrpc lockd floppy cramfs loop edd pcspkr squashfs ipv6 virtio_pci"
USBMODS="ohci-hcd uhci-hcd ehci-hcd hid mousedev usb-storage sd_mod sr_mod ub appletouch"
FIREWIREMODS="ohci1394 sbp2 fw-ohci fw-sbp2 firewire-sbp2 firewire-ohci"
SDMODS="mmc-block sdhci sdhci-pci"
IDEMODS="ide-cd ide-cd_mod"
SCSIMODS="sr_mod sg st sd_mod scsi_mod iscsi_tcp iscsi_ibft"
FSMODS="fat msdos vfat ext2 ext3 ext4dev reiserfs jfs xfs gfs2 cifs"
LVMMODS="dm-mod dm-zero dm-snapshot dm-mirror dm-multipath dm-round-robin dm-crypt"
RAIDMODS="raid0 raid1 raid5 raid6 raid456 raid10 linear"
CRYPTOMODS="sha256_generic cbc xts lrw aes_generic crypto_blkcipher crc32c ecb arc4"
PCMCIASOCKMODS="yenta_socket i82365 tcic pcmcia"
DRMMODS="drm i810 i830 i915 mga nouveau r128 radeon savage sis tdfx via"
INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS $DRMMODS $SDMODS =scsi =net"
. $(dirname $0)/buildinstall.functions
# Set, verify, and create paths
IMAGEPATH=$TOPDESTPATH/images
FULLMODPATH=$TMPDIR/instimagemods.$$
FINALFULLMODPATH=$IMGPATH/modules
INSTIMGPATH=$TOPDESTPATH/images
KERNELBASE=$TMPDIR/updboot.kernel.$$
KERNELNAME=vmlinuz
if [ "$BUILDARCH" = "ia64" ]; then
KERNELDIR="/boot/efi/EFI/redhat"
else
KERNELDIR="/boot"
fi
if [ "$BUILDARCH" = "sparc64" ]; then
BASEARCH=sparc
else
BASEARCH=$BUILDARCH
fi
# explicit block size setting for some arches (FIXME: we compose
# ppc64-ish trees as ppc, so we have to set the "wrong" block size)
if [ "$BUILDARCH" = "sparc64" ]; then
CRAMBS="--blocksize 8192"
elif [ "$BUILDARCH" = "sparc" ]; then
CRAMBS="--blocksize 4096"
else
CRAMBS=""
fi
if [ $BUILDARCH = x86_64 -o $BUILDARCH = s390x ]; then
LIBDIR=lib64
else
LIBDIR=lib
fi
rm -rf $IMAGEPATH
rm -rf $FULLMODPATH
rm -rf $FINALFULLMODPATH
rm -rf $KERNELBASE
mkdir -p $IMAGEPATH
mkdir -p $FULLMODPATH
mkdir -p $FINALFULLMODPATH
mkdir -p $KERNELBASE
mkdir -p $INSTIMGPATH
# Stuff that we need
TRIMPCIIDS=$IMGPATH/usr/lib/anaconda-runtime/trimpciids
GETKEYMAPS=$IMGPATH/usr/lib/anaconda-runtime/getkeymaps
GENINITRDSZ=$IMGPATH/usr/lib/anaconda-runtime/geninitrdsz
MKS390CDBOOT=$IMGPATH/usr/lib/anaconda-runtime/mk-s390-cdboot
GENMODINFO=$IMGPATH/usr/lib/anaconda-runtime/genmodinfo
KEYMAPS=$TMPDIR/keymaps-$BUILDARCH.$$
SCREENFONT=$IMGPATH/usr/lib/anaconda-runtime/screenfont-${BASEARCH}.gz
MODLIST=$IMGPATH/usr/lib/anaconda-runtime/modlist
MODINFO=$TMPDIR/modinfo-$BUILDARCH.$$
LOADERBINDIR=$IMGPATH/usr/lib/anaconda-runtime/loader
BOOTDISKDIR=$IMGPATH/usr/lib/anaconda-runtime/boot
LANGTABLE=$IMGPATH/usr/lib/anaconda/lang-table
PCIIDS=$IMGPATH/usr/share/hwdata/pci.ids
XDRIVERS=$IMGPATH/usr/share/hwdata/videoaliases
XDRIVERDESCS=$IMGPATH/usr/share/hwdata/videodrivers
REQUIREMENTS="$TRIMPCIIDS $PCIIDS $XDRIVERDESCS $GENMODINFO
$LANGTABLE $GETKEYMAPS"
dieLater=
for n in $REQUIREMENTS; do
if [ ! -f $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
for n in $BOOTDISKDIR; do
if [ ! -d $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
if [ -n "$dieLater" ]; then exit 1; fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
# go ahead and create the keymaps so we only have to do it once
if [ -f $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH ]; then
echo "Found keymap override, using it"
cp $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH $KEYMAPS
else
echo "Running: $GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH"
$GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH
if [ $? != 0 ]; then
echo "Unable to create keymaps and thus can't create initrd."
exit 1
fi
fi
fi
findPackage() {
name=$1
pkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" -c $yumconf --archlist=$KERNELARCH $name.$KERNELARCH)
if [ -n "$pkg" ]; then
echo $pkg
return
fi
echo "cannot find package $name" >&2
}
rundepmod () {
where=$1
$FAKEARCH /sbin/depmod -a -F $KERNELROOT/boot/System.map-$version \
-b $where $version
}
# This loops to make sure it resolves dependencies of dependencies of...
resdeps () {
items="$*"
deplist=""
for item in $items ; do
deps=$(awk -F ':' "/$item.ko: / { print gensub(\".*/$item.ko: \",\"\",\"g\") }" $KERNELROOT/lib/modules/$version/modules.dep)
for dep in $deps ; do
depfile=${dep##*/}
depname=${dep%%.ko}
deplist="$deplist $depname"
done
done
items=$(for n in $items $deplist; do echo $n; done | sort -u)
echo $items
}
expandModuleSet() {
SET=""
for name in $1; do
char=$(echo $name | cut -c1)
if [ $char = '=' ]; then
NAME=$(echo $name | cut -c2-)
SET="$SET $($MODLIST --modinfo-file $MODINFO $NAME)"
else
SET="$SET $name"
fi
done
echo $SET
}
makemoduletree() {
MMB_DIR=$1
MMB_MODULESET=$(resdeps $2)
mkdir -p $MMB_DIR/lib
mkdir -p $MMB_DIR/modules
mkdir -p $MMB_DIR/firmware
ln -snf ../modules $MMB_DIR/lib/modules
ln -snf ../firmware $MMB_DIR/lib/firmware
echo "Copying kernel modules..."
cp -a $KERNELROOT/lib/modules/* $MMB_DIR/lib/modules/
echo "Removing extraneous modules..."
find $MMB_DIR/lib/modules/ -name *.ko | while read module ; do
m=${module##*/}
modname=${m%%.ko}
echo $MMB_MODULESET | grep -wq $modname || {
rm -f $module
}
done
# Copy in driver firmware we want during installation. NOTE: This isn't
# the ideal solution, but we'll do this for now. What we really want is
# for the kernel modules to include a modinfo field that names the firmware
# file we should have. If we can get that it would make it even easier to
# push the kernel people to depend on the firmware packages in the kernel,
# but we have to take small steps first.
for module in $MODSET ; do
case $module in
ipw2100)
cp $KERNELROOT/lib/firmware/ipw2100* $MBD_DIR/firmware
;;
ipw2200)
cp $KERNELROOT/lib/firmware/ipw2200* $MBD_DIR/firmware
;;
iwl3945)
cp $KERNELROOT/lib/firmware/iwlwifi-3945* $MBD_DIR/firmware
;;
iwl4965)
cp $KERNELROOT/lib/firmware/iwlwifi-4965* $MBD_DIR/firmware
;;
atmel)
cp $KERNELROOT/lib/firmware/atmel_*.bin $MBD_DIR/firmware
;;
zd1211rw)
cp -r $KERNELROOT/lib/firmware/zd1211 $MBD_DIR/firmware
;;
qla2xxx)
cp $KERNELROOT/lib/firmware/ql* $MBD_DIR/firmware
;;
esac
done
# clean up leftover cruft
find -H $MMB_DIR/lib/modules -type d -exec rmdir -f {} \; 2>/dev/null
$MODLIST --modinfo-file $MODINFO --ignore-missing --modinfo \
$MMB_MODULESET > $MMB_DIR/lib/modules/module-info
# compress modules
find -H $MMB_DIR/lib/modules -type f -name *.ko -exec gzip -9 {} \;
rundepmod $MMB_DIR
rm -f $MMB_DIR/lib/modules/*/modules.*map
rm -f $MMB_DIR/lib/modules/*/{build,source}
# create the pci.ids, from modules.alias and the X driver aliases
awk '!/^(\t\t|#)/ { print ;if ($0 == "ffff Illegal Vendor ID") nextfile; }' < $PCIIDS | \
$TRIMPCIIDS $MMB_DIR/lib/modules/*/modules.alias $XDRIVERS/* > ../pci.ids
}
makeproductfile() {
root=$1
rm -f $root/.buildstamp
echo $IMAGEUUID > $root/.buildstamp
echo $PRODUCT >> $root/.buildstamp
echo $VERSION >> $root/.buildstamp
if [ -n "$BUGURL" ]; then
echo $BUGURL >> $root/.buildstamp
fi
}
instbin() {
ROOT=$1
BIN=$2
DIR=$3
DEST=$4
install -s -m 755 $ROOT/$BIN $DIR/$DEST
get_dso_deps $ROOT "$BIN"
local DEPS="$DSO_DEPS"
mkdir -p $DIR/$LIBDIR
for x in $DEPS ; do
cp -Lfp $ROOT/$x $DIR/$LIBDIR
done
pushd $DIR/$LIBDIR
if [ -f ld-linux.so.2 ]; then
rm -f ld-linux.so.2
linker="$(ls -1 ld-*.*.*.so)"
found=$(echo $linker | wc -l)
if [ $found -ne 1 ]; then
echo "Found too many dynamic linkers:" >&2
echo $linker >&2
exit 1
fi
ln -s $linker ld-linux.so.2
fi
popd
}
setupShellEnvironment() {
echo "tcp 6 TCP" > $MBD_DIR/etc/protocols
# PAM configuration
for i in pam_limits.so pam_env.so pam_unix.so pam_deny.so; do
cp -f $IMGPATH/$LIBDIR/security/$i $MBD_DIR/$LIBDIR/security
done
cp -f $IMGPATH/etc/pam.d/other $MBD_DIR/etc/pam.d
cat > $MBD_DIR/etc/pam.d/login << EOF
#%PAM-1.0
auth required pam_env.so
auth sufficient pam_unix.so likeauth nullok
auth required pam_deny.so
account required pam_unix.so
password sufficient pam_unix.so nullok use_authtok md5 shadow
password required pam_deny.so
session required pam_limits.so
session required pam_unix.so
EOF
cp -f $MBD_DIR/etc/pam.d/login $MBD_DIR/etc/pam.d/sshd
cp -f $MBD_DIR/etc/pam.d/login $MBD_DIR/etc/pam.d/remote
cp -f $IMGPATH/etc/security/{limits.conf,pam_env.conf} $MBD_DIR/etc/security/
# key generation takes ages on s390, you really don't want this for every
# installation attempt. These are NOT the keys of the installed system!
mkdir -m 0700 -p $MBD_DIR/etc/ssh
echo -n "Generating SSH1 RSA host key: "
/usr/bin/ssh-keygen -q -t rsa1 -f $MBD_DIR/etc/ssh/ssh_host_key \
-C '' -N '' >&/dev/null
echo
echo -n "Generating SSH2 RSA host key: "
/usr/bin/ssh-keygen -q -t rsa -f $MBD_DIR/etc/ssh/ssh_host_rsa_key \
-C '' -N '' >&/dev/null
echo
echo -n "Generating SSH2 DSA host key: "
/usr/bin/ssh-keygen -q -t dsa -f $MBD_DIR/etc/ssh/ssh_host_dsa_key \
-C '' -N '' >&/dev/null
echo
(cd $MBD_DIR/etc/ssh; \
chmod 600 ssh_host_key ssh_host_rsa_key ssh_host_dsa_key; \
chmod 644 ssh_host_key.pub ssh_host_rsa_key.pub ssh_host_dsa_key.pub; )
cat > $MBD_DIR/etc/ssh/sshd_config <<EOF
Port 22
HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
PermitRootLogin yes
IgnoreRhosts yes
StrictModes yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd yes
XAuthLocation /sbin/xauth
KeepAlive yes
SyslogFacility AUTHPRIV
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords yes
PermitUserEnvironment yes
EOF
chmod 600 $MBD_DIR/etc/ssh/sshd_config
# copy in the binaries
instbin $IMGPATH /usr/bin/login $MBD_DIR /sbin/login
instbin $IMGPATH /usr/sbin/sshd $MBD_DIR /sbin/sshd
instbin $IMGPATH /usr/bin/busybox $MBD_DIR /sbin/busybox
# make some symlinks
(cd $MBD_DIR/sbin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]_\.\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
while [ -n "$1" ]; do
if [ $1 != "busybox" -a $1 != "sh" ]; then
# if file doesnt already exist, link to busybox
if [ ! -f "$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
fi
shift
done )
}
makeinitrd() {
EXTRAINITRDPATH=""
INITRDSIZE=""
KEEP=""
PADSIZE=""
LOADERBIN=""
INITRDMODULES=""
MYLANGTABLE=$LANGTABLE
MYLOADERTR=loader.tr
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--initrdto" ]; then
EXTRAINITRDPATH=$2
shift; shift
continue
elif [ $1 = "--keep" ]; then
KEEP=yes
shift
continue
elif [ $1 = "--initrdsize" ]; then
INITRDSIZE=$2
shift; shift
continue
elif [ $1 = "--loaderbin" ]; then
LOADERBIN=$2
shift; shift
continue
elif [ $1 = "--modules" ]; then
INITRDMODULES=$2
shift; shift
continue
fi
echo "Unknown option passed to makeinitrd"
exit 1
done
if [ -z "$LOADERBIN" ]; then
echo "no loader binary specified!" >&2
exit 1
fi
if [ -z "$INITRDMODULES" ]; then
echo "warning: no loader modules specified!" >&2
fi
if [ -z "$INITRDSIZE" ]; then
echo "I don't know how big to make the initrd image!" >&2
exit 1
fi
MBD_DIR=$TMPDIR/makebootdisk.dir.$$
MBD_FSIMAGE=$TMPDIR/makebootdisk.initrdimage.$$
MBD_BOOTTREE=$TMPDIR/makebootdisk.tree.$$
rm -rf $MBD_DIR $MBD_FSIMAGE
mkdir -p $MBD_DIR/modules
mkdir -p $MBD_DIR/sbin
mkdir -p $MBD_DIR/dev
mkdir -p $MBD_DIR/etc
mkdir -p $MBD_DIR/etc/udev/rules.d
mkdir -p $MBD_DIR/lib/udev/rules.d
mkdir -p $MBD_DIR/proc
mkdir -p $MBD_DIR/selinux
mkdir -p $MBD_DIR/sys
mkdir -p $MBD_DIR/etc/terminfo/{a,b,d,l,s,v,x}
mkdir -p $MBD_DIR/tmp
mkdir -p $MBD_DIR/usr/libexec
mkdir -p $MBD_DIR/usr/$LIBDIR/NetworkManager
mkdir -p $MBD_DIR/usr/share/dbus-1/system-services
mkdir -p $MBD_DIR/var/cache/hald
mkdir -p $MBD_DIR/var/lib/dbus
mkdir -p $MBD_DIR/var/lib/dhclient
mkdir -p $MBD_DIR/var/lock/rpm
mkdir -p $MBD_DIR/var/run
mkdir -p $MBD_DIR/var/run/dbus
mkdir -p $MBD_DIR/var/run/hald
mkdir -p $MBD_DIR/var/run/NetworkManager
mkdir -p $MBD_DIR/etc/dbus-1/system.d
mkdir -p $MBD_DIR/etc/modprobe.d
mkdir -p $MBD_DIR/etc/NetworkManager/dispatcher.d
mkdir -p $MBD_DIR/$LIBDIR/dbus-1
mkdir -p $MBD_DIR/etc/sysconfig/network-scripts
mkdir -p $MBD_DIR/usr/share/PolicyKit/policy
mkdir -p $MBD_DIR/etc/PolicyKit
mkdir -p $MBD_DIR/var/lib/misc
mkdir -p $MBD_DIR/etc/hal/fdi
mkdir -p $MBD_DIR/usr/share/hal/fdi
mkdir -p $MBD_DIR/usr/share/hwdata
mkdir -p $MBD_DIR/etc/rc.d/init.d
mkdir -p $MBD_DIR/usr/sbin
mkdir -p $MBD_DIR/var/run/wpa_supplicant
if [ "$BUILDARCH" = "s390" -o "$BUILDARCH" = "s390x" ]; then
mkdir -m 111 -p $MBD_DIR/var/empty/sshd
mkdir -p $MBD_DIR/etc/{pam.d,security}
mkdir -p $MBD_DIR/$LIBDIR/security
cp $IMGPATH/$LIBDIR/libpam_misc.so.0.* $MBD_DIR/$LIBDIR/libpam_misc.so.0
ln -s /tmp $MBD_DIR/var/state/xkb
cp $IMGPATH/usr/bin/xauth $MBD_DIR/sbin/xauth
cp $IMGPATH/usr/sbin/cmsfs* $MBD_DIR/sbin/
fi
if [ -n "$INITRDMODULES" ]; then
MODSET=`expandModuleSet "$INITRDMODULES"`
makemoduletree $MBD_DIR "$MODSET"
fi
# set up the arch bits
echo $arch > $MBD_DIR/etc/arch
echo "Setting up arch bits"
instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/$LOADERBIN $MBD_DIR /sbin/loader
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/init $MBD_DIR /sbin/init
ln -s ./init $MBD_DIR/sbin/reboot
ln -s ./init $MBD_DIR/sbin/halt
ln -s ./init $MBD_DIR/sbin/poweroff
else
instbin $IMGPATH ${LOADERBINDIR##IMGPATH}/shutdown $MBD_DIR /sbin/shutdown
instbin $IMGPATH /usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR /sbin/init
instbin $IMGPATH /usr/sbin/dasdfmt $MBD_DIR /sbin/dasdfmt
fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
install -m 644 $KEYMAPS $MBD_DIR/etc/keymaps.gz
install -m 644 $SCREENFONT $MBD_DIR/etc/screenfont.gz
fi
install -m 644 $MYLANGTABLE $MBD_DIR/etc/lang-table
install -m 644 $IMGPATH/etc/passwd $MBD_DIR/etc/passwd
install -m 644 $IMGPATH/etc/group $MBD_DIR/etc/group
install -m 644 $IMGPATH/etc/nsswitch.conf $MBD_DIR/etc/nsswitch.conf
instbin $IMGPATH /usr/bin/mount $MBD_DIR /sbin/mount
instbin $IMGPATH /usr/sbin/mount.nfs $MBD_DIR /sbin/mount.nfs
instbin $IMGPATH /usr/bin/umount $MBD_DIR /sbin/umount
ln -s mount.nfs $MBD_DIR/sbin/umount.nfs
instbin $IMGPATH /usr/sbin/udevd $MBD_DIR /sbin/udevd
instbin $IMGPATH /usr/sbin/udevadm $MBD_DIR /sbin/udevadm
instbin $IMGPATH /usr/bin/udevinfo $MBD_DIR /sbin/udevinfo
ln -s udevadm $MBD_DIR/sbin/udevsettle
instbin $IMGPATH /usr/bin/bash $MBD_DIR /sbin/bash
( cd $MBD_DIR/sbin ; ln -sf bash sh )
instbin $IMGPATH /usr/sbin/consoletype $MBD_DIR /sbin/consoletype
instbin $IMGPATH /usr/bin/logger $MBD_DIR /sbin/logger
( cd $IMGPATH/etc/rc.d/init.d
cp -a functions $MBD_DIR/etc/rc.d/init.d
)
( cd $IMGPATH/etc/sysconfig/network-scripts
cp -a network-functions $MBD_DIR/etc/sysconfig/network-scripts
cp -a network-functions-ipv6 $MBD_DIR/etc/sysconfig/network-scripts
)
( cd $MBD_DIR/etc ; ln -sf /etc/rc.d/init.d init.d )
# DHCP and DHCPv6 client daemons and support programs
instbin $IMGPATH /usr/sbin/dhclient $MBD_DIR /sbin/dhclient
instbin $IMGPATH /usr/sbin/dhcp6c $MBD_DIR /sbin/dhcp6c
touch $MBD_DIR/etc/resolv.conf
# hwdata
cp -a $IMGPATH/usr/share/hwdata/pci.ids $MBD_DIR/usr/share/hwdata/pci.ids
cp -a $IMGPATH/usr/share/hwdata/usb.ids $MBD_DIR/usr/share/hwdata/usb.ids
# hal
instbin $IMGPATH /usr/sbin/hald $MBD_DIR /sbin/hald
( cd $IMGPATH/usr/libexec
for f in hald-runner hald-generate-fdi-cache hal*storage* ; do
instbin $IMGPATH /usr/libexec/$f $MBD_DIR /usr/libexec/$f
done
)
touch $MBD_DIR/var/run/hald.acl-list
cp -a $IMGPATH/usr/share/hal/fdi/* $MBD_DIR/usr/share/hal/fdi
cp -a $IMGPATH/etc/hal/fdi/* $MBD_DIR/etc/hal/fdi
cp -a $IMGPATH/etc/dbus-1/system.d/hal.conf $MBD_DIR/etc/dbus-1/system.d
# PolicyKit
( cd $IMGPATH/etc/PolicyKit
cp -a PolicyKit.conf $MBD_DIR/etc/PolicyKit
)
( cd $IMGPATH/usr/share/dbus-1/system-services
cp -a org.freedesktop.PolicyKit.service $MBD_DIR/usr/share/dbus-1/system-services
)
( cd $IMGPATH/usr/share/PolicyKit/policy
cp -a org.freedesktop.policykit.policy $MBD_DIR/usr/share/PolicyKit/policy
)
( cd $IMGPATH/var/lib/misc
cp -a PolicyKit.reload $MBD_DIR/var/lib/misc
)
# dbus
instbin $IMGPATH /usr/bin/dbus-uuidgen $MBD_DIR /sbin/dbus-uuidgen
instbin $IMGPATH /usr/bin/dbus-daemon $MBD_DIR /sbin/dbus-daemon
cp -a $IMGPATH/etc/dbus-1/system.conf $MBD_DIR/etc/dbus-1/system.conf
cp -a $IMGPATH/$LIBDIR/dbus-1/dbus-daemon-launch-helper $MBD_DIR/$LIBDIR/dbus-1
chown root:dbus $MBD_DIR/$LIBDIR/dbus-1/dbus-daemon-launch-helper
chmod 04750 $MBD_DIR/$LIBDIR/dbus-1/dbus-daemon-launch-helper
# wpa_supplicant
instbin $IMGPATH /usr/sbin/wpa_passphrase $MBD_DIR /usr/sbin/wpa_passphrase
instbin $IMGPATH /usr/sbin/wpa_supplicant $MBD_DIR /usr/sbin/wpa_supplicant
cp -a $IMGPATH/etc/dbus-1/system.d/wpa_supplicant.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/wpa_supplicant/wpa_supplicant.conf $MBD_DIR/etc/wpa_supplicant
( cd $IMGPATH/usr/share/dbus-1/system-services
cp -a fi.epitest.hostap.WPASupplicant.service $MBD_DIR/usr/share/dbus-1/system-services
)
# NetworkManager
instbin $IMGPATH /usr/sbin/NetworkManager $MBD_DIR /usr/sbin/NetworkManager
instbin $IMGPATH /usr/sbin/nm-system-settings $MBD_DIR /usr/sbin/nm-system-settings
cp -a $IMGPATH/etc/dbus-1/system.d/nm-*.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/dbus-1/system.d/NetworkManager.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/NetworkManager/nm-system-settings.conf $MBD_DIR/etc/NetworkManager
instbin $IMGPATH /usr/$LIBDIR/NetworkManager/libnm-settings-plugin-ifcfg-fedora.so \
$MBD_DIR /usr/$LIBDIR/NetworkManager/libnm-settings-plugin-ifcfg-fedora.so
( cd $IMGPATH/usr/libexec
for f in nm-* ; do
instbin $IMGPATH /usr/libexec/$f $MBD_DIR /usr/libexec/$f
done
)
( cd $IMGPATH/usr/share/dbus-1/system-services
cp -a org.freedesktop.NetworkManagerSystemSettings.service $MBD_DIR/usr/share/dbus-1/system-services
cp -a org.freedesktop.nm_dispatcher.service $MBD_DIR/usr/share/dbus-1/system-services
)
# Indirect dependencies
install -m 755 $IMGPATH/$LIBDIR/libfreebl3.so $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libsoftokn3.so $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/usr/$LIBDIR/libsqlite3.so.0 $MBD_DIR/usr/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libnss_dns.so.2 $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libnss_files.so.2 $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libgcc_s.so.1 $MBD_DIR/$LIBDIR/
install -m 644 $IMGPATH/etc/udev/udev.conf $MBD_DIR/etc/udev/udev.conf
for i in $IMGPATH/lib/udev/rules.d/*.rules ; do
install -m 644 $i $MBD_DIR/lib/udev/rules.d/${i##*/}
done
for i in $IMGPATH/etc/udev/rules.d/*.rules ; do
install -m 644 $i $MBD_DIR/etc/udev/rules.d/${i##*/}
done
for i in $IMGPATH/lib/udev/*; do
if [ -f $i ]; then install -m 755 $i $MBD_DIR/lib/udev/${i##*/}; fi
done
rm -f $MBD_DIR/lib/udev/rules.d/*persistent*
rm -f $MBD_DIR/lib/udev/rules.d/*generator*
install -m 644 $LOADERBINDIR/$MYLOADERTR $MBD_DIR/etc/loader.tr
for i in a/ansi d/dumb l/linux s/screen v/vt100 v/vt100-nav v/vt102 x/xterm x/xterm-color g/gnome ; do
[ -f $IMGPATH/usr/share/terminfo/$i ] && \
install -m 644 $IMGPATH/usr/share/terminfo/$i $MBD_DIR/etc/terminfo/$i
done
makeproductfile $MBD_DIR
for n in insmod rmmod modprobe; do
instbin $IMGPATH /usr/sbin/$n $MBD_DIR /sbin/$n
done
ln -s /sbin/init $MBD_DIR/init
ln -s /proc/mounts $MBD_DIR/etc/mtab
ln -s sbin $MBD_DIR/bin
mkdir -p $MBD_DIR/var/lib
ln -s ../../tmp $MBD_DIR/var/lib/xkb
# s390/s390x need sshd setup
if [ "$BUILDARCH" = "s390" -o "$BUILDARCH" = "s390x" ]; then
setupShellEnvironment
fi
cat > $MBD_DIR/.profile <<EOF
PATH=/bin:/usr/bin:/usr/sbin:/mnt/sysimage/sbin:/mnt/sysimage/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin
export PATH
EOF
rm -f $MBD_FSIMAGE
(cd $MBD_DIR; find . |cpio --quiet -c -o) |gzip -9 > $MBD_FSIMAGE
size=$(du $MBD_FSIMAGE | awk '{ print $1 }')
echo "Wrote $MBD_FSIMAGE (${size}k compressed)"
if [ -n "$EXTRAINITRDPATH" ]; then
mkdir -p `dirname $EXTRAINITRDPATH`
cp -a $MBD_FSIMAGE $EXTRAINITRDPATH
fi
if [ -z "$KEEP" ]; then
rm -rf $MBD_FSIMAGE $MBD_BOOTTREE
fi
}
makeinstimage () {
imagename=$1
type=$2
tmp=$TMPDIR/instimage.dir.$$
rm -rf $tmpimage $tmp
mkdir -p $mntpoint $tmp
mkdir -p $tmp
(cd $IMGPATH; find . | cpio --quiet -p $tmp)
makeproductfile $tmp
if [ -z "$type" -o "$type" = "cramfs" ]; then
echo "Running mkcramfs $CRAMBS $tmp $INSTIMGPATH/${imagename}2.img"
mkfs.cramfs $CRAMBS $tmp $TMPDIR/${imagename}2.img.$$
elif [ "$type" = "squashfs" ]; then
echo "Running mksquashfs $tmp $TMPDIR/${imagename}2.img -all-root -no-fragments -no-progress"
mksquashfs $tmp $TMPDIR/${imagename}2.img.$$ -all-root -no-fragments -no-progress
chmod 0644 $TMPDIR/${imagename}2.img.$$
fi
cp $TMPDIR/${imagename}2.img.$$ $INSTIMGPATH/${imagename}2.img
size=$(ls -l $INSTIMGPATH/${imagename}2.img | awk '{print $5}')
size=$(expr $size / 1024)
echo "Wrote $INSTIMGPATH/${imagename}2.img (${size}k)..."
relpath=${INSTIMGPATH#$TOPDESTPATH/}
echo "instimage = ${relpath}/${imagename}2.img" >> $TOPDESTPATH/.treeinfo
rm -rf $tmp
}
makemainimage () {
imagename=$1
type=$2
mmi_tmpimage=$TMPDIR/instimage.img.$$
mmi_mntpoint=$TMPDIR/instimage.mnt.$$
rm -rf $mmi_tmpimage $mmi_mntpoint
mkdir $mmi_mntpoint
if [ $type = "ext2" ]; then
SIZE=$(du -sk $IMGPATH | awk '{ print int($1 * 1.1) }')
if [ -d $IMGPATH/usr/lib/anaconda-runtime ]; then
ERROR=$(du -sk $IMGPATH/usr/lib/anaconda-runtime | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
fi
if [ -d $IMGPATH/usr/lib/syslinux ]; then
ERROR=$(du -sk $IMGPATH/usr/lib/syslinux | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
fi
dd if=/dev/zero bs=1k count=${SIZE} of=$mmi_tmpimage 2>/dev/null
mke2fs -q -F $mmi_tmpimage > /dev/null
tune2fs -c0 -i0 $mmi_tmpimage >/dev/null
mount -o loop $mmi_tmpimage $mmi_mntpoint
(cd $IMGPATH; find . |
fgrep -v "./usr/lib/anaconda-runtime" |
fgrep -v "./usr/lib/syslinux"
cpio -H crc -o) | (cd $mmi_mntpoint; cpio -iumd)
makeproductfile $mmi_mntpoint
umount $mmi_mntpoint
rmdir $mmi_mntpoint
elif [ $type = "squashfs" ]; then
makeproductfile $IMGPATH
echo "Running mksquashfs $IMGPATH $mmi_tmpimage -all-root -no-fragments -no-progress"
mksquashfs $IMGPATH $mmi_tmpimage -all-root -no-fragments -no-progress
chmod 0644 $mmi_tmpimage
SIZE=$(expr `cat $mmi_tmpimage | wc -c` / 1024)
elif [ $type = "cramfs" ]; then
makeproductfile $IMGPATH
echo "Running mkcramfs $CRAMBS $IMGPATH $mmi_tmpimage"
mkfs.cramfs $CRAMBS $IMGPATH $mmi_tmpimage
SIZE=$(expr `cat $mmi_tmpimage | wc -c` / 1024)
fi
cp $mmi_tmpimage $INSTIMGPATH/${imagename}.img
chmod 644 $INSTIMGPATH/${imagename}.img
echo "Wrote $INSTIMGPATH/${imagename}.img (${SIZE}k)"
relpath=${INSTIMGPATH#$TOPDESTPATH/}
echo "mainimage = ${relpath}/${imagename}.img" >> $TOPDESTPATH/.treeinfo
rm $mmi_tmpimage
}
makeSecondStage() {
echo "[stage2]" >> $TOPDESTPATH/.treeinfo
echo "Building install.img"
makemainimage "install" "squashfs"
[ $? = 0 ] || exit 1
}
doPostImages() {
/bin/true
}
# this gets overloaded if we're on an EFI-capable arch (... with grub)
makeEfiImages()
{
/bin/true
}
# source the architecture specific mk-images file so we can call functions
# in it
if [ ${BUILDARCH} = s390x ]; then
# FIXME: this is a bad hack for s390, but better than copying for now
source $TOPDIR/mk-images.s390
elif [ ${BUILDARCH} = ppc64 ]; then
# ... and similar for ppc64
source $TOPDIR/mk-images.ppc
elif [ ${BUILDARCH} = "x86_64" -o ${BUILDARCH} = "i386" ]; then
source $TOPDIR/mk-images.x86
source $TOPDIR/mk-images.efi
else
source $TOPDIR/mk-images.${BUILDARCH}
fi
# Find the kernel, unpack it, and verify it
kerneltags="kernel"
efiarch=""
arches="$BUILDARCH"
if [ "$BUILDARCH" = "ppc" ]; then
arches="ppc64 ppc"
elif [ "$BUILDARCH" = "i386" ]; then
arches="i586"
efiarch="ia32"
kerneltags="kernel kernel-PAE"
kernelxen="kernel-PAE"
elif [ "$BUILDARCH" = "x86_64" ]; then
kerneltags="kernel"
efiarch="x64"
elif [ "$BUILDARCH" = "ia64" ]; then
kerneltags="kernel"
efiarch="ia64"
fi
foundakernel=""
for KERNELARCH in $arches; do
for kernelvers in $kerneltags; do
kpackage=$(findPackage $kernelvers)
if [ "$KERNELARCH" = "i586" -a -z "$kpackage" ]; then
echo "No i586 kernel, trying i686..."
KERNELARCH="i686"
kpackage=$(findPackage $kernelvers)
fi
if [ -z "$kpackage" ]; then
echo "Unable to find kernel package $kernelvers"
continue
fi
yumdownloader -c $yumconf --archlist=$KERNELARCH $kpackage
kpackage="$kpackage.rpm"
if [ ! -f "$kpackage" ]; then
echo "kernel ($kernelvers) doesn't exist for $KERNELARCH. skipping"
continue
fi
KERNELROOT=$KERNELBASE/$KERNELARCH
mkdir -p $KERNELROOT
foundakernel="yes"
if [ "$BUILDARCH" = "ia64" ]; then
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/efi/EFI/redhat/vmlinuz | head -n 1)
version=${vmlinuz##/boot/efi/EFI/redhat/vmlinuz-}
else
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/vmlinuz | head -n 1)
version=${vmlinuz##/boot/vmlinuz-}
fi
arch=$(rpm --nodigest --nosignature --qf '%{ARCH}\n' -qp $kpackage)
rpm2cpio $kpackage | (cd $KERNELROOT; cpio --quiet -iumd)
rm -f $kpackage
# expand out any available firmware too
for p in $(repoquery -c $yumconf '*firmware*') ; do yumdownloader -c $yumconf $p ; rpm2cpio *firmware*.rpm | (cd $KERNELROOT; cpio --quiet -iumd) ; rm -f *firmware*.rpm ; done
if [ ! -d "$KERNELROOT/lib/modules/$version" ]; then
echo "$KERNELROOT/lib/modules/$version is not a valid modules directory" 2>&1
exit 1
fi
if [ ! -f "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version" ]; then
echo "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version does not exist"
exit 1
fi
allmods=$(find $KERNELROOT/lib/modules/$version -name *.ko)
rundepmod $KERNELROOT
$GENMODINFO $KERNELROOT/lib/modules/$version > $MODINFO
# make the boot images
makeBootImages
makeEfiImages $yumconf
done
done
if [ -n "$foundakernel" ]; then
makeSecondStage
rm -rf $KERNELBASE
fi
doPostImages
cd $TOPDIR

View File

@ -0,0 +1,131 @@
#
# mk-images.alpha
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
INITRDMODS="tgafb crc32 $INITRDMODS"
###FSMODS="msdos vfat ext3 reiserfs jfs xfs"
###IDEMODS="cdrom ide-cd"
###SCSIMODS="cdrom scsi_mod sd_mod sg sr_mod st"
###USBMODS="ohci-hcd uhci-hcd hid usb-storage sd_mod sr_mod"
###LATEUSBMODS="mousedev usb-storage"
###SECSTAGE="md raid0 raid1 raid5 dm-mod srm_env $FSMODS $IDEMODS $SCSIMODS $LATEUSBMODS"
NETMODULES="e100 tulip 8139too tulip 3c509 3c59x dl2k eepro epic100 ewrk3 hamachi natsemi ne2k-pci ns83820 starfire yellowfin de4x5 depca acenic tg3"
SCSIMODULES="$SCSIMODS qlogicisp DAC960 cpqfc BusLogic 3w-xxxx dmx3191d dpt_i2o megaraid ncr53c8xx sym53c8xx qlogicfc qla2x00 qla1280 cciss cpqarray aic7xxx aha1740 megaraid"
###ISOMODULES="ehci-hcd ieee1394 ohci1394 sbp2"
prepareBootImage() {
echo "ALPHA: prepareBootImage() is called"
dd if=/dev/zero of=$MBD_TMPIMAGE bs=1k count=$BOOTDISKSIZE 2>/dev/null
echo y | /sbin/mke2fs -b 1024 -r 0 -O none $MBD_TMPIMAGE > /dev/null 2>/dev/null
LODEV=`findloopdevice $MBD_TMPIMAGE`
e2writeboot $LODEV $BOOTDISKDIR/bootlx
mount $LODEV -t ext2 $MBD_BOOTTREE
mkdir -p $MBD_BOOTTREE/etc
cat > $MBD_BOOTTREE/etc/aboot.conf <<EOF
#
# Fedora Linux aboot configuration options:
#
# 0 - Boot the Fedora Linux installer using a 2.6 kernel
# 1 - Boot the Fedora Linux installer in non graphical mode
# 2 - Boot the Fedora Linux installer in text only mode on ttyS0
# for installation control via the serial port
# 3 - Boot in rescue mode
#
0:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 root=/dev/fd0
1:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 text root=/dev/fd0
2:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=ttyS0 text root=/dev/fd0
3:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 rescue root=/dev/fd0
EOF
cat > $MBD_BOOTTREE/etc/milo.conf <<EOF
image=/vmlinux.gz
label=linux
root=/dev/fd0
append="load_ramdisk=1 prompt_ramdisk=1"
EOF
zcat $KERNELROOT/boot/vmlinuz-* | gzip -9 > $MBD_BOOTTREE/vmlinux.gz
umount $LODEV
losetup -d $LODEV
mount -o loop -t ext2 $MBD_TMPIMAGE $MBD_BOOTTREE
}
makeBootImages() {
echo "Building boot images for kernel $kernelvers"
mkdir -p $TOPDESTPATH/boot
cp $BOOTDISKDIR/bootlx $TOPDESTPATH/boot
mkdir -p $TOPDESTPATH/etc
cat > $TOPDESTPATH/etc/aboot.conf <<EOF
#
# Fedora Linux aboot configuration options:
#
# 0 - Boot the Fedora Linux installer using a 2.6 kernel
# 1 - Boot the Fedora Linux installer with kernel messages sent to ttyS0
# 2 - Boot the Fedora Linux installer in text only mode
# 3 - Boot the Fedora Linux installer in text only rescue mode
#
0:/kernels/vmlinux.gz initrd=/images/initrd.img
1:/kernels/vmlinux.gz initrd=/images/initrd.img console=ttyS0
2:/kernels/vmlinux.gz initrd=/images/initrd.img text
3:/kernels/vmlinux.gz initrd=/images/initrd.img rescue
EOF
mkdir -p $TOPDESTPATH/kernels
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/kernels/vmlinux.gz
makeinitrd --initrdto $TOPDESTPATH/images/ramdisk.img \
--initrdsize 8192 \
--loaderbin loader \
--modules "$NETMODULES $SCSIMODULES"
echo "List of init modules: $INITRDMODS"
makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
# makebootdisk --bootdisksize 4096 --kernelto $TOPDESTPATH/kernels/vmlinux.gz \
# --imagename generic.img
if [ -f $KERNELPATH/kernel-jensen-*.rpm ]; then
KJ_PKG=$KERNELPATH/kernel-jensen-*.rpm
KJ_DIR=/tmp/kernelj.dir.$$
mkdir -p $KJ_DIR
rpm2cpio $KJ_PKG | (cd $KJ_DIR; cpio --quiet -iumd ./boot/vmlinuz-*)
cp $KJ_DIR/boot/vmlinuz-* $TOPDESTPATH/kernels/vmlinuz.j
rm -rf $KJ_DIR
fi
# makedriverdisk --padsize 1440 "Supplemental Block Device Drivers" "drvblock" "$SCSIMODULES $EXTRASCSI +scsi"
# makedriverdisk --padsize 1440 "Supplemental Network Device Drivers" "drvnet" "$NETMODULES $EXTRANET +net"
}
#makeSecondStage() {
# makeinstimage "netstg" "$SECSTAGE $SCSIMODULES $IDEMODS =scsi"
# makeinstimage "hdstg" "$SECSTAGE $NETMODULES $IDEMODS =net"
# makemainmodules "$SECSTAGE $NETMODULES $SCSIMODULES $IDEMODS =scsi =net"
# makemainimage "install" "cramfs"
#}

View File

@ -0,0 +1,199 @@
#!/bin/bash
#
# mk-images.efi
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
makeefibootdisk()
{
partimg=$1
target=$2
if [ ! -f $1 ]; then
return
fi
local partsize=$(ls -l $1 | awk '{ print $5; }')
local disksize=$((17408 + $partsize + 17408))
disksize=$(($disksize + $(($disksize % 512))))
local diskimg=$(mktemp /tmp/efidisk.img.XXXXXX)
dd if=/dev/zero of=$diskimg count=1 bs=$disksize
local loop=$(losetup -v -f $diskimg | awk '{ print $4 }')
dmsetup create efiboot$$ --table "0 $(($disksize / 512)) linear $loop 0"
parted --script /dev/mapper/efiboot$$ mklabel gpt unit b mkpart '"EFI System Partition"' fat32 17408 $((17408 + $partsize)) set 1 boot on
dd if=$partimg of=/dev/mapper/efiboot$$p1
dmsetup remove /dev/mapper/efiboot$$p1
dmsetup remove /dev/mapper/efiboot$$
losetup -d $loop
mv -v $diskimg $target
chmod a+r $target
}
#makeefibootimage required for EFI bootloader dosfs image
makeefibootimage() {
MBD_FILENAME=""
KERNELFILE=""
INITRDFILE=""
grubpkg=""
MBD_TMPIMAGE=${TMPDIR:-/tmp}/makebootdisk.image.$$
MBD_BOOTTREE=${TMPDIR:-/tmp}/makebootdisk.tree.$$
MBD_BOOTTREE_TMP=$MBD_BOOTTREE'_tmp'
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--kernel" ]; then
KERNELFILE=$2
shift; shift
continue
elif [ $1 = "--initrd" ]; then
INITRDFILE=$2
shift; shift
continue
elif [ $1 = "--imagename" ]; then
MBD_FILENAME=$IMAGEPATH/$2
shift; shift
continue
elif [ $1 = "--grubpkg" ]; then
grubpkg=$2
shift; shift
continue
fi
echo "Unknown option passed to makebootdisk"
exit 1
done
if [ -z "$MBD_FILENAME" ]; then
echo "No imagename passed"
exit 1
fi
if [ -z "$KERNELFILE" ]; then
echo "No kernel file passed"
exit 1
fi
if [ -z "$INITRDFILE" ]; then
echo "No initrd file passed"
exit 1
fi
MBD_FSIMAGE="$INITRDFILE"
mkdir -p $MBD_BOOTTREE
mkdir -p $MBD_BOOTTREE_TMP
rm -rf $MBD_BOOTTREE_TMP
mkdir -p $MBD_TMPIMAGE
# provided by the mk-image.$ARCH file
prepareEfiImage
left=$(df $MBD_BOOTTREE | tail -n1)
left=$(echo $left | awk '{print $4'})
umount $MBD_BOOTTREE
if [ -n "$EXTRAKERNELPATH" ]; then
mkdir -p `dirname $EXTRAKERNELPATH`
cp -f $KERNELROOT/$KERNELDIR/${KERNELNAME}-* $EXTRAKERNELPATH
fi
mkdir -p `dirname $MBD_FILENAME`
rm -rf $MBD_TMPIMAGE $MBD_MNTPOINT $MBD_BOOTTREE
if [ -z "$INITRDFILE" ]; then
rm -f $MBD_FSIMAGE
fi
chmod a+r $MBD_FILENAME
echo "Wrote $MBD_FILENAME (${left}k free)"
}
# prepare and build an efiboot.img.
prepareEfiImage() {
prepareEfiTree || return 1
# dynamically calculate the size of the dosfs
BOOTDISKSIZE=$(du -kcs $MBD_BOOTTREE_TMP | tail -n1 | awk '{print $1}')
BOOTDISKSIZE=$(expr $BOOTDISKSIZE + 100)
echo "The size of the efiboot.img dosfs is $BOOTDISKSIZE"
mkdosfs -n ANACONDA -C $MBD_FILENAME $BOOTDISKSIZE >/dev/null
mount -o loop,shortname=winnt,umask=0077 -t vfat $MBD_FILENAME $MBD_BOOTTREE
cp -R $MBD_BOOTTREE_TMP/* $MBD_BOOTTREE
}
# prepare a directory with the kernel, initrd, and various message files
# used to populate the efi boot image
prepareEfiTree() {
mkdir -p $MBD_BOOTTREE_TMP/EFI/boot
cp -a $BOOTDISKDIR/* $MBD_BOOTTREE_TMP/EFI/boot/
cp $INITRDFILE $MBD_BOOTTREE_TMP/EFI/boot/initrd.img
cp $KERNELFILE $MBD_BOOTTREE_TMP/EFI/boot/vmlinuz
sed -i "s/@PRODUCT@/$PRODUCT/g" $MBD_BOOTTREE_TMP/EFI/boot/grub.conf
sed -i "s/@VERSION@/$VERSION/g" $MBD_BOOTTREE_TMP/EFI/boot/grub.conf
yumdownloader -c $yumconf $grubpkg
rpm2cpio $grubpkg.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
cp $KERNELROOT/boot/efi/EFI/redhat/grub.efi $MBD_BOOTTREE_TMP/EFI/boot/grub.efi
# The first generation Mactel machines get the bootloader name wrong
# as per the spec. Awesome, guys.
if [ "$efiarch" == "ia32" ]; then
cp $MBD_BOOTTREE_TMP/EFI/boot/grub.efi $MBD_BOOTTREE_TMP/EFI/boot/boot.efi
cp $MBD_BOOTTREE_TMP/EFI/boot/grub.conf $MBD_BOOTTREE_TMP/EFI/boot/boot.conf
fi
mv $MBD_BOOTTREE_TMP/EFI/boot/grub.efi $MBD_BOOTTREE_TMP/EFI/boot/boot${efiarch}.efi
mv $MBD_BOOTTREE_TMP/EFI/boot/grub.conf $MBD_BOOTTREE_TMP/EFI/boot/boot${efiarch}.conf
artpkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" --whatprovides system-logos | grep -v generic-logos | head -1)
if [ -z "$artpkg" ]; then
argpkg="generic-logos"
fi
yumdownloader -c $yumconf $artpkg
rpm2cpio $artpkg.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
cp $KERNELROOT/boot/grub/splash.xpm.gz $MBD_BOOTTREE_TMP/EFI/boot/splash.xpm.gz
}
makeEfiImages() {
yumconf="$1"
if [ "$kernelvers" != "$kernelxen" ]; then
local grubarch=${efiarch}
case ${efiarch} in
ia32) grubarch=i386 ;;
x64) grubarch=x86_64 ;;
esac
grubpkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" -c $yumconf grub.$grubarch)
if [ -z "$grubpkg" ]; then
echo "cannot find package grub.$grubarch" >&2
return 1
fi
echo "Building efiboot.img for ${efiarch}/$KERNELARCH at $TOPDESTPATH/images/efiboot.img"
makeefibootimage \
--imagename pxeboot/efiboot.img \
--kernel $TOPDESTPATH/images/pxeboot/vmlinuz \
--initrd $TOPDESTPATH/images/pxeboot/initrd.img \
--grubpkg ${grubpkg}
local ret=$?
[ $ret -eq 0 ] || return $ret
makeefibootdisk $TOPDESTPATH/images/pxeboot/efiboot.img $TOPDESTPATH/images/efidisk.img
return $?
fi
return 1
}

View File

@ -0,0 +1,173 @@
#!/bin/bash
#
# mk-images.ia64
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#makebootdisk required for EFI bootloader dosfs image
makebootdisk() {
EXTRAKERNELPATH=""
INITRDFLAGS=""
MBD_FILENAME=""
INITRDFILE=""
MBD_TMPIMAGE=${TMPDIR:-/tmp}/makebootdisk.image.$$
MBD_BOOTTREE=${TMPDIR:-/tmp}/makebootdisk.tree.$$
MBD_BOOTTREE_TMP=$MBD_BOOTTREE'_tmp'
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--kernelto" ]; then
EXTRAKERNELPATH=$2
shift; shift
continue
elif [ $1 = "--initrdflags" ]; then
INITRDFLAGS=$2
shift; shift
continue
elif [ $1 = "--initrd" ]; then
INITRDFILE=$2
shift; shift
continue
elif [ $1 = "--imagename" ]; then
MBD_FILENAME=$IMAGEPATH/$2
shift; shift
continue
fi
echo "Unknown option passed to makebootdisk"
exit 1
done
if [ -z "$MBD_FILENAME" ]; then
echo "No imagename passed"
exit 1
fi
if [ -n "$INITRDFILE" ]; then
MBD_FSIMAGE="$INITRDFILE"
elif [ -n "$INITRDFLAGS" ]; then
eval makeinitrd --keep $INITRDFLAGS
fi
mkdir -p $MBD_BOOTTREE
mkdir -p $MBD_BOOTTREE_TMP
rm -rf $MBD_BOOTTREE_TMP
mkdir -p $MBD_TMPIMAGE
# provided by the mk-image.$ARCH file
prepareBootImage
left=$(df $MBD_BOOTTREE | tail -n1)
left=$(echo $left | awk '{print $4'})
umount $MBD_BOOTTREE
if [ -n "$EXTRAKERNELPATH" ]; then
mkdir -p `dirname $EXTRAKERNELPATH`
cp -f $KERNELROOT/$KERNELDIR/${KERNELNAME}-* $EXTRAKERNELPATH
fi
mkdir -p `dirname $MBD_FILENAME`
rm -rf $MBD_TMPIMAGE $MBD_MNTPOINT $MBD_BOOTTREE
if [ -z "$INITRDFILE" ]; then
rm -f $MBD_FSIMAGE
fi
echo "Wrote $MBD_FILENAME (${left}k free)"
}
prepareBootImage() {
prepareBootTree
# dynamically calculate the size of the dosfs
BOOTDISKSIZE=$(du -kcs $MBD_BOOTTREE_TMP | tail -n1 | awk '{print $1}')
BOOTDISKSIZE=$(expr $BOOTDISKSIZE + 100)
echo "The size of the boot.img dosfs is $BOOTDISKSIZE"
mkdosfs -n ANACONDA -C $MBD_FILENAME $BOOTDISKSIZE >/dev/null
mount -o loop -t vfat $MBD_FILENAME $MBD_BOOTTREE
cp -R $MBD_BOOTTREE_TMP/* $MBD_BOOTTREE
}
prepareBootTree() {
mkdir -p $MBD_BOOTTREE_TMP/EFI/boot
cp $MBD_FSIMAGE $MBD_BOOTTREE_TMP/EFI/boot/initrd.img
cp -a $BOOTDISKDIR/* $MBD_BOOTTREE_TMP/EFI/boot/
cp $KERNELROOT/boot/efi/EFI/redhat/vmlinuz-* $MBD_BOOTTREE_TMP/EFI/boot/vmlinuz
cp $MBD_BOOTTREE_TMP/EFI/boot/elilo.efi $MBD_BOOTTREE_TMP/EFI/boot/bootia64.efi
cat > $MBD_BOOTTREE_TMP/EFI/boot/elilo.conf << EOF
prompt
timeout=50
relocatable
image=vmlinuz
label=linux
read-only
initrd=initrd.img
EOF
# make a copy in the root of the image
cp $MBD_BOOTTREE_TMP/EFI/boot/* $MBD_BOOTTREE_TMP
}
makeBootImages() {
# Because ia64 boxes use EFI there needs to be a boot.img dosfs.
echo "making boot.img for EFI bootloader"
makebootdisk --kernelto $TOPDESTPATH/kernels/vmlinuz \
--imagename boot.img \
--initrdflags '--initrdto $TOPDESTPATH/images/ramdisk.img \
--initrdsize 12288 \
--loaderbin loader \
--modules "$INITRDMODS sgiioc4" '
mkdir -p $TOPDESTPATH/images/pxeboot
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/initrd.img \
--initrdsize 12288 \
--loaderbin loader \
--modules "$INITRDMODS sgiioc4"
[ $? = 0 ] || exit 1
mv $TOPDESTPATH/kernels/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
rmdir $TOPDESTPATH/kernels
# make a pxe dir with kernel + initrd
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
The files in this directory are useful for booting a machine via PXE.
The following files are available:
vmlinuz - the kernel used for the installer
initrd.img - an initrd with support for all install methods and
drivers supported for installation of $PRODUCT
EOF
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
boot.img = images/boot.img
[images-xen]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
__EOT__
}
doPostImages() {
if [ -n "$BOOTISO" ]; then
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b boot.img -no-emul-boot -R -J -V "$PRODUCT" -T -graft-points boot.img=$TOPDESTPATH/images/boot.img images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
fi
}

View File

@ -0,0 +1,171 @@
#
# mk-images.ppc
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
makeBootImages() {
echo "Building boot images for kernel $kernelvers"
FAKEARCH=""
if [ "$KERNELARCH" = "ppc64" ]; then
mkdir -p $TOPDESTPATH/ppc/ppc64
echo "Building $KERNELARCH initrd"
makeinitrd --initrdto $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS spufs viocd gpio_mdio"
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc64/vmlinuz
sed -e "s/%BITS%/64/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
$BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc64/yaboot.conf
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = ppc/ppc64/vmlinuz
initrd = ppc/ppc64/ramdisk.image.gz
__EOT__
if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
mkdir -p $TOPDESTPATH/images/netboot
pushd $TOPDESTPATH/ppc/ppc64
cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc64/zImage.lds
$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc64/vmlinuz no no $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc64.img
rmdir $TOPDESTPATH/images/netboot || :
rm -f $TOPDESTPATH/ppc/ppc64/zImage.lds
popd
echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
mkdir -p $TOPDESTPATH/images/netboot
$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc64.img \
-i $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
-D $IMGPATH/usr/lib/kernel-wrapper \
$TOPDESTPATH/ppc/ppc64/vmlinuz
rmdir $TOPDESTPATH/images/netboot || :
echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
fi
echo >> $TOPDESTPATH/.treeinfo
elif [ "$KERNELARCH" = "ppc" ]; then
FAKEARCH="ppc"
mkdir -p $TOPDESTPATH/ppc/ppc32
mkdir -p $TOPDESTPATH/ppc/mac
echo "Building ppc initrd"
makeinitrd --initrdto $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc32/vmlinuz
sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
$BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc32/yaboot.conf
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = ppc/ppc32/vmlinuz
initrd = ppc/ppc32/ramdisk.image.gz
__EOT__
if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
mkdir -p $TOPDESTPATH/images/netboot
pushd $TOPDESTPATH/ppc/ppc32
cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc32/zImage.lds
$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc32/vmlinuz no no $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc32.img
rmdir $TOPDESTPATH/images/netboot || :
rm -f $TOPDESTPATH/ppc/ppc32/zImage.lds
popd
echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc32.img \
-i $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
-D $IMGPATH/usr/lib/kernel-wrapper \
$TOPDESTPATH/ppc/ppc32/vmlinuz
rmdir $TOPDESTPATH/images/netboot || :
popd
echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
fi
echo >> $TOPDESTPATH/.treeinfo
else
echo "Unknown kernel arch: $KERNELARCH"
fi
}
doPostImages() {
mkdir -p $TOPDESTPATH/etc
mkdir -p $TOPDESTPATH/ppc/chrp
# Create ofboot.b and bootinfo.txt files, and yaboot binaries for Mac and CHRP
cp $BOOTDISKDIR/bootinfo.txt $TOPDESTPATH/ppc/bootinfo.txt
cp $IMGPATH/usr/lib/anaconda-runtime/boot/efika.forth $TOPDESTPATH/ppc/efika.forth
if [ -d $TOPDESTPATH/ppc/mac ]; then
cp $BOOTDISKDIR/ofboot.b $TOPDESTPATH/ppc/mac/ofboot.b
cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/mac/yaboot
fi
if [ -d $TOPDESTPATH/ppc/chrp ]; then
cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/chrp/yaboot
$IMGPATH/usr/lib/yaboot/addnote $TOPDESTPATH/ppc/chrp/yaboot
fi
# IBM firmware can't handle boot scripts properly, so for biarch installs
# we use a yaboot.conf which asks the user to select 32-bit or 64-bit kernel.
if [ -r $TOPDESTPATH/ppc/ppc32/yaboot.conf -a -r $TOPDESTPATH/ppc/ppc64/yaboot.conf ]; then
# Both kernels exist. Copy the biarch yaboot.conf into place.
sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
$BOOTDISKDIR/yaboot.conf.3264 > $TOPDESTPATH/etc/yaboot.conf
else
# Copy the one that exists, assuming one does exist
cp $TOPDESTPATH/ppc/ppc??/yaboot.conf $TOPDESTPATH/etc
fi
if [ -z "$BOOTISO" ]; then
return
fi
# Copy it all into the isopath for the boot CD
mkdir -p $TOPDESTPATH/isopath
cp -r $TOPDESTPATH/{ppc,etc} $TOPDESTPATH/isopath
# We want the ppc32 prep image in the boot.iso too.
if [ -d $TOPDESTPATH/images/netboot ]; then
mkdir -p $TOPDESTPATH/isopath/images
cp -r $TOPDESTPATH/images/netboot $TOPDESTPATH/isopath/images
rm -f $TOPDESTPATH/isopath/images/ppc64.img
fi
if [ -r $TOPDESTPATH/isopath/images/netboot/ppc32.img ]; then
PREPBOOT="-prep-boot images/netboot/ppc32.img"
fi
if [ -d $TOPDESTPATH/isopath/ppc/mac ]; then
MACBOOT="-hfs-volid $VERSION -hfs-bless $TOPDESTPATH/isopath/ppc/mac"
fi
# Create the boot.iso
mkisofs -o $TOPDESTPATH/images/$BOOTISO -chrp-boot -U $PREPBOOT \
-part -hfs -T -r -l -J -A "$PRODUCT $VERSION" -sysid PPC \
-V "PBOOT" -volset "$VERSION" -volset-size 1 -volset-seqno 1 \
$MACBOOT \
-map $BOOTDISKDIR/mapping -magic $BOOTDISKDIR/magic \
-no-desktop -allow-multidot -graft-points $TOPDESTPATH/isopath \
images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
rm -rf $TOPDESTPATH/isopath
}

View File

@ -0,0 +1,53 @@
#
# mk-images.s390
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
S390SCSIMODS="zfcp tape390"
S390DASDMODS=" dasd_diag_mod dasd_eckd_mod dasd_fba_mod dasd_mod"
S390NETMODS="ctc netiucv smsgiucv lcs qdio qeth ccwgroup crypto_api xfrm_nalgo"
S390MODS="$S390SCSIMODS $S390DASDMODS $S390NETMODS"
makeBootImages() {
makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
--initrdsize 20000 \
--loaderbin loader \
--modules "$INITRDMODS $S390MODS"
sz=$(ls -l $TOPDESTPATH/images/initrd.img | awk '{print $5}')
$GENINITRDSZ $sz $TOPDESTPATH/images/initrd.size
cp -vf $KERNELROOT/boot/${KERNELNAME}-${version} $TOPDESTPATH/images/kernel.img
cp -v $BOOTDISKDIR/generic.prm $TOPDESTPATH/images/generic.prm
cp -v $BOOTDISKDIR/generic.ins $TOPDESTPATH/generic.ins
$MKS390CDBOOT \
-i $TOPDESTPATH/images/kernel.img \
-r $TOPDESTPATH/images/initrd.img \
-p $TOPDESTPATH/images/generic.prm \
-o $TOPDESTPATH/images/cdboot.img
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = images/kernel.img
initrd = images/initrd.img
initrd.size = images/initrd.size
generic.prm = images/generic.prm
generic.ins = generic.ins
cdboot.img = images/cdboot.img
__EOT__
}

View File

@ -0,0 +1,164 @@
#
# mk-images.x86
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
SYSLINUX=$IMGPATH/usr/lib/syslinux/syslinux-nomtools
if [ ! -f $SYSLINUX ]; then
echo "Warning: nomtools syslinux doesn't exist"
SYSLINUX=$IMGPATH/usr/bin/syslinux
if [ ! -f $SYSLINUX ]; then
echo "$SYSLINUX doesn't exist"
exit 1
fi
fi
# prepare a directory with the kernel, initrd, and various message files
# used to populate a boot image
prepareBootTree() {
(cd $BOOTDISKDIR; find . -maxdepth 1 ! -name "*.msg" ! -type d | cpio --quiet -p $MBD_BOOTTREE)
cp $MBD_FSIMAGE $MBD_BOOTTREE/initrd.img
cp $KERNELROOT/boot/vmlinuz-* $MBD_BOOTTREE/vmlinuz
if [ -f $IMGPATH/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg $MBD_BOOTTREE/splash.jpg
cp $IMGPATH/usr/lib/syslinux/vesamenu.c32 $MBD_BOOTTREE/vesamenu.c32
sed -i s'/default linux/default vesamenu.c32/g' $MBD_BOOTTREE/syslinux.cfg
sed -i 's/prompt 1/#prompt 1/g' $MBD_BOOTTREE/syslinux.cfg
elif [ -x $IMGPATH/usr/lib/anaconda-runtime/splashtolss.sh ]; then
$IMGPATH/usr/lib/anaconda-runtime/splashtolss.sh $BOOTDISKDIR/syslinux-splash.png $BOOTDISKDIR/splash.lss
if [ $? != 0 ]; then
echo $0: Failed to create splash.lss
exit 1
fi
cp $BOOTDISKDIR/splash.lss $MBD_BOOTTREE/splash.lss
elif [ -f $IMGPATH/usr/lib/anaconda-runtime/splash.lss ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/splash.lss $MBD_BOOTTREE/splash.lss
fi
rm -f $MBD_BOOTTREE/syslinux-splash.png
sed -i "s/@PRODUCT@/$PRODUCT/g" $MBD_BOOTTREE/syslinux.cfg
sed -i "s/@VERSION@/$VERSION/g" $MBD_BOOTTREE/syslinux.cfg
rm -f $MBD_BOOTTREE/memtest*
for file in $BOOTDISKDIR/*.msg; do
filename=`basename $file`
sed -e "s/@VERSION@/$VERSION/g" $file > $MBD_BOOTTREE/$filename
done
if [ $? != 0 ]; then
echo $0: Failed to copy messages from $BOOTDISKDIR to $MBD_BOOTTREE.
umount $MBD_BOOTTREE
rm -rf $MBD_BOOTTREE $MBD_TMPIMAGE
exit 1
fi
}
mkdir -p $TOPDESTPATH/images/pxeboot
cat > $TOPDESTPATH/images/README <<EOF
This directory contains image files that can be used to create media
capable of starting the $PRODUCT installation process.
The boot.iso file is an ISO 9660 image of a bootable CD-ROM. It is useful
in cases where the CD-ROM installation method is not desired, but the
CD-ROM's boot speed would be an advantage.
To use this image file, burn the file onto CD-R (or CD-RW) media as you
normally would.
EOF
makeBootImages() {
local initrd="initrd.img"
local kernelimage="vmlinuz"
if [ "$kernelvers" = "$kernelxen" ] ; then
local tag="${kernelvers#kernel}"
if [ -n "$tag" -a "$tag" != "$kernelvers" ] ; then
initrd="initrd${tag}.img"
kernelimage="vmlinuz${tag}"
fi
fi
echo "Building $initrd"
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/$initrd \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
[ $? = 0 ] || exit 1
if [ "$kernelvers" != "$kernelxen" ] ; then
if [ -f $IMGPATH/usr/lib/syslinux/isolinux.bin ]; then
echo "Building isolinux directory"
MBD_BOOTTREE=$TOPDESTPATH/isolinux
MBD_FSIMAGE=$TOPDESTPATH/images/pxeboot/initrd.img
mkdir $MBD_BOOTTREE
cp $IMGPATH/usr/lib/syslinux/isolinux.bin $MBD_BOOTTREE/isolinux.bin
prepareBootTree
# isolinux needs the config file to be isolinux.cfg
mv $MBD_BOOTTREE/syslinux.cfg $MBD_BOOTTREE/isolinux.cfg
# copy in memtest if present
if [ -f $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* $MBD_BOOTTREE/memtest
echo -e "label memtest86\n menu label ^Memory test\n kernel memtest\n append -\n" >> $MBD_BOOTTREE/isolinux.cfg
fi
else
echo "No isolinux binaries. Skipping isolinux creation"
fi
# symlink the kernel for pxe dir
ln $TOPDESTPATH/isolinux/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
The files in this directory are useful for booting a machine via PXE.
The following files are available:
vmlinuz - the kernel used for the installer
initrd.img - an initrd with support for all install methods and
drivers supported for installation of $PRODUCT
EOF
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$BASEARCH]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
__EOT__
if [ -n "$BOOTISO" ]; then echo "boot.iso = images/$BOOTISO" >> $TOPDESTPATH/.treeinfo ; fi
fi
# set up the boot stuff for the xen guest kernel
if [ -z "$kernelxen" -o "$kernelvers" = "$kernelxen" ] ; then
cp $KERNELROOT/boot/vmlinuz-$version $TOPDESTPATH/images/pxeboot/$kernelimage
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-xen]
kernel = images/pxeboot/$kernelimage
initrd = images/pxeboot/$initrd
__EOT__
fi
}
doPostImages() {
if [ -n "$BOOTISO" ]; then
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -V "$PRODUCT" -T -graft-points isolinux=$TOPDESTPATH/isolinux images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
fi
}

82
rewrite/orig/scripts/scrubtree Executable file
View File

@ -0,0 +1,82 @@
#!/bin/bash
#
# scrubtree
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
DEBUG=""
if [ "$1" == "--debug" ]; then
DEBUG="--debug"
shift
fi
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/tree"
exit 1
fi
p=$1
ARCH=`uname -m | sed -e 's/i.86/i386/'`
if [ $ARCH = x86_64 -o $ARCH = s390x ]; then
LIBDIR=lib64
else
LIBDIR=lib
fi
# Must create ld.so.conf, because ldconfig does not cache
# dirs specified on the command line.
touch $p/etc/ld.so.conf
mkdir $p/proc
mount -t proc proc $p/proc
echo /usr/kerberos/$LIBDIR > $p/etc/ld.so.conf
(cd $p; /usr/sbin/chroot $p usr/sbin/ldconfig )
if [ $ARCH != s390 -a $ARCH != s390x ]; then
rm -f $p/usr/sbin/ldconfig
fi
rm $p/etc/ld.so.conf
#
# make sure we have links for programs supplied by busybox
#
# HOWEVER dont clobber existing programs supplied by other packages if exist
#
mv $p/usr/sbin/busybox.anaconda $p/usr/bin/busybox
(cd $p/usr/bin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]\-_\.\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
dontclobber=(sh busybox reboot shutdown poweroff)
while [ -n "$1" ]; do
save=
for n in ${dontclobber[@]} ; do
if [ "$1" == "$n" ]; then
save=$n
fi
done
# if it's not in our list and it doesn't exist, link to busybox
if [ -z "$save" -a ! -f "$1" -a ! -f "$p/usr/sbin/$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
shift
done
)
umount $p/proc

1030
rewrite/orig/scripts/upd-instroot Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
#
# Makefile
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
include ../Makefile.inc
ARCH := $(patsubst i%86,i386,$(shell uname -m))
ARCH := $(patsubst sparc%,sparc,$(ARCH))
ISYSLIB=isys
LOADERDIR = ../loader
LOADLIBES = -lpopt
CFLAGS += -I.. -I$(LOADERDIR) -fno-strict-aliasing
RPMCFLAGS = $(CFLAGS) -I/usr/include/rpm
UTILS = modlist snarffont mapshdr readmap
ifeq (s390, $(ARCH))
UTILS += geninitrdsz mk-s390-cdboot
endif
ifeq (s390x, $(ARCH))
UTILS += geninitrdsz mk-s390-cdboot
endif
ifeq (.depend,$(wildcard .depend))
TARGET=all
else
TARGET=depend all
endif
everything: $(TARGET)
all: $(UTILS)
modlist: modlist.o moduleinfo.o
$(CC) $(LDFLAGS) -o modlist modlist.o moduleinfo.o $(LOADLIBES)
moduleinfo.o: $(LOADERDIR)/moduleinfo.c
cp $(LOADERDIR)/moduleinfo.c ./
$(CC) $(CFLAGS) -c moduleinfo.c
moduledeps.o: $(LOADERDIR)/moduledeps.c
cp $(LOADERDIR)/moduledeps.c ./
$(CC) $(CFLAGS) -c moduledeps.c
md5.o: md5.c md5.h
gcc -c -O -g md5.c -D_FORTIFY_SOURCE=2
hash.o : hash.c
$(CC) $(RPMCFLAGS) -c -o $@ $<
geninitrdsz: geninitrdsz.c
$(CC) $(CFLAGS) -o $@ $<
mk-s390-cdboot: mk-s390-cdboot.c
$(CC) $(CFLAGS) -o $@ $<
depends:
install: all
mkdir -p $(DESTDIR)/usr/bin
mkdir -p $(DESTDIR)/$(RUNTIMEDIR)
install -m755 genmodinfo $(DESTDIR)/$(RUNTIMEDIR)
install -m755 trimpciids $(DESTDIR)/$(RUNTIMEDIR)
install -m755 modlist $(DESTDIR)/$(RUNTIMEDIR)
install -m755 readmap $(DESTDIR)/$(RUNTIMEDIR)
install -m755 mapshdr $(DESTDIR)/$(RUNTIMEDIR)
if [ -x geninitrdsz ]; then \
install -m755 geninitrdsz $(DESTDIR)/$(RUNTIMEDIR) ; \
fi
if [ -x mk-s390-cdboot ]; then \
install -m755 mk-s390-cdboot $(DESTDIR)/$(RUNTIMEDIR) ; \
fi
clean:
rm -f modlist snarffont mapshdr readmap geninitrdsz \
moduledeps.c moduleinfo.c .depend *.o
depend:
$(CPP) -M $(RPMCFLAGS) *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif

View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# filtermoddeps
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
perl -e 'while (<>) { if (/\\\n/) { chop; s/\\$//; print;} else { print $_; } }' | grep ':.*ko' | sed -e '
s/\.ko//g
s,/[^: ]*/,,g
s/[ ][ ]*/ /g'

View File

@ -0,0 +1,62 @@
/*
* geninitrdsz.c
* Generate initrd.size file for zSeries platforms.
* Takes an integer argument and writes out the binary representation of
* that value to the initrd.size file.
* https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197773
*
* Copyright (C) 2007 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int main(int argc,char **argv) {
unsigned int zero = 0;
int fd;
unsigned int size;
mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
if (argc != 3) {
printf("Usage: %s [integer size] [output file]\n", basename(argv[0]));
printf("Example: %s 12288475 initrd.size\n", basename(argv[0]));
return 0;
}
size = htonl(atoi(argv[1]));
fd = open(argv[2], O_CREAT | O_RDWR, mode);
if (write(fd, &zero, sizeof(int)) == -1) {
perror("writing initrd.size (zero)");
return errno;
}
if (write(fd, &size, sizeof(int)) == -1) {
perror("writing initrd.size (size)");
return errno;
}
close(fd);
return 0;
}

76
rewrite/orig/utils/genmodinfo Executable file
View File

@ -0,0 +1,76 @@
#!/usr/bin/python
#
# genmodinfo
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import commands
import os
import string
import sys
uname = os.uname()[2]
if len(sys.argv) > 1:
path = sys.argv[1]
else:
path = '/lib/modules/%s' % (uname,)
mods = {}
for root, dirs, files in os.walk(path):
for file in files:
mods[file] = os.path.join(root,file)
modules = { 'scsi_hostadapter' : [ 'block' ], 'eth' : [ 'networking'] }
blacklist = ("floppy", "scsi_mod", "libiscsi")
list = {}
for modtype in modules.keys():
list[modtype] = {}
for file in modules[modtype]:
try:
f = open('%s/modules.%s' % (path,file),'r')
except:
continue
lines = f.readlines()
f.close()
for line in lines:
line = line.strip()
if mods.has_key(line):
desc = commands.getoutput("modinfo -F description %s" % (mods[line])).split("\n")[0]
desc = desc.strip()
modname = line[:-3]
if modname in blacklist:
continue
if desc and len(desc) > 65:
desc = desc[:65]
if not desc:
desc = "%s driver" % (modname,)
modinfo = """
%s
%s
"%s"
""" % (modname, modtype, desc)
list[modtype][modname] = modinfo
print "Version 0"
for type in list.keys():
modlist = list[type].keys()
modlist.sort()
for m in modlist:
print list[type][m]

View File

@ -0,0 +1,251 @@
/*
* mk-s390-cdboot -- creates one big image using a kernel, a ramdisk and
* a parmfile
*
* 2003-07-24 Volker Sameske <sameske@de.ibm.com>
* 2008-09-22 Updated by David Cantrell <dcantrell@redhat.com>
*
* compile with:
* gcc -Wall -o mk-s390-cdboot mk-s390-cdboot.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <libgen.h>
#define BUFFER_LEN 1024
#define INITRD_START 0x0000000000800000LL
#define START_PSW_ADDRESS 0x80010000
static struct option getopt_long_options[]= {
{ "image", 1, 0, 'i'},
{ "ramdisk", 1, 0, 'r'},
{ "parmfile", 1, 0, 'p'},
{ "outfile", 1, 0, 'o'},
{ "help", 0, 0, 'h'},
{0, 0, 0, 0}
};
static void usage(char *cmd) {
printf("%s [-h] [-v] -i <kernel> -r <ramdisk> -p <parmfile> -o <outfile>\n", cmd);
}
int main (int argc, char **argv) {
char *cmd = basename(argv[0]);
FILE *fd1 = NULL;
FILE *fd2 = NULL;
FILE *fd3 = NULL;
FILE *fd4 = NULL;
char buffer[BUFFER_LEN];
int wc, rc, oc, index;
unsigned long long initrd_start = INITRD_START;
unsigned long long initrd_size;
char *image = NULL;
char *ramdisk = NULL;
char *parmfile = NULL;
char *outfile = NULL;
int image_specified = 0;
int ramdisk_specified = 0;
int parmfile_specified = 0;
int outfile_specified = 0;
int start_psw_address = START_PSW_ADDRESS;
opterr = 0;
while (1) {
oc = getopt_long(argc, argv, "i:r:p:o:h?", getopt_long_options, &index);
if (oc == -1) {
break;
}
switch (oc) {
case '?':
case 'h':
usage(cmd);
exit(0);
case 'i':
image = strdup(optarg);
image_specified = 1;
break;
case 'r':
ramdisk = strdup(optarg);
ramdisk_specified = 1;
break;
case 'p':
parmfile = strdup(optarg);
parmfile_specified = 1;
break;
case 'o':
outfile = strdup(optarg);
outfile_specified = 1;
break;
default:
usage(cmd);
exit(0);
}
}
if (!image_specified || !ramdisk_specified ||
!parmfile_specified || !outfile_specified) {
usage(cmd);
exit(0);
}
printf("Creating bootable CD-ROM image...\n");
printf("kernel is : %s\n", image);
printf("ramdisk is : %s\n", ramdisk);
printf("parmfile is: %s\n", parmfile);
printf("outfile is : %s\n", outfile);
if ((fd1 = fopen(outfile, "w")) == NULL) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
if ((fd2 = fopen(image, "r")) == NULL) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
if ((fd3 = fopen(ramdisk, "r")) == NULL) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
if ((fd4 = fopen(parmfile, "r")) == NULL) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
printf("writing kernel...\n");
while (1) {
rc = fread(buffer, BUFFER_LEN, 1, fd2);
if (rc == 0) {
break;
}
if (feof(fd2) || ferror(fd2)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
wc = fwrite(buffer, BUFFER_LEN, 1, fd1);
if (feof(fd1) || ferror(fd1)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
}
printf("writing initrd...\n");
fseek(fd1, initrd_start, SEEK_SET);
while (1) {
rc = fread(buffer, BUFFER_LEN, 1, fd3);
if (rc == 0) {
break;
}
if (feof(fd3) || ferror(fd3)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
wc = fwrite(buffer, BUFFER_LEN, 1, fd1);
if (feof(fd1) || ferror(fd1)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
}
if (fseek(fd3, 0, SEEK_END) == -1) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
if ((initrd_size = ftell(fd3)) == -1) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
printf("changing start PSW address to 0x%08x...\n", start_psw_address);
if (fseek(fd1, 0x4, SEEK_SET) == -1) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
wc = fwrite(&start_psw_address, 4, 1, fd1);
if (feof(fd1) || ferror(fd1)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
printf("writing initrd address and size...\n");
printf("INITRD start: 0x%016llx\n", initrd_start);
printf("INITRD size : 0x%016llx\n", initrd_size);
if (fseek(fd1, 0x10408, SEEK_SET) == -1) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
wc = fwrite(&initrd_start, 8, 1, fd1);
if (feof(fd1) || ferror(fd1)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
if (fseek(fd1, 0x10410, SEEK_SET) == -1) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
wc = fwrite(&initrd_size, 8, 1, fd1);
if (feof(fd1) || ferror(fd1)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
printf("writing parmfile...\n");
if (fseek(fd1, 0x10480, SEEK_SET) == -1) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
while (1) {
rc = fread(buffer, 1, 1, fd4);
if (rc == 0) {
break;
}
if (feof(fd4) || ferror(fd4)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
wc = fwrite(buffer, 1, 1, fd1);
if (feof(fd1) || ferror(fd1)) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
abort();
}
}
if (fclose(fd1) == EOF) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
}
if (fclose(fd2) == EOF) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
}
if (fclose(fd3) == EOF) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
}
if (fclose(fd4) == EOF) {
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
}
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,130 @@
/*
* modlist.c
*
* Copyright (C) 2007 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../isys/isys.h"
#include "moduleinfo.h"
int main(int argc, char ** argv) {
poptContext optCon;
char * modInfoFile = "/boot/module-info";
enum driverMajor major;
const char * type;
const char * mod;
struct moduleInfo * list, * m;
int rc, i;
int showModInfo = 0;
int ignoreMissing = 0;
moduleInfoSet mis;
struct moduleInfo * mi;
struct poptOption optionTable[] = {
{ "ignore-missing", 'I', POPT_ARG_NONE, &ignoreMissing, 0,
"Ignore modules not in modinfo file for --modinfo" },
{ "modinfo", 'm', POPT_ARG_NONE, &showModInfo, 0,
"Give output in module-info file for listed args" },
{ "modinfo-file", 'f', POPT_ARG_STRING, &modInfoFile, 0,
"Module info file to use"},
POPT_AUTOHELP
{ 0, 0, 0, 0, 0 }
};
optCon = poptGetContext(NULL, argc, (const char **) argv, optionTable, 0);
if ((rc = poptGetNextOpt(optCon)) < -1) {
fprintf(stderr, "bad option %s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(rc));
exit(1);
}
mis = newModuleInfoSet();
if (readModuleInfo(modInfoFile, mis, NULL, 0)) {
fprintf(stderr, "Failed to read %s\n", modInfoFile);
exit(1);
}
if (showModInfo) {
printf("Version 0\n");
while ((mod = poptGetArg(optCon))) {
mi = findModuleInfo(mis, mod);
if (mi) {
printf("%s\n", mi->moduleName);
switch (mi->major) {
case DRIVER_CDROM: printf("\tcdrom\n"); break;
case DRIVER_SCSI: printf("\tscsi\n"); break;
case DRIVER_FS: printf("\tfs\n"); break;
case DRIVER_PCMCIA: printf("\tpcmcia\n"); break;
case DRIVER_IDE: printf("\tide\n"); break;
case DRIVER_OTHER: printf("\tother\n"); break;
case DRIVER_NET:
switch (mi->minor) {
case DRIVER_MINOR_ETHERNET: printf("\teth\n"); break;
case DRIVER_MINOR_TR: printf("\ttr\n"); break;
default:
fprintf(stderr, "unknown net minor type for %s\n",
mi->moduleName);
exit(1);
}
break;
default:
fprintf(stderr, "unknown device type for %s (%d)\n",
mi->moduleName, mi->major);
exit(1);
}
printf("\t\"%s\"\n", mi->description);
for (i = 0; i < mi->numArgs; i++) {
printf("\t%s \"%s\"\n", mi->args[i].arg,
mi->args[i].description);
}
} else if (!ignoreMissing) {
fprintf(stderr, "I know nothing about %s\n", mod);
exit(1);
}
}
} else {
while ((type = poptGetArg(optCon))) {
if (!strcasecmp(type, "scsi")) {
major = DRIVER_SCSI;
} else if (!strcasecmp(type, "net")) {
major = DRIVER_NET;
} else if (!strcasecmp(type, "fs")) {
major = DRIVER_FS;
} else if (!strcasecmp(type, "cdrom")) {
major = DRIVER_CDROM;
} else {
fprintf(stderr, "type must be one of scsi, net, fs, cdrom\n");
exit(1);
}
list = getModuleList(mis, major);
for (m = list; m && m->moduleName; m++)
printf("%s\n", m->moduleName);
free(list);
}
}
return 0;
}

80
rewrite/orig/utils/trimpciids Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/python
#
# trimpciids
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import sys
import os
import string
vendors = []
devices = []
f = open(sys.argv[1])
if f:
pcitable = f.readlines()
f.close()
for line in pcitable:
if not line.startswith("alias pci:"):
continue
vend = "0x%s" % (line[15:19],)
dev = "0x%s" % (line[24:28],)
vend = vend.upper()
dev = dev.upper()
if vend not in vendors:
vendors.append(vend)
if (vend, dev) not in devices:
devices.append( (vend, dev) )
for file in sys.argv[2:]:
if not os.path.exists(file):
sys.stderr.write("WARNING: non-existent file %s for trimpciids\n" %(file,))
continue
f = open(file)
if f:
pcitable = f.readlines()
f.close()
for line in pcitable:
if not line.startswith("alias pcivideo:"):
continue
vend = "0x%s" % (line[20:24],)
dev = "0x%s" % (line[29:33],)
vend = vend.upper()
dev = dev.upper()
if vend not in vendors:
vendors.append(vend)
if (vend, dev) not in devices:
devices.append( (vend, dev) )
pciids = sys.stdin.readlines()
current_vend = 0
for line in pciids:
if line.startswith("#") or line == "\n":
continue
if line.startswith("\t\t"):
continue
if not line.startswith("\t"):
current_vend = "0x%s" % line.split()[0]
current_vend = current_vend.upper()
if current_vend in vendors:
print line,
continue
dev = "0x%s" % line.split()[0]
dev = dev.upper()
if (current_vend, dev) in devices:
print line,

6
rewrite/scratch/buildinstall Executable file
View File

@ -0,0 +1,6 @@
echo "Building images..."
$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH $UPDATES --imgdir $TREEDIR/install $yumconf
# FIXME: need to update mk-images to take the yumconf
echo "Making images..."
$MK_IMAGES $DEBUGSTR $NOGRSTR --imgdir $TREEDIR/install --arch $BUILDARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" --output $OUTPUT $yumconf

View File

@ -0,0 +1,120 @@
#!/bin/bash
# pulled right out of mkinitrd....
DSO_DEPS=""
LDSO=""
get_dso_deps() {
root="$1" ; shift
bin="$1" ; shift
DSO_DEPS=""
declare -a FILES
declare -a NAMES
# this is a hack, but the only better way requires binutils or elfutils
# be installed. i.e., we need readelf to find the interpretter.
if [ -z "$LDSO" ]; then
for ldso in $root/$LIBDIR/ld*.so* ; do
[ -L $ldso ] && continue
[ -x $ldso ] || continue
$ldso --verify $bin >/dev/null 2>&1 || continue
LDSO=$(echo $ldso |sed -e "s,$root,,")
done
fi
# I still hate shell.
declare -i n=0
while read NAME I0 FILE ADDR I1 ; do
[ "$FILE" == "not" ] && FILE="$FILE $ADDR"
NAMES[$n]="$NAME"
FILES[$n]="$FILE"
let n++
done << EOF
$(/usr/sbin/chroot $root env LD_TRACE_PRELINKING=1 LD_WARN= \
LD_TRACE_LOADED_OBJECTS=1 $LDSO $bin)
EOF
[ ${#FILES[*]} -eq 0 ] && return 1
# we don't want the name of the binary in the list
if [ "${FILES[0]}" == "$bin" ]; then
FILES[0]=""
NAMES[0]=""
[ ${#FILES[*]} -eq 1 ] && return 1
fi
declare -i n=0
while [ $n -lt ${#FILES[*]} ]; do
FILE="${FILES[$n]}"
if [ "$FILE" == "not found" ]; then
cat 1>&2 <<EOF
There are missing files on your system. The dynamic object $bin
requires ${NAMES[$n]} n order to properly function. mkinitrd cannot continue.
EOF
exit 1
fi
case "$FILE" in
/lib*)
TLIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'`
BASE=`basename "$FILE"`
# Prefer nosegneg libs over direct segment accesses on i686.
if [ -f "$TLIBDIR/i686/nosegneg/$BASE" ]; then
FILE="$TLIBDIR/i686/nosegneg/$BASE"
# Otherwise, prefer base libraries rather than their optimized
# variants.
elif [ -f "$TLIBDIR/$BASE" ]; then
FILE="$TLIBDIR/$BASE"
fi
;;
esac
dynamic="yes"
let n++
done
DSO_DEPS="${FILES[@]}"
for l in $(/usr/sbin/chroot $root find /$LIBDIR -maxdepth 1 -type l -name ld*.so*); do
[ "$(/usr/sbin/chroot $root readlink -f $l)" == "$LDSO" ] && DSO_DEPS="$DSO_DEPS $l"
done
[ -n "$DEBUG" ] && echo "DSO_DEPS for $bin are $DSO_DEPS"
}
instFile() {
FILE=$1
DESTROOT=$2
[ -n "$DEBUG" ] && echo "Installing $FILE"
if [ -e $DESTROOT/$FILE -o -L $DESTROOT/$FILE ]; then
return
elif [ ! -d $DESTROOT/`dirname $FILE` ]; then
mkdir -p $DESTROOT/`dirname $FILE`
fi
if [ -L $FILE ]; then
cp -al $FILE $DESTROOT/`dirname $FILE`
instFile ./`dirname $FILE`/`readlink $FILE` $DESTROOT
return
else
cp -aL $FILE $DESTROOT/`dirname $FILE`
fi
file $FILE | egrep -q ": (setuid )?ELF" && {
get_dso_deps $(pwd) "$FILE"
local DEPS="$DSO_DEPS"
for x in $DEPS ; do
instFile ./$x $DESTROOT
done
}
}
instDir() {
DIR=$1
DESTROOT=$2
[ -n "$DEBUG" ] && echo "Installing $DIR"
if [ -d $DESTROOT/$DIR -o -h $DESTROOT/$DIR ]; then
return
fi
cp -a --parents $DIR $DESTROOT/
}

25
rewrite/scratch/filtermoddeps Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# filtermoddeps
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
perl -e 'while (<>) { if (/\\\n/) { chop; s/\\$//; print;} else { print $_; } }' | grep ':.*ko' | sed -e '
s/\.ko//g
s,/[^: ]*/,,g
s/[ ][ ]*/ /g'

View File

@ -0,0 +1,62 @@
/*
* geninitrdsz.c
* Generate initrd.size file for zSeries platforms.
* Takes an integer argument and writes out the binary representation of
* that value to the initrd.size file.
* https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197773
*
* Copyright (C) 2007 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int main(int argc,char **argv) {
unsigned int zero = 0;
int fd;
unsigned int size;
mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
if (argc != 3) {
printf("Usage: %s [integer size] [output file]\n", basename(argv[0]));
printf("Example: %s 12288475 initrd.size\n", basename(argv[0]));
return 0;
}
size = htonl(atoi(argv[1]));
fd = open(argv[2], O_CREAT | O_RDWR, mode);
if (write(fd, &zero, sizeof(int)) == -1) {
perror("writing initrd.size (zero)");
return errno;
}
if (write(fd, &size, sizeof(int)) == -1) {
perror("writing initrd.size (size)");
return errno;
}
close(fd);
return 0;
}

76
rewrite/scratch/genmodinfo Executable file
View File

@ -0,0 +1,76 @@
#!/usr/bin/python
#
# genmodinfo
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import commands
import os
import string
import sys
uname = os.uname()[2]
if len(sys.argv) > 1:
path = sys.argv[1]
else:
path = '/lib/modules/%s' % (uname,)
mods = {}
for root, dirs, files in os.walk(path):
for file in files:
mods[file] = os.path.join(root,file)
modules = { 'scsi_hostadapter' : [ 'block' ], 'eth' : [ 'networking'] }
blacklist = ("floppy", "scsi_mod", "libiscsi")
list = {}
for modtype in modules.keys():
list[modtype] = {}
for file in modules[modtype]:
try:
f = open('%s/modules.%s' % (path,file),'r')
except:
continue
lines = f.readlines()
f.close()
for line in lines:
line = line.strip()
if mods.has_key(line):
desc = commands.getoutput("modinfo -F description %s" % (mods[line])).split("\n")[0]
desc = desc.strip()
modname = line[:-3]
if modname in blacklist:
continue
if desc and len(desc) > 65:
desc = desc[:65]
if not desc:
desc = "%s driver" % (modname,)
modinfo = """
%s
%s
"%s"
""" % (modname, modtype, desc)
list[modtype][modname] = modinfo
print "Version 0"
for type in list.keys():
modlist = list[type].keys()
modlist.sort()
for m in modlist:
print list[type][m]

940
rewrite/scratch/mk-images Executable file
View File

@ -0,0 +1,940 @@
#!/bin/bash
#
# mk-images
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
LANG=C
PATH=$PATH:/sbin:/usr/sbin
IMAGEUUID=$(date +%Y%m%d%H%M).$(uname -i)
TMPDIR=${TMPDIR:-/tmp}
usage () {
echo "usage: mk-images <pkgsrc> <toplevel> <template> <imgdir> <buildarch> <productname> <version> [<productpath>]"
exit 0
}
DEBUG=""
BUILDARCH=`uname -m`
BOOTISO="boot.iso"
while [ $# -gt 0 ]; do
case $1 in
--debug)
DEBUG="--debug"
shift
;;
--noiso)
BOOTISO=""
shift
;;
--arch)
BUILDARCH=$2
shift; shift
;;
--imgdir)
IMGPATH=$2
shift; shift
;;
--product)
PRODUCT=$2
shift; shift
;;
--version)
VERSION=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
TOPDESTPATH=$2
shift; shift
;;
--nogr)
echo "*** DeprecationWarning: ignoring --nogr option." >&2
shift
;;
--mindir)
echo "*** DeprecationWarning: ignoring --mindir option." >&2
shift; shift
;;
--stg2dir)
echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
shift; shift
;;
*)
yumconf=$1
shift
;;
esac
done
if [ -z "$TOPDESTPATH" -o -z "$IMGPATH" -o -z "$PRODUCT" -o -z "$VERSION" ]; then usage; fi
TOPDIR=$(echo $0 | sed "s,/[^/]*$,,")
if [ $TOPDIR = $0 ]; then
$TOPDIR="."
fi
TOPDIR=$(cd $TOPDIR; pwd)
# modules that are needed. this is the generic "needed for every arch" stuff
COMMONMODS="fat vfat nfs sunrpc lockd floppy cramfs loop edd pcspkr squashfs ipv6 virtio_pci"
USBMODS="ohci-hcd uhci-hcd ehci-hcd hid mousedev usb-storage sd_mod sr_mod ub appletouch"
FIREWIREMODS="ohci1394 sbp2 fw-ohci fw-sbp2 firewire-sbp2 firewire-ohci"
IDEMODS="ide-cd ide-cd_mod"
SCSIMODS="sr_mod sg st sd_mod scsi_mod iscsi_tcp"
FSMODS="fat msdos vfat ext2 ext3 ext4dev reiserfs jfs xfs gfs2 lock_nolock cifs"
LVMMODS="dm-mod dm-zero dm-snapshot dm-mirror dm-multipath dm-round-robin dm-emc dm-crypt"
RAIDMODS="raid0 raid1 raid5 raid6 raid456 raid10 linear"
CRYPTOMODS="sha256_generic cbc xts lrw aes_generic crypto_blkcipher crc32c ecb arc4"
PCMCIASOCKMODS="yenta_socket i82365 tcic pcmcia"
DRMMODS="drm i810 i830 i915 mga nouveau r128 radeon savage sis tdfx via"
INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS $DRMMODS =scsi =net"
. $(dirname $0)/buildinstall.functions
# Set, verify, and create paths
IMAGEPATH=$TOPDESTPATH/images
FULLMODPATH=$TMPDIR/instimagemods.$$
FINALFULLMODPATH=$IMGPATH/modules
INSTIMGPATH=$TOPDESTPATH/images
KERNELBASE=$TMPDIR/updboot.kernel.$$
KERNELNAME=vmlinuz
if [ "$BUILDARCH" = "ia64" ]; then
KERNELDIR="/boot/efi/EFI/redhat"
else
KERNELDIR="/boot"
fi
if [ "$BUILDARCH" = "sparc64" ]; then
BASEARCH=sparc
else
BASEARCH=$BUILDARCH
fi
# explicit block size setting for some arches (FIXME: we compose
# ppc64-ish trees as ppc, so we have to set the "wrong" block size)
if [ "$BUILDARCH" = "sparc64" ]; then
CRAMBS="--blocksize 8192"
elif [ "$BUILDARCH" = "sparc" ]; then
CRAMBS="--blocksize 4096"
else
CRAMBS=""
fi
if [ $BUILDARCH = x86_64 -o $BUILDARCH = s390x ]; then
LIBDIR=lib64
else
LIBDIR=lib
fi
rm -rf $IMAGEPATH
rm -rf $FULLMODPATH
rm -rf $FINALFULLMODPATH
rm -rf $KERNELBASE
mkdir -p $IMAGEPATH
mkdir -p $FULLMODPATH
mkdir -p $FINALFULLMODPATH
mkdir -p $KERNELBASE
mkdir -p $INSTIMGPATH
# Stuff that we need
TRIMPCIIDS=$IMGPATH/usr/lib/anaconda-runtime/trimpciids
GETKEYMAPS=$IMGPATH/usr/lib/anaconda-runtime/getkeymaps
GENINITRDSZ=$IMGPATH/usr/lib/anaconda-runtime/geninitrdsz
MKS390CDBOOT=$IMGPATH/usr/lib/anaconda-runtime/mk-s390-cdboot
GENMODINFO=$IMGPATH/usr/lib/anaconda-runtime/genmodinfo
KEYMAPS=$TMPDIR/keymaps-$BUILDARCH.$$
SCREENFONT=$IMGPATH/usr/lib/anaconda-runtime/screenfont-${BASEARCH}.gz
MODLIST=$IMGPATH/usr/lib/anaconda-runtime/modlist
MODINFO=$TMPDIR/modinfo-$BUILDARCH.$$
LOADERBINDIR=$IMGPATH/usr/lib/anaconda-runtime/loader
BOOTDISKDIR=$IMGPATH/usr/lib/anaconda-runtime/boot
LANGTABLE=$IMGPATH/usr/lib/anaconda/lang-table
PCIIDS=$IMGPATH/usr/share/hwdata/pci.ids
XDRIVERS=$IMGPATH/usr/share/hwdata/videoaliases
XDRIVERDESCS=$IMGPATH/usr/share/hwdata/videodrivers
REQUIREMENTS="$TRIMPCIIDS $PCIIDS $XDRIVERDESCS $GENMODINFO
$LANGTABLE $GETKEYMAPS"
dieLater=
for n in $REQUIREMENTS; do
if [ ! -f $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
for n in $BOOTDISKDIR; do
if [ ! -d $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
if [ -n "$dieLater" ]; then exit 1; fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
# go ahead and create the keymaps so we only have to do it once
if [ -f $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH ]; then
echo "Found keymap override, using it"
cp $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH $KEYMAPS
else
echo "Running: $GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH"
$GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH
if [ $? != 0 ]; then
echo "Unable to create keymaps and thus can't create initrd."
exit 1
fi
fi
fi
findPackage() {
name=$1
pkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" -c $yumconf --archlist=$KERNELARCH $name.$KERNELARCH)
if [ -n "$pkg" ]; then
echo $pkg
return
fi
echo "cannot find package $name" >&2
}
rundepmod () {
where=$1
$FAKEARCH /sbin/depmod -a -F $KERNELROOT/boot/System.map-$version \
-b $where $version
}
# This loops to make sure it resolves dependencies of dependencies of...
resdeps () {
items="$*"
deplist=""
for item in $items ; do
deps=$(awk -F ':' "/$item.ko: / { print gensub(\".*/$item.ko: \",\"\",\"g\") }" $KERNELROOT/lib/modules/$version/modules.dep)
for dep in $deps ; do
depfile=${dep##*/}
depname=${dep%%.ko}
deplist="$deplist $depname"
done
done
items=$(for n in $items $deplist; do echo $n; done | sort -u)
echo $items
}
expandModuleSet() {
SET=""
for name in $1; do
char=$(echo $name | cut -c1)
if [ $char = '=' ]; then
NAME=$(echo $name | cut -c2-)
SET="$SET $($MODLIST --modinfo-file $MODINFO $NAME)"
else
SET="$SET $name"
fi
done
echo $SET
}
makemoduletree() {
MMB_DIR=$1
MMB_MODULESET=$(resdeps $2)
mkdir -p $MMB_DIR/lib
mkdir -p $MMB_DIR/modules
mkdir -p $MMB_DIR/firmware
ln -snf ../modules $MMB_DIR/lib/modules
ln -snf ../firmware $MMB_DIR/lib/firmware
echo "Copying kernel modules..."
cp -a $KERNELROOT/lib/modules/* $MMB_DIR/lib/modules/
echo "Removing extraneous modules..."
find $MMB_DIR/lib/modules/ -name *.ko | while read module ; do
m=${module##*/}
modname=${m%%.ko}
echo $MMB_MODULESET | grep -wq $modname || {
rm -f $module
}
done
# Copy in driver firmware we want during installation. NOTE: This isn't
# the ideal solution, but we'll do this for now. What we really want is
# for the kernel modules to include a modinfo field that names the firmware
# file we should have. If we can get that it would make it even easier to
# push the kernel people to depend on the firmware packages in the kernel,
# but we have to take small steps first.
for module in $MODSET ; do
case $module in
ipw2100)
cp $KERNELROOT/lib/firmware/ipw2100* $MBD_DIR/firmware
;;
ipw2200)
cp $KERNELROOT/lib/firmware/ipw2200* $MBD_DIR/firmware
;;
iwl3945)
cp $KERNELROOT/lib/firmware/iwlwifi-3945* $MBD_DIR/firmware
;;
iwl4965)
cp $KERNELROOT/lib/firmware/iwlwifi-4965* $MBD_DIR/firmware
;;
atmel)
cp $KERNELROOT/lib/firmware/atmel_*.bin $MBD_DIR/firmware
;;
zd1211rw)
cp -r $KERNELROOT/lib/firmware/zd1211 $MBD_DIR/firmware
;;
qla2xxx)
cp $KERNELROOT/lib/firmware/ql* $MBD_DIR/firmware
;;
esac
done
# clean up leftover cruft
find -H $MMB_DIR/lib/modules -type d -exec rmdir -f {} \; 2>/dev/null
$MODLIST --modinfo-file $MODINFO --ignore-missing --modinfo \
$MMB_MODULESET > $MMB_DIR/lib/modules/module-info
# compress modules
find -H $MMB_DIR/lib/modules -type f -name *.ko -exec gzip -9 {} \;
rundepmod $MMB_DIR
rm -f $MMB_DIR/lib/modules/*/modules.*map
rm -f $MMB_DIR/lib/modules/*/{build,source}
# create the pci.ids, from modules.alias and the X driver aliases
awk '!/^(\t\t|#)/ { print ;if ($0 == "ffff Illegal Vendor ID") nextfile; }' < $PCIIDS | \
$TRIMPCIIDS $MMB_DIR/lib/modules/*/modules.alias $XDRIVERS/* > ../pci.ids
}
makeproductfile() {
root=$1
rm -f $root/.buildstamp
echo $IMAGEUUID > $root/.buildstamp
echo $PRODUCT >> $root/.buildstamp
echo $VERSION >> $root/.buildstamp
if [ -n "$BUGURL" ]; then
echo $BUGURL >> $root/.buildstamp
fi
}
instbin() {
ROOT=$1
BIN=$2
DIR=$3
DEST=$4
install -s -m 755 $ROOT/$BIN $DIR/$DEST
get_dso_deps $ROOT "$BIN"
local DEPS="$DSO_DEPS"
mkdir -p $DIR/$LIBDIR
for x in $DEPS ; do
cp -Lfp $ROOT/$x $DIR/$LIBDIR
done
pushd $DIR/$LIBDIR
if [ -f ld-linux.so.2 ]; then
rm -f ld-linux.so.2
linker="$(ls -1 ld-*.*.*.so)"
found=$(echo $linker | wc -l)
if [ $found -ne 1 ]; then
echo "Found too many dynamic linkers:" >&2
echo $linker >&2
exit 1
fi
ln -s $linker ld-linux.so.2
fi
popd
}
setupShellEnvironment() {
echo "tcp 6 TCP" > $MBD_DIR/etc/protocols
# PAM configuration
for i in pam_limits.so pam_env.so pam_unix.so pam_deny.so; do
cp -f $IMGPATH/$LIBDIR/security/$i $MBD_DIR/$LIBDIR/security
done
cp -f $IMGPATH/etc/pam.d/other $MBD_DIR/etc/pam.d
cat > $MBD_DIR/etc/pam.d/login << EOF
#%PAM-1.0
auth required pam_env.so
auth sufficient pam_unix.so likeauth nullok
auth required pam_deny.so
account required pam_unix.so
password sufficient pam_unix.so nullok use_authtok md5 shadow
password required pam_deny.so
session required pam_limits.so
session required pam_unix.so
EOF
cp -f $MBD_DIR/etc/pam.d/login $MBD_DIR/etc/pam.d/sshd
cp -f $MBD_DIR/etc/pam.d/login $MBD_DIR/etc/pam.d/remote
cp -f $IMGPATH/etc/security/{limits.conf,pam_env.conf} $MBD_DIR/etc/security/
# key generation takes ages on s390, you really don't want this for every
# installation attempt. These are NOT the keys of the installed system!
mkdir -m 0700 -p $MBD_DIR/etc/ssh
echo -n "Generating SSH1 RSA host key: "
/usr/bin/ssh-keygen -q -t rsa1 -f $MBD_DIR/etc/ssh/ssh_host_key \
-C '' -N '' >&/dev/null
echo
echo -n "Generating SSH2 RSA host key: "
/usr/bin/ssh-keygen -q -t rsa -f $MBD_DIR/etc/ssh/ssh_host_rsa_key \
-C '' -N '' >&/dev/null
echo
echo -n "Generating SSH2 DSA host key: "
/usr/bin/ssh-keygen -q -t dsa -f $MBD_DIR/etc/ssh/ssh_host_dsa_key \
-C '' -N '' >&/dev/null
echo
(cd $MBD_DIR/etc/ssh; \
chmod 600 ssh_host_key ssh_host_rsa_key ssh_host_dsa_key; \
chmod 644 ssh_host_key.pub ssh_host_rsa_key.pub ssh_host_dsa_key.pub; )
cat > $MBD_DIR/etc/ssh/sshd_config <<EOF
Port 22
HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
PermitRootLogin yes
IgnoreRhosts yes
StrictModes yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd yes
XAuthLocation /sbin/xauth
KeepAlive yes
SyslogFacility AUTHPRIV
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords yes
PermitUserEnvironment yes
EOF
chmod 600 $MBD_DIR/etc/ssh/sshd_config
# copy in the binaries
instbin $IMGPATH /usr/bin/login $MBD_DIR /sbin/login
instbin $IMGPATH /usr/sbin/sshd $MBD_DIR /sbin/sshd
instbin $IMGPATH /usr/bin/busybox $MBD_DIR /sbin/busybox
# make some symlinks
(cd $MBD_DIR/sbin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]_\.\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
while [ -n "$1" ]; do
if [ $1 != "busybox" -a $1 != "sh" ]; then
# if file doesnt already exist, link to busybox
if [ ! -f "$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
fi
shift
done )
}
makeinitrd() {
EXTRAINITRDPATH=""
INITRDSIZE=""
KEEP=""
PADSIZE=""
LOADERBIN=""
INITRDMODULES=""
MYLANGTABLE=$LANGTABLE
MYLOADERTR=loader.tr
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--initrdto" ]; then
EXTRAINITRDPATH=$2
shift; shift
continue
elif [ $1 = "--keep" ]; then
KEEP=yes
shift
continue
elif [ $1 = "--initrdsize" ]; then
INITRDSIZE=$2
shift; shift
continue
elif [ $1 = "--loaderbin" ]; then
LOADERBIN=$2
shift; shift
continue
elif [ $1 = "--modules" ]; then
INITRDMODULES=$2
shift; shift
continue
fi
echo "Unknown option passed to makeinitrd"
exit 1
done
if [ -z "$LOADERBIN" ]; then
echo "no loader binary specified!" >&2
exit 1
fi
if [ -z "$INITRDMODULES" ]; then
echo "warning: no loader modules specified!" >&2
fi
if [ -z "$INITRDSIZE" ]; then
echo "I don't know how big to make the initrd image!" >&2
exit 1
fi
MBD_DIR=$TMPDIR/makebootdisk.dir.$$
MBD_FSIMAGE=$TMPDIR/makebootdisk.initrdimage.$$
MBD_BOOTTREE=$TMPDIR/makebootdisk.tree.$$
rm -rf $MBD_DIR $MBD_FSIMAGE
mkdir -p $MBD_DIR/modules
mkdir -p $MBD_DIR/sbin
mkdir -p $MBD_DIR/dev
mkdir -p $MBD_DIR/etc
mkdir -p $MBD_DIR/etc/udev/rules.d
mkdir -p $MBD_DIR/lib/udev/rules.d
mkdir -p $MBD_DIR/proc
mkdir -p $MBD_DIR/selinux
mkdir -p $MBD_DIR/sys
mkdir -p $MBD_DIR/etc/terminfo/{a,b,d,l,s,v,x}
mkdir -p $MBD_DIR/tmp
mkdir -p $MBD_DIR/usr/libexec
mkdir -p $MBD_DIR/usr/$LIBDIR/NetworkManager
mkdir -p $MBD_DIR/usr/share/dbus-1/system-services
mkdir -p $MBD_DIR/var/cache/hald
mkdir -p $MBD_DIR/var/lib/dbus
mkdir -p $MBD_DIR/var/lib/dhclient
mkdir -p $MBD_DIR/var/lock/rpm
mkdir -p $MBD_DIR/var/run
mkdir -p $MBD_DIR/var/run/dbus
mkdir -p $MBD_DIR/var/run/hald
mkdir -p $MBD_DIR/var/run/NetworkManager
mkdir -p $MBD_DIR/etc/dbus-1/system.d
mkdir -p $MBD_DIR/etc/modprobe.d
mkdir -p $MBD_DIR/etc/NetworkManager/dispatcher.d
mkdir -p $MBD_DIR/$LIBDIR/dbus-1
mkdir -p $MBD_DIR/etc/sysconfig/network-scripts
mkdir -p $MBD_DIR/usr/share/PolicyKit/policy
mkdir -p $MBD_DIR/etc/PolicyKit
mkdir -p $MBD_DIR/var/lib/misc
mkdir -p $MBD_DIR/etc/hal/fdi
mkdir -p $MBD_DIR/usr/share/hal/fdi
mkdir -p $MBD_DIR/usr/share/hwdata
mkdir -p $MBD_DIR/etc/rc.d/init.d
mkdir -p $MBD_DIR/usr/sbin
mkdir -p $MBD_DIR/var/run/wpa_supplicant
if [ "$BUILDARCH" = "s390" -o "$BUILDARCH" = "s390x" ]; then
mkdir -m 111 -p $MBD_DIR/var/empty/sshd
mkdir -p $MBD_DIR/etc/{pam.d,security}
mkdir -p $MBD_DIR/$LIBDIR/security
cp $IMGPATH/$LIBDIR/libpam_misc.so.0.* $MBD_DIR/$LIBDIR/libpam_misc.so.0
ln -s /tmp $MBD_DIR/var/state/xkb
cp $IMGPATH/usr/bin/xauth $MBD_DIR/sbin/xauth
cp $IMGPATH/usr/sbin/cmsfs* $MBD_DIR/sbin/
fi
if [ -n "$INITRDMODULES" ]; then
MODSET=`expandModuleSet "$INITRDMODULES"`
makemoduletree $MBD_DIR "$MODSET"
fi
# set up the arch bits
echo $arch > $MBD_DIR/etc/arch
echo "Setting up arch bits"
instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/$LOADERBIN $MBD_DIR /sbin/loader
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/init $MBD_DIR /sbin/init
ln -s ./init $MBD_DIR/sbin/reboot
ln -s ./init $MBD_DIR/sbin/halt
ln -s ./init $MBD_DIR/sbin/poweroff
else
instbin $IMGPATH ${LOADERBINDIR##IMGPATH}/shutdown $MBD_DIR /sbin/shutdown
instbin $IMGPATH /usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR /sbin/init
instbin $IMGPATH /usr/sbin/dasdfmt $MBD_DIR /sbin/dasdfmt
fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
install -m 644 $KEYMAPS $MBD_DIR/etc/keymaps.gz
install -m 644 $SCREENFONT $MBD_DIR/etc/screenfont.gz
fi
install -m 644 $MYLANGTABLE $MBD_DIR/etc/lang-table
install -m 644 $IMGPATH/etc/passwd $MBD_DIR/etc/passwd
install -m 644 $IMGPATH/etc/group $MBD_DIR/etc/group
install -m 644 $IMGPATH/etc/nsswitch.conf $MBD_DIR/etc/nsswitch.conf
instbin $IMGPATH /usr/bin/mount $MBD_DIR /sbin/mount
instbin $IMGPATH /usr/sbin/mount.nfs $MBD_DIR /sbin/mount.nfs
instbin $IMGPATH /usr/bin/umount $MBD_DIR /sbin/umount
ln -s mount.nfs $MBD_DIR/sbin/umount.nfs
instbin $IMGPATH /usr/sbin/udevd $MBD_DIR /sbin/udevd
instbin $IMGPATH /usr/sbin/udevadm $MBD_DIR /sbin/udevadm
instbin $IMGPATH /usr/bin/udevinfo $MBD_DIR /sbin/udevinfo
ln -s udevadm $MBD_DIR/sbin/udevsettle
instbin $IMGPATH /usr/bin/bash $MBD_DIR /sbin/bash
( cd $MBD_DIR/sbin ; ln -sf bash sh )
instbin $IMGPATH /usr/sbin/consoletype $MBD_DIR /sbin/consoletype
instbin $IMGPATH /usr/bin/logger $MBD_DIR /sbin/logger
( cd $IMGPATH/etc/rc.d/init.d
cp -a functions $MBD_DIR/etc/rc.d/init.d
)
( cd $IMGPATH/etc/sysconfig/network-scripts
cp -a network-functions $MBD_DIR/etc/sysconfig/network-scripts
cp -a network-functions-ipv6 $MBD_DIR/etc/sysconfig/network-scripts
)
( cd $MBD_DIR/etc ; ln -sf /etc/rc.d/init.d init.d )
# DHCP and DHCPv6 client daemons and support programs
instbin $IMGPATH /usr/sbin/dhclient $MBD_DIR /sbin/dhclient
cp -a $IMGPATH/usr/sbin/dhclient-script $MBD_DIR/sbin/dhclient-script
chmod 0755 $MBD_DIR/sbin/dhclient-script
instbin $IMGPATH /usr/sbin/dhcp6c $MBD_DIR /sbin/dhcp6c
instbin $IMGPATH /usr/sbin/arping $MBD_DIR /sbin/arping
instbin $IMGPATH /usr/sbin/ifconfig $MBD_DIR /sbin/ifconfig
instbin $IMGPATH /usr/sbin/ip $MBD_DIR /sbin/ip
touch $MBD_DIR/etc/resolv.conf
# hwdata
cp -a $IMGPATH/usr/share/hwdata/pci.ids $MBD_DIR/usr/share/hwdata/pci.ids
cp -a $IMGPATH/usr/share/hwdata/usb.ids $MBD_DIR/usr/share/hwdata/usb.ids
# hal
instbin $IMGPATH /usr/sbin/hald $MBD_DIR /sbin/hald
( cd $IMGPATH/usr/libexec
for f in hald-runner hald-generate-fdi-cache hal*storage* ; do
instbin $IMGPATH /usr/libexec/$f $MBD_DIR /usr/libexec/$f
done
)
touch $MBD_DIR/var/run/hald.acl-list
cp -a $IMGPATH/usr/share/hal/fdi/* $MBD_DIR/usr/share/hal/fdi
cp -a $IMGPATH/etc/hal/fdi/* $MBD_DIR/etc/hal/fdi
cp -a $IMGPATH/etc/dbus-1/system.d/hal.conf $MBD_DIR/etc/dbus-1/system.d
# PolicyKit
( cd $IMGPATH/etc/PolicyKit
cp -a PolicyKit.conf $MBD_DIR/etc/PolicyKit
)
( cd $IMGPATH/usr/share/dbus-1/system-services
cp -a org.freedesktop.PolicyKit.service $MBD_DIR/usr/share/dbus-1/system-services
)
( cd $IMGPATH/usr/share/PolicyKit/policy
cp -a org.freedesktop.policykit.policy $MBD_DIR/usr/share/PolicyKit/policy
)
( cd $IMGPATH/var/lib/misc
cp -a PolicyKit.reload $MBD_DIR/var/lib/misc
)
# dbus
instbin $IMGPATH /usr/bin/dbus-uuidgen $MBD_DIR /sbin/dbus-uuidgen
instbin $IMGPATH /usr/bin/dbus-daemon $MBD_DIR /sbin/dbus-daemon
cp -a $IMGPATH/etc/dbus-1/system.conf $MBD_DIR/etc/dbus-1/system.conf
cp -a $IMGPATH/$LIBDIR/dbus-1/dbus-daemon-launch-helper $MBD_DIR/$LIBDIR/dbus-1
chown root:dbus $MBD_DIR/$LIBDIR/dbus-1/dbus-daemon-launch-helper
chmod 04750 $MBD_DIR/$LIBDIR/dbus-1/dbus-daemon-launch-helper
# wpa_supplicant
instbin $IMGPATH /usr/sbin/wpa_passphrase $MBD_DIR /usr/sbin/wpa_passphrase
instbin $IMGPATH /usr/sbin/wpa_supplicant $MBD_DIR /usr/sbin/wpa_supplicant
cp -a $IMGPATH/etc/dbus-1/system.d/wpa_supplicant.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/wpa_supplicant/wpa_supplicant.conf $MBD_DIR/etc/wpa_supplicant
( cd $IMGPATH/usr/share/dbus-1/system-services
cp -a fi.epitest.hostap.WPASupplicant.service $MBD_DIR/usr/share/dbus-1/system-services
)
# NetworkManager
instbin $IMGPATH /usr/sbin/NetworkManager $MBD_DIR /usr/sbin/NetworkManager
instbin $IMGPATH /usr/sbin/nm-system-settings $MBD_DIR /usr/sbin/nm-system-settings
cp -a $IMGPATH/etc/dbus-1/system.d/nm-*.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/dbus-1/system.d/NetworkManager.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/NetworkManager/nm-system-settings.conf $MBD_DIR/etc/NetworkManager
instbin $IMGPATH /usr/$LIBDIR/NetworkManager/libnm-settings-plugin-ifcfg-fedora.so \
$MBD_DIR /usr/$LIBDIR/NetworkManager/libnm-settings-plugin-ifcfg-fedora.so
( cd $IMGPATH/usr/libexec
for f in nm-* ; do
instbin $IMGPATH /usr/libexec/$f $MBD_DIR /usr/libexec/$f
done
)
( cd $IMGPATH/usr/share/dbus-1/system-services
cp -a org.freedesktop.NetworkManagerSystemSettings.service $MBD_DIR/usr/share/dbus-1/system-services
cp -a org.freedesktop.nm_dispatcher.service $MBD_DIR/usr/share/dbus-1/system-services
)
# Indirect dependencies
install -m 755 $IMGPATH/$LIBDIR/libfreebl3.so $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libsoftokn3.so $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/usr/$LIBDIR/libsqlite3.so.0 $MBD_DIR/usr/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libnss_dns.so.2 $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libnss_files.so.2 $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libgcc_s.so.1 $MBD_DIR/$LIBDIR/
install -m 644 $IMGPATH/etc/udev/udev.conf $MBD_DIR/etc/udev/udev.conf
for i in $IMGPATH/lib/udev/rules.d/*.rules ; do
install -m 644 $i $MBD_DIR/lib/udev/rules.d/${i##*/}
done
for i in $IMGPATH/etc/udev/rules.d/*.rules ; do
install -m 644 $i $MBD_DIR/etc/udev/rules.d/${i##*/}
done
for i in $IMGPATH/lib/udev/*; do
if [ -f $i ]; then install -m 755 $i $MBD_DIR/lib/udev/${i##*/}; fi
done
rm -f $MBD_DIR/lib/udev/rules.d/*persistent*
rm -f $MBD_DIR/lib/udev/rules.d/*generator*
install -m 644 $LOADERBINDIR/$MYLOADERTR $MBD_DIR/etc/loader.tr
for i in a/ansi d/dumb l/linux s/screen v/vt100 v/vt100-nav v/vt102 x/xterm x/xterm-color g/gnome ; do
[ -f $IMGPATH/usr/share/terminfo/$i ] && \
install -m 644 $IMGPATH/usr/share/terminfo/$i $MBD_DIR/etc/terminfo/$i
done
makeproductfile $MBD_DIR
for n in insmod rmmod modprobe; do
instbin $IMGPATH /usr/sbin/$n $MBD_DIR /sbin/$n
done
ln -s /sbin/init $MBD_DIR/init
ln -s /proc/mounts $MBD_DIR/etc/mtab
ln -s sbin $MBD_DIR/bin
mkdir -p $MBD_DIR/var/lib
ln -s ../../tmp $MBD_DIR/var/lib/xkb
# s390/s390x need sshd setup
if [ "$BUILDARCH" = "s390" -o "$BUILDARCH" = "s390x" ]; then
setupShellEnvironment
fi
cat > $MBD_DIR/.profile <<EOF
PATH=/bin:/usr/bin:/usr/sbin:/mnt/sysimage/sbin:/mnt/sysimage/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin
export PATH
EOF
rm -f $MBD_FSIMAGE
(cd $MBD_DIR; find . |cpio --quiet -c -o) |gzip -9 > $MBD_FSIMAGE
size=$(du $MBD_FSIMAGE | awk '{ print $1 }')
echo "Wrote $MBD_FSIMAGE (${size}k compressed)"
if [ -n "$EXTRAINITRDPATH" ]; then
mkdir -p `dirname $EXTRAINITRDPATH`
cp -a $MBD_FSIMAGE $EXTRAINITRDPATH
fi
if [ -z "$KEEP" ]; then
rm -rf $MBD_FSIMAGE $MBD_BOOTTREE
fi
}
makemainimage () {
imagename=$1
type=$2
mmi_tmpimage=$TMPDIR/instimage.img.$$
mmi_mntpoint=$TMPDIR/instimage.mnt.$$
rm -rf $mmi_tmpimage $mmi_mntpoint
mkdir $mmi_mntpoint
if [ $type = "ext2" ]; then
SIZE=$(du -sk $IMGPATH | awk '{ print int($1 * 1.1) }')
if [ -d $IMGPATH/usr/lib/anaconda-runtime ]; then
ERROR=$(du -sk $IMGPATH/usr/lib/anaconda-runtime | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
fi
if [ -d $IMGPATH/usr/lib/syslinux ]; then
ERROR=$(du -sk $IMGPATH/usr/lib/syslinux | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
fi
dd if=/dev/zero bs=1k count=${SIZE} of=$mmi_tmpimage 2>/dev/null
mke2fs -q -F $mmi_tmpimage > /dev/null
tune2fs -c0 -i0 $mmi_tmpimage >/dev/null
mount -o loop $mmi_tmpimage $mmi_mntpoint
(cd $IMGPATH; find . |
fgrep -v "./usr/lib/anaconda-runtime" |
fgrep -v "./usr/lib/syslinux"
cpio -H crc -o) | (cd $mmi_mntpoint; cpio -iumd)
makeproductfile $mmi_mntpoint
umount $mmi_mntpoint
rmdir $mmi_mntpoint
elif [ $type = "squashfs" ]; then
makeproductfile $IMGPATH
echo "Running mksquashfs $IMGPATH $mmi_tmpimage -all-root -no-fragments -no-progress"
mksquashfs $IMGPATH $mmi_tmpimage -all-root -no-fragments -no-progress
chmod 0644 $mmi_tmpimage
SIZE=$(expr `cat $mmi_tmpimage | wc -c` / 1024)
elif [ $type = "cramfs" ]; then
makeproductfile $IMGPATH
echo "Running mkcramfs $CRAMBS $IMGPATH $mmi_tmpimage"
mkfs.cramfs $CRAMBS $IMGPATH $mmi_tmpimage
SIZE=$(expr `cat $mmi_tmpimage | wc -c` / 1024)
fi
cp $mmi_tmpimage $INSTIMGPATH/${imagename}.img
chmod 644 $INSTIMGPATH/${imagename}.img
echo "Wrote $INSTIMGPATH/${imagename}.img (${SIZE}k)"
relpath=${INSTIMGPATH#$TOPDESTPATH/}
echo "mainimage = ${relpath}/${imagename}.img" >> $TOPDESTPATH/.treeinfo
rm $mmi_tmpimage
}
makeSecondStage() {
echo "[stage2]" >> $TOPDESTPATH/.treeinfo
echo "Building install.img"
makemainimage "install" "squashfs"
[ $? = 0 ] || exit 1
}
doPostImages() {
/bin/true
}
# this gets overloaded if we're on an EFI-capable arch (... with grub)
makeEfiImages()
{
/bin/true
}
# source the architecture specific mk-images file so we can call functions
# in it
if [ ${BUILDARCH} = s390x ]; then
# FIXME: this is a bad hack for s390, but better than copying for now
source $TOPDIR/mk-images.s390
elif [ ${BUILDARCH} = ppc64 ]; then
# ... and similar for ppc64
source $TOPDIR/mk-images.ppc
elif [ ${BUILDARCH} = "x86_64" -o ${BUILDARCH} = "i386" ]; then
source $TOPDIR/mk-images.x86
source $TOPDIR/mk-images.efi
else
source $TOPDIR/mk-images.${BUILDARCH}
fi
# Find the kernel, unpack it, and verify it
kerneltags="kernel"
efiarch=""
arches="$BUILDARCH"
if [ "$BUILDARCH" = "ppc" ]; then
arches="ppc64 ppc"
elif [ "$BUILDARCH" = "i386" ]; then
arches="i586"
efiarch="ia32"
kerneltags="kernel kernel-PAE"
kernelxen="kernel-PAE"
elif [ "$BUILDARCH" = "x86_64" ]; then
kerneltags="kernel"
efiarch="x64"
elif [ "$BUILDARCH" = "ia64" ]; then
kerneltags="kernel"
efiarch="ia64"
fi
foundakernel=""
for KERNELARCH in $arches; do
for kernelvers in $kerneltags; do
kpackage=$(findPackage $kernelvers)
if [ "$KERNELARCH" = "i586" -a -z "$kpackage" ]; then
echo "No i586 kernel, trying i686..."
KERNELARCH="i686"
kpackage=$(findPackage $kernelvers)
fi
if [ -z "$kpackage" ]; then
echo "Unable to find kernel package $kernelvers"
continue
fi
yumdownloader -c $yumconf --archlist=$KERNELARCH $kpackage
kpackage="$kpackage.rpm"
if [ ! -f "$kpackage" ]; then
echo "kernel ($kernelvers) doesn't exist for $KERNELARCH. skipping"
continue
fi
KERNELROOT=$KERNELBASE/$KERNELARCH
mkdir -p $KERNELROOT
foundakernel="yes"
if [ "$BUILDARCH" = "ia64" ]; then
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/efi/EFI/redhat/vmlinuz | head -n 1)
version=${vmlinuz##/boot/efi/EFI/redhat/vmlinuz-}
else
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/vmlinuz | head -n 1)
version=${vmlinuz##/boot/vmlinuz-}
fi
arch=$(rpm --nodigest --nosignature --qf '%{ARCH}\n' -qp $kpackage)
rpm2cpio $kpackage | (cd $KERNELROOT; cpio --quiet -iumd)
rm -f $kpackage
# expand out any available firmware too
for p in $(repoquery -c $yumconf '*firmware*') ; do yumdownloader -c $yumconf $p ; rpm2cpio *firmware*.rpm | (cd $KERNELROOT; cpio --quiet -iumd) ; rm -f *firmware*.rpm ; done
if [ ! -d "$KERNELROOT/lib/modules/$version" ]; then
echo "$KERNELROOT/lib/modules/$version is not a valid modules directory" 2>&1
exit 1
fi
if [ ! -f "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version" ]; then
echo "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version does not exist"
exit 1
fi
allmods=$(find $KERNELROOT/lib/modules/$version -name *.ko)
rundepmod $KERNELROOT
$GENMODINFO $KERNELROOT/lib/modules/$version > $MODINFO
# make the boot images
makeBootImages
makeEfiImages $yumconf
done
done
if [ -n "$foundakernel" ]; then
makeSecondStage
rm -rf $KERNELBASE
fi
doPostImages
cd $TOPDIR

View File

@ -0,0 +1,131 @@
#
# mk-images.alpha
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
INITRDMODS="tgafb crc32 $INITRDMODS"
###FSMODS="msdos vfat ext3 reiserfs jfs xfs"
###IDEMODS="cdrom ide-cd"
###SCSIMODS="cdrom scsi_mod sd_mod sg sr_mod st"
###USBMODS="ohci-hcd uhci-hcd hid usb-storage sd_mod sr_mod"
###LATEUSBMODS="mousedev usb-storage"
###SECSTAGE="md raid0 raid1 raid5 dm-mod srm_env $FSMODS $IDEMODS $SCSIMODS $LATEUSBMODS"
NETMODULES="e100 tulip 8139too tulip 3c509 3c59x dl2k eepro epic100 ewrk3 hamachi natsemi ne2k-pci ns83820 starfire yellowfin de4x5 depca acenic tg3"
SCSIMODULES="$SCSIMODS qlogicisp DAC960 cpqfc BusLogic 3w-xxxx dmx3191d dpt_i2o megaraid ncr53c8xx sym53c8xx qlogicfc qla2x00 qla1280 cciss cpqarray aic7xxx aha1740 megaraid"
###ISOMODULES="ehci-hcd ieee1394 ohci1394 sbp2"
prepareBootImage() {
echo "ALPHA: prepareBootImage() is called"
dd if=/dev/zero of=$MBD_TMPIMAGE bs=1k count=$BOOTDISKSIZE 2>/dev/null
echo y | /sbin/mke2fs -b 1024 -r 0 -O none $MBD_TMPIMAGE > /dev/null 2>/dev/null
LODEV=`findloopdevice $MBD_TMPIMAGE`
e2writeboot $LODEV $BOOTDISKDIR/bootlx
mount $LODEV -t ext2 $MBD_BOOTTREE
mkdir -p $MBD_BOOTTREE/etc
cat > $MBD_BOOTTREE/etc/aboot.conf <<EOF
#
# Fedora Linux aboot configuration options:
#
# 0 - Boot the Fedora Linux installer using a 2.6 kernel
# 1 - Boot the Fedora Linux installer in non graphical mode
# 2 - Boot the Fedora Linux installer in text only mode on ttyS0
# for installation control via the serial port
# 3 - Boot in rescue mode
#
0:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 root=/dev/fd0
1:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 text root=/dev/fd0
2:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=ttyS0 text root=/dev/fd0
3:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 rescue root=/dev/fd0
EOF
cat > $MBD_BOOTTREE/etc/milo.conf <<EOF
image=/vmlinux.gz
label=linux
root=/dev/fd0
append="load_ramdisk=1 prompt_ramdisk=1"
EOF
zcat $KERNELROOT/boot/vmlinuz-* | gzip -9 > $MBD_BOOTTREE/vmlinux.gz
umount $LODEV
losetup -d $LODEV
mount -o loop -t ext2 $MBD_TMPIMAGE $MBD_BOOTTREE
}
makeBootImages() {
echo "Building boot images for kernel $kernelvers"
mkdir -p $TOPDESTPATH/boot
cp $BOOTDISKDIR/bootlx $TOPDESTPATH/boot
mkdir -p $TOPDESTPATH/etc
cat > $TOPDESTPATH/etc/aboot.conf <<EOF
#
# Fedora Linux aboot configuration options:
#
# 0 - Boot the Fedora Linux installer using a 2.6 kernel
# 1 - Boot the Fedora Linux installer with kernel messages sent to ttyS0
# 2 - Boot the Fedora Linux installer in text only mode
# 3 - Boot the Fedora Linux installer in text only rescue mode
#
0:/kernels/vmlinux.gz initrd=/images/initrd.img
1:/kernels/vmlinux.gz initrd=/images/initrd.img console=ttyS0
2:/kernels/vmlinux.gz initrd=/images/initrd.img text
3:/kernels/vmlinux.gz initrd=/images/initrd.img rescue
EOF
mkdir -p $TOPDESTPATH/kernels
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/kernels/vmlinux.gz
makeinitrd --initrdto $TOPDESTPATH/images/ramdisk.img \
--initrdsize 8192 \
--loaderbin loader \
--modules "$NETMODULES $SCSIMODULES"
echo "List of init modules: $INITRDMODS"
makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
# makebootdisk --bootdisksize 4096 --kernelto $TOPDESTPATH/kernels/vmlinux.gz \
# --imagename generic.img
if [ -f $KERNELPATH/kernel-jensen-*.rpm ]; then
KJ_PKG=$KERNELPATH/kernel-jensen-*.rpm
KJ_DIR=/tmp/kernelj.dir.$$
mkdir -p $KJ_DIR
rpm2cpio $KJ_PKG | (cd $KJ_DIR; cpio --quiet -iumd ./boot/vmlinuz-*)
cp $KJ_DIR/boot/vmlinuz-* $TOPDESTPATH/kernels/vmlinuz.j
rm -rf $KJ_DIR
fi
# makedriverdisk --padsize 1440 "Supplemental Block Device Drivers" "drvblock" "$SCSIMODULES $EXTRASCSI +scsi"
# makedriverdisk --padsize 1440 "Supplemental Network Device Drivers" "drvnet" "$NETMODULES $EXTRANET +net"
}
#makeSecondStage() {
# makeinstimage "netstg" "$SECSTAGE $SCSIMODULES $IDEMODS =scsi"
# makeinstimage "hdstg" "$SECSTAGE $NETMODULES $IDEMODS =net"
# makemainmodules "$SECSTAGE $NETMODULES $SCSIMODULES $IDEMODS =scsi =net"
# makemainimage "install" "cramfs"
#}

199
rewrite/scratch/mk-images.efi Executable file
View File

@ -0,0 +1,199 @@
#!/bin/bash
#
# mk-images.efi
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
makeefibootdisk()
{
partimg=$1
target=$2
if [ ! -f $1 ]; then
return
fi
local partsize=$(ls -l $1 | awk '{ print $5; }')
local disksize=$((17408 + $partsize + 17408))
disksize=$(($disksize + $(($disksize % 512))))
local diskimg=$(mktemp /tmp/efidisk.img.XXXXXX)
dd if=/dev/zero of=$diskimg count=1 bs=$disksize
local loop=$(losetup -v -f $diskimg | awk '{ print $4 }')
dmsetup create efiboot$$ --table "0 $(($disksize / 512)) linear $loop 0"
parted --script /dev/mapper/efiboot$$ mklabel gpt unit b mkpart '"EFI System Partition"' fat32 17408 $((17408 + $partsize)) set 1 boot on
dd if=$partimg of=/dev/mapper/efiboot$$p1
dmsetup remove /dev/mapper/efiboot$$p1
dmsetup remove /dev/mapper/efiboot$$
losetup -d $loop
mv -v $diskimg $target
chmod a+r $target
}
#makeefibootimage required for EFI bootloader dosfs image
makeefibootimage() {
MBD_FILENAME=""
KERNELFILE=""
INITRDFILE=""
grubpkg=""
MBD_TMPIMAGE=${TMPDIR:-/tmp}/makebootdisk.image.$$
MBD_BOOTTREE=${TMPDIR:-/tmp}/makebootdisk.tree.$$
MBD_BOOTTREE_TMP=$MBD_BOOTTREE'_tmp'
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--kernel" ]; then
KERNELFILE=$2
shift; shift
continue
elif [ $1 = "--initrd" ]; then
INITRDFILE=$2
shift; shift
continue
elif [ $1 = "--imagename" ]; then
MBD_FILENAME=$IMAGEPATH/$2
shift; shift
continue
elif [ $1 = "--grubpkg" ]; then
grubpkg=$2
shift; shift
continue
fi
echo "Unknown option passed to makebootdisk"
exit 1
done
if [ -z "$MBD_FILENAME" ]; then
echo "No imagename passed"
exit 1
fi
if [ -z "$KERNELFILE" ]; then
echo "No kernel file passed"
exit 1
fi
if [ -z "$INITRDFILE" ]; then
echo "No initrd file passed"
exit 1
fi
MBD_FSIMAGE="$INITRDFILE"
mkdir -p $MBD_BOOTTREE
mkdir -p $MBD_BOOTTREE_TMP
rm -rf $MBD_BOOTTREE_TMP
mkdir -p $MBD_TMPIMAGE
# provided by the mk-image.$ARCH file
prepareEfiImage
left=$(df $MBD_BOOTTREE | tail -n1)
left=$(echo $left | awk '{print $4'})
umount $MBD_BOOTTREE
if [ -n "$EXTRAKERNELPATH" ]; then
mkdir -p `dirname $EXTRAKERNELPATH`
cp -f $KERNELROOT/$KERNELDIR/${KERNELNAME}-* $EXTRAKERNELPATH
fi
mkdir -p `dirname $MBD_FILENAME`
rm -rf $MBD_TMPIMAGE $MBD_MNTPOINT $MBD_BOOTTREE
if [ -z "$INITRDFILE" ]; then
rm -f $MBD_FSIMAGE
fi
chmod a+r $MBD_FILENAME
echo "Wrote $MBD_FILENAME (${left}k free)"
}
# prepare and build an efiboot.img.
prepareEfiImage() {
prepareEfiTree || return 1
# dynamically calculate the size of the dosfs
BOOTDISKSIZE=$(du -kcs $MBD_BOOTTREE_TMP | tail -n1 | awk '{print $1}')
BOOTDISKSIZE=$(expr $BOOTDISKSIZE + 100)
echo "The size of the efiboot.img dosfs is $BOOTDISKSIZE"
mkdosfs -n ANACONDA -C $MBD_FILENAME $BOOTDISKSIZE >/dev/null
mount -o loop,shortname=winnt,umask=0077 -t vfat $MBD_FILENAME $MBD_BOOTTREE
cp -R $MBD_BOOTTREE_TMP/* $MBD_BOOTTREE
}
# prepare a directory with the kernel, initrd, and various message files
# used to populate the efi boot image
prepareEfiTree() {
mkdir -p $MBD_BOOTTREE_TMP/EFI/boot
cp -a $BOOTDISKDIR/* $MBD_BOOTTREE_TMP/EFI/boot/
cp $INITRDFILE $MBD_BOOTTREE_TMP/EFI/boot/initrd.img
cp $KERNELFILE $MBD_BOOTTREE_TMP/EFI/boot/vmlinuz
sed -i "s/@PRODUCT@/$PRODUCT/g" $MBD_BOOTTREE_TMP/EFI/boot/grub.conf
sed -i "s/@VERSION@/$VERSION/g" $MBD_BOOTTREE_TMP/EFI/boot/grub.conf
yumdownloader -c $yumconf $grubpkg
rpm2cpio $grubpkg.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
cp $KERNELROOT/boot/efi/EFI/redhat/grub.efi $MBD_BOOTTREE_TMP/EFI/boot/grub.efi
# The first generation Mactel machines get the bootloader name wrong
# as per the spec. Awesome, guys.
if [ "$efiarch" == "ia32" ]; then
cp $MBD_BOOTTREE_TMP/EFI/boot/grub.efi $MBD_BOOTTREE_TMP/EFI/boot/boot.efi
cp $MBD_BOOTTREE_TMP/EFI/boot/grub.conf $MBD_BOOTTREE_TMP/EFI/boot/boot.conf
fi
mv $MBD_BOOTTREE_TMP/EFI/boot/grub.efi $MBD_BOOTTREE_TMP/EFI/boot/boot${efiarch}.efi
mv $MBD_BOOTTREE_TMP/EFI/boot/grub.conf $MBD_BOOTTREE_TMP/EFI/boot/boot${efiarch}.conf
artpkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" --whatprovides system-logos | grep -v generic-logos | head -1)
if [ -z "$artpkg" ]; then
argpkg="generic-logos"
fi
yumdownloader -c $yumconf $artpkg
rpm2cpio $artpkg.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
cp $KERNELROOT/boot/grub/splash.xpm.gz $MBD_BOOTTREE_TMP/EFI/boot/splash.xpm.gz
}
makeEfiImages() {
yumconf="$1"
if [ "$kernelvers" != "$kernelxen" ]; then
local grubarch=${efiarch}
case ${efiarch} in
ia32) grubarch=i386 ;;
x64) grubarch=x86_64 ;;
esac
grubpkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" -c $yumconf grub.$grubarch)
if [ -z "$grubpkg" ]; then
echo "cannot find package grub.$grubarch" >&2
return 1
fi
echo "Building efiboot.img for ${efiarch}/$KERNELARCH at $TOPDESTPATH/images/efiboot.img"
makeefibootimage \
--imagename pxeboot/efiboot.img \
--kernel $TOPDESTPATH/images/pxeboot/vmlinuz \
--initrd $TOPDESTPATH/images/pxeboot/initrd.img \
--grubpkg ${grubpkg}
local ret=$?
[ $ret -eq 0 ] || return $ret
makeefibootdisk $TOPDESTPATH/images/pxeboot/efiboot.img $TOPDESTPATH/images/efidisk.img
return $?
fi
return 1
}

View File

@ -0,0 +1,173 @@
#!/bin/bash
#
# mk-images.ia64
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#makebootdisk required for EFI bootloader dosfs image
makebootdisk() {
EXTRAKERNELPATH=""
INITRDFLAGS=""
MBD_FILENAME=""
INITRDFILE=""
MBD_TMPIMAGE=${TMPDIR:-/tmp}/makebootdisk.image.$$
MBD_BOOTTREE=${TMPDIR:-/tmp}/makebootdisk.tree.$$
MBD_BOOTTREE_TMP=$MBD_BOOTTREE'_tmp'
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--kernelto" ]; then
EXTRAKERNELPATH=$2
shift; shift
continue
elif [ $1 = "--initrdflags" ]; then
INITRDFLAGS=$2
shift; shift
continue
elif [ $1 = "--initrd" ]; then
INITRDFILE=$2
shift; shift
continue
elif [ $1 = "--imagename" ]; then
MBD_FILENAME=$IMAGEPATH/$2
shift; shift
continue
fi
echo "Unknown option passed to makebootdisk"
exit 1
done
if [ -z "$MBD_FILENAME" ]; then
echo "No imagename passed"
exit 1
fi
if [ -n "$INITRDFILE" ]; then
MBD_FSIMAGE="$INITRDFILE"
elif [ -n "$INITRDFLAGS" ]; then
eval makeinitrd --keep $INITRDFLAGS
fi
mkdir -p $MBD_BOOTTREE
mkdir -p $MBD_BOOTTREE_TMP
rm -rf $MBD_BOOTTREE_TMP
mkdir -p $MBD_TMPIMAGE
# provided by the mk-image.$ARCH file
prepareBootImage
left=$(df $MBD_BOOTTREE | tail -n1)
left=$(echo $left | awk '{print $4'})
umount $MBD_BOOTTREE
if [ -n "$EXTRAKERNELPATH" ]; then
mkdir -p `dirname $EXTRAKERNELPATH`
cp -f $KERNELROOT/$KERNELDIR/${KERNELNAME}-* $EXTRAKERNELPATH
fi
mkdir -p `dirname $MBD_FILENAME`
rm -rf $MBD_TMPIMAGE $MBD_MNTPOINT $MBD_BOOTTREE
if [ -z "$INITRDFILE" ]; then
rm -f $MBD_FSIMAGE
fi
echo "Wrote $MBD_FILENAME (${left}k free)"
}
prepareBootImage() {
prepareBootTree
# dynamically calculate the size of the dosfs
BOOTDISKSIZE=$(du -kcs $MBD_BOOTTREE_TMP | tail -n1 | awk '{print $1}')
BOOTDISKSIZE=$(expr $BOOTDISKSIZE + 100)
echo "The size of the boot.img dosfs is $BOOTDISKSIZE"
mkdosfs -n ANACONDA -C $MBD_FILENAME $BOOTDISKSIZE >/dev/null
mount -o loop -t vfat $MBD_FILENAME $MBD_BOOTTREE
cp -R $MBD_BOOTTREE_TMP/* $MBD_BOOTTREE
}
prepareBootTree() {
mkdir -p $MBD_BOOTTREE_TMP/EFI/boot
cp $MBD_FSIMAGE $MBD_BOOTTREE_TMP/EFI/boot/initrd.img
cp -a $BOOTDISKDIR/* $MBD_BOOTTREE_TMP/EFI/boot/
cp $KERNELROOT/boot/efi/EFI/redhat/vmlinuz-* $MBD_BOOTTREE_TMP/EFI/boot/vmlinuz
cp $MBD_BOOTTREE_TMP/EFI/boot/elilo.efi $MBD_BOOTTREE_TMP/EFI/boot/bootia64.efi
cat > $MBD_BOOTTREE_TMP/EFI/boot/elilo.conf << EOF
prompt
timeout=50
relocatable
image=vmlinuz
label=linux
read-only
initrd=initrd.img
EOF
# make a copy in the root of the image
cp $MBD_BOOTTREE_TMP/EFI/boot/* $MBD_BOOTTREE_TMP
}
makeBootImages() {
# Because ia64 boxes use EFI there needs to be a boot.img dosfs.
echo "making boot.img for EFI bootloader"
makebootdisk --kernelto $TOPDESTPATH/kernels/vmlinuz \
--imagename boot.img \
--initrdflags '--initrdto $TOPDESTPATH/images/ramdisk.img \
--initrdsize 12288 \
--loaderbin loader \
--modules "$INITRDMODS sgiioc4" '
mkdir -p $TOPDESTPATH/images/pxeboot
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/initrd.img \
--initrdsize 12288 \
--loaderbin loader \
--modules "$INITRDMODS sgiioc4"
[ $? = 0 ] || exit 1
mv $TOPDESTPATH/kernels/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
rmdir $TOPDESTPATH/kernels
# make a pxe dir with kernel + initrd
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
The files in this directory are useful for booting a machine via PXE.
The following files are available:
vmlinuz - the kernel used for the installer
initrd.img - an initrd with support for all install methods and
drivers supported for installation of $PRODUCT
EOF
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
boot.img = images/boot.img
[images-xen]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
__EOT__
}
doPostImages() {
if [ -n "$BOOTISO" ]; then
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b boot.img -no-emul-boot -R -J -V "$PRODUCT" -T -graft-points boot.img=$TOPDESTPATH/images/boot.img images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
fi
}

View File

@ -0,0 +1,171 @@
#
# mk-images.ppc
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
makeBootImages() {
echo "Building boot images for kernel $kernelvers"
FAKEARCH=""
if [ "$KERNELARCH" = "ppc64" ]; then
mkdir -p $TOPDESTPATH/ppc/ppc64
echo "Building $KERNELARCH initrd"
makeinitrd --initrdto $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS spufs viocd gpio_mdio"
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc64/vmlinuz
sed -e "s/%BITS%/64/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
$BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc64/yaboot.conf
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = ppc/ppc64/vmlinuz
initrd = ppc/ppc64/ramdisk.image.gz
__EOT__
if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
mkdir -p $TOPDESTPATH/images/netboot
pushd $TOPDESTPATH/ppc/ppc64
cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc64/zImage.lds
$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc64/vmlinuz no no $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc64.img
rmdir $TOPDESTPATH/images/netboot || :
rm -f $TOPDESTPATH/ppc/ppc64/zImage.lds
popd
echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
mkdir -p $TOPDESTPATH/images/netboot
$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc64.img \
-i $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
-D $IMGPATH/usr/lib/kernel-wrapper \
$TOPDESTPATH/ppc/ppc64/vmlinuz
rmdir $TOPDESTPATH/images/netboot || :
echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
fi
echo >> $TOPDESTPATH/.treeinfo
elif [ "$KERNELARCH" = "ppc" ]; then
FAKEARCH="ppc"
mkdir -p $TOPDESTPATH/ppc/ppc32
mkdir -p $TOPDESTPATH/ppc/mac
echo "Building ppc initrd"
makeinitrd --initrdto $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc32/vmlinuz
sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
$BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc32/yaboot.conf
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = ppc/ppc32/vmlinuz
initrd = ppc/ppc32/ramdisk.image.gz
__EOT__
if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
mkdir -p $TOPDESTPATH/images/netboot
pushd $TOPDESTPATH/ppc/ppc32
cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc32/zImage.lds
$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc32/vmlinuz no no $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc32.img
rmdir $TOPDESTPATH/images/netboot || :
rm -f $TOPDESTPATH/ppc/ppc32/zImage.lds
popd
echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc32.img \
-i $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
-D $IMGPATH/usr/lib/kernel-wrapper \
$TOPDESTPATH/ppc/ppc32/vmlinuz
rmdir $TOPDESTPATH/images/netboot || :
popd
echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
fi
echo >> $TOPDESTPATH/.treeinfo
else
echo "Unknown kernel arch: $KERNELARCH"
fi
}
doPostImages() {
mkdir -p $TOPDESTPATH/etc
mkdir -p $TOPDESTPATH/ppc/chrp
# Create ofboot.b and bootinfo.txt files, and yaboot binaries for Mac and CHRP
cp $BOOTDISKDIR/bootinfo.txt $TOPDESTPATH/ppc/bootinfo.txt
cp $IMGPATH/usr/lib/anaconda-runtime/boot/efika.forth $TOPDESTPATH/ppc/efika.forth
if [ -d $TOPDESTPATH/ppc/mac ]; then
cp $BOOTDISKDIR/ofboot.b $TOPDESTPATH/ppc/mac/ofboot.b
cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/mac/yaboot
fi
if [ -d $TOPDESTPATH/ppc/chrp ]; then
cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/chrp/yaboot
$IMGPATH/usr/lib/yaboot/addnote $TOPDESTPATH/ppc/chrp/yaboot
fi
# IBM firmware can't handle boot scripts properly, so for biarch installs
# we use a yaboot.conf which asks the user to select 32-bit or 64-bit kernel.
if [ -r $TOPDESTPATH/ppc/ppc32/yaboot.conf -a -r $TOPDESTPATH/ppc/ppc64/yaboot.conf ]; then
# Both kernels exist. Copy the biarch yaboot.conf into place.
sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
$BOOTDISKDIR/yaboot.conf.3264 > $TOPDESTPATH/etc/yaboot.conf
else
# Copy the one that exists, assuming one does exist
cp $TOPDESTPATH/ppc/ppc??/yaboot.conf $TOPDESTPATH/etc
fi
if [ -z "$BOOTISO" ]; then
return
fi
# Copy it all into the isopath for the boot CD
mkdir -p $TOPDESTPATH/isopath
cp -r $TOPDESTPATH/{ppc,etc} $TOPDESTPATH/isopath
# We want the ppc32 prep image in the boot.iso too.
if [ -d $TOPDESTPATH/images/netboot ]; then
mkdir -p $TOPDESTPATH/isopath/images
cp -r $TOPDESTPATH/images/netboot $TOPDESTPATH/isopath/images
rm -f $TOPDESTPATH/isopath/images/ppc64.img
fi
if [ -r $TOPDESTPATH/isopath/images/netboot/ppc32.img ]; then
PREPBOOT="-prep-boot images/netboot/ppc32.img"
fi
if [ -d $TOPDESTPATH/isopath/ppc/mac ]; then
MACBOOT="-hfs-volid $VERSION -hfs-bless $TOPDESTPATH/isopath/ppc/mac"
fi
# Create the boot.iso
mkisofs -o $TOPDESTPATH/images/$BOOTISO -chrp-boot -U $PREPBOOT \
-part -hfs -T -r -l -J -A "$PRODUCT $VERSION" -sysid PPC \
-V "PBOOT" -volset "$VERSION" -volset-size 1 -volset-seqno 1 \
$MACBOOT \
-map $BOOTDISKDIR/mapping -magic $BOOTDISKDIR/magic \
-no-desktop -allow-multidot -graft-points $TOPDESTPATH/isopath \
images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
rm -rf $TOPDESTPATH/isopath
}

View File

@ -0,0 +1,53 @@
#
# mk-images.s390
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
S390SCSIMODS="zfcp tape390"
S390DASDMODS=" dasd_diag_mod dasd_eckd_mod dasd_fba_mod dasd_mod"
S390NETMODS="ctc netiucv smsgiucv lcs qdio qeth ccwgroup crypto_api xfrm_nalgo"
S390MODS="$S390SCSIMODS $S390DASDMODS $S390NETMODS"
makeBootImages() {
makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
--initrdsize 20000 \
--loaderbin loader \
--modules "$INITRDMODS $S390MODS"
sz=$(ls -l $TOPDESTPATH/images/initrd.img | awk '{print $5}')
$GENINITRDSZ $sz $TOPDESTPATH/images/initrd.size
cp -vf $KERNELROOT/boot/${KERNELNAME}-${version} $TOPDESTPATH/images/kernel.img
cp -v $BOOTDISKDIR/generic.prm $TOPDESTPATH/images/generic.prm
cp -v $BOOTDISKDIR/generic.ins $TOPDESTPATH/generic.ins
$MKS390CDBOOT \
-i $TOPDESTPATH/images/kernel.img \
-r $TOPDESTPATH/images/initrd.img \
-p $TOPDESTPATH/images/generic.prm \
-o $TOPDESTPATH/images/cdboot.img
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = images/kernel.img
initrd = images/initrd.img
initrd.size = images/initrd.size
generic.prm = images/generic.prm
generic.ins = generic.ins
cdboot.img = images/cdboot.img
__EOT__
}

View File

@ -0,0 +1,164 @@
#
# mk-images.x86
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
SYSLINUX=$IMGPATH/usr/lib/syslinux/syslinux-nomtools
if [ ! -f $SYSLINUX ]; then
echo "Warning: nomtools syslinux doesn't exist"
SYSLINUX=$IMGPATH/usr/bin/syslinux
if [ ! -f $SYSLINUX ]; then
echo "$SYSLINUX doesn't exist"
exit 1
fi
fi
# prepare a directory with the kernel, initrd, and various message files
# used to populate a boot image
prepareBootTree() {
(cd $BOOTDISKDIR; find . -maxdepth 1 ! -name "*.msg" ! -type d | cpio --quiet -p $MBD_BOOTTREE)
cp $MBD_FSIMAGE $MBD_BOOTTREE/initrd.img
cp $KERNELROOT/boot/vmlinuz-* $MBD_BOOTTREE/vmlinuz
if [ -f $IMGPATH/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg $MBD_BOOTTREE/splash.jpg
cp $IMGPATH/usr/lib/syslinux/vesamenu.c32 $MBD_BOOTTREE/vesamenu.c32
sed -i s'/default linux/default vesamenu.c32/g' $MBD_BOOTTREE/syslinux.cfg
sed -i 's/prompt 1/#prompt 1/g' $MBD_BOOTTREE/syslinux.cfg
elif [ -x $IMGPATH/usr/lib/anaconda-runtime/splashtolss.sh ]; then
$IMGPATH/usr/lib/anaconda-runtime/splashtolss.sh $BOOTDISKDIR/syslinux-splash.png $BOOTDISKDIR/splash.lss
if [ $? != 0 ]; then
echo $0: Failed to create splash.lss
exit 1
fi
cp $BOOTDISKDIR/splash.lss $MBD_BOOTTREE/splash.lss
elif [ -f $IMGPATH/usr/lib/anaconda-runtime/splash.lss ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/splash.lss $MBD_BOOTTREE/splash.lss
fi
rm -f $MBD_BOOTTREE/syslinux-splash.png
sed -i "s/@PRODUCT@/$PRODUCT/g" $MBD_BOOTTREE/syslinux.cfg
sed -i "s/@VERSION@/$VERSION/g" $MBD_BOOTTREE/syslinux.cfg
rm -f $MBD_BOOTTREE/memtest*
for file in $BOOTDISKDIR/*.msg; do
filename=`basename $file`
sed -e "s/@VERSION@/$VERSION/g" $file > $MBD_BOOTTREE/$filename
done
if [ $? != 0 ]; then
echo $0: Failed to copy messages from $BOOTDISKDIR to $MBD_BOOTTREE.
umount $MBD_BOOTTREE
rm -rf $MBD_BOOTTREE $MBD_TMPIMAGE
exit 1
fi
}
mkdir -p $TOPDESTPATH/images/pxeboot
cat > $TOPDESTPATH/images/README <<EOF
This directory contains image files that can be used to create media
capable of starting the $PRODUCT installation process.
The boot.iso file is an ISO 9660 image of a bootable CD-ROM. It is useful
in cases where the CD-ROM installation method is not desired, but the
CD-ROM's boot speed would be an advantage.
To use this image file, burn the file onto CD-R (or CD-RW) media as you
normally would.
EOF
makeBootImages() {
local initrd="initrd.img"
local kernelimage="vmlinuz"
if [ "$kernelvers" = "$kernelxen" ] ; then
local tag="${kernelvers#kernel}"
if [ -n "$tag" -a "$tag" != "$kernelvers" ] ; then
initrd="initrd${tag}.img"
kernelimage="vmlinuz${tag}"
fi
fi
echo "Building $initrd"
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/$initrd \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
[ $? = 0 ] || exit 1
if [ "$kernelvers" != "$kernelxen" ] ; then
if [ -f $IMGPATH/usr/lib/syslinux/isolinux.bin ]; then
echo "Building isolinux directory"
MBD_BOOTTREE=$TOPDESTPATH/isolinux
MBD_FSIMAGE=$TOPDESTPATH/images/pxeboot/initrd.img
mkdir $MBD_BOOTTREE
cp $IMGPATH/usr/lib/syslinux/isolinux.bin $MBD_BOOTTREE/isolinux.bin
prepareBootTree
# isolinux needs the config file to be isolinux.cfg
mv $MBD_BOOTTREE/syslinux.cfg $MBD_BOOTTREE/isolinux.cfg
# copy in memtest if present
if [ -f $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* $MBD_BOOTTREE/memtest
echo -e "label memtest86\n menu label ^Memory test\n kernel memtest\n append -\n" >> $MBD_BOOTTREE/isolinux.cfg
fi
else
echo "No isolinux binaries. Skipping isolinux creation"
fi
# symlink the kernel for pxe dir
ln $TOPDESTPATH/isolinux/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
The files in this directory are useful for booting a machine via PXE.
The following files are available:
vmlinuz - the kernel used for the installer
initrd.img - an initrd with support for all install methods and
drivers supported for installation of $PRODUCT
EOF
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$BASEARCH]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
__EOT__
if [ -n "$BOOTISO" ]; then echo "boot.iso = images/$BOOTISO" >> $TOPDESTPATH/.treeinfo ; fi
fi
# set up the boot stuff for the xen guest kernel
if [ -z "$kernelxen" -o "$kernelvers" = "$kernelxen" ] ; then
cp $KERNELROOT/boot/vmlinuz-$version $TOPDESTPATH/images/pxeboot/$kernelimage
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-xen]
kernel = images/pxeboot/$kernelimage
initrd = images/pxeboot/$initrd
__EOT__
fi
}
doPostImages() {
if [ -n "$BOOTISO" ]; then
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -V "$PRODUCT" -T -graft-points isolinux=$TOPDESTPATH/isolinux images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
fi
}

View File

@ -0,0 +1,156 @@
/*
* mk-s390-cdboot -- creates one big image using a kernel, a ramdisk and
* a parmfile
*
*
* 2003-07-24 Volker Sameske <sameske@de.ibm.com>
*
* compile with:
* gcc -Wall -o mk-s390-cdboot mk-s390-cdboot.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <stdarg.h>
#define BUFFER_LEN 1024
#define INITRD_START 0x0000000000800000LL
#define START_PSW_ADDRESS 0x80010000
#define PARAMETER_BUFFER_LEN 80
static struct option getopt_long_options[]=
{
{ "image", 1, 0, 'i'},
{ "ramdisk", 1, 0, 'r'},
{ "parmfile", 1, 0, 'p'},
{ "outfile", 1, 0, 'o'},
{ "help", 0, 0, 'h'},
{0, 0, 0, 0}
};
static void usage(char *cmd)
{
printf("%s [-h] [-v] -i <kernel> -r <ramdisk> -p <parmfile> -o <outfile>\n", cmd);
}
int main (int argc, char **argv)
{
char *cmd = basename(argv[0]);
FILE *fd1;
FILE *fd2;
FILE *fd3;
FILE *fd4;
char buffer[BUFFER_LEN];
int rc, oc, index;
unsigned long long initrd_start = INITRD_START;
unsigned long long initrd_size;
char image[PARAMETER_BUFFER_LEN];
char ramdisk[PARAMETER_BUFFER_LEN];
char parmfile[PARAMETER_BUFFER_LEN];
char outfile[PARAMETER_BUFFER_LEN];
int image_specified = 0;
int ramdisk_specified = 0;
int parmfile_specified = 0;
int outfile_specified = 0;
int start_psw_address = START_PSW_ADDRESS;
opterr=0;
while (1)
{
oc = getopt_long(argc, argv, "i:r:p:o:h?", getopt_long_options, &index);
if (oc==-1) break;
switch (oc)
{
case '?':
case 'h':
usage(cmd);
exit(0);
case 'i':
strcpy(image, optarg);
image_specified = 1;
break;
case 'r':
strcpy(ramdisk, optarg);
ramdisk_specified = 1;
break;
case 'p':
strcpy(parmfile, optarg);
parmfile_specified = 1;
break;
case 'o':
strcpy(outfile, optarg);
outfile_specified = 1;
break;
default:
usage(cmd);
exit(0);
}
}
if (!image_specified || !ramdisk_specified ||
!parmfile_specified || !outfile_specified) {
usage(cmd);
exit(0);
}
printf("Creating bootable CD-ROM image...\n");
printf("kernel is : %s\n", image);
printf("ramdisk is : %s\n", ramdisk);
printf("parmfile is: %s\n", parmfile);
printf("outfile is : %s\n", outfile);
fd1 = fopen(outfile, "w");
fd2 = fopen(image, "r");
fd3 = fopen(ramdisk, "r");
fd4 = fopen(parmfile, "r");
printf("writing kernel...\n");
while (1) {
rc = fread(buffer, BUFFER_LEN, 1, fd2);
fwrite(buffer, BUFFER_LEN, 1, fd1);
if (rc == 0) break;
}
printf("writing initrd...\n");
fseek(fd1, initrd_start, SEEK_SET);
while (1) {
rc = fread(buffer, BUFFER_LEN, 1, fd3);
fwrite(buffer, BUFFER_LEN, 1, fd1);
if (rc == 0) break;
}
fseek(fd3, 0 ,SEEK_END);
initrd_size = ftell(fd3);
printf("changing start PSW address to 0x%08x...\n", start_psw_address);
fseek(fd1, 0x4, SEEK_SET);
fwrite(&start_psw_address, 4, 1, fd1);
printf("writing initrd address and size...\n");
printf("INITRD start: 0x%016llx\n", initrd_start);
printf("INITRD size : 0x%016llx\n", initrd_size);
fseek(fd1, 0x10408, SEEK_SET);
fwrite(&initrd_start, 8, 1, fd1);
fseek(fd1, 0x10410, SEEK_SET);
fwrite(&initrd_size, 8, 1, fd1);
printf("writing parmfile...\n");
fseek(fd1, 0x10480, SEEK_SET);
while (1) {
rc = fread(buffer, 1, 1, fd4);
fwrite(buffer, 1, 1, fd1);
if (rc == 0) break;
}
fclose(fd1);
fclose(fd2);
fclose(fd3);
fclose(fd4);
return 0;
}

130
rewrite/scratch/modlist.c Normal file
View File

@ -0,0 +1,130 @@
/*
* modlist.c
*
* Copyright (C) 2007 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../isys/isys.h"
#include "moduleinfo.h"
int main(int argc, char ** argv) {
poptContext optCon;
char * modInfoFile = "/boot/module-info";
enum driverMajor major;
const char * type;
const char * mod;
struct moduleInfo * list, * m;
int rc, i;
int showModInfo = 0;
int ignoreMissing = 0;
moduleInfoSet mis;
struct moduleInfo * mi;
struct poptOption optionTable[] = {
{ "ignore-missing", 'I', POPT_ARG_NONE, &ignoreMissing, 0,
"Ignore modules not in modinfo file for --modinfo" },
{ "modinfo", 'm', POPT_ARG_NONE, &showModInfo, 0,
"Give output in module-info file for listed args" },
{ "modinfo-file", 'f', POPT_ARG_STRING, &modInfoFile, 0,
"Module info file to use"},
POPT_AUTOHELP
{ 0, 0, 0, 0, 0 }
};
optCon = poptGetContext(NULL, argc, (const char **) argv, optionTable, 0);
if ((rc = poptGetNextOpt(optCon)) < -1) {
fprintf(stderr, "bad option %s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(rc));
exit(1);
}
mis = newModuleInfoSet();
if (readModuleInfo(modInfoFile, mis, NULL, 0)) {
fprintf(stderr, "Failed to read %s\n", modInfoFile);
exit(1);
}
if (showModInfo) {
printf("Version 0\n");
while ((mod = poptGetArg(optCon))) {
mi = findModuleInfo(mis, mod);
if (mi) {
printf("%s\n", mi->moduleName);
switch (mi->major) {
case DRIVER_CDROM: printf("\tcdrom\n"); break;
case DRIVER_SCSI: printf("\tscsi\n"); break;
case DRIVER_FS: printf("\tfs\n"); break;
case DRIVER_PCMCIA: printf("\tpcmcia\n"); break;
case DRIVER_IDE: printf("\tide\n"); break;
case DRIVER_OTHER: printf("\tother\n"); break;
case DRIVER_NET:
switch (mi->minor) {
case DRIVER_MINOR_ETHERNET: printf("\teth\n"); break;
case DRIVER_MINOR_TR: printf("\ttr\n"); break;
default:
fprintf(stderr, "unknown net minor type for %s\n",
mi->moduleName);
exit(1);
}
break;
default:
fprintf(stderr, "unknown device type for %s (%d)\n",
mi->moduleName, mi->major);
exit(1);
}
printf("\t\"%s\"\n", mi->description);
for (i = 0; i < mi->numArgs; i++) {
printf("\t%s \"%s\"\n", mi->args[i].arg,
mi->args[i].description);
}
} else if (!ignoreMissing) {
fprintf(stderr, "I know nothing about %s\n", mod);
exit(1);
}
}
} else {
while ((type = poptGetArg(optCon))) {
if (!strcasecmp(type, "scsi")) {
major = DRIVER_SCSI;
} else if (!strcasecmp(type, "net")) {
major = DRIVER_NET;
} else if (!strcasecmp(type, "fs")) {
major = DRIVER_FS;
} else if (!strcasecmp(type, "cdrom")) {
major = DRIVER_CDROM;
} else {
fprintf(stderr, "type must be one of scsi, net, fs, cdrom\n");
exit(1);
}
list = getModuleList(mis, major);
for (m = list; m && m->moduleName; m++)
printf("%s\n", m->moduleName);
free(list);
}
}
return 0;
}

70
rewrite/scratch/scrubtree Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
DEBUG=""
if [ "$1" == "--debug" ]; then
DEBUG="--debug"
shift
fi
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/tree"
exit 1
fi
p=$1
STRIP=strip
ARCH=`uname -m | sed -e 's/i.86/i386/'`
if [ $ARCH = ia64 ]; then
STRIP="strip --strip-debug"
fi
if [ $ARCH = x86_64 -o $ARCH = s390x ]; then
LIBDIR=lib64
else
LIBDIR=lib
fi
# Must create ld.so.conf, because ldconfig does not cache
# dirs specified on the command line.
touch $p/etc/ld.so.conf
mkdir $p/proc
mount -t proc proc $p/proc
[ -d $p/usr/X11R6/$LIBDIR ] && echo /usr/X11R6/$LIBDIR > $p/etc/ld.so.conf
echo /usr/kerberos/$LIBDIR > $p/etc/ld.so.conf
(cd $p; /usr/sbin/chroot $p usr/sbin/ldconfig )
if [ $ARCH != s390 -a $ARCH != s390x ]; then
rm -f $p/usr/sbin/ldconfig
fi
rm $p/etc/ld.so.conf
#
# make sure we have links for programs supplied by busybox
#
# HOWEVER dont clobber existing programs supplied by other packages if exist
#
mv $p/usr/sbin/busybox.anaconda $p/usr/bin/busybox
(cd $p/usr/bin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]_\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
while [ -n "$1" ]; do
if [ $1 != "busybox" -a $1 != "sh" -a $1 != "shutdown" -a $1 != "poweroff" -a $1 != "reboot" ]; then
# if file doesnt already exist, link to busybox
if [ ! -f "$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
fi
shift
done
)
umount $p/proc
for l in `find $p -type f -perm +100 | grep -v "usr/X11R6/$LIBDIR/modules" | xargs file | sed -n 's/^\([^:]*\):.*ELF.*$/\1/p'`; do
$STRIP $l -R .comment -R .note `objdump -h $l | \
sed -n 's/^.*\(\.gnu\.warning\.[^ ]*\) .*$/-R \1/p'`
done

80
rewrite/scratch/trimpciids Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/python
#
# trimpciids
#
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import sys
import os
import string
vendors = []
devices = []
f = open(sys.argv[1])
if f:
pcitable = f.readlines()
f.close()
for line in pcitable:
if not line.startswith("alias pci:"):
continue
vend = "0x%s" % (line[15:19],)
dev = "0x%s" % (line[24:28],)
vend = vend.upper()
dev = dev.upper()
if vend not in vendors:
vendors.append(vend)
if (vend, dev) not in devices:
devices.append( (vend, dev) )
for file in sys.argv[2:]:
if not os.path.exists(file):
sys.stderr.write("WARNING: non-existent file %s for trimpciids\n" %(file,))
continue
f = open(file)
if f:
pcitable = f.readlines()
f.close()
for line in pcitable:
if not line.startswith("alias pcivideo:"):
continue
vend = "0x%s" % (line[20:24],)
dev = "0x%s" % (line[29:33],)
vend = vend.upper()
dev = dev.upper()
if vend not in vendors:
vendors.append(vend)
if (vend, dev) not in devices:
devices.append( (vend, dev) )
pciids = sys.stdin.readlines()
current_vend = 0
for line in pciids:
if line.startswith("#") or line == "\n":
continue
if line.startswith("\t\t"):
continue
if not line.startswith("\t"):
current_vend = "0x%s" % line.split()[0]
current_vend = current_vend.upper()
if current_vend in vendors:
print line,
continue
dev = "0x%s" % line.split()[0]
dev = dev.upper()
if (current_vend, dev) in devices:
print line,

266
rewrite/scratch/upd-instroot Executable file
View File

@ -0,0 +1,266 @@
. $(dirname $0)/buildinstall.functions
# ..........this is the pylorax.instroot.installPackages() function in lorax
expandPackageSet() {
if [ -n "$UPDATES" ]; then
(cd $UPDATES; find) | (cd $UPDATES ; /bin/cpio --quiet -pmdu $YUMDIR)
fi
# figure out the theme to keep
if [ -f $YUMDIR/etc/gtk-2.0/gtkrc ]; then
gtktheme=$(grep "gtk-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
echo "usr/share/themes/$gtktheme" >> $KEEPFILES
# find gtk engine needed
for engine in `grep engine $YUMDIR/usr/share/themes/$gtktheme/gtk-2.0/gtkrc | awk {'print $2;'} | sed -e 's/"//g' | sort -u` ; do
echo "usr/$LIBDIR/gtk-2.0/*/engines/*$engine*" >> $KEEPFILES
done
theme=$(grep "gtk-icon-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
while [ -n "$theme" ]; do
echo "usr/share/icons/$theme" >> $KEEPFILES
theme=$(grep Inherits $YUMDIR/usr/share/icons/$theme/index.theme | cut -d = -f 2)
done
fi
echo `date` "Installing files"
pushd $YUMDIR >/dev/null
cat $KEEPFILES | while read spec ; do
#Pull off path
path=`echo "$spec" | sed 's,\([^[*\?]*\)/.*,\1,'`
for filespec in `find ./$path -path "./$spec" 2> /dev/null` ; do
if [ ! -e $filespec ]; then
continue
elif [ ! -d $filespec ]; then
instFile $filespec $PKGDEST
else
for i in `find $filespec -type f 2> /dev/null` ; do instFile $i $PKGDEST ; done
for i in `find $filespec -type l 2> /dev/null` ; do instFile $i $PKGDEST ; done
for d in `find $filespec -type d 2> /dev/null` ; do instDir $d $PKGDEST ; done
fi
done
done
popd >/dev/null
}
rm -rf $DEST; mkdir -p $DEST/usr/sbin $DEST/var/lib $DEST/boot
ln -s /tmp $DEST/var/lib/xkb
echo `date` "Expanding packages..."
YUMDIR=${TMPDIR:-/tmp}/yumdir.$$
mkdir -p $YUMDIR/var/log
mkdir -p $YUMDIR/var/lib/yum
expandPackageSet $yumconf $YUMDIR "$RPMS" $DEST $KEEPFILE
echo `date` "Done Expanding packages..."
# Dogtail will check this
echo "Creating customized GConf2 settings for root"
mkdir -p $DEST/.gconf/desktop/gnome/interface
touch $DEST/.gconf/desktop/%gconf.xml
touch $DEST/.gconf/desktop/gnome/%gconf.xml
cat > $DEST/.gconf/desktop/gnome/interface/%gconf.xml <<EOF
<?xml version="1.0"?>
<gconf>
<entry name="accessibility" mtime="1176200664" type="bool" value="true">
</entry>
</gconf>
EOF
rm -rf $YUMDIR
chown -R root:root $DEST
chmod -R a+rX-w $DEST
# Remove locales unused during the install
cat $DEST/usr/lib/anaconda/lang-table* | awk '
{ gsub("-", "", $4);
print $4;
print gensub(/\..*$/,"","",$4);
print gensub(/_.*$/,"","",$4);
if (split ($4, a, ".") > 1) {
print gensub(/\..*$/,tolower("." a[2]),"",$4);
};
print $2;
}
' | sed -e 's/latn/Latn/g' | LC_ALL=C sort -u > $DEST/locales
for p in lib share; do (
cd $DEST/usr/$p/locale && {
ls | grep -v locale.alias | grep -v locale-archive | LC_ALL=C sort > $DEST/locales.list
LC_ALL=C comm -13 $DEST/locales $DEST/locales.list | xargs rm -rf
}
); done
rm -f $DEST/locales $DEST/locales.list
# fixup joe links
if [ -d "$DESTDIR"/etc/joe ]; then
ln -fs jpicorc $DEST/etc/joe/picorc
ln -fs jpicorc $DEST/etc/joe/jnanorc
ln -fs jpicorc $DEST/etc/joe/nanorc
ln -fs jmacsrc $DEST/etc/joe/emacsrc
ln -fs jmacs $DEST/usr/bin/emacs
ln -fs jpico $DEST/usr/bin/pico
ln -fs jpico $DEST/usr/bin/nano
fi
# fix up some links for man page related stuff
for file in nroff groff iconv geqn gtbl gpic grefer ; do
ln -fs /mnt/sysimage/usr/bin/$file $DEST/usr/bin/$file
done
# create selinux config
if [ -e $DEST/etc/selinux/targeted ]; then
cat > $DEST/etc/selinux/config <<EOF
SELINUX=permissive
SELINUXTYPE=targeted
EOF
fi
echo "Creating libuser.conf"
cat > $DEST/etc/libuser.conf <<EOF
[defaults]
skeleton = /mnt/sysimage/etc/skel
mailspooldir = /mnt/sysimage/var/mail
crypt_style = md5
modules = files shadow
create_modules = files shadow
[files]
directory = /mnt/sysimage/etc
[shadow]
directory = /mnt/sysimage/etc
EOF
sed -i 's|\(installforallkernels\) = 0|\1 = 1|' $DEST/etc/yum/pluginconf.d/fedorakmod.conf
#
# Manual pages in rescue: We dont have man pages in the image, so we point everything (The pages
# and the man scripts to the /mnt/sysimage. We want the man command to depend only on the
# man.conf file, so we don't use the $MANPATH env variable. The executables stay unchanged as
# they will be soft links to /mnt/sysimage.
#
echo "Fixing up /etc/man.config to point into /mnt/sysimage"
#
# Lets avoid the lines with MANPATH_MAP for now
#
sed -i "s,^MANPATH[^_MAP][ \t]*,&/mnt/sysimage," $DEST/etc/man.config
#
# Lets change the lines with MANPATH_MAP. Don't know how much of a difference this will make.
#
sed -i "s,^MANPATH_MAP[ \t]*[a-zA-Z0-9/]*[ \t]*,&/mnt/sysimage," $DEST/etc/man.config
echo "Scrubbing tree..." "$DEST"
mkdir -p $DEST/lib
mkdir -p $DEST/firmware
ln -snf /modules $DEST/lib/modules
ln -snf /firmware $DEST/lib/firmware
cp $DEST/usr/lib/anaconda/raidstart-stub $DEST/usr/bin/raidstart
cp $DEST/usr/lib/anaconda/raidstop-stub $DEST/usr/bin/raidstop
cp $DEST/usr/lib/anaconda/losetup-stub $DEST/usr/bin/losetup
cp $DEST/usr/lib/anaconda/list-harddrives-stub $DEST/usr/bin/list-harddrives
cp $DEST/usr/lib/anaconda/loadkeys-stub $DEST/usr/bin/loadkeys
cp $DEST/usr/lib/anaconda/mknod-stub $DEST/usr/bin/mknod
cp $DEST/usr/lib/anaconda/syslogd-stub $DEST/usr/bin/syslogd
mv $DEST/usr/sbin/anaconda $DEST/usr/bin/anaconda
mv $DEST/usr/lib/anaconda-runtime/lib* $DEST/usr/$LIBDIR 2>/dev/null
mv $DEST/etc/yum.repos.d $DEST/etc/anaconda.repos.d
rm -f $DEST/usr/$LIBDIR/libunicode-lite*
find $DEST -type d | xargs chmod 755
if [ -f $DEST/bin/bash ]; then
rm -f $DEST/bin/ash
ln -s bash $DEST/bin/sh
else
ln -sf busybox $DEST/bin/sh
fi
[ -d $DEST/bin ] || die "ERROR: directory missing: $DEST/bin"
[ -d $DEST/sbin ] || die "ERROR: directory missing: $DEST/sbin"
(cd $DEST/bin; find) | (cd $DEST/bin; /bin/cpio --quiet -pdmu $DEST/usr/bin)
(cd $DEST/sbin; find) | (cd $DEST/sbin; /bin/cpio --quiet -pdmu $DEST/usr/sbin)
rm -rf $DEST/bin
rm -rf $DEST/sbin
# Fix relative links like /usr/bin/udevinfo -> ../../sbin/udevadm
for brokenlink in $(find $DEST/usr/{bin,sbin} -follow -lname '*') ; do
target="$(readlink $brokenlink)"
for pathbit in bin sbin; do
# if it starts with "../../sbin/", remove that
newtarget="${target##../../$pathbit/}"
# if we removed something, replace it with the proper path
if [ "$newtarget" != "$target" ]; then
# make it ../sbin/ instead
ln -sf "../$pathbit/$newtarget" "$brokenlink"
fi
done
done
# copy bootloader files for sparc
if [ $ARCH = sparc ]; then
mkdir -p $DEST/usr/lib/anaconda-runtime/boot
[ -d $DEST/boot ] || die "ERROR: directory missing: $DEST/boot"
(cd $DEST/boot; find -name "*.b") | (cd $DEST/boot; /bin/cpio --quiet -pdmu $DEST/usr/lib/anaconda-runtime/boot)
fi
# copy bootloader file for ppc
if [ $ARCH = ppc -o $ARCH = ppc64 ]; then
mkdir -p $DEST/usr/lib/anaconda-runtime/boot
cp -af $DEST/boot/efika.forth $DEST/usr/lib/anaconda-runtime/boot
fi
# copy bootloader file for alpha
if [ $ARCH = alpha ]; then
mkdir -p $DEST/usr/lib/anaconda-runtime/boot
cp -af $DEST/boot/bootlx $DEST/usr/lib/anaconda-runtime/boot
fi
# copy bootloader files for ia64
if [ $ARCH = ia64 ]; then
mkdir -p $DEST/usr/lib/anaconda-runtime/boot
cp -af $DEST/boot/efi/EFI/redhat//* $DEST/usr/lib/anaconda-runtime/boot
fi
# copy bootloader files for i386/x86_64
if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
mkdir -p $DEST/usr/lib/anaconda-runtime/boot
cp -af $DEST/boot/memtest* $DEST/usr/lib/anaconda-runtime/boot
fi
rm -rf $DEST/boot $DEST/home $DEST/root $DEST/tmp
find $DEST -name "*.a" | grep -v kernel-wrapper/wrapper.a | xargs rm -rf
find $DEST -name "lib*.la" |grep -v "usr/$LIBDIR/gtk-2.0" | xargs rm -rf
# nuke some python stuff we don't need
for d in idle distutils bsddb lib-old hotshot doctest.py pydoc.py site-packages/japanese site-packages/japanese.pth ; do
rm -rf $DEST/$d
done
$DEST/usr/lib/anaconda-runtime/scrubtree $DEST
echo "Creating debug dir"
mkdir -p $DEST/usr/lib/debug
mkdir -p $DEST/usr/src/debug
find $DEST -name "*.py" | while read fn; do
rm -f ${fn}o
rm -f ${fn}c
ln -sf /dev/null ${fn}c
done
# some python stuff we don't need for install image
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/distutils/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/lib-dynload/japanese
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/encodings/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/compiler/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/email/test/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/curses/
rm -rf $DEST/usr/$LIBDIR/python?.?/site-packages/pydoc.py

View File

@ -0,0 +1,20 @@
scripts/buildinstall
scripts/buildinstall.functions
DONE scripts/makestamp.py
DONE scripts/maketreeinfo.py
scripts/mk-images
scripts/mk-images.alpha
scripts/mk-images.efi
scripts/mk-images.ia64
scripts/mk-images.ppc
scripts/mk-images.s390
scripts/mk-images.x86
scripts/scrubtree
scripts/upd-instroot
utils/trimpciids
utils/mk-s390-cdboot.c
utils/filtermoddeps
utils/geninitrdsz.c
utils/genmodinfo
utils/modlist