diff --git a/etc/templates/includes/initrd/initrd.common b/etc/initrd/includes/initrd.common
similarity index 100%
rename from etc/templates/includes/initrd/initrd.common
rename to etc/initrd/includes/initrd.common
diff --git a/etc/templates/initrd.alpha b/etc/initrd/initrd.alpha
similarity index 100%
rename from etc/templates/initrd.alpha
rename to etc/initrd/initrd.alpha
diff --git a/etc/templates/initrd.i386 b/etc/initrd/initrd.i386
similarity index 89%
rename from etc/templates/initrd.i386
rename to etc/initrd/initrd.i386
index 57501b24..b6c71784 100644
--- a/etc/templates/initrd.i386
+++ b/etc/initrd/initrd.i386
@@ -1,6 +1,6 @@
# initrd template
-#include includes/initrd/initrd.common
+#include includes/initrd.common
# loader
copy @instroot@ usr/lib/anaconda-runtime/loader/init to @initrd@ sbin/init
diff --git a/etc/templates/initrd.ia64 b/etc/initrd/initrd.ia64
similarity index 100%
rename from etc/templates/initrd.ia64
rename to etc/initrd/initrd.ia64
diff --git a/etc/templates/initrd.ppc b/etc/initrd/initrd.ppc
similarity index 100%
rename from etc/templates/initrd.ppc
rename to etc/initrd/initrd.ppc
diff --git a/etc/templates/initrd.ppc64 b/etc/initrd/initrd.ppc64
similarity index 100%
rename from etc/templates/initrd.ppc64
rename to etc/initrd/initrd.ppc64
diff --git a/etc/templates/initrd.s390 b/etc/initrd/initrd.s390
similarity index 98%
rename from etc/templates/initrd.s390
rename to etc/initrd/initrd.s390
index 50494cde..cf079699 100644
--- a/etc/templates/initrd.s390
+++ b/etc/initrd/initrd.s390
@@ -1,6 +1,6 @@
# initrd template
-#include includes/initrd/initrd.common
+#include includes/initrd.common
# create required directories
makedir @initrd@/var/empty/sshd mode 0111
diff --git a/etc/templates/initrd.s390x b/etc/initrd/initrd.s390x
similarity index 100%
rename from etc/templates/initrd.s390x
rename to etc/initrd/initrd.s390x
diff --git a/etc/templates/initrd.sparc b/etc/initrd/initrd.sparc
similarity index 100%
rename from etc/templates/initrd.sparc
rename to etc/initrd/initrd.sparc
diff --git a/etc/templates/initrd.x86_64 b/etc/initrd/initrd.x86_64
similarity index 100%
rename from etc/templates/initrd.x86_64
rename to etc/initrd/initrd.x86_64
diff --git a/etc/modules/modules b/etc/modules/modules.all
similarity index 100%
rename from etc/modules/modules
rename to etc/modules/modules.all
diff --git a/etc/packages/packages.all b/etc/packages/packages.all
index 62065d25..df07843e 100644
--- a/etc/packages/packages.all
+++ b/etc/packages/packages.all
@@ -1,260 +1,43 @@
-GConf2
-NetworkManager
-ORBit2
-PolicyKit
-acl
-#anaconda
-anaconda-yum-plugins
-at-spi
-atk
-attr
-audit-libs
-bash
-bitmap-fonts-cjk
-btrfs-progs
-bzip2
-bzip2-libs
-cairo
-cjkuni-uming-fonts
-comps-extras
-coreutils
-cpio
-cracklib
-cracklib-dicts
-cracklib-python
-cryptsetup-luks
-db4
-dbus
-dbus-python
-dejavu-sans-fonts
-dejavu-sans-mono-fonts
-device-mapper
-device-mapper-libs
-dhclient
-dhcpv6-client
-dmraid
-dmraid-libs
-dogtail
-dosfstools
-e2fsprogs
-e2fsprogs-libs
-echo-icon-theme
-ethtool
-elfutils-libelf
-expat
-firstboot
-fontconfig
-fonts-ISO8859-2
-freetype
-gail
-gawk
-gdb-gdbserver
-gdk-pixbuf
-gfs2-utils
-glib2
-glibc-common
-gnome-python2-canvas
-gnome-python2-gconf
-gnome-python2-gtkhtml2
-gnome-themes
-gpm
-grep
-gtk2
-gtk2-engines
-gtkhtml2
-hal
-hdparm
-hwdata
-initscripts
-iproute
-iputils
-iscsi-initiator-utils
-jfsutils
-keyutils-libs
-krb5-libs
-libICE
-libSM
-libX11
-libXau
-libXaw
-libXcursor
-libXdmcp
-libXevie
-libXext
-libXfixes
-libXfont
-libXft
-libXi
-libXinerama
-libXmu
-libXpm
-libXrandr
-libXrender
-libXt
-libXtst
-libXxf86misc
-libacl
-libart_lgpl
-libattr
-libbdevid
-libbdevid-python
-libbonobo
-libfontenc
-libgcc
-libglade2
-libgnomecanvas
-libgcrypt
-libgpg-error
-libjpeg
-libnl
-libpng
-libselinux
-libselinux-python
-libsemanage
-libsemanage-python
-libsepol
-libstdc++
-libthai
-libuser
-libuser-python
-libvolume_id
-libxcb
-libxkbfile
-libxml2
-lklug-fonts
-lohit-assamese-fonts
-lohit-bengali-fonts
-lohit-gujarati-fonts
-lohit-hindi-fonts
-lohit-kashmiri-fonts
-lohit-kannada-fonts
-lohit-maithili-fonts
-lohit-marathi-fonts
-lohit-oriya-fonts
-lohit-punjabi-fonts
-lohit-sindhi-fonts
-lohit-tamil-fonts
-lohit-telugu-fonts
-lvm2
-madan-fonts
-mdadm
-mesa-dri-drivers
-mkinitrd
-module-init-tools
-nash
-ncurses
-neon
-net-tools
-newt
-newt-python
-nfs-utils
-nspr
-nss
-ntfs-3g
-pam
-pango
-parted
-pciutils
-pcre
-policycoreutils
-popt
-prelink
-procps
-pycairo
-pygobject2
-pygtk2
-pygtk2-libglade
-pykickstart
-pyparted
-python
-python-bugzilla
-python-decorator
-python-libs
-python-pyblock
-python-sqlite
-python-urlgrabber
-pyxf86config
-readline
-redhat-artwork
-reiserfs-utils
-rhpl
-rpm
-rpm-libs
-rpm-python
-sed
-selinux-policy-targeted
-setup
-slang
-smc-meera-fonts
-specspo
-sqlite
-synaptics
-system-config-date
-system-config-keyboard
-#${brandpkgname}-logos
-#${brandpkgname}-release
-taipeifonts
-tcp_wrappers
-tzdata
-udev
-un-core-fonts-dotum
-urw-fonts
-util-linux-ng
-tigervnc-server
-tigervnc-server-module
-vlgothic-fonts
-vim-minimal
-wpa_supplicant
-xkeyboard-config
-xfsdump
-xfsprogs
-xorg-x11-auth
-xorg-x11-drivers
-xorg-x11-font-utils
-xorg-x11-fonts-ethiopic
-xorg-x11-fonts-misc
-xorg-x11-server-utils
-xorg-x11-server-Xorg
-xorg-x11-xkb-utils
-xorg-x11-xfs yum
-yum-metadata-parser
-zenity
-zlib
-#/etc/gtk-2.0/gtkrc
-glibc
-openssl
-
-# rescue
-bzip2
-bzip2-libs
-dump
-libidn
-findutils
-ftp
-gzip
-iputils
joe
-krb5-libs
-less
-man
-modutils
-mtools
-mt-st
-mtr
-net-tools
-smartmontools
-openssh
-openssh-clients
-pciutils
-rsh
-traceroute
-tar
-rsync
-device-mapper
-device-mapper-libs
-dmraid
-ntfsprogs
-samba-client
+gnome-icon-theme
+fedora-icon-theme
+xorg-x11-server-Xorg
firstaidkit
-firstaidkit-plugin-all
-dialog
+bzip2
+busybox
+selinux-policy-targeted
+python-imaging
+hal
+specspo
+xorg-x11-fonts-misc
+xorg-x11-drivers
+rhpxl
+ntfs-3g
+ntfsprogs
+xfsprogs
+xfsdump
+reiserfs-utils
+gfs2-utils
+jfsutils
+nfs-utils
+btrfs-progs
+mesa-dri-drivers
+dogtail
+rsh
+rsync
+prelink
+smartmontools
+iscsi-initiator-utils
+samba-client
+mtr
+gtk-nodoka-engine
+ftp
+openssh-clients
+gtk+
+gdk-pixbuf
+madan-fonts
+lklug-fonts
+xorg-x11-fonts-ethiopic
+un-core-fonts-dotum
+man
+yum-fedorakmod
\ No newline at end of file
diff --git a/etc/packages/packages.i386 b/etc/packages/packages.i386
index f6d90190..c1aa3a2f 100644
--- a/etc/packages/packages.i386
+++ b/etc/packages/packages.i386
@@ -1,11 +1,7 @@
--glibc
--openssl
-glibc.i386
-openssl.i386
pcmciautils
grub
dmidecode
efibootmgr
gpart
syslinux
-memtest86+
+memtest86+
\ No newline at end of file
diff --git a/etc/packages/packages.i586 b/etc/packages/packages.i586
deleted file mode 100644
index c5fb1549..00000000
--- a/etc/packages/packages.i586
+++ /dev/null
@@ -1,11 +0,0 @@
--glibc
--openssl
-glibc.i586
-openssl.i586
-pcmciautils
-grub
-dmidecode
-efibootmgr
-gpart
-syslinux
-memtest86+
diff --git a/etc/packages/packages.i586 b/etc/packages/packages.i586
new file mode 120000
index 00000000..cd9dd23d
--- /dev/null
+++ b/etc/packages/packages.i586
@@ -0,0 +1 @@
+packages.i386
\ No newline at end of file
diff --git a/etc/packages/packages.x86_64 b/etc/packages/packages.x86_64
deleted file mode 100644
index 6921bc17..00000000
--- a/etc/packages/packages.x86_64
+++ /dev/null
@@ -1,7 +0,0 @@
-pcmciautils
-grub
-dmidecode
-efibootmgr
-gpart
-syslinux
-memtest86+
diff --git a/etc/packages/packages.x86_64 b/etc/packages/packages.x86_64
new file mode 120000
index 00000000..cd9dd23d
--- /dev/null
+++ b/etc/packages/packages.x86_64
@@ -0,0 +1 @@
+packages.i386
\ No newline at end of file
diff --git a/rewrite/scripts/buildinstall b/rewrite/scripts/buildinstall
deleted file mode 100755
index bdc7cef3..00000000
--- a/rewrite/scripts/buildinstall
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/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 .
-#
-
-die() {
- [ -n "$TREEDIR" ] && rm -rf $TREEDIR
- [ -n "$BUILDINSTDIR" ] && rm -rf $BUILDINSTDIR
- [ -n "$yumconf" ] && rm -rf $yumconf
- echo "Aborting buildinstall"
- echo "$@"
- exit 1
-}
-
-usage() {
- echo "Usage: buildinstall --version --product --release [--output outputdir] [--discs ] " >&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
-
-# The first -release and -logos package we are going to look for is the lowercase
-# equivalent of the PRODUCTSTR
-export brandpkgname="`echo $PRODUCTSTR | tr '[:upper:]' '[:lower:]'`"
-
-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 <> $yumconf <> $yumconf </dev/null 2>&1
- case $? in
- [02]) ;;
- *) unset LDSO ;;
- esac
- if [ -z "$LDSO" ]; then
- for ldso in $root/$LDSODIR/ld*.so* ; do
- [ -L $ldso ] && continue
- [ -x $ldso ] || continue
- $ldso --verify $bin >/dev/null 2>&1
- case $? in
- [02]) LDSO=$(echo $ldso |sed -e "s,$root,,") ; break ;;
- esac
- 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 <.
-#
-
-ARCH=$1
-if [ -z "$ARCH" ]; then
- echo "usage: $0 "
- exit 1
-fi
-
-TOPDIR=`pwd`
-OUTPUT=$2
-if [ -z "$OUTPUT" ]; then
- echo "No output specified, using ${TMPDIR:-/tmp}/keymaps-$ARCH.$$"
- OUTPUT=${TMPDIR:-/tmp}/keymaps-$ARCH.$$
-fi
-
-UTILDIR=$3
-if [ -z "$UTILDIR" ]; then
- READMAP=../utils/readmap
- MAPSHDR=$TOPDIR/../utils/mapshdr
-else
- READMAP=$UTILDIR/usr/lib/anaconda-runtime/readmap
- MAPSHDR=$UTILDIR/usr/lib/anaconda-runtime/mapshdr
-fi
-
-TMP=${TMPDIR:-/tmp}/keymaps.$$
-
-rm -rf $TMP
-mkdir -p $TMP
-
-if [ $ARCH = "sparc" ]; then
- PATTERN={i386,sun}
-else
- PATTERN=i386
-fi
-
-MAPS=$(python -c "import rhpl.keyboard_models ; rhpl.keyboard_models.get_supported_models()")
-
-for map in $MAPS ; do
- eval find /lib/kbd/keymaps/$PATTERN -name "$map.map*.gz" | while read n; do
- /bin/loadkeys `basename $n .gz` >/dev/null
- $READMAP $TMP/`basename $n .map.gz`.map
- done
-done
-
-loadkeys us
-
-rm -f $TMP/defkeymap* $TMP/ANSI* $TMP/lt.map
-
-(cd $TMP; $MAPSHDR *.map) > $TMP/hdr
-cat $TMP/hdr $TMP/*.map | gzip -9 > $OUTPUT
-rm -rf $TMP
diff --git a/rewrite/scripts/getlangnames.py b/rewrite/scripts/getlangnames.py
deleted file mode 100644
index b81d26d2..00000000
--- a/rewrite/scripts/getlangnames.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# getlangnames.py
-#
-# 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 .
-#
-
-import sys
-sys.path.append("..")
-import language
-
-import gettext
-
-langs = language.Language()
-names = {}
-for k in langs.localeInfo.keys():
- found = False
- for l in language.expandLangs(k):
- try:
- f = open("po/%s.mo" %(l,))
- except (OSError, IOError):
- continue
- cat = gettext.GNUTranslations(f)
- cat.set_output_charset("utf-8")
- names[langs.localeInfo[k][0]] = cat.lgettext(langs.localeInfo[k][0])
- found = True
- break
- if not found:
- names[langs.localeInfo[k][0]] = langs.localeInfo[k][0]
-
-nameList = names.keys()
-nameList.sort()
-
-for k in nameList:
- print("%s\t%s" % (k, names[k]))
diff --git a/rewrite/scripts/makestamp.py b/rewrite/scripts/makestamp.py
deleted file mode 100755
index 0638c6de..00000000
--- a/rewrite/scripts/makestamp.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/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 .
-#
-
-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")
-
-
diff --git a/rewrite/scripts/maketreeinfo.py b/rewrite/scripts/maketreeinfo.py
deleted file mode 100644
index 226d5139..00000000
--- a/rewrite/scripts/maketreeinfo.py
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/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 .
-#
-# Author(s): Will Woods
-#
-
-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)
diff --git a/rewrite/scripts/makeupdates b/rewrite/scripts/makeupdates
deleted file mode 100755
index a8947ed0..00000000
--- a/rewrite/scripts/makeupdates
+++ /dev/null
@@ -1,212 +0,0 @@
-#!/usr/bin/env python
-#
-# makeupdates - Generate an updates.img containing changes since the last
-# tag, but only changes that do not need to be compiled. If
-# you need an updated _isys.so or a new loader, you should
-# still compile things as usual.
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published
-# by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-#
-# Author: David Cantrell
-
-import getopt
-import os
-import shutil
-import subprocess
-import sys
-
-def getArchiveTag(configure, spec):
- tag = ""
-
- f = open(configure)
- lines = f.readlines()
- f.close()
-
- for line in lines:
- if line.startswith('AC_INIT('):
- fields = line.split('[')
- tag += fields[1].split(']')[0] + '-' + fields[2].split(']')[0]
- break
- else:
- continue
-
- f = open(spec)
- lines = f.readlines()
- f.close()
-
- for line in lines:
- if line.startswith('Release:'):
- tag += '-' + line.split()[1].split('%')[0]
- else:
- continue
-
- return tag
-
-def doGitDiff(tag, args=[]):
- proc = subprocess.Popen(['git', 'diff', '--stat', tag] + args,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE).communicate()
-
- lines = proc[0].split('\n')
- return lines
-
-def copyUpdatedFiles(tag, updates, cwd):
- def pruneFile(src, names):
- lst = []
-
- for name in names:
- if name.startswith('Makefile') or name.endswith('.pyc'):
- lst.append(name)
-
- return lst
-
- subdirs = []
-
- lines = doGitDiff(tag)
- for line in lines:
- if line.find(' | ') == -1:
- continue
-
- fields = line.split()
- file = fields[0]
-
- if file.endswith('.spec.in') or file.startswith('Makefile') or \
- file.endswith('.c') or file.endswith('.h') or \
- file.endswith('.sh') or file == 'configure.ac':
- continue
-
- if file.find('/') != -1:
- fields = file.split('/')
- subdir = fields[0]
-
- if subdir == 'installclasses' or subdir == 'storage' or \
- subdir == 'booty':
- subupdates = os.path.realpath(updates + '/' + subdir)
- if os.path.isdir(subupdates):
- shutil.rmtree(subupdates)
-
- if not subdir in subdirs:
- sys.stdout.write("Including %s/\n" % (subdir,))
- subdirs.append(subdir)
-
- shutil.copytree(os.path.realpath(cwd + '/' + subdir),
- subupdates, ignore=pruneFile)
- elif subdir == 'loader' or subdir == 'po' or \
- subdir =='scripts' or subdir == 'command-stubs' or \
- subdir == 'tests' or subdir == 'bootdisk' or \
- subdir == 'docs' or subdir == 'fonts' or \
- subdir == 'utils' or subdir == 'gptsync':
- continue
- else:
- sys.stdout.write("Including %s\n" % (file,))
- shutil.copy2(file, updates)
-
-def isysChanged(tag):
- lines = doGitDiff(tag, ['isys'])
-
- for line in lines:
- if line.find(' | ') == -1:
- continue
-
- fields = line.split()
- file = fields[0]
-
- if file.startswith('Makefile') or file.endswith('.h') or \
- file.endswith('.c'):
- return True
-
- return False
-
-def copyUpdatedIsys(updates, cwd):
- os.chdir(cwd)
-
- if not os.path.isfile('Makefile'):
- if not os.path.isfile('configure'):
- os.system('./autogen.sh')
- os.system('./configure')
-
- os.system('make')
-
- isysmodule = os.path.realpath(cwd + '/isys/.libs/_isys.so')
- if os.path.isfile(isysmodule):
- shutil.copy2(isysmodule, updates)
-
-def createUpdatesImage(cwd, updates):
- os.chdir(updates)
- os.system("find . | cpio -c -o | gzip -9cv > %s/updates.img" % (cwd,))
- sys.stdout.write("updates.img ready\n")
-
-def usage(cmd):
- sys.stdout.write("Usage: %s [OPTION]...\n" % (cmd,))
- sys.stdout.write("Options:\n")
- sys.stdout.write(" -k, --keep Do not delete updates subdirectory.\n")
- sys.stdout.write(" -c, --compile Compile code if there are isys changes.\n")
- sys.stdout.write(" -h, --help Display this help and exit.\n")
-
-def main(argv):
- prog = os.path.basename(sys.argv[0])
- cwd = os.getcwd()
- configure = os.path.realpath(cwd + '/configure.ac')
- spec = os.path.realpath(cwd + '/anaconda.spec.in')
- updates = cwd + '/updates'
- keep, compile, help, unknown = False, False, False, False
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'kc?',
- ['keep', 'compile', 'help'])
- except getopt.GetoptError:
- help = True
-
- for o, a in opts:
- if o in ('-k', '--keep'):
- keep = True
- elif o in ('-c', '--compile'):
- compile = True
- elif o in ('-?', '--help'):
- help = True
- else:
- unknown = True
-
- if help:
- usage(prog)
- sys.exit(0)
- elif unknown:
- sys.stderr.write("%s: extra operand `%s'" % (prog, sys.argv[1],))
- sys.stderr.write("Try `%s --help' for more information." % (prog,))
- sys.exit(1)
-
- if not os.path.isfile(configure) and not os.path.isfile(spec):
- sys.stderr.write("You must be at the top level of the anaconda source tree.\n")
- sys.exit(1)
-
- tag = getArchiveTag(configure, spec)
-
- if not os.path.isdir(updates):
- os.makedirs(updates)
-
- copyUpdatedFiles(tag, updates, cwd)
-
- if compile:
- if isysChanged(tag):
- copyUpdatedIsys(updates, cwd)
-
- createUpdatesImage(cwd, updates)
-
- if not keep:
- shutil.rmtree(updates)
-
-if __name__ == "__main__":
- main(sys.argv)
diff --git a/rewrite/scripts/mk-images b/rewrite/scripts/mk-images
deleted file mode 100755
index 56a7a88d..00000000
--- a/rewrite/scripts/mk-images
+++ /dev/null
@@ -1,1019 +0,0 @@
-#!/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 .
-#
-
-LANG=C
-
-PATH=$PATH:/sbin:/usr/sbin
-IMAGEUUID=$(date +%Y%m%d%H%M).$(uname -i)
-TMPDIR=${TMPDIR:-/tmp}
-
-usage () {
- echo "usage: mk-images []"
- 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 usbhid 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 ext4 reiserfs jfs xfs gfs2 cifs fuse btrfs"
-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"
-INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS $SDMODS =scsi =net =drm"
-
-. $(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" -o "$BUILDARCH" = "ppc64" ]; 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-)
- if [ "$NAME" = "ata" ]; then
- SET="$SET $(egrep '(ata|ahci)' $KERNELROOT/lib/modules/$version/modules.block |sed -e 's/.ko//')"
- elif [ "$NAME" = "scsi" ]; then
- SET="$SET $(sed -e 's/.ko//' $KERNELROOT/lib/modules/$version/modules.block)"
- elif [ "$NAME" = "net" ]; then
- SET="$SET $(sed -e 's/.ko//' $KERNELROOT/lib/modules/$version/modules.networking)"
- else
- # Ignore if group list does not exist
- if [ -e $KERNELROOT/lib/modules/$version/modules.$NAME ]; then
- SET="$SET $(sed -e 's/.ko//' $KERNELROOT/lib/modules/$version/modules.$NAME)"
- fi
- fi
- 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
-
- echo "Copying required firmware..."
- find $MMB_DIR/lib/modules/ -name *.ko | while read module ; do
- for fw in $(modinfo -F firmware $module); do
- dest=$MBD_DIR/firmware/$fw
- destdir=$(dirname $dest)
-
- # Some firmware files are expected to be in their own directories.
- if [ ! -d $destdir ]; then
- mkdir -p $destdir
- fi
-
- cp $KERNELROOT/lib/firmware/$fw $dest
- done
- done
-
- # Copy in driver firmware we know we'll want during installation. This is
- # required for modules which still don't (or can't) export information
- # about what firmware files they require.
- 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
- ;;
- atmel)
- cp $KERNELROOT/lib/firmware/atmel_*.bin $MBD_DIR/firmware
- ;;
- zd1211rw)
- cp -r $KERNELROOT/lib/firmware/zd1211 $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
-
- iself="$(file $ROOT/$BIN | grep ELF)"
-
- if [ -L $ROOT/$BIN ]; then
- cp -a $ROOT/$BIN $DIR/$DEST
- else
- if [ -z "$iself" ]; then
- install -m 755 $ROOT/$BIN $DIR/$DEST
- else
- 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 -a ! -L ld-linux.so.2 ]; then
- rm -f ld-linux.so.2
- linker="$(ls -1 ld-*.*.*.so)"
- if [ -z "$linker" ]; then
- linker="$(ls -1 ld-*.*.so)"
- fi
- 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
- if [ "$BUILDARCH" = "s390x" ]; then
- pushd $DIR/lib
- ln -s ../$LIBDIR/ld64.so.1
- popd
- fi
- fi
- fi
-}
-
-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 <&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/etc/dhcp
- 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
- cp $IMGPATH/$LIBDIR/libwrap*.so* $MBD_DIR/$LIBDIR/
- 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/lib/anaconda-runtime/loader/lsznet.raw $MBD_DIR /sbin/lsznet
- instbin $IMGPATH /usr/lib/anaconda-runtime/loader/controlunits.sh $MBD_DIR /sbin/controlunits
- 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
- install -m 644 $IMGPATH/etc/hosts $MBD_DIR/etc/hosts
- mkdir -p $MBD_DIR/usr/lib/locale
- localedef -c -i en_US -f UTF-8 --prefix $MBD_DIR en_US
-
- instbin $IMGPATH /usr/bin/mount $MBD_DIR /sbin/mount
- for mountcmd in $IMGPATH/usr/sbin/mount.* ; do
- cmd="$(basename $mountcmd)"
- instbin $IMGPATH /usr/sbin/$cmd $MBD_DIR /sbin/$cmd
- done
- instbin $IMGPATH /usr/bin/umount $MBD_DIR /sbin/umount
- for umountcmd in $IMGPATH/usr/sbin/umount.* ; do
- cmd="$(basename $umountcmd)"
- instbin $IMGPATH /usr/sbin/$cmd $MBD_DIR /sbin/$cmd
- done
-
- 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
- instbin $IMGPATH /usr/sbin/udevsettle $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
- instbin $IMGPATH /usr/bin/ipcalc $MBD_DIR /sbin/ipcalc
- instbin $IMGPATH /usr/bin/hostname $MBD_DIR /sbin/hostname
- instbin $IMGPATH /usr/sbin/ethtool $MBD_DIR /sbin/ethtool
- instbin $IMGPATH /usr/sbin/route $MBD_DIR /sbin/route
- 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
- ( cd $IMGPATH/usr/$LIBDIR/NetworkManager
- for f in *.so ; do
- instbin $IMGPATH /usr/$LIBDIR/NetworkManager/$f $MBD_DIR /usr/$LIBDIR/NetworkManager/$f
- done
- )
- ( 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
- )
-
- # Misc
- instbin $IMGPATH /usr/bin/awk $MBD_DIR /sbin/awk
- instbin $IMGPATH /usr/bin/egrep $MBD_DIR /sbin/egrep
- instbin $IMGPATH /usr/bin/fgrep $MBD_DIR /sbin/fgrep
- instbin $IMGPATH /usr/bin/gawk $MBD_DIR /sbin/gawk
- instbin $IMGPATH /usr/bin/grep $MBD_DIR /sbin/grep
- instbin $IMGPATH /usr/bin/kill $MBD_DIR /sbin/kill
- instbin $IMGPATH /usr/bin/ln $MBD_DIR /sbin/ln
- instbin $IMGPATH /usr/bin/readlink $MBD_DIR /sbin/readlink
- instbin $IMGPATH /usr/bin/rm $MBD_DIR /sbin/rm
- instbin $IMGPATH /usr/bin/rmdir $MBD_DIR /sbin/rmdir
- instbin $IMGPATH /usr/bin/sed $MBD_DIR /sbin/sed
- instbin $IMGPATH /usr/bin/sleep $MBD_DIR /sbin/sleep
- instbin $IMGPATH /usr/bin/touch $MBD_DIR /sbin/touch
-
- # 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 < $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/share/syslinux ]; then
- ERROR=$(du -sk $IMGPATH/usr/share/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/share/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()
-{
- echo "Not on an EFI capable machine; skipping EFI images."
- /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
diff --git a/rewrite/scripts/mk-images.alpha b/rewrite/scripts/mk-images.alpha
deleted file mode 100644
index fb2ad60a..00000000
--- a/rewrite/scripts/mk-images.alpha
+++ /dev/null
@@ -1,131 +0,0 @@
-#
-# 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 .
-#
-
-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 < $MBD_BOOTTREE/etc/milo.conf < $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 <.
-#
-
-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() {
- echo "in makeefibootimage: 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 = "--kernelpath" ]; then
- KERNELPATH=$2
- shift; shift
- continue
- elif [ $1 = "--initrd" ]; then
- INITRDFILE=$2
- shift; shift
- continue
- elif [ $1 = "--initrdpath" ]; then
- INITRDPATH=$2
- shift; shift
- continue
- elif [ $1 = "--imagename" ]; then
- MBD_FILENAME=$IMAGEPATH/$2
- shift; shift
- continue
- elif [ $1 = "--grubpkg" ]; then
- grubpkg=$2
- echo "grubpkg=$grubpkg"
- shift; shift
- continue
- fi
- echo "Unknown option passed to makebootdisk: \"$1\""
- exit 1
- done
-
- if [ -z "$MBD_FILENAME" ]; then
- echo "No imagename 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" -a -n "$MBD_FSIMAGE" ]; 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() {
- echo "in 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() {
- echo "in prepareEfiTree"
- mkdir -p $MBD_BOOTTREE_TMP/EFI/BOOT
-
- cp -av $BOOTDISKDIR/*.conf $MBD_BOOTTREE_TMP/EFI/BOOT/
- [ -n "$KERNELFILE" ] && cp -av $KERNELFILE $MBD_BOOTTREE_TMP/EFI/BOOT/vmlinuz
- [ -n "$INITRDFILE" ] && cp -av $INITRDFILE $MBD_BOOTTREE_TMP/EFI/BOOT/initrd.img
- [ -z "$KERNELPATH" ] && KERNELPATH="/EFI/BOOT/vmlinuz"
- [ -z "$INITRDPATH" ] && INITRDPATH="/EFI/BOOT/initrd.img"
-
- SPLASHPATH="/EFI/BOOT/splash.xpm.gz"
- sed -e "s/@PRODUCT@/$PRODUCT/g" \
- -e "s/@VERSION@/$VERSION/g" \
- -e "s,@KERNELPATH@,$KERNELPATH,g" \
- -e "s,@INITRDPATH@,$INITRDPATH,g" \
- -e "s,@SPLASHPATH@,$SPLASHPATH,g" \
- -i $MBD_BOOTTREE_TMP/EFI/BOOT/grub.conf
-
- ydcmd="yumdownloader -c $yumconf $grubpkg"
- echo "(grubpkg) $ydcmd"
- $ydcmd
- rpm2cpio $grubpkg.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
- cp -av $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 -av $MBD_BOOTTREE_TMP/EFI/BOOT/grub.efi $MBD_BOOTTREE_TMP/EFI/BOOT/BOOT.efi
- cp -av $MBD_BOOTTREE_TMP/EFI/BOOT/grub.conf $MBD_BOOTTREE_TMP/EFI/BOOT/BOOT.conf
- fi
-
- local tmpefiarch=${efiarch}
- case ${efiarch} in
- x64) tmpefiarch="X64" ;;
- ia32) tmpefiarch="IA32" ;;
- esac
- mv -v $MBD_BOOTTREE_TMP/EFI/BOOT/grub.efi $MBD_BOOTTREE_TMP/EFI/BOOT/BOOT${tmpefiarch}.efi
- mv -v $MBD_BOOTTREE_TMP/EFI/BOOT/grub.conf $MBD_BOOTTREE_TMP/EFI/BOOT/BOOT${tmpefiarch}.conf
-
- artpkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" --whatprovides ${brandpkgname}-logos | grep -v generic-logos | head -1)
- if [ -z "$artpkg" ]; then
- argpkg="generic-logos"
- fi
-
- ydcmd="yumdownloader -c ${yumconf} ${artpkg}"
- echo "(artpkg) $ydcmd"
- $ydcmd
- rpm2cpio ${artpkg}.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
- cp -av $KERNELROOT/boot/grub/splash.xpm.gz $MBD_BOOTTREE_TMP/$SPLASHPATH
-
- # if we don't have a kernel or initrd, we're making a CD image and we need
- # to mirror EFI/ to the cd.
- if [ -z "$KERNELFILE" -a -z "$INITRDFILE" ]; then
- cp -av $MBD_BOOTTREE_TMP/EFI/ $TOPDESTPATH/EFI/
- rm -f $TOPDESTPATH/EFI/BOOT/*.efi
- fi
-}
-
-makeEfiImages() {
- echo "in makeEfiImages"
- yumconf="$1"
- echo "Making EFI images ($PWD)"
- if [ "$kernelvers" != "$kernelxen" ]; then
- local grubarch=${efiarch}
- case ${efiarch} in
- ia32) grubarch=i?86 ;;
- 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"
- echo "grubpkg: ${grubpkg}"
-
- makeefibootimage \
- --imagename efiboot.img \
- --kernel $TOPDESTPATH/images/pxeboot/vmlinuz \
- --initrd $TOPDESTPATH/images/pxeboot/initrd.img \
- --grubpkg ${grubpkg}
- local ret=$?
- if [ $ret -ne 0 ]; then
- echo "makeefibootimage (1) failed" >&2
- return $ret
- fi
-
- makeefibootdisk $TOPDESTPATH/images/efiboot.img $TOPDESTPATH/images/efidisk.img
- local ret=$?
- [ $ret -eq 0 ] || return $ret
- rm -vf $TOPDESTPATH/images/efiboot.img
-
- # make a boot image with just boot*.efi in it...
- makeefibootimage \
- --imagename efiboot.img \
- --kernelpath /images/pxeboot/vmlinuz \
- --initrdpath /images/pxeboot/initrd.img \
- --grubpkg ${grubpkg}
- local ret=$?
- if [ $ret -ne 0 ]; then
- echo "makeefibootimage (2) failed" >&2
- fi
- return $ret
- fi
- return 0
-}
diff --git a/rewrite/scripts/mk-images.ia64 b/rewrite/scripts/mk-images.ia64
deleted file mode 100644
index d4dae357..00000000
--- a/rewrite/scripts/mk-images.ia64
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# 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 .
-#
-
-#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 <> $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
-}
diff --git a/rewrite/scripts/mk-images.ppc b/rewrite/scripts/mk-images.ppc
deleted file mode 100644
index b90865b6..00000000
--- a/rewrite/scripts/mk-images.ppc
+++ /dev/null
@@ -1,171 +0,0 @@
-#
-# 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 .
-#
-
-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
-}
diff --git a/rewrite/scripts/mk-images.s390 b/rewrite/scripts/mk-images.s390
deleted file mode 100644
index b3e9db1a..00000000
--- a/rewrite/scripts/mk-images.s390
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# 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 .
-#
-
-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/redhat.exec $TOPDESTPATH/images/redhat.exec
- 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__
-}
diff --git a/rewrite/scripts/mk-images.x86 b/rewrite/scripts/mk-images.x86
deleted file mode 100644
index 2d94e06a..00000000
--- a/rewrite/scripts/mk-images.x86
+++ /dev/null
@@ -1,181 +0,0 @@
-#
-# 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 .
-#
-
-SYSLINUX=$IMGPATH/usr/share/syslinux/syslinux-nomtools
-CDLABEL=$PRODUCT
-
-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)
-
- ln $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/share/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 <> $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 <> $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
- EFIARGS=""
- EFIGRAFT=""
- if [ -f $TOPDESTPATH/images/efiboot.img ]; then
- echo "Found efiboot.img, making an EFI-capable boot.iso"
- EFIARGS="-eltorito-alt-boot -e images/efiboot.img -no-emul-boot"
- EFIGRAFT="EFI/BOOT=$TOPDESTPATH/EFI/BOOT"
- else
- echo "No efiboot.img found, making BIOS-only boot.iso"
- fi
- BIOSARGS="-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
- mkisocmd="mkisofs -v -o $TOPDESTPATH/images/$BOOTISO $BIOSARGS $EFIARGS -R -J -V "$CDLABEL" -T -graft-points isolinux=$TOPDESTPATH/isolinux images=$TOPDESTPATH/images $EFIGRAFT"
- echo $PWD:\$ $mkisocmd
- $mkisocmd
- if [ -x /usr/bin/isohybrid ]; then
- isohybrid $TOPDESTPATH/images/$BOOTISO || echo "Unable to make hybrid boot.iso"
- fi
- fi
-}
diff --git a/rewrite/scripts/pyrc.py b/rewrite/scripts/pyrc.py
deleted file mode 100644
index 6acee5b9..00000000
--- a/rewrite/scripts/pyrc.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# pyrc.py
-#
-# 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 .
-#
-
-try:
- import readline
- import rlcompleter
- readline.parse_and_bind("tab: complete")
- del rlcompleter
- del readline
-except:
- pass
diff --git a/rewrite/scripts/scrubtree b/rewrite/scripts/scrubtree
deleted file mode 100755
index 26c67f3a..00000000
--- a/rewrite/scripts/scrubtree
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/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 .
-#
-
-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 -o $ARCH = ppc64 ]; 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
-
-umount $p/proc
diff --git a/rewrite/scripts/upd-bootimage b/rewrite/scripts/upd-bootimage
deleted file mode 100755
index 9fcf3642..00000000
--- a/rewrite/scripts/upd-bootimage
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-#
-# upd-bootimage
-#
-# 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 .
-#
-
-if [ -z "$1" ]; then
- echo "$0: []"
- exit 1
-fi
-
-if [ ! -f $1 ]; then
- echo "$1 doesn't exist"
- exit 1
-fi
-
-MNTPOINT=/tmp/updboottree.$$
-INITRD=/tmp/updboottree.$$.initrd
-LOOPMNT=/tmp/updboottree.$$.initrdmnt
-
-rm -rf $MNTPOINT $LOOPMNT
-mkdir $MNTPOINT $LOOPMNT
-mount -t vfat -o loop $1 $MNTPOINT
-
-gunzip < $MNTPOINT/initrd.img > $INITRD
-
-mount -o loop $INITRD $LOOPMNT
-
-FROM=$2
-TO=$FROM
-if [ $(echo $FROM | cut -d- -f1) = loader ]; then
- TO=loader
-fi
-
-if [ ! -x $LOOPMNT/sbin/$TO ]; then
- echo "$LOOPMNT/sbin/$TO doesn't exist"
-else
- cp $FROM $FROM.foo
- strip $FROM.foo
- install $FROM.foo $LOOPMNT/sbin/$TO
- rm -f $FROM.foo
-fi
-
-umount $LOOPMNT
-gzip -9 < $INITRD > $INITRD.new
-cp $INITRD.new $MNTPOINT/initrd.img
-if [ -f $MNTPOINT/efi/boot/initrd.img ]; then
- cp $INITRD.new $MNTPOINT/efi/boot/initrd.img
-fi
-umount $MNTPOINT
-
-if [ -n "$3" -a -f "$3" ]; then
- echo "Replacing $3"
- cp -f $INITRD.new $3
-fi
-
-rm -rf $MNTPOINT $LOOPMNT $INITRD $INITRD.new
diff --git a/rewrite/scripts/upd-initrd b/rewrite/scripts/upd-initrd
deleted file mode 100755
index 66006d8c..00000000
--- a/rewrite/scripts/upd-initrd
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-#
-# Updates an installer initrd with a new loader binary
-# Usage: upd-initrd
-#
-# Copyright (C) 2005 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 .
-#
-# Author(s): Jeremy Katz
-#
-
-if [ $# -ne 3 ]; then
- echo "Usage: $0 "
- exit 1
-fi
-
-INITRD=`readlink -f $1`
-BIN=`readlink -f $2`
-if [ -f $3 ]; then
- OUT=`readlink -f $3`
-else
- OUT=`readlink -f .`/$3
-fi
-
-tmpdir=$(mktemp -d)
-pushd $tmpdir
-zcat $INITRD |cpio -id
-strip -s -o sbin/$(basename $BIN) $BIN
-(find . |cpio -c -o |gzip -9) > $OUT
-popd
-rm -rf $tmpdir
diff --git a/rewrite/scripts/upd-instroot b/rewrite/scripts/upd-instroot
deleted file mode 100755
index e1750349..00000000
--- a/rewrite/scripts/upd-instroot
+++ /dev/null
@@ -1,1046 +0,0 @@
-#!/bin/bash
-#
-# upd-instroot
-#
-# Copyright (C) 2007, 2008 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 .
-#
-
-ORIGDIR=`pwd`
-DEBUG=""
-ARCH=`uname -m`
-
-while [ $# -gt 0 ]; do
- case $1 in
- --debug)
- DEBUG="--debug"
- shift
- ;;
-
- --arch)
- ARCH=$2
- shift; shift
- ;;
-
- --imgdir)
- DEST=$2
- shift; shift
- ;;
-
- # a filesystem tree to use as updates. could be the output
- # of 'make install' from anaconda...
- --updates)
- UPDATES=$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 "$yumconf" ]; then
- echo "upd-instroot: updates instimage from a Red Hat RPMS directory"
- echo "usage: $0 [--debug] [--arch arch] [--imgdir imgdir] [yumconf]"
- exit 1
-fi
-
-if [ $ARCH = x86_64 -o $ARCH = s390x -o $ARCH = ppc64 ]; then
- LIBDIR=lib64
-else
- LIBDIR=lib
-fi
-
-if [ -z "$DEST" ]; then
- DEST=`mktemp -d ${TMPDIR:-/tmp}/dest.XXXXXX`
-fi
-
-if [ ! -f $yumconf ]; then
- echo "Unable to find yum repo information!"
- exit 1
-fi
-
-. $(dirname $0)/buildinstall.functions
-
-expandPackageSet() {
- YUMCONF=$1
- YUMDIR=$2
- RPMS=$3
- PKGDEST=$4
- KEEPFILES=$5
-
- [ -d $PKGDEST ] || die "ERROR: directory missing: $PKGDEST"
-
- [ -z "$DEBUG" ] && outlvl="--quiet" || outlvl="--verbose"
-
- yum $outlvl -c $YUMCONF -y --installroot=$YUMDIR install $RPMS 2>&1 || die "ERROR: could not install packages"
-
- 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
-}
-
-die () {
- echo "$@"
- echo "Aborting instroot creation..."
- exit 1
-}
-
-PACKAGES="GConf2 NetworkManager ORBit2 PolicyKit acl anaconda
- anaconda-yum-plugins at-spi atk attr audit-libs bash bitmap-fonts-cjk
- btrfs-progs bzip2 bzip2-libs cairo cjkuni-uming-fonts
- comps-extras coreutils cpio cracklib cracklib-dicts cracklib-python
- cryptsetup-luks db4 dbus dbus-python dejavu-sans-fonts
- dejavu-sans-mono-fonts device-mapper
- device-mapper-libs dhclient dhcpv6-client dmraid dmraid-libs
- dogtail dosfstools e2fsprogs e2fsprogs-libs echo-icon-theme ethtool
- elfutils-libelf expat firstboot fontconfig fonts-ISO8859-2 freetype gail gawk gdb-gdbserver
- gdk-pixbuf gfs2-utils glib2 glibc-common gnome-python2-canvas gnome-python2-gconf
- gnome-python2-gtkhtml2 gnome-themes gpm grep gtk2 gtk2-engines gtkhtml2 hal
- hdparm hwdata initscripts iproute iputils iscsi-initiator-utils
- jfsutils keyutils-libs krb5-libs libICE libSM libX11 libXau
- libXaw libXcursor libXdmcp libXevie libXext libXfixes libXfont libXft
- libXi libXinerama libXmu libXpm libXrandr libXrender libXt libXtst
- libXxf86misc libacl libart_lgpl libattr libbdevid libbdevid-python
- libbonobo libfontenc libgcc
- libglade2 libgnomecanvas libgcrypt libgpg-error libjpeg libnl
- libpng libselinux libselinux-python libsemanage
- libsemanage-python libsepol libstdc++ libthai libuser
- libuser-python libvolume_id libxcb libxkbfile libxml2 lklug-fonts
- lohit-assamese-fonts lohit-bengali-fonts lohit-gujarati-fonts lohit-hindi-fonts
- lohit-kashmiri-fonts lohit-kannada-fonts lohit-maithili-fonts lohit-marathi-fonts
- lohit-oriya-fonts lohit-punjabi-fonts lohit-sindhi-fonts lohit-tamil-fonts
- lohit-telugu-fonts lvm2 madan-fonts mdadm
- mesa-dri-drivers mkinitrd module-init-tools nash ncurses neon net-tools
- newt newt-python nfs-utils nspr nss ntfs-3g pam pango parted pciutils pcre
- policycoreutils popt prelink procps pycairo pygobject2 pygtk2
- pygtk2-libglade pykickstart pyparted python python-bugzilla python-decorator
- python-libs python-pyblock python-sqlite
- python-urlgrabber pyxf86config readline redhat-artwork
- reiserfs-utils rhpl rpm rpm-libs rpm-python sed selinux-policy-targeted
- setup slang smc-meera-fonts specspo sqlite synaptics system-config-date
- system-config-keyboard ${brandpkgname}-logos ${brandpkgname}-release taipeifonts tcp_wrappers
- tzdata udev un-core-fonts-dotum urw-fonts util-linux-ng tigervnc-server
- tigervnc-server-module vlgothic-fonts vim-minimal
- wpa_supplicant xkeyboard-config xfsdump xfsprogs xorg-x11-auth
- xorg-x11-drivers xorg-x11-font-utils xorg-x11-fonts-ethiopic
- xorg-x11-fonts-misc xorg-x11-server-utils
- xorg-x11-server-Xorg xorg-x11-xkb-utils xorg-x11-xfs yum
- yum-metadata-parser zenity zlib /etc/gtk-2.0/gtkrc"
-
-if [ $ARCH = i386 ]; then
- PACKAGES="$PACKAGES glibc.i386 openssl.i386"
-elif [ $ARCH = i586 ]; then
- PACKAGES="$PACKAGES glibc.i586 openssl.i586"
-else
- PACKAGES="$PACKAGES glibc openssl"
-fi
-
-if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
- PACKAGES="$PACKAGES pcmciautils grub"
-fi
-
-if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 -o $ARCH = ia64 ]; then
- PACKAGES="$PACKAGES dmidecode efibootmgr"
-fi
-
-if [ $ARCH = ia64 ]; then
- # XXX this needs to switch to grub at some point...
- PACKAGES="$PACKAGES elilo"
-fi
-
-if [ $ARCH = s390 -o $ARCH = s390x ]; then
- PACKAGES="$PACKAGES s390utils binutils libgcc tcp_wrappers
- sed net-tools openssh openssh-server coreutils
- login initscripts portmap pam
- login mount modutils s390utils-cmsfs
- strace xorg-x11-xauth xorg-x11-libs"
-fi
-
-if [ $ARCH = ppc -o $ARCH = ppc64 ]; then
- PACKAGES="$PACKAGES pcmciautils pdisk yaboot hfsutils"
-fi
-
-#
-# stuff ONLY included for rescue mode
-#
-# these packages are combined with the PACKAGES for big stage 2
-#
-PACKAGESRESCUE="bzip2 bzip2-libs dump libidn
- findutils ftp gzip iputils joe krb5-libs less man
- modutils mtools mt-st mtr net-tools smartmontools
- openssh openssh-clients pciutils rsh traceroute tar rsync
- device-mapper device-mapper-libs dmraid ntfsprogs samba-client
- firstaidkit firstaidkit-plugin-all dialog"
-
-if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
- PACKAGESRESCUE="$PACKAGESRESCUE gpart grub"
-fi
-
-#
-# add bootloader for particular arch
-#
-if [ $ARCH = sparc ]; then
- PACKAGES="$PACKAGES tilo silo"
-fi
-
-if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
- PACKAGES="$PACKAGES syslinux memtest86+ grub"
-fi
-
-if [ $ARCH = alpha ]; then
- PACKAGES="$PACKAGES aboot"
-fi
-
-if [ $ARCH = ppc ]; then
- PACKAGES="$PACKAGES fbset yaboot ppc64-utils"
-fi
-
-#
-# KEEPFILE is all files to keep from the packages in PACKAGES
-#
-# The files in this list define the install image used for all installation
-# methods.
-#
-# The rescue mode of anaconda uses these files as well as those defined
-# by KEEPFILERESCUE below. The total size of this image should be
-# under the size of the miniature CD used for the rescue CD (around 68MB).
-#
-KEEPFILE=${TMPDIR:-/tmp}/keepfile.$$
-cat > $KEEPFILE <> $KEEPFILE <> $KEEPFILE < $KEEPFILERESCUE <> $KEEPFILERESCUE <<-EOF
-sbin/grub
-usr/bin/gpart
-usr/share/grub
-EOF
-fi
-
-echo "Assembling package list..."
-RPMS="$PACKAGES $PACKAGESRESCUE"
-[ -n "$DEBUG" ] && echo "RPMS are $RPMS"
-
-rm -rf $DEST; mkdir -p $DEST/usr/sbin $DEST/var/lib $DEST/boot
-ln -s /tmp $DEST/var/lib/xkb
-
-#
-# concat KEEPFILE and KEEPFILERESCUE lists
-#
-cat $KEEPFILERESCUE >> $KEEPFILE
-
-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
-
-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 < $DEST/etc/libuser.conf </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
-fi
-
-if [ -f $DEST/bin/gawk ]; then
- ln -sf awk $DEST/bin/gawk
-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 = i586 -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
diff --git a/rewrite/scripts/upd-kernel b/rewrite/scripts/upd-kernel
deleted file mode 100755
index 30871135..00000000
--- a/rewrite/scripts/upd-kernel
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-#
-# take a boot directory with kernel + initrd and create a new one
-# with a new kernel + initrd
-# Usage: ./upd-kernel
-#
-# 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 .
-#
-
-OLDDIR=`readlink -f $1`
-NEWDIR=$2
-KRPM=`readlink -f $3`
-
-NEWVER=$(rpm -qp --provides $KRPM | awk -F ' = ' '/kernel-uname-r/ { print $2; }')
-
-if [ -z "$OLDDIR" -o -z "$NEWDIR" -o -z "$KRPM" ]; then
- echo "Usage: $0 "
- exit 1
-fi
-
-if [ ! -d $OLDDIR ]; then
- echo "Directory $OLDDIR doesn't exist"
- exit 1
-fi
-
-if [ -d $NEWDIR ]; then
- NEWDIR=`readlink -f $NEWDIR`
-else
- NEWDIR=`readlink -f .`/$NEWDIR
- mkdir $NEWDIR
-fi
-
-WORKDIR=$(/bin/mktemp -d /tmp/kernrpm.XXXXXX)
-
-pushd $WORKDIR > /dev/null
-
-# explode the rpm
-mkdir rpm
-pushd rpm > /dev/null
-rpm2cpio $KRPM | cpio -id --quiet
-popd > /dev/null
-
-# explode the initrd
-mkdir initrd
-pushd initrd > /dev/null
-zcat $OLDDIR/initrd.img | cpio -id --quiet
-
-for mod in $(find modules/ -type f -name '*.ko.gz' -exec basename {} \; | sort | uniq) ; do
- for path in $(find $WORKDIR/rpm/lib/modules/$NEWVER/ -name ${mod%.gz}); do
- dest=${path##$WORKDIR/rpm/lib/}
- mkdir -p $(dirname $dest)
- gzip < $path > $dest.gz
- done
-done
-
-/sbin/depmod -a -b . $NEWVER
-rm -f modules/$NEWVER/modules.*map
-
-find . | cpio --quiet -c -o | gzip -9 > $NEWDIR/initrd.img
-popd > /dev/null
-
-cp $WORKDIR/rpm/boot/vmlinuz-* $NEWDIR/vmlinuz
-popd > /dev/null
-rm -rf $WORKDIR
diff --git a/rewrite/scripts/upd-updates b/rewrite/scripts/upd-updates
deleted file mode 100755
index 5e0e7998..00000000
--- a/rewrite/scripts/upd-updates
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/bash
-#
-# upd-updates
-#
-# 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 .
-#
-
-isAnacondaGitDir() {
- [ -f .git/config ] || return 1
- grep -q 'url = git+ssh://git\.fedoraproject\.org/git/hosted/anaconda\.git' .git/config
-}
-
-usage() {
- if [ $1 -ne 0 ]; then
- >&2
- fi
- echo "upd-updates [ [ [...]]]"
- exit $1
-}
-
-[ -z "$1" ] && usage 1
-[ "$1" == "--help" ] && usage 0
-updateAll=no
-if [ -z "$2" ]; then
- if isAnacondaGitDir ; then
- updateAll=yes
- else
- usage 1
- fi
-fi
-
-TARGET="$1" ; shift
-if [ ! -f "$1" ]; then
- echo -n | cpio -H newc --quiet -o | gzip -9 > "$1"
-fi
-
-OK=no
-if [ -e "$TARGET" -a -w "$TARGET" -o -w $(dirname "$TARGET") ] ; then
- OK=yes
-fi
-
-if [ "$OK" == "no" ]; then
- echo "upd-updates: cannot write to $TARGET" 1>&2
- exit 2
-fi
-
-if [ "$updateAll" == "no" ]; then
- n=1
- while [ -n "$(eval echo '${'$n'}')" ]; do
- arg="$(eval echo '${'$n'}')"
- [ ${arg} == "--help" -o ${arg} == "-h" ] && usage 0
-
- if [ ! -r ${arg} ]; then
- echo "upd-updates: cannot read ${arg}" 1>&2
- exit 3
- fi
- n=$(($n + 1))
- done
-fi
-
-TMPDIR=$(mktemp -d)
-if [ ! -d ${TMPDIR} ]; then
- echo "upd-updates: cannot make tmpdir ${TMPDIR}" 1>&2
- exit 4
-fi
-
-if [ -e "$TARGET" ]; then
- zcat "$TARGET" | ( cd $TMPDIR ; cpio -di --quiet -dm --unconditional )
- [ $? -eq 0 ] || exit 5
-fi
-
-if [ "$updateAll" == "yes" ]; then
- # this may do the wrong thing if we have two files named the same...
- # so, uh, don't do that.
- for oldfile in $(find "$TMPDIR" -type f) ; do
- for newfile in $(find . -name $(basename $oldfile)) ; do
- if [ "$oldfile" -ot "$newfile" ]; then
- cp -av "$newfile" "$oldfile"
- fi
- done
- done
-else
- echo ${@} | tr ' ' '\0' | tr -d '\n' | \
- cpio --null -H newc --quiet -o | \
- ( cd $TMPDIR ; cpio -di --quiet -dm --unconditional )
-
- [ $? -eq 0 ] || exit 6
-fi
-
-(cd $TMPDIR ; find . -depth -print0 | cpio -H newc --quiet --null -o ) | \
- gzip -9 > "$TARGET"
-
-[ $? -eq 0 ] || exit 7
-
-rm -rf "$TMPDIR"
-
-[ $? -eq 0 ] || exit 8
-
-exit 0
diff --git a/rewrite/utils/filtermoddeps b/rewrite/utils/filtermoddeps
deleted file mode 100755
index 3deeed04..00000000
--- a/rewrite/utils/filtermoddeps
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/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 .
-#
-
-perl -e 'while (<>) { if (/\\\n/) { chop; s/\\$//; print;} else { print $_; } }' | grep ':.*ko' | sed -e '
-s/\.ko//g
-s,/[^: ]*/,,g
-s/[ ][ ]*/ /g'
-
diff --git a/rewrite/utils/geninitrdsz.c b/rewrite/utils/geninitrdsz.c
deleted file mode 100644
index 6dfd9761..00000000
--- a/rewrite/utils/geninitrdsz.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 .
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-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;
-}
diff --git a/rewrite/utils/genmodinfo b/rewrite/utils/genmodinfo
deleted file mode 100755
index 44c8247d..00000000
--- a/rewrite/utils/genmodinfo
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/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 .
-#
-
-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]
diff --git a/rewrite/utils/mapshdr.c b/rewrite/utils/mapshdr.c
deleted file mode 100644
index f2209c75..00000000
--- a/rewrite/utils/mapshdr.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * mapshdr.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 .
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "../isys/lang.h"
-
-int main(int argc, char ** argv) {
- struct kmapHeader h;
- struct kmapInfo info;
- int i, x;
- struct stat sb;
- char * chptr;
-
- h.magic = KMAP_MAGIC;
- h.numEntries = argc - 1;
- x = write(1, &h, sizeof(h));
-
- for (i = 1; i < argc; i++) {
- if (stat(argv[i], &sb)) {
- fprintf(stderr, "stat error for %s: %s\n", argv[i],
- strerror(errno));
- exit(1);
- }
-
- memset(info.name, 0, KMAP_NAMELEN);
- strncpy(info.name, argv[i], KMAP_NAMELEN - 1);
-
- chptr = info.name + strlen(info.name) - 1;
- while (*chptr != '.') *chptr-- = '\0';
- *chptr = '\0';
-
- info.size = sb.st_size;
- x = write(1, &info, sizeof(info));
- }
-
- return 0;
-}
diff --git a/rewrite/utils/mk-s390-cdboot.c b/rewrite/utils/mk-s390-cdboot.c
deleted file mode 100644
index 4a582585..00000000
--- a/rewrite/utils/mk-s390-cdboot.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * mk-s390-cdboot -- creates one big image using a kernel, a ramdisk and
- * a parmfile
- *
- * 2003-07-24 Volker Sameske
- * 2008-09-22 Updated by David Cantrell
- *
- * compile with:
- * gcc -Wall -o mk-s390-cdboot mk-s390-cdboot.c
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#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 -r -p -o \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, 1, 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, 1, 1, fd1);
- if (feof(fd1) || ferror(fd1)) {
- fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
- abort();
- }
-
- if (wc != rc) {
- fprintf(stderr, "could only write %i of %i bytes of kernel\n",
- wc, rc);
- }
- }
-
- printf("writing initrd...\n");
- fseek(fd1, initrd_start, SEEK_SET);
- while (1) {
- rc = fread(buffer, 1, 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, 1, 1, fd1);
- if (feof(fd1) || ferror(fd1)) {
- fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
- abort();
- }
-
- if (wc != rc) {
- fprintf(stderr, "could only write %i of %i bytes of initrd\n",
- wc, rc);
- }
- }
-
- 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, 1, 4, fd1);
- if (feof(fd1) || ferror(fd1)) {
- fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
- abort();
- }
-
- if (wc != 4) {
- fprintf(stderr, "could only write %i of %i bytes of PSW address\n",
- wc, 4);
- }
-
- 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, 1, 8, fd1);
- if (feof(fd1) || ferror(fd1)) {
- fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
- abort();
- }
-
- if (wc != 8) {
- fprintf(stderr, "could only write %i of %i bytes of INITRD start\n",
- wc, 8);
- }
-
- if (fseek(fd1, 0x10410, SEEK_SET) == -1) {
- fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
- abort();
- }
-
- wc = fwrite(&initrd_size, 1, 8, fd1);
- if (feof(fd1) || ferror(fd1)) {
- fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
- abort();
- }
-
- if (wc != 8) {
- fprintf(stderr, "could only write %i of %i bytes of INITRD size\n",
- wc, 8);
- }
-
- 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 (wc != 1) {
- fprintf(stderr, "could only write %i of %i bytes of parmfile\n",
- wc, 1);
- }
- }
-
- 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;
-}
diff --git a/rewrite/utils/modlist.c b/rewrite/utils/modlist.c
deleted file mode 100644
index 5c88e323..00000000
--- a/rewrite/utils/modlist.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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 .
- */
-
-#include
-#include
-#include
-#include
-
-#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;
-}
diff --git a/rewrite/utils/readmap.c b/rewrite/utils/readmap.c
deleted file mode 100644
index 7d656363..00000000
--- a/rewrite/utils/readmap.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * readmap.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 .
- */
-
-#include
-#include
-#include
-#include
-#ifdef NR_KEYS
-#undef NR_KEYS
-#define NR_KEYS 128
-#endif
-
-#include
-#include
-#include
-#include
-#include
-
-#include "../isys/lang.h"
-
-int main(int argc, char ** argv) {
- int console;
- int kmap, key;
- struct kbentry entry;
- int keymaps[MAX_NR_KEYMAPS];
- int count = 0;
- int out;
- short keymap[NR_KEYS];
- int magic = KMAP_MAGIC;
- int verbose = 0;
-
- if (argc != 2) {
- printf("bad usage\n");
- exit(1);
- }
-
- if (getenv("DEBUG") != NULL)
- verbose = 1;
-
- memset(keymaps, 0, sizeof(keymaps));
-
- console = open("/dev/tty0", O_RDWR);
- if (console < 0) {
- perror("open VGA+KBD");
- exit(1);
- }
-
- for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) {
- for (key = 0; key < NR_KEYS; key++) {
- entry.kb_index = key;
- entry.kb_table = kmap;
- if (ioctl(console, KDGKBENT, &entry)) {
- perror("ioctl failed");
- exit(1);
- } else if (KTYP(entry.kb_value) != KT_SPEC) {
- keymaps[kmap] = 1;
- count++;
- break;
- }
- }
- }
-
- if (verbose) fprintf(stderr, "found %d valid keymaps\n", count);
-
- if (verbose) fprintf(stderr, "creating keymap file %s\n", argv[1]);
- if ((out = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 1) {
- perror("open keymap");
- exit(1);
- }
-
- if (write(out, &magic, sizeof(magic)) != sizeof(magic)) {
- perror("write magic");
- exit(1);
- }
-
- if (write(out, keymaps, sizeof(keymaps)) != sizeof(keymaps)) {
- perror("write header");
- exit(1);
- }
-
- for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) {
- if (!keymaps[kmap]) continue;
- for (key = 0; key < NR_KEYS; key++) {
- entry.kb_index = key;
- entry.kb_table = kmap;
- if (ioctl(console, KDGKBENT, &entry)) {
- perror("ioctl failed");
- exit(1);
- } else {
- keymap[key] = entry.kb_value;
- }
- }
-
- if (write(out, keymap, sizeof(keymap)) != sizeof(keymap)) {
- perror("write keymap");
- exit(1);
- }
- }
-
- close(out);
-
- return 0;
-}
diff --git a/rewrite/utils/snarffont.c b/rewrite/utils/snarffont.c
deleted file mode 100644
index 1d8bce7c..00000000
--- a/rewrite/utils/snarffont.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * snarffont.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 .
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-void die(char * mess) {
- perror(mess);
- exit(1);
-}
-
-#define MAXFONTSIZE 65536
-
-int main(void) {
- unsigned char buf[MAXFONTSIZE];
- struct console_font_op cfo;
- unsigned short map[E_TABSZ];
- struct unipair descs[2048];
- struct unimapdesc d;
- int fd, i;
-
- if ((fd = open("/dev/tty0", O_RDONLY)) < 0)
- die("open");
-
- cfo.op = KD_FONT_OP_GET;
- cfo.flags = 0;
- cfo.width = 8;
- cfo.height = 16;
- cfo.charcount = 512;
- cfo.data = buf;
- if (ioctl(fd, KDFONTOP, &cfo))
- die("KDFONTOP KD_FONT_OP_GET");
-
- if (ioctl(fd, GIO_UNISCRNMAP, map))
- die("GIO_UNISCRNMAP");
-
- d.entry_ct = 2048;
- d.entries = descs;
- if (ioctl(fd, GIO_UNIMAP, &d))
- die("GIO_UNIMAP");
-
- i = write(1, &cfo, sizeof(cfo));
- i = write(1, buf, sizeof(buf));
- i = write(1, map, sizeof(map));
- i = write(1, &d.entry_ct, sizeof(d.entry_ct));
- i = write(1, descs, d.entry_ct * sizeof(descs[0]));
- return 0;
-}
diff --git a/rewrite/utils/trimpciids b/rewrite/utils/trimpciids
deleted file mode 100755
index ba946297..00000000
--- a/rewrite/utils/trimpciids
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/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 .
-#
-
-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,
diff --git a/src/bin/lorax b/src/bin/lorax
index 7021a6ed..94fc3d0c 100755
--- a/src/bin/lorax
+++ b/src/bin/lorax
@@ -30,9 +30,9 @@ from optparse import OptionParser, OptionGroup
import pylorax
-if __name__ == '__main__':
- version = '%s 0.1' % os.path.basename(sys.argv[0])
- usage = '%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUTDIR REPOSITORY'
+if __name__ == "__main__":
+ version = "%s 0.1" % (os.path.basename(sys.argv[0]),)
+ usage = "%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUTDIR REPOSITORY"
parser = OptionParser(usage=usage)
@@ -40,49 +40,50 @@ if __name__ == '__main__':
if os.path.isdir(value):
setattr(parser.values, option.dest, value)
else:
- parser.error('%s is not a directory' % value)
+ parser.error("'%s' is not a directory" % (value,))
# required
# XXX "options" should not be required
- group = OptionGroup(parser, 'Required')
- group.add_option('-p', '--product', help='Product name',
- metavar='STRING')
- group.add_option('-v', '--version', help='Version identifier',
- metavar='STRING')
- group.add_option('-r', '--release', help='Release information or comment',
- metavar='STRING')
- group.add_option('-o', '--output', help='Destination directory',
- metavar='PATHSPEC')
+ group = OptionGroup(parser, "Required")
+ group.add_option("-p", "--product", help="Product name",
+ metavar="STRING")
+ group.add_option("-v", "--version", help="Version identifier",
+ metavar="STRING")
+ group.add_option("-r", "--release", help="Release information or comment",
+ metavar="STRING")
+ group.add_option("-o", "--output", help="Destination directory",
+ metavar="PATHSPEC")
parser.add_option_group(group)
# optional
# XXX are all of these used?
- group = OptionGroup(parser, 'Optional')
- group.add_option('-d', '--debug', help='Enable debugging messages',
- action='store_true', default=False)
- group.add_option('-t', '--variant', help='Variant name',
- metavar='STRING')
- group.add_option('-b', '--bugurl', help='Bug reporting URL for the product',
- metavar='URL', default='your distribution provided bug reporting tool.')
- group.add_option('-u', '--updates', help='Directory containing updates',
- metavar='PATHSPEC')
- group.add_option('-m', '--mirrorlist',
- help='Mirror list repository (may be listed multiple times)',
- metavar='REPOSITORY', action='append', default=[])
- group.add_option('-c', '--confdir', help='Path to config files (default: /etc/lorax).',
- metavar='PATHSPEC', action='callback', callback=check_dir,
- type='string', default='/etc/lorax')
- group.add_option('-C', '--cleanup', help='Cleanup on exit',
- action='store_true', default=False)
- group.add_option('-V', help='Print version and exit',
- action='store_true', default=False, dest='printver')
+ group = OptionGroup(parser, "Optional")
+ group.add_option("-d", "--debug", help="Enable debugging messages",
+ action="store_true", default=False)
+ group.add_option("-t", "--variant", help="Variant name",
+ metavar="STRING")
+ group.add_option("-b", "--bugurl", help="Bug reporting URL for the product",
+ metavar="URL",
+ default="your distribution provided bug reporting tool")
+ group.add_option("-u", "--updates", help="Directory containing updates",
+ metavar="PATHSPEC")
+ group.add_option("-m", "--mirrorlist",
+ help="Mirror list repository (may be listed multiple times)",
+ metavar="REPOSITORY", action="append", default=[])
+ group.add_option("-c", "--confdir", help="Path to config files (default: /etc/lorax)",
+ metavar="PATHSPEC", action="callback", callback=check_dir,
+ type="string", default="/etc/lorax")
+ group.add_option("-C", "--cleanup", help="Clean up on exit",
+ action="store_true", default=False)
+ group.add_option("-V", help="Print version and exit",
+ action="store_true", default=False, dest="printver")
parser.add_option_group(group)
# additional information
- group = OptionGroup(parser, 'Additional information',
- 'A "REPOSITORY" specification is a valid yum repository path.\n'
- 'See the man page lorax(8) for more information.')
+ group = OptionGroup(parser, "Additional information",
+ "A 'REPOSITORY' specification is a valid yum repository path.\n"
+ "See the man page lorax(8) for more information.")
parser.add_option_group(group)
(opts, args) = parser.parse_args()
@@ -92,10 +93,10 @@ if __name__ == '__main__':
sys.exit(0)
if not opts.product or not opts.version or not opts.release or not opts.output:
- parser.error('Missing required argument')
+ parser.error("Missing required argument")
if not args:
- parser.error('Missing repository')
+ parser.error("Missing repository")
config = pylorax.Config()
config.set(confdir=opts.confdir,
diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py
index d26679ed..6ed60af9 100644
--- a/src/pylorax/__init__.py
+++ b/src/pylorax/__init__.py
@@ -17,63 +17,65 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-# Red Hat Author(s): David Cantrell
-# Martin Gracik
+# Red Hat Author(s): Martin Gracik
+# David Cantrell
#
import sys
import os
-import stat
-import commands
-import shutil
-import glob
import tempfile
+import re
+import shutil
+import ConfigParser
import time
import datetime
-import ConfigParser
-import re
-import fnmatch
-import pwd
-import grp
-from errors import LoraxError
+import commands
from config import Container
-from utils.rpmutils import Yum
-from utils.fileutils import cp, mv, rm, touch, edit, replace
+from utils.yumwrapper import Yum
+from utils.fileutils import copy, edit, replace
+import output
+import insttree
import images
class Config(Container):
+
def __init__(self):
- config = ('confdir', 'datadir', 'tempdir', 'debug', 'cleanup')
+ config = ("confdir", "datadir", "tempdir", "debug", "cleanup")
# options
- required = ('product', 'version', 'release', 'outdir', 'repos')
- optional = ('variant', 'bugurl', 'updates', 'mirrorlist')
+ required = ("product", "version", "release", "outdir", "repos")
+ optional = ("variant", "bugurl", "updates", "mirrorlist")
Container.__init__(self, config + required + optional)
# set defaults
- self.set(confdir='/etc/lorax',
- datadir='/usr/share/lorax',
- tempdir=tempfile.mkdtemp(prefix='lorax.tmp.', dir=tempfile.gettempdir()),
- debug=False,
- cleanup=False)
+ self.set(confdir="/etc/lorax",
+ datadir="/usr/share/lorax",
+ tempdir=tempfile.mkdtemp(prefix="lorax.tmp.",
+ dir=tempfile.gettempdir()),
+ debug=False,
+ cleanup=False)
- self.set(product='',
- version='',
- release='',
- outdir='',
- repos=[])
+ self.set(product="",
+ version="",
+ release="",
+ outdir="",
+ repos=[])
- self.set(variant='',
- bugurl='',
- updates='',
- mirrorlist=[])
+ self.set(variant="",
+ bugurl="",
+ updates="",
+ mirrorlist=[])
+class LoraxError(Exception):
+ pass
+
class Lorax(object):
+
def __init__(self, config):
assert isinstance(config, Config) == True
self.conf = config
@@ -92,746 +94,360 @@ class Lorax(object):
self.yum = None
- def run(self):
- bold = ('\033[1m', '\033[0m')
+ # initialize the output objects
+ self.so, self.se = output.initialize(verbose=self.conf.debug)
- print("%s:: Collecting repos%s" % bold)
- self.collect_repos()
-
- # check if we have at least one valid repository
- if not self.conf.repo:
- sys.stderr.write("ERROR: No valid repository\n")
- sys.exit(1)
-
- print("%s:: Initializing temporary directories%s" % bold)
- self.init_dirs()
-
- print("%s:: Initializing yum%s" % bold)
- self.init_yum()
-
- print("%s:: Setting build architecture%s" % bold)
- self.set_buildarch()
-
- print("%s:: Writing .treeinfo%s" % bold)
- self.write_treeinfo()
-
- print("%s:: Writing .discinfo%s" % bold)
- self.write_discinfo()
-
- print("%s:: Preparing the install tree%s" % bold)
- self.prepare_treedir()
-
- print("%s:: Scrubbing the install tree%s" % bold)
- self.scrub_treedir()
-
- print("%s:: Writing .buildstamp%s" % bold)
- self.write_buildstamp()
-
- print("%s:: Initializing output directories%s" % bold)
- self.init_outputdirs()
-
- print("%s:: Creating the initrd image%s" % bold)
- self.create_initrd()
-
- print("%s:: Creating the install image%s" % bold)
- self.create_installimg()
-
- print("%s:: Creating the boot image%s" % bold)
- self.create_bootiso()
-
- if self.conf.cleanup:
- print("%s::Cleaning up%s" % bold)
- self.clean_up()
-
- def collect_repos(self):
+ def collect_repositories(self):
repolist = []
+
for repospec in self.conf.repos:
- if repospec.startswith('/'):
- repo = 'file://%s' % repospec
- print("Adding local repo: %s" % repo)
+ if repospec.startswith("/"):
+ repo = "file://%s" % (repospec,)
+ self.so.info("Adding local repo: %s" % (repo,))
repolist.append(repo)
- elif repospec.startswith('http://') or repospec.startswith('ftp://'):
- print("Adding remote repo: %s" % repospec)
+ elif repospec.startswith("http://") or repospec.startswith("ftp://"):
+ self.so.info("Adding remote repo: %s" % (repospec,))
repolist.append(repospec)
else:
- print("Invalid repo path: %s" % repospec)
+ self.se.warning("Invalid repo path: %s" % (repospec,))
if not repolist:
- repo, extrarepos = None, []
+ return False
else:
- repo, extrarepos = repolist[0], repolist[1:]
+ mainrepo, extrarepos = repolist[0], repolist[1:]
- self.conf.addAttr(['repo', 'extrarepos'])
- self.conf.set(repo=repo, extrarepos=extrarepos)
+ self.conf.addAttr(["mainrepo", "extrarepos"])
+ self.conf.set(mainrepo=mainrepo, extrarepos=extrarepos)
+
+ # remove not needed attributes from config
+ self.conf.delAttr("repos")
- # remove repos attribute, to get a traceback, if we use it later accidentaly
- self.conf.delAttr('repos')
+ return True
- def init_dirs(self):
+ def initialize_directories(self):
+ # create the temporary directories
+ treedir = os.path.join(self.conf.tempdir, "treedir", "install")
+ os.makedirs(treedir)
+
+ self.so.info("Working directories:")
+
+ self.so.indent()
+ self.so.info("tempdir = %s" % (self.conf.tempdir,))
+ self.so.info("treedir = %s" % (treedir,))
+ self.so.unindent()
+
+ self.conf.addAttr("treedir")
+ self.conf.set(treedir=treedir)
+
+ # create the destination directories
if not os.path.isdir(self.conf.outdir):
os.makedirs(self.conf.outdir, mode=0755)
- treedir = os.path.join(self.conf.tempdir, 'treedir', 'install')
- os.makedirs(treedir)
- initrddir = os.path.join(self.conf.tempdir, 'initrddir')
- os.makedirs(initrddir)
- efitreedir = os.path.join(self.conf.tempdir, 'EFI', 'BOOT')
- os.makedirs(efitreedir)
+ imagesdir = os.path.join(self.conf.outdir, "images")
+ if not os.path.isdir(imagesdir):
+ os.makedirs(imagesdir)
- print("Working directories:")
- print(" tempdir = %s" % self.conf.tempdir)
- print(" treedir = %s" % treedir)
- print(" initrddir = %s" % initrddir)
- print(" efitreedir = %s" % efitreedir)
+ pxebootdir = os.path.join(imagesdir, "pxeboot")
+ if not os.path.isdir(pxebootdir):
+ os.makedirs(pxebootdir)
- self.conf.addAttr(['treedir', 'initrddir', 'efitreedir'])
- self.conf.set(treedir=treedir, initrddir=initrddir, efitreedir=efitreedir)
+ efibootdir = os.path.join(self.conf.outdir, "EFI", "BOOT")
+ if not os.path.isdir(efibootdir):
+ os.makedirs(efibootdir)
- def init_yum(self):
- yumconf = os.path.join(self.conf.tempdir, 'yum.conf')
+ # create the isolinux directory
+ isolinuxdir = os.path.join(self.conf.outdir, "isolinux")
+ if not os.path.isdir(isolinuxdir):
+ os.makedirs(isolinuxdir)
- cachedir = os.path.join(self.conf.tempdir, 'yumcache')
+ self.so.info("Destination directories:")
+
+ self.so.indent()
+ self.so.info("outdir = %s" % (self.conf.outdir,))
+ self.so.info("imagesdir = %s" % (imagesdir,))
+ self.so.info("pxebootdir = %s" % (pxebootdir,))
+ self.so.info("efibootdir = %s" % (efibootdir,))
+ self.so.info("isolinuxdir = %s" % (isolinuxdir,))
+ self.so.unindent()
+
+ self.conf.addAttr(["imagesdir", "pxebootdir",
+ "efibootdir", "isolinuxdir"])
+ self.conf.set(imagesdir=imagesdir, pxebootdir=pxebootdir,
+ efibootdir=efibootdir, isolinuxdir=isolinuxdir)
+
+ def initialize_yum(self):
+ yumconf = os.path.join(self.conf.tempdir, "yum.conf")
+
+ # create the yum cache directory
+ cachedir = os.path.join(self.conf.tempdir, "yumcache")
os.makedirs(cachedir)
+ c = ConfigParser.ConfigParser()
+
+ # main section
+ section = "main"
+ data = { "cachedir": cachedir,
+ "keepcache": 0,
+ "gpgcheck": 0,
+ "plugins": 0,
+ "reposdir": "",
+ "tsflags": "nodocs" }
+ c.add_section(section)
+ [c.set(section, key, value) for key, value in data.items()]
+
+ # main repo
+ section = "lorax-repo"
+ data = { "name": "lorax repo",
+ "baseurl": self.conf.mainrepo,
+ "enabled": 1 }
+ c.add_section(section)
+ [c.set(section, key, value) for key, value in data.items()]
+
+ # extra repos
+ for n, extra in enumerate(self.conf.extrarepos, start=1):
+ section = "lorax-extrarepo-%d" % (n,)
+ data = { "name": "lorax extra repo %d" % (n,),
+ "baseurl": extra,
+ "enabled": 1 }
+ c.add_section(section)
+ [c.set(section, key, value) for key, value in data.items()]
+
+ # mirrorlist repos
+ for n, mirror in enumerate(self.conf.mirrorlist, start=1):
+ section = "lorax-mirrorlistrepo-%d" % (n,)
+ data = { "name": "lorax mirrorlist repo %d" % (n,),
+ "mirrorlist": mirror,
+ "enabled": 1 }
+ c.add_section(section)
+ [c.set(section, key, value) for key, value in data.items()]
+
try:
- f = open(yumconf, 'w')
+ f = open(yumconf, "w")
except IOError as why:
- sys.stderr.write("ERROR: Unable to write yum.conf file: %s\n" % why)
- sys.exit(1)
+ self.se.error("Unable to write yum.conf file: %s" % (why,))
+ return False
else:
- f.write('[main]\n')
- f.write('cachedir=%s\n' % cachedir)
- f.write('keepcache=0\n')
- f.write('gpgcheck=0\n')
- f.write('plugins=0\n')
- f.write('reposdir=\n')
- f.write('tsflags=nodocs\n\n')
-
- f.write('[loraxrepo]\n')
- f.write('name=lorax repo\n')
- f.write('baseurl=%s\n' % self.conf.repo)
- f.write('enabled=1\n\n')
-
- for n, extra in enumerate(self.conf.extrarepos, start=1):
- f.write('[lorax-extrarepo-%d]\n' % n)
- f.write('name=lorax extra repo %d\n' % n)
- f.write('baseurl=%s\n' % extra)
- f.write('enabled=1\n')
-
- for n, mirror in enumerate(self.conf.mirrorlist, start=1):
- f.write('[lorax-mirrorlistrepo-%d]\n' % n)
- f.write('name=lorax mirrorlist repo %d\n' % n)
- f.write('mirrorlist=%s\n' % mirror)
- f.write('enabled=1\n')
-
+ c.write(f)
f.close()
- self.conf.addAttr('yumconf')
+ self.conf.addAttr("yumconf")
self.conf.set(yumconf=yumconf)
- # create the yum err file path
- err_file = os.path.join(self.conf.tempdir, 'yum.errors')
+ # remove not needed attributes from config
+ self.conf.delAttr(["mainrepo", "extrarepos", "mirrorlist"])
# create the Yum object
self.yum = Yum(yumconf=self.conf.yumconf, installroot=self.conf.treedir,
- err_file=err_file)
+ errfile=os.path.join(self.conf.tempdir, "yum.errors"))
- # remove not needed attributes
- self.conf.delAttr(['repo', 'extrarepos', 'mirrorlist'])
+ return True
- def set_buildarch(self):
+ def set_architecture(self):
+ # get the system architecture
unamearch = os.uname()[4]
- self.conf.addAttr('buildarch')
+ self.conf.addAttr("buildarch")
self.conf.set(buildarch=unamearch)
- installed, available = self.yum.find('anaconda')
+ # get the anaconda package architecture
+ installed, available = self.yum.find("anaconda")
try:
self.conf.set(buildarch=available[0].arch)
except:
pass
# set basearch
- self.conf.addAttr('basearch')
+ self.conf.addAttr("basearch")
self.conf.set(basearch=self.conf.buildarch)
- if re.match(r'i.86', self.conf.basearch):
- self.conf.set(basearch='i386')
- elif self.conf.buildarch == 'sparc64':
- self.conf.set(basearch='sparc')
+
+ if re.match(r"i.86", self.conf.basearch):
+ self.conf.set(basearch="i386")
+ elif self.conf.basearch == "sparc64":
+ self.conf.set(basearch="sparc")
# set the libdir
- self.conf.addAttr('libdir')
- self.conf.set(libdir='lib')
+ self.conf.addAttr("libdir")
+ self.conf.set(libdir="lib")
+
# on 64-bit systems, make sure we use lib64 as the lib directory
- if self.conf.buildarch.endswith('64') or self.conf.buildarch == 's390x':
- self.conf.set(libdir='lib64')
+ if self.conf.buildarch.endswith("64") or self.conf.buildarch == "s390x":
+ self.conf.set(libdir="lib64")
# set efiarch
- self.conf.addAttr('efiarch')
- self.conf.set(efiarch='')
+ self.conf.addAttr("efiarch")
+ self.conf.set(efiarch="")
- if self.conf.buildarch == 'i386':
- self.conf.set(efiarch='ia32')
- elif self.conf.buildarch == 'x86_64':
- self.conf.set(efiarch='x64')
- elif self.conf.buildarch == 'ia64':
- self.conf.set(efiarch='ia64')
+ if self.conf.buildarch == "i386":
+ self.conf.set(efiarch="ia32")
+ elif self.conf.buildarch == "x86_64":
+ self.conf.set(efiarch="x64")
+ elif self.conf.buildarch == "ia64":
+ self.conf.set(efiarch="ia64")
- def write_treeinfo(self, discnum=1, totaldiscs=1, packagedir=''):
- outfile = os.path.join(self.conf.outdir, '.treeinfo')
+ def write_treeinfo(self, discnum=1, totaldiscs=1, packagedir=""):
+ outfile = os.path.join(self.conf.outdir, ".treeinfo")
# don't print anything instead of None, if variant is not specified
- variant = ''
- if self.conf.variant:
+ variant = ""
+ if self.conf.variant is not None:
variant = self.conf.variant
-
- data = { 'timestamp': time.time(),
- 'family': self.conf.product,
- 'version': self.conf.version,
- 'arch': self.conf.basearch,
- 'variant': variant,
- 'discnum': str(discnum),
- 'totaldiscs': str(totaldiscs),
- 'packagedir': packagedir }
-
+
c = ConfigParser.ConfigParser()
-
- section = 'general'
- c.add_section(section)
- for key, value in data.items():
- c.set(section, key, value)
- section = 'images-%s' % self.conf.basearch
+ # general section
+ section = "general"
+ data = { "timestamp": time.time(),
+ "family": self.conf.product,
+ "version": self.conf.version,
+ "arch": self.conf.basearch,
+ "variant": variant,
+ "discnum": discnum,
+ "totaldiscs": totaldiscs,
+ "packagedir": packagedir }
c.add_section(section)
- c.set(section, 'kernel', 'images/pxeboot/vmlinuz')
- c.set(section, 'initrd', 'images/pxeboot/initrd.img')
- c.set(section, 'boot.iso', 'images/boot.iso')
+ [c.set(section, key, value) for key, value in data.items()]
+
+ # images section
+ section = "images-%s" % (self.conf.basearch,)
+ data = { "kernel": "images/pxeboot/vmlinuz",
+ "initrd": "images/pxeboot/initrd.img",
+ "boot.iso": "images/boot.iso" }
+ c.add_section(section)
+ [c.set(section, key, value) for key, value in data.items()]
try:
- f = open(outfile, 'w')
- except IOError:
+ f = open(outfile, "w")
+ except IOError as why:
+ self.se.error("Unable to write .treeinfo file: %s" % (why,))
return False
else:
c.write(f)
f.close()
- return True
-
- def write_discinfo(self, discnum='ALL'):
- outfile = os.path.join(self.conf.outdir, '.discinfo')
+
+ return True
+
+ def write_discinfo(self, discnum="ALL"):
+ outfile = os.path.join(self.conf.outdir, ".discinfo")
try:
- f = open(outfile, 'w')
- except IOError:
+ f = open(outfile, "w")
+ except IOError as why:
+ self.se.error("Unable to write .discinfo file: %s" % (why,))
return False
else:
- f.write('%f\n' % time.time())
- f.write('%s\n' % self.conf.release)
- f.write('%s\n' % self.conf.basearch)
- f.write('%s\n' % discnum)
+ f.write("%f\n" % (time.time(),))
+ f.write("%s\n" % (self.conf.release,))
+ f.write("%s\n" % (self.conf.basearch,))
+ f.write("%s\n" % (discnum,))
f.close()
- return True
-
- def prepare_treedir(self):
- # required packages
- self.yum.addPackages(['anaconda', 'anaconda-runtime', 'kernel', '*firmware*',
- 'syslinux', '/etc/gtk-2.0/gtkrc'])
-
- # get packages from confdir
- packages_files = []
- packages_files.append(os.path.join(self.conf.confdir, 'packages', 'packages.all'))
- packages_files.append(os.path.join(self.conf.confdir, 'packages', 'packages.%s' % self.conf.buildarch))
-
- packages = set()
- for pfile in packages_files:
- if os.path.isfile(pfile):
- f = open(pfile, 'r')
- for line in f.readlines():
- line, sep, comment = line.partition('#')
- line = line.strip()
-
- if not line:
- continue
-
- if line.startswith('-'):
- packages.discard(line[1:])
- else:
- packages.add(line)
-
- f.close()
-
- self.yum.addPackages(list(packages))
-
- # add logos
- self.yum.addPackages(['%s-logos' % self.conf.product.lower(),
- '%s-release' % self.conf.product.lower()])
-
- # XXX why do we need this?
- os.symlink(os.path.join(os.path.sep, 'tmp'),
- os.path.join(self.conf.treedir, 'var', 'lib', 'xkb'))
-
- # install packages
- self.yum.install()
-
- # copy updates
- if self.conf.updates and os.path.isdir(self.conf.updates):
- cp(src_root=self.conf.updates, src_path='*',
- dst_root=self.conf.treedir, dst_path='')
- self.conf.delAttr('updates')
-
-
- # XXX here comes a lot of crazy tree modification stuff, beware! XXX
-
- # create dogtail conf files
- dogtailconf = os.path.join(self.conf.datadir, 'dogtail', '%gconf.xml')
- if os.path.isfile(dogtailconf):
- dst = os.path.join(self.conf.treedir, '.gconf', 'desktop', 'gnome', 'interface')
- os.makedirs(dst)
- shutil.copy2(dogtailconf, dst)
-
- touch(os.path.join(self.conf.treedir, '.gconf', 'desktop', '%gconf.xml'))
- touch(os.path.join(self.conf.treedir, '.gconf', 'desktop', 'gnome', '%gconf.xml'))
-
- # XXX wth is this part useful for?
-
- # XXX this one already exists
- #os.makedirs(os.path.join(self.conf.treedir, 'lib'))
- os.makedirs(os.path.join(self.conf.treedir, 'firmware'))
- os.makedirs(os.path.join(self.conf.treedir, 'modules'))
-
- # XXX this will overwrite the modules which are installed, why would i want to do that?
- #os.symlink('/modules', os.path.join(self.conf.treedir, 'lib', 'modules'))
- #os.symlink('/firmware', os.path.join(self.conf.treedir, 'lib', 'firmware'))
-
- # create debug dirs
- os.makedirs(os.path.join(self.conf.treedir, 'usr', 'lib', 'debug'))
- os.makedirs(os.path.join(self.conf.treedir, 'usr', 'src', 'debug'))
-
- # copy stubs
- for file in ('raidstart', 'raidstop', 'losetup', 'list-harddrives', 'loadkeys', 'mknod',
- 'syslogd'):
- src = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda', file + '-stub')
- dst = os.path.join(self.conf.treedir, 'usr', 'bin', file)
- shutil.copy2(src, dst)
-
- # move anaconda executable
- src = os.path.join(self.conf.treedir, 'usr', 'sbin', 'anaconda')
- dst = os.path.join(self.conf.treedir, 'usr', 'bin', 'anaconda')
- shutil.move(src, dst)
-
- # move anaconda libraries
- src = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'lib*')
- dst = os.path.join(self.conf.treedir, 'usr', self.conf.libdir)
- for name in glob.iglob(src):
- shutil.move(name, dst)
-
- # change tree permissions
- root_uid = pwd.getpwnam('root')[2]
- root_gid = grp.getgrnam('root')[2]
-
- for root, files, dirs in os.walk(self.conf.treedir):
- os.chown(root, root_uid, root_gid)
- os.chmod(root, 0755)
-
- for file in files:
- path = os.path.join(root, file)
- os.chown(path, root_uid, root_gid)
-
- mode = os.stat(path).st_mode
- if (mode & stat.S_IXUSR) or (mode & stat.S_IXGRP) or (mode & stat.S_IXOTH):
- os.chmod(path, 0555)
- else:
- os.chmod(path, 0444)
-
- # create ld.so.conf
- ldsoconf = os.path.join(self.conf.treedir, 'etc', 'ld.so.conf')
- touch(ldsoconf)
-
- procdir = os.path.join(self.conf.treedir, 'proc')
- if not os.path.isdir(procdir):
- os.makedirs(procdir)
- os.system('mount -t proc proc %s' % procdir)
-
- f = open(ldsoconf, 'w')
- f.write('/usr/kerberos/%s\n' % self.conf.libdir)
- f.close()
-
- cwd = os.getcwd()
- os.chdir(self.conf.treedir)
- os.system('/usr/sbin/chroot %s /sbin/ldconfig' % self.conf.treedir)
- os.chdir(cwd)
-
- if self.conf.buildarch not in ('s390', 's390x'):
- # XXX this is not in usr
- rm(os.path.join(self.conf.treedir, 'usr', 'sbin', 'ldconfig'))
- # XXX why are we removing this?
- #rm(os.path.join(self.conf.treedir, 'etc', 'ld.so.conf'))
- os.system('umount %s' % procdir)
-
- def scrub_treedir(self):
- # XXX another part of crazy tree modification XXX
-
- # figure out the gtk+ theme to keep
- gtkrc = os.path.join(self.conf.treedir, 'etc', 'gtk-2.0', 'gtkrc')
- gtk_theme_name = None
- gtk_engine = None
- gtk_icon_themes = []
-
- if os.path.isfile(gtkrc):
- f = open(gtkrc, 'r')
- lines = f.readlines()
- f.close()
-
- for line in lines:
- line = line.strip()
- if line.startswith('gtk-theme-name'):
- gtk_theme_name = line[line.find('=') + 1:]
- gtk_theme_name = gtk_theme_name.replace('"', '').strip()
-
- # find the engine for this theme
- gtkrc = os.path.join(self.conf.treedir, 'usr', 'share', 'themes',
- gtk_theme_name, 'gtk-2.0', 'gtkrc')
- if os.path.isfile(gtkrc):
- f = open(gtkrc, 'r')
- engine_lines = f.readlines()
- f.close()
-
- for engine_line in engine_lines:
- engine_line = engine_line.strip()
- if engine_line.find('engine') != -1:
- gtk_engine = engine_line[engine_line.find('"') + 1:]
- gtk_engine = gtk_engine.replace('"', '').strip()
- break
-
- elif line.startswith('gtk-icon-theme-name'):
- icon_theme = line[line.find('=') + 1:]
- icon_theme = icon_theme.replace('"', '').strip()
- gtk_icon_themes.append(icon_theme)
-
- # bring in all inherited themes
- while True:
- icon_theme_index = os.path.join(self.conf.treedir, 'usr', 'share', 'icons',
- icon_theme, 'index.theme')
- if os.path.isfile(icon_theme_index):
- inherits = False
- f = open(icon_theme_index, 'r')
- icon_lines = f.readlines()
- f.close()
-
- for icon_line in icon_lines:
- icon_line = icon_line.strip()
- if icon_line.startswith('Inherits='):
- inherits = True
- icon_theme = icon_line[icon_line.find('=') + 1:]
- icon_theme = icon_theme.replace('"', '').strip()
- gtk_icon_themes.append(icon_theme)
- break
-
- if not inherits:
- break
- else:
- break
-
- # remove themes we don't need
- theme_path = os.path.join(self.conf.treedir, 'usr', 'share', 'themes')
- if os.path.isdir(theme_path):
- for theme in filter(lambda theme: theme != gtk_theme_name, os.listdir(theme_path)):
- theme = os.path.join(theme_path, theme)
- shutil.rmtree(theme, ignore_errors=True)
-
- # remove icons we don't need
- icon_path = os.path.join(self.conf.treedir, 'usr', 'share', 'icons')
- if os.path.isdir(icon_path):
- for icon in filter(lambda icon: icon not in gtk_icon_themes, os.listdir(icon_path)):
- icon = os.path.join(icon_path, icon)
- shutil.rmtree(icon, ignore_errors=True)
-
- # remove engines we don't need
- tmp_path = os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'gtk-2.0')
- if os.path.isdir(tmp_path):
- fnames = map(lambda fname: os.path.join(tmp_path, fname, 'engines'), os.listdir(tmp_path))
- dnames = filter(lambda fname: os.path.isdir(fname), fnames)
- for dir in dnames:
- engines = filter(lambda engine: engine.find(gtk_engine) == -1, os.listdir(dir))
- for engine in engines:
- engine = os.path.join(dir, engine)
- os.unlink(engine)
-
- # remove locales
- langtable = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda', 'lang-table')
- localepath = os.path.join(self.conf.treedir, 'usr', 'share', 'locale')
- if os.path.isfile(langtable):
- locales = set()
- all_locales = set()
-
- f = open(langtable, 'r')
- lines = f.readlines()
- f.close()
-
- for line in lines:
- line = line.strip()
- if not line or line.startswith('#'):
- continue
-
- fields = line.split('\t')
-
- if os.path.isdir(os.path.join(localepath, fields[1])):
- locales.add(fields[1])
-
- locale = fields[3].split('.')[0]
- if os.path.isdir(os.path.join(localepath, locale)):
- locales.add(locale)
-
- for locale in os.listdir(localepath):
- all_locales.add(locale)
-
- locales_to_remove = list(all_locales.difference(locales))
- for locale in locales_to_remove:
- rmpath = os.path.join(localepath, locale)
- shutil.rmtree(rmpath, ignore_errors=True)
-
- # fixup joe links
- joedir = os.path.join(self.conf.treedir, 'etc', 'joe')
- if os.path.isdir(joedir):
- os.symlink('jpicorc', os.path.join(joedir, 'picorc'))
- os.symlink('jpicorc', os.path.join(joedir, 'jnanorc'))
- os.symlink('jpicorc', os.path.join(joedir, 'nanorc'))
- os.symlink('jmacsrc', os.path.join(joedir, 'emacsrc'))
- os.symlink('jmacs', os.path.join(self.conf.treedir, 'usr', 'bin', 'emacs'))
- os.symlink('jpico', os.path.join(self.conf.treedir, 'usr', 'bin', 'pico'))
- os.symlink('jpico', os.path.join(self.conf.treedir, 'usr', 'bin', 'nano'))
-
- # fix up some links for man page related stuff
- for file in ['nroff', 'groff', 'iconv', 'geqn', 'gtbl', 'gpic', 'grefer']:
- src = os.path.join('mnt', 'sysimage', 'usr', 'bin', file)
- dst = os.path.join(self.conf.treedir, 'usr', 'bin', file)
- if not os.path.isfile(dst):
- os.symlink(src, dst)
-
- # create selinux config
- if os.path.exists(os.path.join(self.conf.treedir, 'etc', 'selinux', 'targeted')):
- src = os.path.join(self.conf.datadir, 'selinux', 'config')
- dst = os.path.join(self.conf.treedir, 'etc', 'selinux', 'config')
- shutil.copy2(src, dst)
-
- # create libuser.conf
- src = os.path.join(self.conf.datadir, 'libuser', 'libuser.conf')
- dst = os.path.join(self.conf.treedir, 'etc', 'libuser.conf')
- shutil.copy2(src, dst)
-
- # configure fedorakmod
- fedorakmodconf = os.path.join(self.conf.treedir, 'etc', 'yum', 'pluginconf.d',
- 'fedorakmod.conf')
- replace(fedorakmodconf, r'\(installforallkernels\) = 0', r'\1 = 1')
-
- # fix /etc/man.config to point into /mnt/sysimage
- manconfig = os.path.join(self.conf.treedir, 'etc', 'man.config')
-
- # don't change MANPATH_MAP lines now
- replace(manconfig, r'^MANPATH[^_MAP][ \t]*', r'&/mnt/sysimage')
- # change MANPATH_MAP lines now
- replace(manconfig, r'^MANPATH_MAP[ \t]*[a-zA-Z0-9/]*[ \t]*', r'&/mnt/sysimage')
-
- # move yum repos
- src = os.path.join(self.conf.treedir, 'etc', 'yum.repos.d')
- dst = os.path.join(self.conf.treedir, 'etc', 'anaconda.repos.d')
- shutil.move(src, dst)
-
- # remove libunicode-lite
- rm(os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'libunicode-lite*'))
-
- # make bash link
- # XXX already exists
- #if os.path.isfile(os.path.join(self.conf.treedir, 'bin', 'bash')):
- # rm(os.path.join(self.conf.treedir, 'bin', 'ash'))
- # os.symlink('bash', os.path.join(self.conf.treedir, 'bin', 'sh'))
-
- # make awk link
- # XXX already exists
- #if os.path.isfile(os.path.join(self.conf.treedir, 'bin', 'gawk')):
- # os.symlink('awk', os.path.join(self.conf.treedir, 'bin', 'gawk'))
-
- # copy bootloaders
- bootpath = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'boot')
- if not os.path.isdir(bootpath):
- os.makedirs(bootpath)
-
- if self.conf.buildarch in ('i386', 'i586', 'x86_64'):
- for file in os.listdir(os.path.join(self.conf.treedir, 'boot')):
- if file.startswith('memtest'):
- src = os.path.join(self.conf.treedir, 'boot', file)
- dst = os.path.join(bootpath, file)
- shutil.copy2(src, dst)
- elif self.conf.buildarch in ('sparc',):
- for file in os.listdir(os.path.join(self.conf.treedir, 'boot')):
- if file.endswith('.b'):
- src = os.path.join(self.conf.treedir, 'boot', file)
- dst = os.path.join(bootpath, file)
- shutil.copy2(src, dst)
- elif self.conf.buildarch in ('ppc', 'ppc64'):
- src = os.path.join(self.conf.treedir, 'boot', 'efika.forth')
- shutil.copy2(src, bootpath)
- elif self.conf.buildarch in ('alpha',):
- src = os.path.join(self.conf.treedir, 'boot', 'bootlx')
- shutil.copy2(src, bootpath)
- elif self.conf.buildarch in ('ia64',):
- src = os.path.join(self.conf.treedir, 'boot', 'efi', 'EFI', 'redhat', '*')
- shutil.copy2(src, bootpath)
-
- # remove not needed directories
- # XXX i need this for kernel
- #for dir in ('boot', 'home', 'root', 'tmp'):
- # rm(os.path.join(self.conf.treedir, dir))
-
- # remove not needed files
- to_remove = set()
- for root, dirs, files in os.walk(self.conf.treedir):
- for file in files:
- path = os.path.join(root, file)
- if fnmatch.fnmatch(path, '*.a'):
- if path.find('kernel-wrapper/wrapper.a') == -1:
- to_remove.add(path)
- elif fnmatch.fnmatch(path, 'lib*.la'):
- if path.find('usr/' + self.conf.libdir + '/gtk-2.0') == -1:
- to_remove.add(path)
- elif fnmatch.fnmatch(path, '*.py'):
- to_remove.add(path + 'o')
-
- rm(path + 'c')
- os.symlink('/dev/null', path + 'c')
-
- for file in to_remove:
- rm(file)
-
- # nuke some python stuff we don't need
- for fname in ['idle', 'distutils', 'bsddb', 'lib-old', 'hotshot', 'doctest.py', 'pydoc.py',
- 'site-packages/japanese', 'site-packages/japanese.pth']:
- rm(os.path.join(self.conf.treedir, fname))
-
- for fname in ['distutils', 'lib-dynload/japanese', 'encodings', 'compiler', 'email/test',
- 'curses', 'pydoc.py']:
- rm(os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'python?.?', 'site-packages',
- fname))
+ return True
def write_buildstamp(self):
- outfile = os.path.join(self.conf.treedir, '.buildstamp')
+ outfile = os.path.join(self.conf.treedir, ".buildstamp")
- # make imageuuid
+ # make image uuid
now = datetime.datetime.now()
- arch = self.conf.buildarch
- imageuuid = '%s.%s' % (now.strftime('%Y%m%d%H%M'), arch)
+ uuid = "%s.%s" % (now.strftime("%Y%m%d%H%M"), self.conf.buildarch)
try:
- f = open(outfile, 'w')
- except IOError:
+ f = open(outfile, "w")
+ except IOError as why:
+ self.se.error("Unable to write .buildstamp file: %s" % (why,))
return False
else:
- f.write('%s\n' % imageuuid)
- f.write('%s\n' % self.conf.product)
- f.write('%s\n' % self.conf.version)
- f.write('%s\n' % self.conf.bugurl)
+ f.write("%s\n" % (uuid,))
+ f.write("%s\n" % (self.conf.product,))
+ f.write("%s\n" % (self.conf.version,))
+ f.write("%s\n" % (self.conf.bugurl,))
f.close()
- return True
- def init_outputdirs(self):
- # create the destination directories
- imagesdir = os.path.join(self.conf.outdir, 'images')
- if os.path.exists(imagesdir):
- rm(imagesdir)
- os.makedirs(imagesdir)
+ self.conf.addAttr("buildstamp")
+ self.conf.set(buildstamp=outfile)
- pxebootdir = os.path.join(imagesdir, 'pxeboot')
- os.makedirs(pxebootdir)
-
- # create the isolinux directory
- isolinuxdir = os.path.join(self.conf.outdir, 'isolinux')
- if os.path.exists(isolinuxdir):
- rm(isolinuxdir)
- os.makedirs(isolinuxdir)
-
- self.conf.addAttr(['imagesdir', 'pxebootdir', 'isolinuxdir'])
- self.conf.set(imagesdir=imagesdir, pxebootdir=pxebootdir, isolinuxdir=isolinuxdir)
+ return True
+ def prepare_output_directory(self):
# write the images/README
- src = os.path.join(self.conf.datadir, 'images', 'README')
- dst = os.path.join(self.conf.imagesdir, 'README')
+ src = os.path.join(self.conf.datadir, "images", "README")
+ dst = os.path.join(self.conf.imagesdir, "README")
shutil.copy2(src, dst)
- replace(dst, r'@PRODUCT@', self.conf.product)
+ replace(dst, r"@PRODUCT@", self.conf.product)
# write the images/pxeboot/README
- src = os.path.join(self.conf.datadir, 'images', 'pxeboot', 'README')
- dst = os.path.join(self.conf.pxebootdir, 'README')
+ src = os.path.join(self.conf.datadir, "images", "pxeboot", "README")
+ dst = os.path.join(self.conf.pxebootdir, "README")
shutil.copy2(src, dst)
- replace(dst, r'@PRODUCT@', self.conf.product)
-
-
- # populate the isolinux directory
-
- # XXX don't see this used anywhere...
- syslinux = os.path.join(self.conf.treedir, 'usr', 'lib', 'syslinux', 'syslinux-nomtools')
- if not os.path.isfile(syslinux):
- sys.stderr.write('WARNING: %s does not exist\n' % syslinux)
- syslinux = os.path.join(self.conf.treedir, 'usr', 'bin', 'syslinux')
- if not os.path.isfile(syslinux):
- sys.stderr.write('ERROR: %s does not exist\n' % syslinux)
- sys.exit(1)
+ replace(dst, r"@PRODUCT@", self.conf.product)
# set up some dir variables for further use
- anacondadir = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime')
- bootdiskdir = os.path.join(anacondadir, 'boot')
- self.conf.addAttr('bootdiskdir')
+ anacondadir = os.path.join(self.conf.treedir,
+ "usr", "lib", "anaconda-runtime")
+
+ bootdiskdir = os.path.join(anacondadir, "boot")
+ self.conf.addAttr("bootdiskdir")
self.conf.set(bootdiskdir=bootdiskdir)
- syslinuxdir = os.path.join(self.conf.treedir, 'usr', 'lib', 'syslinux')
- isolinuxbin = os.path.join(syslinuxdir, 'isolinux.bin')
- if os.path.exists(isolinuxbin):
+ syslinuxdir = os.path.join(self.conf.treedir, "usr", "lib", "syslinux")
+ isolinuxbin = os.path.join(syslinuxdir, "isolinux.bin")
+
+ if os.path.isfile(isolinuxbin):
# copy the isolinux.bin
shutil.copy2(isolinuxbin, self.conf.isolinuxdir)
# copy the syslinux.cfg to isolinux/isolinux.cfg
- isolinuxcfg = os.path.join(self.conf.isolinuxdir, 'isolinux.cfg')
- shutil.copy2(os.path.join(bootdiskdir, 'syslinux.cfg'), isolinuxcfg)
+ isolinuxcfg = os.path.join(self.conf.isolinuxdir, "isolinux.cfg")
+ shutil.copy2(os.path.join(bootdiskdir, "syslinux.cfg"), isolinuxcfg)
# set the product and version in isolinux.cfg
- replace(isolinuxcfg, r'@PRODUCT@', self.conf.product)
- replace(isolinuxcfg, r'@VERSION@', self.conf.version)
+ replace(isolinuxcfg, r"@PRODUCT@", self.conf.product)
+ replace(isolinuxcfg, r"@VERSION@", self.conf.version)
# set up the label for finding stage2 with a hybrid iso
- replace(isolinuxcfg, r'initrd=initrd.img', 'initrd=initrd.img stage2=hd:LABEL=%s' % self.conf.product)
+ replace(isolinuxcfg, r"initrd=initrd.img",
+ "initrd=initrd.img stage2=hd:LABEL=%s" % (self.conf.product,))
# copy the grub.conf
- shutil.copy2(os.path.join(bootdiskdir, 'grub.conf'), self.conf.isolinuxdir)
+ shutil.copy2(os.path.join(bootdiskdir, "grub.conf"),
+ self.conf.isolinuxdir)
# copy the splash files
- vesasplash = os.path.join(anacondadir, 'syslinux-vesa-splash.jpg')
+ vesasplash = os.path.join(anacondadir, "syslinux-vesa-splash.jpg")
if os.path.isfile(vesasplash):
- shutil.copy2(vesasplash, os.path.join(self.conf.isolinuxdir, 'splash.jpg'))
- vesamenu = os.path.join(syslinuxdir, 'vesamenu.c32')
+ shutil.copy2(vesasplash,
+ os.path.join(self.conf.isolinuxdir, "splash.jpg"))
+
+ vesamenu = os.path.join(syslinuxdir, "vesamenu.c32")
shutil.copy2(vesamenu, self.conf.isolinuxdir)
- replace(isolinuxcfg, r'default linux', r'default vesamenu.c32')
- replace(isolinuxcfg, r'prompt 1', r'#prompt 1')
+
+ replace(isolinuxcfg, r"default linux", r"default vesamenu.c32")
+ replace(isolinuxcfg, r"prompt 1", r"#prompt 1")
else:
- splashtools = os.path.join(anacondadir, 'splashtools.sh')
- splashlss = os.path.join(bootdiskdir, 'splash.lss')
+ splashtools = os.path.join(anacondadir, "splashtools.sh")
+ splashlss = os.path.join(bootdiskdir, "splash.lss")
+
if os.path.isfile(splashtools):
- cmd = '%s %s %s' % (splashtools,
- os.path.join(bootdiskdir, 'syslinux-splash.jpg'),
- splashlss)
- os.system(cmd)
+ cmd = "%s %s %s" % (splashtools,
+ os.path.join(bootdiskdir, "syslinux-splash.jpg"),
+ splashlss)
+ out = commands.getoutput(cmd)
+
if os.path.isfile(splashlss):
shutil.copy2(splashlss, self.conf.isolinuxdir)
# copy the .msg files
for file in os.listdir(bootdiskdir):
- if file.endswith('.msg'):
- shutil.copy2(os.path.join(bootdiskdir, file), self.conf.isolinuxdir)
- replace(os.path.join(self.conf.isolinuxdir, file), r'@VERSION@', self.conf.version)
+ if file.endswith(".msg"):
+ shutil.copy2(os.path.join(bootdiskdir, file),
+ self.conf.isolinuxdir)
+ replace(os.path.join(self.conf.isolinuxdir, file),
+ r"@VERSION@", self.conf.version)
# if present, copy the memtest
- for fname in os.listdir(os.path.join(self.conf.treedir, 'boot')):
- if fname.startswith('memtest'):
- src = os.path.join(self.conf.treedir, 'boot', fname)
- dst = os.path.join(self.conf.isolinuxdir, 'memtest')
+ for fname in os.listdir(os.path.join(self.conf.treedir, "boot")):
+ if fname.startswith("memtest"):
+ src = os.path.join(self.conf.treedir, "boot", fname)
+ dst = os.path.join(self.conf.isolinuxdir, "memtest")
shutil.copy2(src, dst)
text = "label memtest86\n"
@@ -840,261 +456,177 @@ class Lorax(object):
text = text + " append -\n"
edit(isolinuxcfg, text, append=True)
else:
- sys.stderr.write('ERROR: %s does not exist\n' % isolinuxbin)
- sys.exit(1)
-
- def create_efi(self, kernelfile=None, initrd=None, kernelpath=None, initrdpath=None):
- rm(os.path.join(self.conf.efitreedir, '*'))
-
- # copy conf files to EFI tree dir
- cp(src_root=self.conf.bootdiskdir, src_path='*.conf',
- dst_root=self.conf.efitreedir, dst_path='')
-
- # copy files to efi tree dir
- if kernelfile and initrd:
- shutil.copy2(kernelfile, os.path.join(self.conf.efitreedir, 'vmlinuz'))
- shutil.copy2(initrd, self.conf.efitreedir)
- efikernelpath = os.path.join(os.sep, 'EFI', 'BOOT', 'vmlinuz')
- efiinitrdpath = os.path.join(os.sep, 'EFI', 'BOOT', 'initrd.img')
- else:
- efikernelpath = kernelpath
- efiinitrdpath = initrdpath
-
- splashpath = os.path.join(os.sep, 'EFI', 'BOOT', 'splash.xpm.gz')
-
- grubconf = os.path.join(self.conf.efitreedir, 'grub.conf')
- replace(grubconf, '@PRODUCT@', self.conf.product)
- replace(grubconf, '@VERSION@', self.conf.version)
- replace(grubconf, '@KERNELPATH@', efikernelpath)
- replace(grubconf, '@INITRDPATH@', efiinitrdpath)
- replace(grubconf, '@SPLASHPATH@', splashpath)
-
- src = os.path.join(self.conf.treedir, 'boot', 'efi', 'EFI', 'redhat', 'grub.efi')
- shutil.copy2(src, self.conf.efitreedir)
-
- # the first generation mactel machines get the bootloader name wrong
- if self.conf.efiarch in ('ia32'):
- src = os.path.join(self.conf.efitreedir, 'grub.efi')
- dst = os.path.join(self.conf.efitreedir, 'BOOT.efi')
- shutil.copy2(src, dst)
-
- src = os.path.join(self.conf.efitreedir, 'grub.conf')
- dst = os.path.join(self.conf.efitreedir, 'BOOT.conf')
- shutil.copy2(src, dst)
-
- efiarch = self.conf.efiarch
- if efiarch == 'x64':
- efiarch = 'X64'
- elif efiarch == 'ia32':
- efiarch = 'IA32'
+ return False
- src = os.path.join(self.conf.efitreedir, 'grub.efi')
- dst = os.path.join(self.conf.efitreedir, 'BOOT%s.efi' % efiarch)
- shutil.move(src, dst)
+ return True
- src = os.path.join(self.conf.efitreedir, 'grub.conf')
- dst = os.path.join(self.conf.efitreedir, 'BOOT%s.conf' % efiarch)
- shutil.move(src, dst)
+ def create_install_image(self, type="squashfs"):
+ # scrub the install tree
+ install = images.Install(self.conf)
+ install.run()
- # copy splash
- src = os.path.join(self.conf.treedir, 'boot', 'grub', 'splash.xpm.gz')
- dst = os.path.join(self.conf.efitreedir, 'splash.xpm.gz')
- shutil.copy2(src, dst)
+ installimg = os.path.join(self.conf.imagesdir, "install.img")
- # calculate the size of the dosfs
- cmd = 'du -kcs %s | tail -n1 | awk \'{print $1}\'' % self.conf.efitreedir
- size = int(commands.getoutput(cmd)) + 100
+ if type == "squashfs":
+ cmd = "mksquashfs %s %s -all-root -no-fragments -no-progress" \
+ % (self.conf.treedir, installimg)
+ self.so.debug(cmd)
+ err, output = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(output)
+ # XXX this gives an error on read only filesystem
+ #return False
- efiimage = os.path.join(self.conf.outdir, 'images', 'efiboot.img')
- cmd = 'mkdosfs -n ANACONDA -C %s %s > /dev/null' % (efiimage, size)
- out = commands.getoutput(cmd)
+ elif type == "cramfs":
+ if self.conf.buildarch == "sparc64":
+ crambs = "--blocksize 8192"
+ elif self.conf.buildarch == "sparc":
+ crambs = "--blocksize 4096"
+ else:
+ crambs = ""
- tempdir = os.path.join(self.conf.tempdir, 'efiimage')
- if not os.path.isdir(tempdir):
- os.makedirs(tempdir)
- cmd = 'mount -o loop,shortname=winnt,umask=0777 -t vfat %s %s' % \
- (efiimage, tempdir)
- out = commands.getoutput(cmd)
+ cmd = "mkfs.cramfs %s %s %s" % (crambs, self.conf.treedir,
+ installimg)
+ self.so.debug(cmd)
+ err, output = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(output)
+ return False
- cp(src_root=self.conf.efitreedir, src_path='*',
- dst_root=tempdir, dst_path='')
+ elif type == "ext2":
+ # TODO
+ return False
- cmd = 'umount %s' % tempdir
- out = commands.getoutput(cmd)
+ # append stage2 to .treeinfo file
+ text = "\n[stage2]\n"
+ text += "mainimage = %s\n" % (installimg,)
+ edit(os.path.join(self.conf.outdir, ".treeinfo"), append=True, text=text)
- # copy efi to cd
- if not kernelfile and not initrd:
- dst = os.path.join(self.conf.outdir, 'EFI', 'BOOT')
- if os.path.exists(dst):
- rm(dst)
- os.makedirs(dst)
+ return True
- for name in glob.iglob(os.path.join(self.conf.efitreedir, '*.conf')):
- shutil.copy2(name, dst)
+ def create_boot_iso(self):
+ efiboot = os.path.join(self.conf.imagesdir, "efiboot.img")
- return efiimage
+ if os.path.exists(efiboot):
+ self.so.info("Found efiboot.img, making an EFI-capable boot.iso")
+ efiargs = "-eltorito-alt-boot -e images/efiboot.img -no-emul-boot"
+ efigraft = "EFI/BOOT=%s" % (os.path.join(self.conf.outdir,
+ "EFI", "BOOT"),)
+ else:
+ self.so.info("No efiboot.img found, making BIOS-only boot.iso")
+ efiargs = ""
+ efigraft = ""
- def create_initrd(self):
- # get installed kernel file
- kernelfile = None
- kerneldir = os.path.join(self.conf.treedir, 'boot')
+ biosargs = "-b isolinux/isolinux.bin -c isolinux/boot.cat" \
+ " -no-emul-boot -boot-load-size 4 -boot-info-table"
+ mkisocmd = "mkisofs -v -o %s %s %s -R -J -V %s -T -graft-points" \
+ " isolinux=%s images=%s %s" % (os.path.join(self.conf.imagesdir,
+ "boot.iso"), biosargs, efiargs, self.conf.product,
+ self.conf.isolinuxdir, self.conf.imagesdir, efigraft)
+ self.so.debug(mkisocmd)
+ err, out = commands.getstatusoutput(mkisocmd)
+ if err:
+ self.se.info(out)
+ return False
- if self.conf.buildarch in ('ia64',):
- kerneldir = os.path.join(self.conf.treedir, 'boot', 'efi', 'EFI', 'redhat')
+ hybrid = os.path.join("/", "usr", "bin", "isohybrid")
+ if os.path.exists(hybrid):
+ cmd = "%s %s" % (hybrid, os.path.join(self.conf.imagesdir, "boot.iso"))
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ # XXX is this a problem?
+ # should we return false, or just go on?
- for file in os.listdir(kerneldir):
- if fnmatch.fnmatch(file, 'vmlinuz-*'):
- kernelfile = os.path.join(self.conf.treedir, 'boot', file)
+ return True
- if not kernelfile:
- sys.stderr.write('ERROR: No kernel image found\n')
+ def clean_up(self):
+ if os.path.isdir(self.conf.tempdir):
+ shutil.rmtree(self.conf.tempdir, ignore_errors=True)
+
+ def run(self):
+ self.so.header(":: Collecting repositories")
+ ok = self.collect_repositories()
+ if not ok:
+ # we have no valid repository to work with
+ self.se.error("No valid repository")
sys.exit(1)
- initrd = images.InitRD(self.conf, self.yum, kernelfile)
+ self.so.header(":: Initializing directories")
+ self.initialize_directories()
- # install needed packages
- packages = initrd.get_packages()
- self.yum.addPackages(list(packages))
- self.yum.install()
+ self.so.header(":: Initializing yum")
+ ok = self.initialize_yum()
+ if not ok:
+ # the yum object could not be initialized
+ self.se.error("Unable to initialize the yum object")
+ sys.exit(1)
- # copy the kernel file
- shutil.copy2(kernelfile, os.path.join(self.conf.isolinuxdir, 'vmlinuz'))
- shutil.copy2(kernelfile, os.path.join(self.conf.pxebootdir, 'vmlinuz'))
+ self.so.header(":: Setting the architecture")
+ self.set_architecture()
- # create the initrd.img
- initrd.create(os.path.join(self.conf.isolinuxdir, 'initrd.img'))
- initrd.clean_up()
-
- # copy the initrd.img
- shutil.copy2(os.path.join(self.conf.isolinuxdir, 'initrd.img'), self.conf.pxebootdir)
-
- # create efiimage
- efiimage = self.create_efi(kernelfile=kernelfile,
- initrd=os.path.join(self.conf.isolinuxdir, 'initrd.img'))
-
- # create efi bootdisk
- # XXX now this is not nice, can it be done some other way?
- cmd = 'ls -l %s | awk \'{print $5}\'' % efiimage
- partsize = int(commands.getoutput(cmd))
- disksize = 17408 + partsize + 17408
- disksize = disksize + (disksize % 512)
-
- efidiskimg = os.path.join(self.conf.imagesdir, 'efidisk.img')
- touch(efidiskimg)
-
- cmd = 'dd if=/dev/zero of=%s count=1 bs=%s' % (efidiskimg, disksize)
- out = commands.getoutput(cmd)
-
- cmd = 'losetup -v -f %s | awk \'{print $4}\'' % efidiskimg
- loop = commands.getoutput(cmd)
-
- cmd = 'dmsetup create efiboot --table "0 %s linear %s 0"' % (disksize / 512, loop)
- out = commands.getoutput(cmd)
-
- cmd = 'parted --script /dev/mapper/efiboot mklabel gpt unit b mkpart \'"EFI System Partition"\' fat32 17408 %s set 1 boot on' % (partsize + 17408)
- out = commands.getoutput(cmd)
-
- cmd = 'dd if=%s of=/dev/mapper/efibootp1' % efiimage
- out = commands.getoutput(cmd)
-
- cmd = 'dmsetup remove /dev/mapper/efibootp1'
- out = commands.getoutput(cmd)
- cmd = 'dmsetup remove /dev/mapper/efiboot'
- out = commands.getoutput(cmd)
-
- cmd = 'losetup -d %s' % loop
- out = commands.getoutput(cmd)
-
- # remove efiimage
- rm(efiimage)
-
- # create new efiimage
- efiimage = self.create_efi(kernelpath='/images/pxeboot/vmlinuz',
- initrdpath='/images/pxeboot/initrd.img')
-
- # XEN
- if self.conf.buildarch in ('i386',):
- print('Installing the XEN kernel')
- self.yum.addPackages('kernel-PAE')
- self.yum.install()
-
- xenkernel = None
- for file in os.listdir(kerneldir):
- if fnmatch.fnmatch(file, 'vmlinuz-*.PAE'):
- xenkernel = os.path.join(self.conf.treedir, 'boot', file)
-
- if not xenkernel:
- sys.stderr.write('ERROR: No XEN kernel image found\n')
- sys.exit(1)
-
- initrd = images.InitRD(self.conf, self.yum, xenkernel)
-
- shutil.copy2(xenkernel, os.path.join(self.conf.pxebootdir, 'vmlinuz-PAE'))
-
- initrd.create(os.path.join(self.conf.pxebootdir, 'initrd-PAE.img'))
- #initrd.clean_up()
-
- # add xen kernel files to .treeinfo
- text = '[images-xen]\n'
- text += 'kernel = images/pxeboot/vmlinuz-PAE\n'
- text += 'initrd = images/pxeboot/initrd-PAE.img\n'
- edit(os.path.join(self.conf.outdir, '.treeinfo'), append=True, text=text)
-
- def create_installimg(self, type='squashfs'):
- print('Removing not needed files from install tree')
- i = images.Install(self.conf)
- i.scrub()
- i.fix_links()
-
- print('Creating the image file')
- if type == 'squashfs':
- cmd = 'mksquashfs %s %s -all-root -no-fragments -no-progress' % (self.conf.treedir,
- os.path.join(self.conf.imagesdir, 'install.img'))
- err, output = commands.getstatusoutput(cmd)
- elif type == 'cramfs':
- if self.conf.buildarch == 'sparc64':
- crambs = '--blocksize 8192'
- elif self.conf.buildarch == 'sparc':
- crambs = '--blocksize 4096'
- else:
- crambs = ''
-
- cmd = 'mkfs.cramfs %s %s %s' % (crambs, self.conf.treedir, os.path.join(self.conf.imagesdir, 'install.img'))
- err, output = commands.getstatusoutput(cmd)
- elif type == 'ext2':
- # TODO
+ self.so.header(":: Writing the .treeinfo file")
+ ok = self.write_treeinfo()
+ if not ok:
+ # XXX is this a problem?
pass
- text = '\n[stage2]\n'
- text += 'mainimage = %s/install.img\n' % self.conf.imagesdir
- edit(os.path.join(self.conf.outdir, '.treeinfo'), append=True, text=text)
+ self.so.header(":: Writing the .discinfo file")
+ ok = self.write_discinfo()
+ if not ok:
+ # XXX is this a problem?
+ pass
- def create_bootiso(self):
- efiboot = os.path.join(self.conf.imagesdir, 'efiboot.img')
- efiargs = ''
- efigraft = ''
- if os.path.exists(efiboot):
- print('Found efiboot.img, making an EFI-capable boot.iso')
- efiargs = '-eltorito-alt-boot -e images/efiboot.img -no-emul-boot'
- efigraft = 'EFI/BOOT=%s' % os.path.join(self.conf.outdir, 'EFI', 'BOOT')
- else:
- print('No efiboot.img found, making BIOS-only boot.iso')
+ self.so.header(":: Writing the .buildstamp file")
+ ok = self.write_buildstamp()
+ if not ok:
+ # XXX is this a problem?
+ pass
- biosargs = '-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table'
- mkisocmd = 'mkisofs -v -o %s %s %s -R -J -V %s -T -graft-points isolinux=%s images=%s %s' % (os.path.join(self.conf.imagesdir, 'boot.iso'), biosargs, efiargs, self.conf.product, self.conf.isolinuxdir, self.conf.imagesdir, efigraft)
+ self.so.header(":: Preparing the install tree")
+ tree = insttree.InstallTree(self.conf, self.yum, (self.so, self.se))
+ kernelfiles = tree.run()
- out = commands.getoutput(mkisocmd)
+ if not kernelfiles:
+ self.se.error("No kernel image found")
+ sys.exit(1)
- hybrid = os.path.join(os.sep, 'usr', 'bin', 'isohybrid')
- if os.path.exists(hybrid):
- cmd = '%s %s' % (hybrid, os.path.join(self.conf.imagesdir, 'boot.iso'))
- out = commands.getoutput(cmd)
+ self.so.header(":: Preparing the output directory")
+ ok = self.prepare_output_directory()
+ if not ok:
+ # XXX there's no isolinux.bin, i guess this is a problem...
+ self.se.error("Unable to prepare the output directory")
+ sys.exit(1)
- def clean_up(self, trash=[]):
- for item in trash:
- if os.path.exists(item):
- rm(item)
+ self.conf.addAttr(["kernelfile", "kernelver"])
+ for kernelfile in kernelfiles:
+ # get the kernel version
+ m = re.match(r".*vmlinuz-(.*)", kernelfile)
+ if m:
+ kernelver = m.group(1)
+ self.conf.set(kernelfile=kernelfile, kernelver=kernelver)
+ else:
+ self.se.warning("Invalid kernel filename '%s'" % (kernelfile,))
+ continue
- # remove the whole lorax temp directory
- if os.path.exists(self.conf.tempdir):
- rm(self.conf.tempdir)
+ self.so.header(":: Creating the initrd image for kernel '%s'" \
+ % (os.path.basename(kernelfile),))
+ initrd = images.InitRD(self.conf, self.yum, (self.so, self.se))
+ initrd.run()
+
+ self.so.header(":: Creating the install image")
+ ok = self.create_install_image()
+ if not ok:
+ self.se.error("Unable to create the install image")
+ sys.exit(1)
+
+ self.so.header(":: Creating the boot iso")
+ ok = self.create_boot_iso()
+ if not ok:
+ self.se.error("Unable to create the boot iso")
+ sys.exit(1)
+
+ if self.conf.cleanup:
+ self.so.header(":: Cleaning up")
+ self.clean_up()
diff --git a/src/pylorax/_backup/scrubs.py b/src/pylorax/_backup/scrubs.py
deleted file mode 100644
index c0961cc6..00000000
--- a/src/pylorax/_backup/scrubs.py
+++ /dev/null
@@ -1,74 +0,0 @@
- def __setBusyboxLinks(self):
- src = os.path.join(self.destdir, 'sbin', 'busybox.anaconda')
- dst = os.path.join(self.destdir, 'bin', 'busybox')
- mv(src, dst)
-
- cwd = os.getcwd()
- os.chdir(os.path.join(self.destdir, 'bin'))
-
- busybox_process = subprocess.Popen(['./busybox'], stdout=subprocess.PIPE)
- busybox_process.wait()
-
- if busybox_process.returncode:
- raise Error, 'busybox error'
-
- busybox_output = busybox_process.stdout.readlines()
- busybox_output = map(lambda line: line.strip(), busybox_output)
- busybox_output = busybox_output[busybox_output.index('Currently defined functions:') + 1:]
-
- commands = []
- for line in busybox_output:
- commands.extend(map(lambda c: c.strip(), line.split(',')))
-
- # remove empty strings
- commands = filter(lambda c: c, commands)
-
- for command in commands:
- # XXX why do we skip these commands? can "busybox" be there at all?
- if command not in ['buxybox', 'sh', 'shutdown', 'poweroff', 'reboot']:
- if not os.path.exists(command):
- os.symlink('busybox', command)
-
- os.chdir(cwd)
-
- def __strip(self):
- # XXX is this thing really needed? it's ugly
- fnames = map(lambda fname: os.path.join(self.destdir, fname), os.listdir(self.destdir))
- fnames = filter(lambda fname: os.path.isfile(fname), fnames)
-
- executables = []
- xmodules = os.path.join('usr', 'X11R6', self.libdir, 'modules')
- for fname in fnames:
- if not fname.find(xmodules) == -1:
- continue
-
- mode = os.stat(fname).st_mode
- if (mode & stat.S_IXUSR):
- executables.append(fname)
-
- elfs = []
- for exe in executables:
- p = subprocess.Popen(['file', exe], stdout=subprocess.PIPE)
- p.wait()
-
- output = p.stdout.readlines()
- output = ''.join(output)
- if re.match(r'^[^:]*:.*ELF.*$', output):
- elfs.append(exe)
-
- for elf in elfs:
- p = subprocess.Popen(['objdump', '-h', elf], stdout=subprocess.PIPE)
- p.wait()
-
- cmd = ['strip']
- if self.arch == 'ia64':
- cmd.append('--strip-debug')
-
- arglist = [elf, '-R', '.comment', '-R', '.note']
- for line in p.stdout.readlines():
- m = re.match(r'^.*(?P\.gnu\.warning\.[^ ]*) .*$', line)
- if m:
- arglist.extend(['-R', m.group('warning')])
-
- p = subprocess.Popen(cmd + arglist)
- p.wait()
diff --git a/src/pylorax/_backup/utils.py b/src/pylorax/_backup/utils.py
deleted file mode 100644
index e4c46202..00000000
--- a/src/pylorax/_backup/utils.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import sys
-import os
-import commands
-import re
-import socket
-
-import logging
-logging.basicConfig(level=logging.DEBUG)
-logger = logging.getLogger('pylorax')
-
-# XXX is the input a path to a file?
-def filtermoddeps(input):
- try:
- f = open(input, 'r')
- except IOError:
- logger.error('cannot open file %s', input)
- return
-
- # concatenate lines ending with \
- lines = []
- for line in f.readlines():
- if line.endswith('\\\n'):
- line = line[:-2]
- lines.append(line)
-
- f.close()
-
- lines = ''.join(lines).split('\n')
-
- # XXX what's the purpose of these gentlemen?
- lines = filter(lambda line: re.search(':.*ko', line), lines)
- lines = map(lambda line: re.sub('\.ko', '', line), lines)
- lines = map(lambda line: re.sub('/[^: ]*/', '', line), lines)
- lines = map(lambda line: re.sub('\t+', ' ', line), lines)
-
- return lines
-
-# XXX what is this whole thing for?
-def geninitrdsz(size, filename):
- size = socket.htonl(size)
-
- try:
- f = open(filename, 'w')
- except IOError:
- logger.error('cannot open file %s', filename)
- else:
- f.write(str(size))
- f.close()
-
- # XXX is this needed? default mode is 0664
- os.chmod(filename, 0644)
diff --git a/src/pylorax/_rewrite/__init__.py b/src/pylorax/_rewrite/__init__.py
new file mode 100644
index 00000000..17f7c786
--- /dev/null
+++ b/src/pylorax/_rewrite/__init__.py
@@ -0,0 +1,341 @@
+import stat
+import commands
+import glob
+import fnmatch
+import pwd
+import grp
+
+
+class Lorax(object):
+
+ def scrub_treedir(self):
+ # XXX here comes a lot of crazy tree modification stuff, beware! XXX
+
+ # create dogtail conf files
+ dogtailconf = os.path.join(self.conf.datadir, 'dogtail', '%gconf.xml')
+ if os.path.isfile(dogtailconf):
+ dst = os.path.join(self.conf.treedir, '.gconf', 'desktop', 'gnome', 'interface')
+ os.makedirs(dst)
+ shutil.copy2(dogtailconf, dst)
+
+ touch(os.path.join(self.conf.treedir, '.gconf', 'desktop', '%gconf.xml'))
+ touch(os.path.join(self.conf.treedir, '.gconf', 'desktop', 'gnome', '%gconf.xml'))
+
+ # XXX wth is this part useful for?
+
+ # XXX this one already exists
+ #os.makedirs(os.path.join(self.conf.treedir, 'lib'))
+ os.makedirs(os.path.join(self.conf.treedir, 'firmware'))
+ os.makedirs(os.path.join(self.conf.treedir, 'modules'))
+
+ # XXX this will overwrite the modules which are installed, why would i want to do that?
+ #os.symlink('/modules', os.path.join(self.conf.treedir, 'lib', 'modules'))
+ #os.symlink('/firmware', os.path.join(self.conf.treedir, 'lib', 'firmware'))
+
+ # create debug dirs
+ os.makedirs(os.path.join(self.conf.treedir, 'usr', 'lib', 'debug'))
+ os.makedirs(os.path.join(self.conf.treedir, 'usr', 'src', 'debug'))
+
+ # copy stubs
+ for file in ('raidstart', 'raidstop', 'losetup', 'list-harddrives', 'loadkeys', 'mknod',
+ 'syslogd'):
+ src = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda', file + '-stub')
+ dst = os.path.join(self.conf.treedir, 'usr', 'bin', file)
+ shutil.copy2(src, dst)
+
+ # move anaconda executable
+ src = os.path.join(self.conf.treedir, 'usr', 'sbin', 'anaconda')
+ dst = os.path.join(self.conf.treedir, 'usr', 'bin', 'anaconda')
+ shutil.move(src, dst)
+
+ # move anaconda libraries
+ src = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'lib*')
+ dst = os.path.join(self.conf.treedir, 'usr', self.conf.libdir)
+ for name in glob.iglob(src):
+ shutil.move(name, dst)
+
+ # change tree permissions
+ root_uid = pwd.getpwnam('root')[2]
+ root_gid = grp.getgrnam('root')[2]
+
+ for root, files, dirs in os.walk(self.conf.treedir):
+ os.chown(root, root_uid, root_gid)
+ os.chmod(root, 0755)
+
+ for file in files:
+ path = os.path.join(root, file)
+ os.chown(path, root_uid, root_gid)
+
+ mode = os.stat(path).st_mode
+ if (mode & stat.S_IXUSR) or (mode & stat.S_IXGRP) or (mode & stat.S_IXOTH):
+ os.chmod(path, 0555)
+ else:
+ os.chmod(path, 0444)
+
+ # create ld.so.conf
+ ldsoconf = os.path.join(self.conf.treedir, 'etc', 'ld.so.conf')
+ touch(ldsoconf)
+
+ procdir = os.path.join(self.conf.treedir, 'proc')
+ if not os.path.isdir(procdir):
+ os.makedirs(procdir)
+ os.system('mount -t proc proc %s' % procdir)
+
+ f = open(ldsoconf, 'w')
+ f.write('/usr/kerberos/%s\n' % self.conf.libdir)
+ f.close()
+
+ cwd = os.getcwd()
+ os.chdir(self.conf.treedir)
+ os.system('/usr/sbin/chroot %s /sbin/ldconfig' % self.conf.treedir)
+ os.chdir(cwd)
+
+ if self.conf.buildarch not in ('s390', 's390x'):
+ # XXX this is not in usr
+ rm(os.path.join(self.conf.treedir, 'usr', 'sbin', 'ldconfig'))
+
+ # XXX why are we removing this?
+ #rm(os.path.join(self.conf.treedir, 'etc', 'ld.so.conf'))
+ os.system('umount %s' % procdir)
+
+ # figure out the gtk+ theme to keep
+ gtkrc = os.path.join(self.conf.treedir, 'etc', 'gtk-2.0', 'gtkrc')
+ gtk_theme_name = None
+ gtk_engine = None
+ gtk_icon_themes = []
+
+ if os.path.isfile(gtkrc):
+ f = open(gtkrc, 'r')
+ lines = f.readlines()
+ f.close()
+
+ for line in lines:
+ line = line.strip()
+ if line.startswith('gtk-theme-name'):
+ gtk_theme_name = line[line.find('=') + 1:]
+ gtk_theme_name = gtk_theme_name.replace('"', '').strip()
+
+ # find the engine for this theme
+ gtkrc = os.path.join(self.conf.treedir, 'usr', 'share', 'themes',
+ gtk_theme_name, 'gtk-2.0', 'gtkrc')
+ if os.path.isfile(gtkrc):
+ f = open(gtkrc, 'r')
+ engine_lines = f.readlines()
+ f.close()
+
+ for engine_line in engine_lines:
+ engine_line = engine_line.strip()
+ if engine_line.find('engine') != -1:
+ gtk_engine = engine_line[engine_line.find('"') + 1:]
+ gtk_engine = gtk_engine.replace('"', '').strip()
+ break
+
+ elif line.startswith('gtk-icon-theme-name'):
+ icon_theme = line[line.find('=') + 1:]
+ icon_theme = icon_theme.replace('"', '').strip()
+ gtk_icon_themes.append(icon_theme)
+
+ # bring in all inherited themes
+ while True:
+ icon_theme_index = os.path.join(self.conf.treedir, 'usr', 'share', 'icons',
+ icon_theme, 'index.theme')
+ if os.path.isfile(icon_theme_index):
+ inherits = False
+ f = open(icon_theme_index, 'r')
+ icon_lines = f.readlines()
+ f.close()
+
+ for icon_line in icon_lines:
+ icon_line = icon_line.strip()
+ if icon_line.startswith('Inherits='):
+ inherits = True
+ icon_theme = icon_line[icon_line.find('=') + 1:]
+ icon_theme = icon_theme.replace('"', '').strip()
+ gtk_icon_themes.append(icon_theme)
+ break
+
+ if not inherits:
+ break
+ else:
+ break
+
+ # remove themes we don't need
+ theme_path = os.path.join(self.conf.treedir, 'usr', 'share', 'themes')
+ if os.path.isdir(theme_path):
+ for theme in filter(lambda theme: theme != gtk_theme_name, os.listdir(theme_path)):
+ theme = os.path.join(theme_path, theme)
+ shutil.rmtree(theme, ignore_errors=True)
+
+ # remove icons we don't need
+ icon_path = os.path.join(self.conf.treedir, 'usr', 'share', 'icons')
+ if os.path.isdir(icon_path):
+ for icon in filter(lambda icon: icon not in gtk_icon_themes, os.listdir(icon_path)):
+ icon = os.path.join(icon_path, icon)
+ shutil.rmtree(icon, ignore_errors=True)
+
+ # remove engines we don't need
+ tmp_path = os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'gtk-2.0')
+ if os.path.isdir(tmp_path):
+ fnames = map(lambda fname: os.path.join(tmp_path, fname, 'engines'), os.listdir(tmp_path))
+ dnames = filter(lambda fname: os.path.isdir(fname), fnames)
+ for dir in dnames:
+ engines = filter(lambda engine: engine.find(gtk_engine) == -1, os.listdir(dir))
+ for engine in engines:
+ engine = os.path.join(dir, engine)
+ os.unlink(engine)
+
+ # remove locales
+ langtable = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda', 'lang-table')
+ localepath = os.path.join(self.conf.treedir, 'usr', 'share', 'locale')
+ if os.path.isfile(langtable):
+ locales = set()
+ all_locales = set()
+
+ f = open(langtable, 'r')
+ lines = f.readlines()
+ f.close()
+
+ for line in lines:
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+
+ fields = line.split('\t')
+
+ if os.path.isdir(os.path.join(localepath, fields[1])):
+ locales.add(fields[1])
+
+ locale = fields[3].split('.')[0]
+ if os.path.isdir(os.path.join(localepath, locale)):
+ locales.add(locale)
+
+ for locale in os.listdir(localepath):
+ all_locales.add(locale)
+
+ locales_to_remove = list(all_locales.difference(locales))
+ for locale in locales_to_remove:
+ rmpath = os.path.join(localepath, locale)
+ shutil.rmtree(rmpath, ignore_errors=True)
+
+ # fixup joe links
+ joedir = os.path.join(self.conf.treedir, 'etc', 'joe')
+ if os.path.isdir(joedir):
+ os.symlink('jpicorc', os.path.join(joedir, 'picorc'))
+ os.symlink('jpicorc', os.path.join(joedir, 'jnanorc'))
+ os.symlink('jpicorc', os.path.join(joedir, 'nanorc'))
+ os.symlink('jmacsrc', os.path.join(joedir, 'emacsrc'))
+ os.symlink('jmacs', os.path.join(self.conf.treedir, 'usr', 'bin', 'emacs'))
+ os.symlink('jpico', os.path.join(self.conf.treedir, 'usr', 'bin', 'pico'))
+ os.symlink('jpico', os.path.join(self.conf.treedir, 'usr', 'bin', 'nano'))
+
+ # fix up some links for man page related stuff
+ for file in ['nroff', 'groff', 'iconv', 'geqn', 'gtbl', 'gpic', 'grefer']:
+ src = os.path.join('mnt', 'sysimage', 'usr', 'bin', file)
+ dst = os.path.join(self.conf.treedir, 'usr', 'bin', file)
+ if not os.path.isfile(dst):
+ os.symlink(src, dst)
+
+ # create selinux config
+ if os.path.exists(os.path.join(self.conf.treedir, 'etc', 'selinux', 'targeted')):
+ src = os.path.join(self.conf.datadir, 'selinux', 'config')
+ dst = os.path.join(self.conf.treedir, 'etc', 'selinux', 'config')
+ shutil.copy2(src, dst)
+
+ # create libuser.conf
+ src = os.path.join(self.conf.datadir, 'libuser', 'libuser.conf')
+ dst = os.path.join(self.conf.treedir, 'etc', 'libuser.conf')
+ shutil.copy2(src, dst)
+
+ # configure fedorakmod
+ fedorakmodconf = os.path.join(self.conf.treedir, 'etc', 'yum', 'pluginconf.d',
+ 'fedorakmod.conf')
+ replace(fedorakmodconf, r'\(installforallkernels\) = 0', r'\1 = 1')
+
+ # fix /etc/man.config to point into /mnt/sysimage
+ manconfig = os.path.join(self.conf.treedir, 'etc', 'man.config')
+
+ # don't change MANPATH_MAP lines now
+ replace(manconfig, r'^MANPATH[^_MAP][ \t]*', r'&/mnt/sysimage')
+ # change MANPATH_MAP lines now
+ replace(manconfig, r'^MANPATH_MAP[ \t]*[a-zA-Z0-9/]*[ \t]*', r'&/mnt/sysimage')
+
+ # move yum repos
+ src = os.path.join(self.conf.treedir, 'etc', 'yum.repos.d')
+ dst = os.path.join(self.conf.treedir, 'etc', 'anaconda.repos.d')
+ shutil.move(src, dst)
+
+ # remove libunicode-lite
+ rm(os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'libunicode-lite*'))
+
+ # make bash link
+ # XXX already exists
+ #if os.path.isfile(os.path.join(self.conf.treedir, 'bin', 'bash')):
+ # rm(os.path.join(self.conf.treedir, 'bin', 'ash'))
+ # os.symlink('bash', os.path.join(self.conf.treedir, 'bin', 'sh'))
+
+ # make awk link
+ # XXX already exists
+ #if os.path.isfile(os.path.join(self.conf.treedir, 'bin', 'gawk')):
+ # os.symlink('awk', os.path.join(self.conf.treedir, 'bin', 'gawk'))
+
+ # copy bootloaders
+ bootpath = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'boot')
+ if not os.path.isdir(bootpath):
+ os.makedirs(bootpath)
+
+ if self.conf.buildarch in ('i386', 'i586', 'x86_64'):
+ for file in os.listdir(os.path.join(self.conf.treedir, 'boot')):
+ if file.startswith('memtest'):
+ src = os.path.join(self.conf.treedir, 'boot', file)
+ dst = os.path.join(bootpath, file)
+ shutil.copy2(src, dst)
+ elif self.conf.buildarch in ('sparc',):
+ for file in os.listdir(os.path.join(self.conf.treedir, 'boot')):
+ if file.endswith('.b'):
+ src = os.path.join(self.conf.treedir, 'boot', file)
+ dst = os.path.join(bootpath, file)
+ shutil.copy2(src, dst)
+ elif self.conf.buildarch in ('ppc', 'ppc64'):
+ src = os.path.join(self.conf.treedir, 'boot', 'efika.forth')
+ shutil.copy2(src, bootpath)
+ elif self.conf.buildarch in ('alpha',):
+ src = os.path.join(self.conf.treedir, 'boot', 'bootlx')
+ shutil.copy2(src, bootpath)
+ elif self.conf.buildarch in ('ia64',):
+ src = os.path.join(self.conf.treedir, 'boot', 'efi', 'EFI', 'redhat', '*')
+ shutil.copy2(src, bootpath)
+
+ # remove not needed directories
+ # XXX i need this for kernel
+ #for dir in ('boot', 'home', 'root', 'tmp'):
+ # rm(os.path.join(self.conf.treedir, dir))
+
+ # remove not needed files
+ to_remove = set()
+ for root, dirs, files in os.walk(self.conf.treedir):
+ for file in files:
+ path = os.path.join(root, file)
+ if fnmatch.fnmatch(path, '*.a'):
+ if path.find('kernel-wrapper/wrapper.a') == -1:
+ to_remove.add(path)
+ elif fnmatch.fnmatch(path, 'lib*.la'):
+ if path.find('usr/' + self.conf.libdir + '/gtk-2.0') == -1:
+ to_remove.add(path)
+ elif fnmatch.fnmatch(path, '*.py'):
+ to_remove.add(path + 'o')
+
+ rm(path + 'c')
+ os.symlink('/dev/null', path + 'c')
+
+ for file in to_remove:
+ rm(file)
+
+ # nuke some python stuff we don't need
+ for fname in ['idle', 'distutils', 'bsddb', 'lib-old', 'hotshot', 'doctest.py', 'pydoc.py',
+ 'site-packages/japanese', 'site-packages/japanese.pth']:
+ rm(os.path.join(self.conf.treedir, fname))
+
+ for fname in ['distutils', 'lib-dynload/japanese', 'encodings', 'compiler', 'email/test',
+ 'curses', 'pydoc.py']:
+ rm(os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'python?.?', 'site-packages',
+ fname))
diff --git a/src/pylorax/_rewrite/images.py b/src/pylorax/_rewrite/images.py
new file mode 100644
index 00000000..a45d91b3
--- /dev/null
+++ b/src/pylorax/_rewrite/images.py
@@ -0,0 +1,168 @@
+#
+# images.py
+# lorax images manipulation
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# 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 .
+#
+# Red Hat Author(s): Martin Gracik
+#
+
+
+class Install(object):
+ def __init__(self, config):
+ self.conf = config
+
+ def scrub(self):
+ # move bin to usr/bin
+ cp(src_root=self.conf.treedir,
+ src_path=os.path.join('bin', '*'),
+ dst_root=self.conf.treedir,
+ dst_path=os.path.join('usr', 'bin'),
+ ignore_errors=True)
+
+ rm(os.path.join(self.conf.treedir, 'bin'))
+
+ # move sbin to /usr/sbin
+ cp(src_root=self.conf.treedir,
+ src_path=os.path.join('sbin', '*'),
+ dst_root=self.conf.treedir,
+ dst_path=os.path.join('usr', 'sbin'),
+ ignore_errors=True)
+
+ rm(os.path.join(self.conf.treedir, 'sbin'))
+
+ # remove dirs from root
+ dirs = ('boot', 'dev', 'home', 'media', 'mnt', 'opt', 'root', 'selinux', 'srv', 'sys', 'tmp', 'keymaps')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, dir))
+
+ # remove dirs from usr
+ dirs = ('etc', 'games', 'include', 'kerberos', 'local', 'tmp')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'usr', dir))
+
+ # remove dirs from var
+ dirs = ('db', 'empty', 'games', 'local', 'lock', 'log', 'mail', 'nis', 'opt', 'preserve', 'spool', 'tmp', 'yp')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'var', dir))
+
+ # remove modules and firmware
+ rm(os.path.join(self.conf.treedir, 'lib', 'modules'))
+ rm(os.path.join(self.conf.treedir, 'lib', 'firmware'))
+
+ # remove dirs from usr/lib
+ dirs = ('ConsoleKit', 'X11', 'alsa-lib', 'asterisk', 'avahi', 'booty', 'db4.5*', 'enchant', 'games', 'gio', 'gnome-keyring', 'gnome-vfs-2.0',
+ 'krb5', 'libglade', 'libxslt-plugins', 'lua', 'notification-daemon*', 'nss', 'openssl', 'orbit-2.0', 'perl5', 'pkgconfig', 'plymouth',
+ 'pm-utils', 'pppd', 'pygtk', 'rsyslog', 'samba', 'sasl2', 'sse2', 'syslinux', 'tc', 'tls', 'udev', 'window-manager-settings')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'usr', 'lib', dir))
+
+ # remove dirs from usr/share
+ dirs = ('GConf', 'NetworkManager', 'aclocal', 'alsa', 'application-registry', 'applications', 'asterisk', 'augeas', 'authconfig', 'avahi',
+ 'awk', 'createrepo', 'desktop-directories', 'dict', 'doc', 'dogtail', 'emacs', 'empty', 'enchant', 'file', 'firmware', 'firmware-tools',
+ 'firstboot', 'games', 'gnome*', 'gnupg', 'groff', 'gtk-*', 'help', 'i18n', 'info', 'kde*', 'librarian', 'libthai', 'lua',
+ 'makebootfat', 'man', 'metacity', 'mime*', 'misc', 'myspell', 'octave', 'omf', 'pkgconfig', 'plymouth', 'pygtk', 'selinux',
+ 'setuptool', 'sgml', 'system-config-firewall', 'system-config-network', 'system-config-users', 'tabset', 'tc', 'usermode', 'xml',
+ 'xsessions', 'yum-cli', 'magic')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'usr', 'share', dir))
+
+ # remove dirs from usr/share/themes
+ dirs = ('AgingGorilla', 'Atlanta', 'Bright', 'Clearlooks', 'ClearlooksClassic', 'Crux', 'Default', 'Emacs', 'Esco', 'Glider', 'Glossy',
+ 'HighContrast*', 'Industrial', 'Inverted', 'LargePrint', 'LowContrast*', 'Metabox', 'Mist', 'Raleigh', 'Simple', 'ThinIce')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'usr', 'share', 'themes', dir))
+
+ # remove dirs from etc
+ dirs = ('ConsoleKit', 'X11', 'alternatives', 'asterisk', 'avahi', 'blkid', 'bonobo-activation', 'chkconfig.d', 'cron.*', 'default', 'depmod.d',
+ 'dirmngr', 'dnsmasq.d', 'event.d', 'firmware', 'firstaidkit', 'gconf', 'gcrypt', 'gnome-vfs*', 'gnupg', 'gtk', 'hotplug', 'init.d',
+ 'iproute2', 'iscsi', 'kernel', 'ld.so.conf.d', 'logrotate.d', 'lvm', 'makedev.d', 'modprobe.d', 'netplug*', 'ntp', 'openldap', 'opt',
+ 'pam.d', 'pki', 'pm', 'popt.d', 'ppp', 'prelink.conf.d', 'profile.d', 'rc[0-6].d', 'rwtab.d', 'samba', 'sasl2', 'security', 'setuptool.d',
+ 'skel', 'ssh', 'statetab.d', 'terminfo', 'xdg', 'xinetd.d', 'yum.repos.d')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'etc', dir))
+
+ # remove dirs from lib
+ dirs = ('i686', 'kbd', 'rtkaio', 'security', 'tls', 'xtables')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'lib', dir))
+
+ # remove dirs from usr/libexec
+ dirs = ('awk', 'gcc', 'getconf', 'openssh', 'plymouth')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'usr', 'libexec', dir))
+
+ # remove dirs from usr/share/locale
+ dirs = ('af_ZA', 'ca_ES', 'cs_CZ', 'de_DE', 'el_GR', 'en', 'en_US', 'es_ES', 'et_EE', 'fa_IR', 'fr_FR', 'he_IL', 'hr_HR', 'it_IT', 'ja_JP',
+ 'ko_KR', 'nb_NO', 'nl_NL', 'nso', 'pl_PL', 'pt_PT', 'ru_RU', 'sr', 'sv_SE', 'uk_UA')
+ for dir in dirs:
+ rm(os.path.join(self.conf.treedir, 'usr', 'share', 'locale'))
+
+ # remove dirs from var/cache
+ dirs = ('dirmngr', 'fontconfig', 'man', 'yum')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'cache', dir)), dirs)
+
+ # remove dirs from var/lib
+ dirs = ('alternatives', 'asterisk', 'authconfig', 'dhclient', 'dhcpv6', 'dirmngr', 'dnsmasq', 'games', 'iscsi', 'nfs', 'ntp', 'plymouth',
+ 'rpcbind', 'rpm', 'samba', 'selinux', 'sepolgen', 'stateless', 'udev', 'yum', 'logrotate.status')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'lib', dir)), dirs)
+
+ # remove dirs from var/run
+ dirs = ('ConsoleKit', 'NetworkManager', 'asterisk', 'avahi-daemon', 'console', 'dirmngr', 'hald', 'mdadm', 'netreport', 'plymouth',
+ 'pm-utils', 'ppp', 'sepermit', 'setrans', 'winbindd', 'wpa_supplicant', 'utmp')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'run', dir)), dirs)
+
+ # remove dirs from usr/share/terminfo
+ dirs = ('A', 'E', 'a', 'c', 'd', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'r', 's', 't', 'w')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'terminfo', dir)), dirs)
+
+ # remove dirs from usr/share/pixmaps
+ dirs = ('redhat', 'splash')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'pixmaps', dir)), dirs)
+
+ # remove dirs form usr/share/X11/fonts
+ dirs = ('OTF', 'encodings', 'util')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'X11', 'fonts', dir)), dirs)
+
+ # remove dirs from usr/lib/python2.5/site-packages
+ dirs = ('firmware_addon_dell', 'firmwaretools')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'lib', 'python2.5', 'site-packages', dir)), dirs)
+
+ # remove dirs from etc/rc.d
+ dirs = ('rc?.d', 'rc', 'rc.local', 'rc.sysinit')
+ map(lambda dir: rm(os.path.join(self.conf.treedir, 'etc', 'rc.d', dir)), dirs)
+
+ def fix_links(self):
+ print("Fixing broken links")
+ for dir in ('bin', 'sbin'):
+ dir = os.path.join(self.conf.treedir, 'usr', dir)
+
+ brokenlinks = []
+ for root, dnames, fnames in os.walk(dir):
+ for fname in fnames:
+ fname = os.path.join(root, fname)
+ if os.path.islink(fname):
+ target = os.readlink(fname)
+ if not os.path.exists(fname):
+ brokenlinks.append(fname)
+
+ for link in brokenlinks:
+ target = os.readlink(link)
+ for dir in ('bin', 'sbin'):
+ newtarget = re.sub(r'^\.\./\.\./%s/(.*)' % dir, '../%s/\g<1>' % dir, target)
+ if newtarget != target:
+ os.unlink(link)
+ os.symlink(newtarget, link)
diff --git a/src/pylorax/actions/__init__.py b/src/pylorax/actions/__init__.py
index ac0991ee..59d52e29 100644
--- a/src/pylorax/actions/__init__.py
+++ b/src/pylorax/actions/__init__.py
@@ -32,17 +32,17 @@ def getActions(verbose=False):
modules = set()
for filename in os.listdir(os.path.join(root, actions_dir)):
- if filename.endswith('.py') and filename != '__init__.py':
+ if filename.endswith(".py") and filename != "__init__.py":
basename, extension = os.path.splitext(filename)
- modules.add(os.path.join(actions_dir, basename).replace('/', '.'))
+ modules.add(os.path.join(actions_dir, basename).replace("/", "."))
for module in modules:
if verbose:
- print("Loading actions from module '%s'" % module)
+ print("Loading actions from module '%s'" % (module,))
imported = __import__(module, globals(), locals(), [module], -1)
try:
- commands = getattr(imported, 'COMMANDS')
+ commands = getattr(imported, "COMMANDS")
except AttributeError:
if verbose:
print("No actions found")
diff --git a/src/pylorax/actions/base.py b/src/pylorax/actions/base.py
index 7862afb9..245a40ed 100644
--- a/src/pylorax/actions/base.py
+++ b/src/pylorax/actions/base.py
@@ -26,7 +26,7 @@ import pwd
import grp
import glob
-from pylorax.utils.fileutils import cp, mv, rm, touch, edit, replace, chmod
+from pylorax.utils.fileutils import copy, move, remove, touch, edit, replace, chmod
# command:action mapping
@@ -123,9 +123,9 @@ class Copy(LoraxAction):
self._attrs['nolinks'] = False
def execute(self, verbose=False):
- cp(src_root=self.src_root, src_path=self.src_path,
- dst_root=self.dst_root, dst_path=self.dst_path,
- nolinks=self.nolinks, ignore_errors=True, verbose=verbose)
+ copy(src_root=self.src_root, src_path=self.src_path,
+ dst_root=self.dst_root, dst_path=self.dst_path,
+ nolinks=self.nolinks, ignore_errors=False, verbose=verbose)
self._attrs['success'] = True
@property
@@ -176,9 +176,9 @@ class Copy(LoraxAction):
class Move(Copy):
def execute(self, verbose=False):
- mv(src_root=self.src_root, src_path=self.src_path,
- dst_root=self.dst_root, dst_path=self.dst_path,
- nolinks=self.nolinks, ignore_errors=True, verbose=verbose)
+ move(src_root=self.src_root, src_path=self.src_path,
+ dst_root=self.dst_root, dst_path=self.dst_path,
+ nolinks=self.nolinks, ignore_errors=False, verbose=verbose)
self._attrs['success'] = True
@@ -191,8 +191,7 @@ class Remove(LoraxAction):
self._attrs['filename'] = kwargs.get('filename')
def execute(self, verbose=False):
- for f in glob.iglob(self.filename):
- rm(f)
+ remove(self.filename, verbose=verbose)
self._attrs['success'] = True
@property
diff --git a/src/pylorax/config.py b/src/pylorax/config.py
index 02dcff91..aee19a1f 100644
--- a/src/pylorax/config.py
+++ b/src/pylorax/config.py
@@ -20,18 +20,14 @@
# Red Hat Author(s): Martin Gracik
#
-import sys
-import os
-import re
-from errors import TemplateError
-
-from utils.rpmutils import seq
+from misc import seq
class Container(object):
+
def __init__(self, attrs=None):
- self.__dict__['__internal'] = {}
- self.__dict__['__internal']['attrs'] = set()
+ self.__dict__["__internal"] = {}
+ self.__dict__["__internal"]["attrs"] = set()
if attrs:
self.addAttr(attrs)
@@ -46,29 +42,29 @@ class Container(object):
self.__checkInternal(attr)
if attr not in self.__dict__:
- raise AttributeError, "'Container' object has no attribute '%s'" % attr
+ raise AttributeError, "object has no attribute '%s'" % attr
return self.__dict__[attr]
def __setattr__(self, attr, value):
- raise AttributeError, "you can't do that, use addAttr() and/or set()"
+ raise AttributeError, "you can't do that, use addAttr() and/or set() instead"
def __delattr__(self, attr):
- raise AttributeError, "you can't do that, use delAttr()"
+ raise AttributeError, "you can't do that, use delAttr() instead"
def addAttr(self, attrs):
for attr in filter(lambda attr: attr not in self.__dict__, seq(attrs)):
self.__checkInternal(attr)
self.__dict__[attr] = None
- self.__dict__['__internal']['attrs'].add(attr)
+ self.__dict__["__internal"]["attrs"].add(attr)
def delAttr(self, attrs):
for attr in filter(lambda attr: attr in self.__dict__, seq(attrs)):
self.__checkInternal(attr)
del self.__dict__[attr]
- self.__dict__['__internal']['attrs'].discard(attr)
+ self.__dict__["__internal"]["attrs"].discard(attr)
def set(self, **kwargs):
unknown = set()
@@ -84,95 +80,11 @@ class Container(object):
def __makeDict(self):
d = {}
- for attr in self.__dict__['__internal']['attrs']:
+ for attr in self.__dict__["__internal"]["attrs"]:
d[attr] = self.__dict__[attr]
return d
def __checkInternal(self, attr):
- if attr.startswith('__'):
+ if attr.startswith("__"):
raise AttributeError, "do not mess with internal objects"
-
-
-class Template(object):
- def __init__(self):
- self._actions = []
-
- self.lines = []
- self.included_files = []
-
- def preparse(self, filename):
- try:
- f = open(filename, 'r')
- except IOError as why:
- sys.stderr.write("ERROR: Unable to open template file '%s': %s\n" % (filename, why))
- return False
- else:
- lines = f.readlines()
- f.close()
-
- self.included_files.append(filename)
-
- for line in lines:
- line = line.strip()
-
- if line.startswith('#include'):
- file_to_include = line.split()[1]
- path = os.path.join(os.path.dirname(filename), file_to_include)
- if path not in self.included_files:
- self.preparse(path)
- else:
- self.lines.append(line)
-
- def parse(self, supported_actions, variables):
- lines = self.lines
-
- # append next line if line ends with '\'
- temp = []
- for line in lines:
- line = line.strip()
- if line.endswith('\\'):
- line = line[:-1]
- line = line.rstrip()
- line = line + ' '
- else:
- line = line + '\n'
- temp.append(line)
- temp = ''.join(temp)
- lines = temp.splitlines()
-
- # check template variables
- for lineno, line in enumerate(lines, start=1):
- for var in filter(lambda var: var not in variables, re.findall(r'@(.*?)@', line)):
- raise TemplateError, "unknown variable '%s' on line %d" % (var, lineno)
-
- # parse the template
- for lineno, line in enumerate(lines, start=1):
- line, sep, comment = line.partition('#')
- if not line:
- continue
-
- # expand variables
- for var, value in variables.items():
- line = re.sub(r'@%s@' % var, value, line)
-
- # get the command
- command, line = line.split(None, 1)
- if command not in supported_actions:
- raise TemplateError, "unknown command '%s' on line %d" % (command, lineno)
-
- # create the action object
- regex = supported_actions[command].REGEX
- m = re.match(regex, line)
- if m:
- new_action = supported_actions[command](**m.groupdict())
- self._actions.append(new_action)
- else:
- # didn't match the regex
- raise TemplateError, "invalid command format '%s' on line %d" % (line, lineno)
-
- return True
-
- @property
- def actions(self):
- return self._actions
diff --git a/src/pylorax/images.py b/src/pylorax/images.py
index 8c91f0ba..182f6a89 100644
--- a/src/pylorax/images.py
+++ b/src/pylorax/images.py
@@ -22,177 +22,217 @@
import sys
import os
+import glob
import shutil
import commands
import re
-import fnmatch
-import datetime
-import glob
import actions
import actions.base
-from config import Template
-from utils.fileutils import cp, mv, rm, touch, edit, replace
+from template import Template
+
+from utils.fileutils import copy, remove, touch, edit, replace
from utils.ldd import LDD
-from utils.genmodinfo import genmodinfo
class InitRD(object):
- def __init__(self, config, yum, kernelfile):
+
+ def __init__(self, config, yum, output):
self.conf = config
self.yum = yum
- self.kernelfile = kernelfile
- # get the kernel version
- m = re.match(r'.*vmlinuz-(?P.*)', self.kernelfile)
- self.kernelver = m.group('ver')
+ self.so, self.se = output
+ def read_template(self):
# get supported actions
- supported_actions = actions.getActions()
+ supported_actions = actions.getActions(verbose=self.conf.debug)
- # vars supported in template
- vars = { 'instroot': self.conf.treedir,
- 'initrd': self.conf.initrddir,
- 'libdir': self.conf.libdir,
- 'buildarch': self.conf.buildarch,
- 'confdir' : self.conf.confdir,
- 'datadir': self.conf.datadir }
+ # variables supported in templates
+ vars = { "instroot": self.conf.treedir,
+ "initrd": self.conf.initrddir,
+ "libdir": self.conf.libdir,
+ "buildarch": self.conf.buildarch,
+ "basearch": self.conf.basearch,
+ "confdir" : self.conf.confdir,
+ "datadir": self.conf.datadir }
+
+ # parse the template file
+ initrd_template = os.path.join(self.conf.confdir, "initrd",
+ "initrd.%s" % self.conf.buildarch)
- initrd_template = os.path.join(self.conf.confdir, 'templates',
- 'initrd.%s' % self.conf.buildarch)
self.template = Template()
self.template.preparse(initrd_template)
self.template.parse(supported_actions, vars)
- # additional actions that need to be processed
- self._actions = []
-
- if not os.path.isdir(self.conf.initrddir):
- os.makedirs(self.conf.initrddir)
-
- def get_packages(self):
+ def install_required_packages(self):
packages = set()
for action in filter(lambda action: action.install, self.template.actions):
- m = re.match(r'%s(.*)' % self.conf.treedir, action.install)
+ m = re.match(r"%s(.*)" % (self.conf.treedir,), action.install)
if m:
packages.add(m.group(1))
- return packages
+ for package in packages:
+ ok = self.yum.add_package(package)
+ if not ok:
+ self.se.error("No package '%s' found" % (package,))
- def get_deps(self):
+ self.yum.install()
+
+ def get_file_dependencies(self):
libroots = []
libroots.append(os.path.join(self.conf.treedir, self.conf.libdir))
- libroots.append(os.path.join(self.conf.treedir, 'usr', self.conf.libdir))
+ libroots.append(os.path.join(self.conf.treedir, "usr", self.conf.libdir))
# on 64 bit systems, add also normal lib directories
- if self.conf.libdir.endswith('64'):
- libroots.append(os.path.join(self.conf.treedir, self.conf.libdir[:-2]))
- libroots.append(os.path.join(self.conf.treedir, 'usr', self.conf.libdir[:-2]))
+ if self.conf.libdir.endswith("64"):
+ libdir = self.conf.libdir[:-2]
+ libroots.append(os.path.join(self.conf.treedir, libdir))
+ libroots.append(os.path.join(self.conf.treedir, "usr", libdir))
ldd = LDD(libroots)
- for action in filter(lambda action: hasattr(action, 'getDeps'), self.template.actions):
- ldd.getDeps(action.getDeps)
+
+ for action in self.template.actions:
+ if action.getDeps:
+ [ldd.getDeps(fname) for fname in glob.glob(action.getDeps)]
- # resolve symlinks
- # XXX we don't need this, because cp function gets the symlinks
- #ldd.getLinks()
+ if ldd.errors:
+ # XXX ldd didn't get all the dependencies, what now?
+ for filename, error in ldd.errors:
+ self.se.error(filename)
+ self.se.error(error)
- # add dependencies to actions
+ # additional actions that need to be processed
+ self._actions = []
+
+ # add dependencies to actions, so they are copied too
for dep in ldd.deps:
kwargs = {}
- kwargs['src_root'] = self.conf.treedir
- kwargs['src_path'] = dep.replace(self.conf.treedir + os.sep, '', 1)
- kwargs['dst_root'] = self.conf.initrddir
- kwargs['dst_path'] = dep.replace(self.conf.treedir + os.sep, '', 1)
- kwargs['dst_path'] = os.path.dirname(kwargs['dst_path'])
+ kwargs["src_root"] = self.conf.treedir
+ kwargs["src_path"] = dep.replace(self.conf.treedir + "/", "", 1)
+ kwargs["dst_root"] = self.conf.initrddir
+ kwargs["dst_path"] = os.path.dirname(kwargs["src_path"])
+
+ if kwargs["dst_path"].startswith("/"):
+ kwargs["dst_path"] = kwargs["dst_path"][1:]
new_action = actions.base.Copy(**kwargs)
self._actions.append(new_action)
def process_actions(self):
- for action in self.template.actions + self._actions:
+ for action in self.template.actions:
action.execute()
- def get_keymaps(self):
- override = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime',
- 'keymaps-override-%s' % self.conf.buildarch)
- if os.path.exists(override):
- print('Found keymap override, using it')
- shutil.copy2(override, os.path.join(self.conf.treedir, 'keymaps.gz'))
- else:
- cmd = '%s %s %s %s' % \
- (os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'getkeymaps'),
- self.conf.buildarch, os.path.join(self.conf.treedir, 'keymaps.gz'), self.conf.treedir)
- rc = commands.getstatus(cmd)
- if rc != 0:
- sys.stderr.write('Unable to create keymaps and thus can\'t create initrd\n')
- sys.exit(1)
+ # process dependencies
+ for action in self._actions:
+ action.execute()
- shutil.copy2(os.path.join(self.conf.treedir, 'keymaps.gz'),
- os.path.join(self.conf.initrddir, 'etc'))
+ def create_modinfo(self, moddir, target):
+ # XXX why do we need this thing?
+ mods = {}
+ for root, dirs, files in os.walk(moddir):
+ for file in files:
+ mods[file] = os.path.join(root, file)
- def create_locales(self):
- os.makedirs(os.path.join(self.conf.initrddir, 'usr', 'lib', 'locale'))
- rc, output = commands.getstatusoutput('localedef -c -i en_US -f UTF-8 --prefix %s en_US' % self.conf.initrddir)
+ modules = { "scsi_hostadapter" : ["block"],
+ "eth" : ["networking"] }
+ blacklist = ("floppy", "scsi_mod", "libiscsi")
- def get_modules(self):
- modlist = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'modlist')
- modinfo = os.path.join(self.conf.tempdir, 'modinfo')
- genmodinfo(os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver), modinfo)
+ list = {}
+ for modtype in modules:
+ list[modtype] = {}
+ for file in modules[modtype]:
+ try:
+ filename = os.path.join(moddir, "modules.%s" % file)
+ f = open(filename, "r")
+ except IOError as why:
+ self.se.error("Unable to open file '%s'" % (filename,))
+ continue
+ else:
+ lines = f.readlines()
+ f.close()
- moddir = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver)
+ for line in lines:
+ line = line.strip()
+ if line in mods:
+ modname, ext = os.path.splitext(line)
+ if modname in blacklist:
+ continue
+
+ cmd = "modinfo -F description %s" % (mods[line],)
+ outtext = commands.getoutput(cmd)
+
+ desc = outtext.split("\n")[0]
+ desc = desc.strip()
+ desc = desc[:65]
+
+ if not desc:
+ desc = "%s driver" % modname
+ modinfo = '%s\n\t%s\n\t"%s"\n' % (modname, modtype, desc)
+ list[modtype][modname] = modinfo
+
+ f = open(target, "a")
+ f.write("Version 0\n")
+ for type in list:
+ modlist = list[type].keys()
+ modlist.sort()
+ for m in modlist:
+ f.write("%s\n" % (list[type][m],))
+ f.close()
+
+ def get_kernel_modules(self):
+ kernelver = self.conf.kernelver
modfiles = []
- modfiles.append(os.path.join(self.conf.confdir, 'modules', 'modules'))
- modfiles.append(os.path.join(self.conf.confdir, 'modules', self.conf.buildarch, 'modules'))
+ modfiles.append(os.path.join(self.conf.confdir, "modules",
+ "modules.all"))
+ modfiles.append(os.path.join(self.conf.confdir, "modules",
+ "modules.%s" % (self.conf.buildarch,)))
+
+ src_moddir = os.path.join(self.conf.treedir, "lib", "modules", kernelver)
+ dst_moddir = os.path.join(self.conf.initrddir, "lib", "modules", kernelver)
- # expand modules
+ # get the modules from configuration files
modules = set()
for file in modfiles:
if os.path.isfile(file):
- f = open(file, 'r')
+ f = open(file, "r")
lines = f.readlines()
f.close()
for line in lines:
- line, sep, comment = line.partition('#')
+ line, sep, comment = line.partition("#")
line = line.strip()
if not line:
continue
- if line.startswith('-'):
+ if line.startswith("-"):
modules.discard(line[1:])
- elif line.startswith('='):
+ elif line.startswith("="):
+ # expand modules
group = line[1:]
- if group in ('scsi', 'ata'):
- path = os.path.join(moddir, 'modules.block')
- elif group == 'net':
- path = os.path.join(moddir, 'modules.networking')
+ if group in ("scsi", "ata"):
+ path = os.path.join(src_moddir, "modules.block")
+ elif group == "net":
+ path = os.path.join(src_moddir, "modules.networking")
else:
- path = os.path.join(moddir, 'modules.%s' % group)
+ path = os.path.join(src_moddir, "modules.%s" % (group,))
- modules_to_add = []
if os.path.isfile(path):
- f = open(path, 'r')
+ f = open(path, "r")
for module in f.readlines():
module = module.strip()
- module = module.replace('.ko', '')
- modules_to_add.append(module)
+ module = module.replace(".ko", "")
+ modules.add(module)
f.close()
-
- # XXX do we really need to filter only ata or ahci if group == ata?
-
- for module in modules_to_add:
- modules.add(module)
else:
modules.add(line)
- # resolve deps
- depfile = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver, 'modules.dep')
- f = open(depfile, 'r')
+ # resolve modules dependencies
+ depfile = os.path.join(src_moddir, "modules.dep")
+ f = open(depfile, "r")
lines = f.readlines()
f.close()
@@ -201,354 +241,529 @@ class InitRD(object):
for line in lines:
changed = False
line = line.strip()
- m = re.match(r'^.*/(?P.*)\.ko:(?P.*)$', line)
- modname = m.group('name')
+
+ m = re.match(r"^.*/(?P.*)\.ko:(?P.*)$", line)
+ modname = m.group("name")
+
if modname in modules:
- for dep in m.group('deps').split():
- m = re.match(r'^.*/(?P.*)\.ko$', dep)
- if m.group('name') not in modules:
+ for dep in m.group("deps").split():
+ m = re.match(r"^.*/(?P.*)\.ko$", dep)
+ depname = m.group("name")
+
+ if depname not in modules:
changed = True
- modules.add(m.group('name'))
+ modules.add(depname)
- srcdir = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver)
- dstdir = os.path.join(self.conf.initrddir, 'lib', 'modules')
-
- cp(src_root=self.conf.treedir,
- src_path=os.path.join('lib', 'modules', self.kernelver),
- dst_root=self.conf.initrddir,
- dst_path=os.path.join('lib', 'modules'),
- ignore_errors=True)
+ # copy the modules directory
+ copy(src_root=self.conf.treedir,
+ src_path=os.path.join("lib", "modules", kernelver),
+ dst_root=self.conf.initrddir,
+ dst_path=os.path.join("lib", "modules"))
- for root, dirs, files in os.walk(dstdir):
+ # remove not needed modules
+ for root, dirs, files in os.walk(dst_moddir):
for file in files:
+ full_path = os.path.join(root, file)
name, ext = os.path.splitext(file)
- if ext == '.ko':
+
+ if ext == ".ko":
if name not in modules:
- rm(os.path.join(root, file))
+ remove(full_path)
else:
# copy the required firmware
- module = os.path.join(root, file)
- output = commands.getoutput('modinfo -F firmware %s' % module)
- output = output.strip()
+ cmd = "modinfo -F firmware %s" % (full_path,)
+ err, output = commands.getstatusoutput(cmd)
for fw in output.split():
- dst = os.path.join(self.conf.initrddir, 'lib', 'firmware', fw)
+ dst = os.path.join(self.conf.initrddir,
+ "lib", "firmware", fw)
+
dir = os.path.dirname(dst)
if not os.path.exists(dir):
os.makedirs(dir)
- cp(src_root = self.conf.treedir,
- src_path = os.path.join('lib', 'firmware', fw),
- dst_root = self.conf.initrddir,
- dst_path = os.path.join('lib', 'firmware', fw))
+ copy(src_root = self.conf.treedir,
+ src_path = os.path.join("lib", "firmware", fw),
+ dst_root = self.conf.initrddir,
+ dst_path = os.path.join("lib", "firmware", fw))
- # copy firmware
- srcdir = os.path.join(self.conf.treedir, 'lib', 'firmware')
- dstdir = os.path.join(self.conf.initrddir, 'lib', 'firmware')
+ # copy additional firmware
+ srcdir = os.path.join(self.conf.treedir, "lib", "firmware")
+ dstdir = os.path.join(self.conf.initrddir, "lib", "firmware")
- fw = ( ('ipw2100', 'ipw2100*'),
- ('ipw2200', 'ipw2200*'),
- ('iwl3945', 'iwlwifi-3945*'),
- ('iwl4965', 'iwlwifi-4965*'),
- ('atmel', 'atmel_*.bin'),
- ('zd1211rw', 'zd1211'),
- ('qla2xxx', 'ql*') )
+ fw = ( ("ipw2100", "ipw2100*"),
+ ("ipw2200", "ipw2200*"),
+ ("iwl3945", "iwlwifi-3945*"),
+ ("iwl4965", "iwlwifi-4965*"),
+ ("atmel", "atmel_*.bin"),
+ ("zd1211rw", "zd1211"),
+ ("qla2xxx", "ql*") )
for module, file in fw:
if module in modules:
- cp(src_root=self.conf.treedir,
- src_path=os.path.join('lib', 'firmware', file),
- dst_root=self.conf.initrddir,
- dst_path=os.path.join('lib', 'firmware'))
-
- # create modinfo
- dst = os.path.join(self.conf.initrddir, 'lib', 'modules', 'module-info')
- cmd = '%s --modinfo-file %s --ignore-missing --modinfo %s > %s' % \
- (modlist, modinfo, ' '.join(list(modules)), dst)
- commands.getoutput(cmd)
+ copy(src_root=self.conf.treedir,
+ src_path=os.path.join("lib", "firmware", file),
+ dst_root=self.conf.initrddir,
+ dst_path=os.path.join("lib", "firmware"))
# compress modules
- cmd = 'find -H %s -type f -name *.ko -exec gzip -9 {} \\;' % \
- os.path.join(self.conf.initrddir, 'lib', 'modules')
- commands.getoutput(cmd)
+ cmd = "find -H %s -type f -name *.ko -exec gzip -9 {} \\;" % (dst_moddir,)
+ err, output = commands.getstatusoutput(cmd)
+ if err:
+ self.se.debug(output)
+
+ # create modinfo
+ modinfo = os.path.join(self.conf.tempdir, "modinfo")
+ self.create_modinfo(src_moddir, modinfo)
+
+ modlist = os.path.join(self.conf.treedir,
+ "usr", "lib", "anaconda-runtime", "modlist")
+
+ target = os.path.join(self.conf.initrddir, "lib", "modules", "module-info")
+ cmd = "%s --modinfo-file %s --ignore-missing --modinfo %s > %s" % \
+ (modlist, modinfo, " ".join(list(modules)), target)
+ err, output = commands.getstatusoutput(cmd)
+ if err:
+ self.se.debug(output)
# run depmod
- cmd = '/sbin/depmod -a -F %s -b %s %s' % \
- (os.path.join(self.conf.treedir, 'boot', 'System.map-%s' % self.kernelver),
- self.conf.initrddir, self.kernelver)
- commands.getoutput(cmd)
+ systemmap = os.path.join(self.conf.treedir, "boot", "System.map-%s" \
+ % (kernelver,))
+ cmd = "/sbin/depmod -a -F %s -b %s %s" % (systemmap,
+ self.conf.initrddir, kernelver)
+ err, output = commands.getstatusoutput(cmd)
+ if err:
+ self.se.debug(output)
# remove leftovers
- rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.kernelver, 'modules.*map'))
- rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.kernelver, 'source'))
- rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.kernelver, 'build'))
+ remove(os.path.join(dst_moddir, "modules.*map"))
- # trim pci ids
+ def trim_pci_ids(self):
+ kernelver = self.conf.kernelver
+ # XXX is this needed? does it save so much space?
vendors = set()
devices = set()
- modulesalias = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver, 'modules.alias')
+ modulesalias = os.path.join(self.conf.treedir,
+ "lib", "modules", kernelver, "modules.alias")
f = open(modulesalias)
pcitable = f.readlines()
f.close()
for line in pcitable:
- if not line.startswith('alias pci:'):
+ if not line.startswith("alias pci:"):
continue
- vend = '0x%s' % line[15:19]
- vend.upper()
- dev = '0x%s' % line[24:28]
+ vend = "0x%s" % (line[15:19],)
+ vend = vend.upper()
+ dev = "0x%s" % (line[24:28],)
dev = dev.upper()
vendors.add(vend)
devices.add((vend, dev))
- videoaliases = os.path.join(self.conf.treedir, 'usr', 'share', 'hwdata', 'videoaliases', '*')
+ videoaliases = os.path.join(self.conf.treedir,
+ "usr", "share", "hwdata", "videoaliases", "*")
for file in glob.iglob(videoaliases):
f = open(file)
pcitable = f.readlines()
f.close()
for line in pcitable:
- if not line.startswith('alias pcivideo:'):
+ if not line.startswith("alias pcivideo:"):
continue
- vend = '0x%s' % line[20:24]
+ vend = "0x%s" % (line[20:24],)
vend = vend.upper()
- dev = '0x%s' % line[29:33]
+ dev = "0x%s" % (line[29:33],)
dev = dev.upper()
vendors.add(vend)
devices.add((vend, dev))
- # create pci.ids
- # XXX this file is NOT in the original initrd image...
- src = os.path.join(self.conf.treedir, 'usr', 'share', 'hwdata', 'pci.ids')
- #dst = os.path.join(self.conf.initrddir, 'pci.ids')
- dst = os.path.join(self.conf.treedir, 'pci.ids')
+ # create the pci.ids file
+ src = os.path.join(self.conf.treedir, "usr", "share", "hwdata", "pci.ids")
+ dst = os.path.join(self.conf.initrddir, "usr", "share", "hwdata", "pci.ids")
- input = open(src, 'r')
+ input = open(src, "r")
pcitable = input.readlines()
input.close()
- output = open(dst, 'w')
+ output = open(dst, "w")
current_vend = 0
for line in pcitable:
# skip lines that start with 2 tabs or #
- if line.startswith('\t\t') or line.startswith('#'):
+ if line.startswith("\t\t") or line.startswith("#"):
continue
# skip empty lines
- if line == '\n':
+ if line == "\n":
continue
# end of file
- if line == 'ffff Illegal Vendor ID':
+ if line == "ffff Illegal Vendor ID":
break
- if not line.startswith('\t'):
- current_vend = '0x%s' % line.split()[0]
+ if not line.startswith("\t"):
+ current_vend = "0x%s" % (line.split()[0],)
current_vend = current_vend.upper()
if current_vend in vendors:
output.write(line)
continue
- dev = '0x%s' % line.split()[0]
+ dev = "0x%s" % (line.split()[0],)
dev = dev.upper()
if (current_vend, dev) in devices:
output.write(line)
output.close()
- def get_missing_links(self):
- missing_files = []
+ def get_keymaps(self):
+ anadir = os.path.join(self.conf.treedir, "usr", "lib", "anaconda-runtime")
+ override = os.path.join(anadir,
+ "keymaps-override-%s" % (self.conf.buildarch,))
- for root, dnames, fnames in os.walk(self.conf.initrddir):
- for fname in fnames:
- file = os.path.join(root, fname)
- if os.path.islink(file) and not os.path.exists(file):
- # broken link
- target = os.readlink(file)
- missing = os.path.join(os.path.dirname(file), target)
- missing = os.path.normpath(missing)
-
- missing_files.append(missing)
+ if os.path.isfile(override):
+ self.so.debug("Found keymap override, using it")
+ shutil.copy2(override,
+ os.path.join(self.conf.initrddir, "etc", "keymaps.gz"))
+ else:
+ cmd = "%s %s %s %s" % (os.path.join(anadir, "getkeymaps"),
+ self.conf.buildarch,
+ os.path.join(self.conf.initrddir, "etc", "keymaps.gz"),
+ self.conf.treedir)
+
+ err, output = commands.getstatusoutput(cmd)
+ if err:
+ return False
- print 'Missing files:', missing_files
+ return True
- def create(self, dst):
- # copy the productfile
- shutil.copy2(os.path.join(self.conf.treedir, '.buildstamp'),
- os.path.join(self.conf.initrddir, '.buildstamp'))
+ def create_locales(self):
+ os.makedirs(os.path.join(self.conf.initrddir, "usr", "lib", "locale"))
+ err, output = commands.getstatusoutput("localedef -c -i en_US -f UTF-8"
+ " --prefix %s en_US" % (self.conf.initrddir,))
- print('Getting dependencies')
- self.get_deps()
- print('Processing actions')
- self.process_actions()
- print('Getting keymaps')
- self.get_keymaps()
- print('Creating locales')
- self.create_locales()
- print('Getting modules')
- self.get_modules()
- #print('Getting missing links')
- #self.get_missing_links()
+ def create(self, target):
+ # copy the .buildstamp file
+ shutil.copy2(self.conf.buildstamp, self.conf.initrddir)
- # create the initrd
- print('Creating the %s' % dst)
cwd = os.getcwd()
os.chdir(self.conf.initrddir)
- out = commands.getoutput('find . | cpio --quiet -c -o | gzip -9 > %s' % dst)
+
+ cmd = "find . | cpio --quiet -c -o | gzip -9 > %s" % (target,)
+ output = commands.getoutput(cmd)
+
os.chdir(cwd)
- def clean_up(self):
- rm(self.conf.initrddir)
+ def run(self):
+ # create the temporary directory for initrd
+ initrddir = os.path.join(self.conf.tempdir, "initrddir",
+ self.conf.kernelver)
+ self.so.info("Creating the temporary initrd directory")
+ os.makedirs(initrddir)
+ self.conf.addAttr("initrddir")
+ self.conf.set(initrddir=initrddir)
+
+ self.so.info("Reading the initrd template file")
+ self.read_template()
+
+ self.so.info("Installing additional packages")
+ self.install_required_packages()
+
+ self.so.info("Getting required dependencies")
+ self.get_file_dependencies()
+
+ self.so.info("Copying required files to initrd directory")
+ self.process_actions()
+
+ self.so.info("Getting required kernel modules")
+ self.get_kernel_modules()
+
+ self.so.info("Getting the pci.ids file")
+ self.trim_pci_ids()
+
+ ok = self.get_keymaps()
+ if not ok:
+ self.se.error("Unable to create the keymaps")
+ sys.exit(1)
+
+ self.so.info("Creating locales")
+ self.create_locales()
+
+ initrd_filename = "initrd.img"
+ kernel_filename = "vmlinuz"
+
+ if self.conf.kernelfile.endswith("PAE"):
+ initrd_filename = "initrd-PAE.img"
+ kernel_filename = "vmlinuz-PAE"
+
+ text = "[images-xen]\n"
+ text += "kernel = images/pxeboot/vmlinuz-PAE\n"
+ text += "initrd = images/pxeboot/initrd-PAE.img\n"
+ edit(os.path.join(self.conf.outdir, ".treeinfo"),
+ append=True, text=text)
+
+ self.so.info("Compressing the image file '%s'" % (initrd_filename,))
+ self.create(os.path.join(self.conf.pxebootdir, initrd_filename))
+
+ self.so.info("Copying the kernel file")
+ shutil.copy2(self.conf.kernelfile,
+ os.path.join(self.conf.pxebootdir, kernel_filename))
+
+ if not self.conf.kernelfile.endswith("PAE"):
+ # copy the kernel and initrd to the isolinux directory
+ shutil.copy2(self.conf.kernelfile,
+ os.path.join(self.conf.isolinuxdir, kernel_filename))
+ shutil.copy2(os.path.join(self.conf.pxebootdir, initrd_filename),
+ os.path.join(self.conf.isolinuxdir, initrd_filename))
+
+ # create the efi images
+ efi = EFI(self.conf, (self.so, self.se))
+ efi.run(kernelfile=self.conf.kernelfile,
+ initrd=os.path.join(self.conf.pxebootdir, initrd_filename),
+ kernelpath="/images/pxeboot/vmlinuz",
+ initrdpath="/images/pxeboot/initrd.img")
+
+
+class EFI(object):
+
+ def __init__(self, config, output):
+ self.conf = config
+ self.so, self.se = output
+
+ # create the temporary efi directory
+ tempdir = os.path.join(self.conf.tempdir, "efi")
+ if os.path.exists(tempdir):
+ remove(tempdir)
+ os.makedirs(tempdir)
+ self.tempdir = tempdir
+
+ def create(self, kernelfile=None, initrd=None, kernelpath=None, initrdpath=None):
+ # create the temporary efi tree directory
+ efitreedir = os.path.join(self.tempdir, "tree")
+ if os.path.exists(efitreedir):
+ remove(efitreedir)
+ os.makedirs(efitreedir)
+
+ # copy kernel and initrd files to efi tree directory
+ if kernelfile and initrd:
+ shutil.copy2(kernelfile, os.path.join(efitreedir, "vmlinuz"))
+ shutil.copy2(initrd, os.path.join(efitreedir, "initrd.img"))
+ efikernelpath = os.path.join("/", "EFI", "BOOT", "vmlinuz")
+ efiinitrdpath = os.path.join("/", "EFI", "BOOT", "initrd.img")
+ else:
+ efikernelpath = kernelpath
+ efiinitrdpath = initrdpath
+
+ # copy conf files to efi tree directory
+ copy(src_root=self.conf.bootdiskdir, src_path="*.conf",
+ dst_root=efitreedir, dst_path="")
+
+ # edit the grub.conf file
+ grubconf = os.path.join(efitreedir, "grub.conf")
+ replace(grubconf, "@PRODUCT@", self.conf.product)
+ replace(grubconf, "@VERSION@", self.conf.version)
+ replace(grubconf, "@KERNELPATH@", efikernelpath)
+ replace(grubconf, "@INITRDPATH@", efiinitrdpath)
+ replace(grubconf, "@SPLASHPATH@", "/EFI/BOOT/splash.xpm.gz")
+
+ # copy grub.efi
+ src = os.path.join(self.conf.treedir,
+ "boot", "efi", "EFI", "redhat", "grub.efi")
+ shutil.copy2(src, efitreedir)
+
+ # the first generation mactel machines get the bootloader name wrong
+ if self.conf.efiarch == "ia32":
+ src = os.path.join(efitreedir, "grub.efi")
+ dst = os.path.join(efitreedir, "BOOT.efi")
+ shutil.copy2(src, dst)
+ src = os.path.join(efitreedir, "grub.conf")
+ dst = os.path.join(efitreedir, "BOOT.conf")
+ shutil.copy2(src, dst)
+
+ efiarch = self.conf.efiarch
+ if efiarch == "x64":
+ efiarch = efiarch.upper()
+ elif efiarch == "ia32":
+ efiarch = efiarch.upper()
+
+ src = os.path.join(efitreedir, "grub.efi")
+ dst = os.path.join(efitreedir, "BOOT%s.efi" % (efiarch,))
+ shutil.move(src, dst)
+ src = os.path.join(efitreedir, "grub.conf")
+ dst = os.path.join(efitreedir, "BOOT%s.conf" % (efiarch,))
+ shutil.move(src, dst)
+
+ # copy splash
+ src = os.path.join(self.conf.treedir, "boot", "grub", "splash.xpm.gz")
+ shutil.copy2(src, efitreedir)
+
+ # calculate the size of the efi image
+ cmd = "du -kcs %s | tail -n1 | awk '{print $1}'" % (efitreedir,)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ size = int(out) + 100
+
+ efiimage = os.path.join(self.tempdir, "efiboot.img")
+ if os.path.exists(efiimage):
+ remove(efiimage)
+
+ cmd = "mkdosfs -n ANACONDA -C %s %s > /dev/null" % (efiimage, size)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ # mount the efi image
+ efiimagedir = os.path.join(self.tempdir, "efiboot.img.d")
+ if os.path.exists(efiimagedir):
+ remove(efiimagedir)
+ os.makedirs(efiimagedir)
+
+ cmd = "mount -o loop,shortname=winnt,umask=0777 -t vfat %s %s" % \
+ (efiimage, efiimagedir)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ # copy the files to the efi image
+ copy(src_root=efitreedir, src_path="*",
+ dst_root=efiimagedir, dst_path="")
+
+ # unmount the efi image
+ cmd = "umount %s" % (efiimagedir,)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+
+ # copy the conf files to the output directory
+ if not kernelfile and not initrd:
+ copy(src_root=efitreedir, src_path="*.conf",
+ dst_root=self.conf.efibootdir, dst_path="")
+
+ return efiimage
+
+ def create_bootdisk(self, efiimage):
+ cmd = "ls -l %s | awk '{print $5}'" % (efiimage,)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ partsize = int(out)
+ disksize = 17408 + partsize + 17408
+ disksize = disksize + (disksize % 512)
+
+ efidiskimg = os.path.join(self.tempdir, "efidisk.img")
+ if os.path.exists(efidiskimg):
+ remove(efidiskimg)
+ touch(efidiskimg)
+
+ cmd = "dd if=/dev/zero of=%s count=1 bs=%s" % (efidiskimg, disksize)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ cmd = "losetup -v -f %s | awk '{print $4}'" % (efidiskimg,)
+ self.so.debug(cmd)
+ err, loop = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(loop)
+ return False
+
+ cmd = "dmsetup create efiboot --table \"0 %s linear %s 0\"" \
+ % (disksize / 512, loop)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ cmd = "parted --script /dev/mapper/efiboot" \
+ " mklabel gpt unit b mkpart '\"EFI System Partition\"'" \
+ " fat32 17408 %s set 1 boot on" % (partsize + 17408,)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ cmd = "dd if=%s of=/dev/mapper/efibootp1" % (efiimage,)
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ cmd = "dmsetup remove /dev/mapper/efibootp1"
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ cmd = "dmsetup remove /dev/mapper/efiboot"
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ cmd = "losetup -d %s" % loop
+ self.so.debug(cmd)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self.se.info(out)
+ return False
+
+ return efidiskimg
+
+ def run(self, kernelfile=None, initrd=None, kernelpath=None, initrdpath=None):
+ self.so.info("Creating the EFI image file")
+ efiimage = self.create(kernelfile, initrd)
+
+ if not efiimage:
+ sys.exit(1)
+
+ self.so.info("Creating the boot disk")
+ bootdisk = self.create_bootdisk(efiimage)
+
+ if not bootdisk:
+ sys.exit(1)
+
+ # copy the boot disk file to the output directory
+ dst = os.path.join(self.conf.imagesdir, "efidisk.img")
+ shutil.copy2(bootdisk, dst)
+
+ self.so.info("Creating the second EFI image file")
+ efiimage = self.create(kernelpath=kernelpath, initrdpath=initrdpath)
+
+ # copy the efi image to the output directory
+ dst = os.path.join(self.conf.imagesdir, "efiboot.img")
+ shutil.copy2(efiimage, dst)
class Install(object):
+
def __init__(self, config):
self.conf = config
def scrub(self):
- # move bin to usr/bin
- cp(src_root=self.conf.treedir,
- src_path=os.path.join('bin', '*'),
- dst_root=self.conf.treedir,
- dst_path=os.path.join('usr', 'bin'),
- ignore_errors=True)
-
- rm(os.path.join(self.conf.treedir, 'bin'))
+ # XXX all the install tree modification stuff goes here
+ pass
- # move sbin to /usr/sbin
- cp(src_root=self.conf.treedir,
- src_path=os.path.join('sbin', '*'),
- dst_root=self.conf.treedir,
- dst_path=os.path.join('usr', 'sbin'),
- ignore_errors=True)
-
- rm(os.path.join(self.conf.treedir, 'sbin'))
-
- # remove dirs from root
- dirs = ('boot', 'dev', 'home', 'media', 'mnt', 'opt', 'root', 'selinux', 'srv', 'sys', 'tmp', 'keymaps')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, dir))
-
- # remove dirs from usr
- dirs = ('etc', 'games', 'include', 'kerberos', 'local', 'tmp')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'usr', dir))
-
- # remove dirs from var
- dirs = ('db', 'empty', 'games', 'local', 'lock', 'log', 'mail', 'nis', 'opt', 'preserve', 'spool', 'tmp', 'yp')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'var', dir))
-
- # remove modules and firmware
- rm(os.path.join(self.conf.treedir, 'lib', 'modules'))
- rm(os.path.join(self.conf.treedir, 'lib', 'firmware'))
-
- # remove dirs from usr/lib
- dirs = ('ConsoleKit', 'X11', 'alsa-lib', 'asterisk', 'avahi', 'booty', 'db4.5*', 'enchant', 'games', 'gio', 'gnome-keyring', 'gnome-vfs-2.0',
- 'krb5', 'libglade', 'libxslt-plugins', 'lua', 'notification-daemon*', 'nss', 'openssl', 'orbit-2.0', 'perl5', 'pkgconfig', 'plymouth',
- 'pm-utils', 'pppd', 'pygtk', 'rsyslog', 'samba', 'sasl2', 'sse2', 'syslinux', 'tc', 'tls', 'udev', 'window-manager-settings')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'usr', 'lib', dir))
-
- # remove dirs from usr/share
- dirs = ('GConf', 'NetworkManager', 'aclocal', 'alsa', 'application-registry', 'applications', 'asterisk', 'augeas', 'authconfig', 'avahi',
- 'awk', 'createrepo', 'desktop-directories', 'dict', 'doc', 'dogtail', 'emacs', 'empty', 'enchant', 'file', 'firmware', 'firmware-tools',
- 'firstboot', 'games', 'gnome*', 'gnupg', 'groff', 'gtk-*', 'help', 'i18n', 'info', 'kde*', 'librarian', 'libthai', 'lua',
- 'makebootfat', 'man', 'metacity', 'mime*', 'misc', 'myspell', 'octave', 'omf', 'pkgconfig', 'plymouth', 'pygtk', 'selinux',
- 'setuptool', 'sgml', 'system-config-firewall', 'system-config-network', 'system-config-users', 'tabset', 'tc', 'usermode', 'xml',
- 'xsessions', 'yum-cli', 'magic')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'usr', 'share', dir))
-
- # remove dirs from usr/share/themes
- dirs = ('AgingGorilla', 'Atlanta', 'Bright', 'Clearlooks', 'ClearlooksClassic', 'Crux', 'Default', 'Emacs', 'Esco', 'Glider', 'Glossy',
- 'HighContrast*', 'Industrial', 'Inverted', 'LargePrint', 'LowContrast*', 'Metabox', 'Mist', 'Raleigh', 'Simple', 'ThinIce')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'usr', 'share', 'themes', dir))
-
- # remove dirs from etc
- dirs = ('ConsoleKit', 'X11', 'alternatives', 'asterisk', 'avahi', 'blkid', 'bonobo-activation', 'chkconfig.d', 'cron.*', 'default', 'depmod.d',
- 'dirmngr', 'dnsmasq.d', 'event.d', 'firmware', 'firstaidkit', 'gconf', 'gcrypt', 'gnome-vfs*', 'gnupg', 'gtk', 'hotplug', 'init.d',
- 'iproute2', 'iscsi', 'kernel', 'ld.so.conf.d', 'logrotate.d', 'lvm', 'makedev.d', 'modprobe.d', 'netplug*', 'ntp', 'openldap', 'opt',
- 'pam.d', 'pki', 'pm', 'popt.d', 'ppp', 'prelink.conf.d', 'profile.d', 'rc[0-6].d', 'rwtab.d', 'samba', 'sasl2', 'security', 'setuptool.d',
- 'skel', 'ssh', 'statetab.d', 'terminfo', 'xdg', 'xinetd.d', 'yum.repos.d')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'etc', dir))
-
- # remove dirs from lib
- dirs = ('i686', 'kbd', 'rtkaio', 'security', 'tls', 'xtables')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'lib', dir))
-
- # remove dirs from usr/libexec
- dirs = ('awk', 'gcc', 'getconf', 'openssh', 'plymouth')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'usr', 'libexec', dir))
-
- # remove dirs from usr/share/locale
- dirs = ('af_ZA', 'ca_ES', 'cs_CZ', 'de_DE', 'el_GR', 'en', 'en_US', 'es_ES', 'et_EE', 'fa_IR', 'fr_FR', 'he_IL', 'hr_HR', 'it_IT', 'ja_JP',
- 'ko_KR', 'nb_NO', 'nl_NL', 'nso', 'pl_PL', 'pt_PT', 'ru_RU', 'sr', 'sv_SE', 'uk_UA')
- for dir in dirs:
- rm(os.path.join(self.conf.treedir, 'usr', 'share', 'locale'))
-
- # remove dirs from var/cache
- dirs = ('dirmngr', 'fontconfig', 'man', 'yum')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'cache', dir)), dirs)
-
- # remove dirs from var/lib
- dirs = ('alternatives', 'asterisk', 'authconfig', 'dhclient', 'dhcpv6', 'dirmngr', 'dnsmasq', 'games', 'iscsi', 'nfs', 'ntp', 'plymouth',
- 'rpcbind', 'rpm', 'samba', 'selinux', 'sepolgen', 'stateless', 'udev', 'yum', 'logrotate.status')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'lib', dir)), dirs)
-
- # remove dirs from var/run
- dirs = ('ConsoleKit', 'NetworkManager', 'asterisk', 'avahi-daemon', 'console', 'dirmngr', 'hald', 'mdadm', 'netreport', 'plymouth',
- 'pm-utils', 'ppp', 'sepermit', 'setrans', 'winbindd', 'wpa_supplicant', 'utmp')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'run', dir)), dirs)
-
- # remove dirs from usr/share/terminfo
- dirs = ('A', 'E', 'a', 'c', 'd', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'r', 's', 't', 'w')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'terminfo', dir)), dirs)
-
- # remove dirs from usr/share/pixmaps
- dirs = ('redhat', 'splash')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'pixmaps', dir)), dirs)
-
- # remove dirs form usr/share/X11/fonts
- dirs = ('OTF', 'encodings', 'util')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'X11', 'fonts', dir)), dirs)
-
- # remove dirs from usr/lib/python2.5/site-packages
- dirs = ('firmware_addon_dell', 'firmwaretools')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'lib', 'python2.5', 'site-packages', dir)), dirs)
-
- # remove dirs from etc/rc.d
- dirs = ('rc?.d', 'rc', 'rc.local', 'rc.sysinit')
- map(lambda dir: rm(os.path.join(self.conf.treedir, 'etc', 'rc.d', dir)), dirs)
-
- def fix_links(self):
- print("Fixing broken links")
- for dir in ('bin', 'sbin'):
- dir = os.path.join(self.conf.treedir, 'usr', dir)
-
- brokenlinks = []
- for root, dnames, fnames in os.walk(dir):
- for fname in fnames:
- fname = os.path.join(root, fname)
- if os.path.islink(fname):
- target = os.readlink(fname)
- if not os.path.exists(fname):
- brokenlinks.append(fname)
-
- for link in brokenlinks:
- target = os.readlink(link)
- for dir in ('bin', 'sbin'):
- newtarget = re.sub(r'^\.\./\.\./%s/(.*)' % dir, '../%s/\g<1>' % dir, target)
- if newtarget != target:
- os.unlink(link)
- os.symlink(newtarget, link)
+ def run(self):
+ self.scrub()
diff --git a/src/pylorax/insttree.py b/src/pylorax/insttree.py
new file mode 100644
index 00000000..00c98077
--- /dev/null
+++ b/src/pylorax/insttree.py
@@ -0,0 +1,149 @@
+#
+# instroot.py
+# install root class
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# 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 .
+#
+# Red Hat Author(s): Martin Gracik
+#
+
+import os
+import glob
+
+from utils.fileutils import copy
+
+
+class InstallTree(object):
+
+ def __init__(self, config, yum, output):
+ self.conf = config
+ self.yum = yum
+
+ self.so, self.se = output
+
+ def get_packages(self):
+ required = ["anaconda", "anaconda-runtime", "/etc/gtk-2.0/gtkrc"]
+
+ # kernel packages
+ required.extend(["kernel", "*firmware*"])
+
+ # add the XEN kernel package
+ if self.conf.buildarch == "i386":
+ required.append("kernel-PAE")
+
+ # get additional packages from the configuration files
+ packages_files = []
+ packages_files.append(os.path.join(self.conf.confdir, "packages",
+ "packages.all")),
+ packages_files.append(os.path.join(self.conf.confdir, "packages",
+ "packages.%s" % (self.conf.buildarch,)))
+
+ packages = set()
+ for file in packages_files:
+ if os.path.isfile(file):
+ try:
+ f = open(file, "r")
+ except IOError as why:
+ self.se.error("Unable to read packages configuration:"
+ " %s" % (why,))
+ else:
+ for line in f.readlines():
+ line, sep, comment = line.partition("#")
+ line = line.strip()
+
+ if not line:
+ continue
+
+ if line.startswith("-"):
+ packages.discard(line[1:])
+ else:
+ packages.add(line)
+
+ f.close()
+
+ required.extend(list(packages))
+
+ # logos
+ required.extend(["%s-logos" % (self.conf.product.lower(),),
+ "%s-release" % (self.conf.product.lower(),)])
+
+ return required
+
+ def add_packages(self, packages):
+ for package in packages:
+ ok = self.yum.add_package(package)
+ if not ok:
+ self.se.warning("No package '%s' available" (package,))
+
+ def install_packages(self):
+ # XXX why do we need this?
+ os.symlink(os.path.join("/", "tmp"),
+ os.path.join(self.conf.treedir, "var", "lib", "xkb"))
+
+ self.yum.install()
+
+ def copy_updates(self):
+ if self.conf.updates and os.path.isdir(self.conf.updates):
+ copy(src_root=self.conf.updates, src_path="*",
+ dst_root=self.conf.treedir, dst_path="")
+
+ self.conf.delAttr("updates")
+
+ def fix_udev_links(self):
+ # these links are broken by default (at least on i386)
+ for filename in ("udevcontrol", "udevsettle", "udevtrigger"):
+ filename = os.path.join(self.conf.treedir, "sbin", filename)
+ if os.path.islink(filename):
+ os.unlink(filename)
+ os.symlink("udevadm", filename)
+
+ def remove_modules_broken_links(self):
+ # remove build and source links from modules directories
+ build = os.path.join(self.conf.treedir, "lib", "modules", "*", "build")
+ build_files = glob.glob(build)
+
+ source = os.path.join(self.conf.treedir, "lib", "modules", "*", "source")
+ source_files = glob.glob(source)
+
+ [os.unlink(filename) for filename in build_files + source_files
+ if os.path.islink(filename)]
+
+ def get_kernelfiles(self):
+ kerneldir = os.path.join(self.conf.treedir, "boot")
+
+ if self.conf.buildarch == "ia64":
+ kerneldir = os.path.join(kerneldir, "efi", "EFI", "redhat")
+
+ return glob.glob(os.path.join(kerneldir, "vmlinuz-*"))
+
+ def run(self):
+ self.so.info("Getting the list of packages")
+ packages = self.get_packages()
+
+ self.so.info("Running yum")
+ self.add_packages(packages)
+ self.install_packages()
+
+ self.so.info("Copying the updates")
+ self.copy_updates()
+
+ self.so.info("Fixing udev links")
+ self.fix_udev_links()
+
+ self.so.info("Removing build and source links in modules directories")
+ self.remove_modules_broken_links()
+
+ return self.get_kernelfiles()
diff --git a/src/pylorax/errors.py b/src/pylorax/misc.py
similarity index 62%
rename from src/pylorax/errors.py
rename to src/pylorax/misc.py
index b98aa225..5a1b4cb4 100644
--- a/src/pylorax/errors.py
+++ b/src/pylorax/misc.py
@@ -1,6 +1,6 @@
#
-# errors.py
-# lorax errors
+# misc.py
+# miscellaneous functions
#
# Copyright (C) 2009 Red Hat, Inc.
#
@@ -20,8 +20,22 @@
# Red Hat Author(s): Martin Gracik
#
-class LoraxError(Exception):
- pass
+import commands
-class TemplateError(Exception):
- pass
+
+def seq(arg):
+ if type(arg) not in (type([]), type(())):
+ return [arg]
+ else:
+ return arg
+
+def get_console_size():
+ err, output = commands.getstatusoutput("stty size")
+ if not err:
+ height, width = output.split()
+ height, width = int(height), int(width)
+ else:
+ # set defaults
+ height, width = 24, 80
+
+ return height, width
diff --git a/src/pylorax/output.py b/src/pylorax/output.py
index 9c6f0b38..c0794964 100644
--- a/src/pylorax/output.py
+++ b/src/pylorax/output.py
@@ -39,57 +39,80 @@ C_LIGHTRED = "\x1b[1;31m"
C_LIGHTGREEN = "\x1b[1;32m"
C_LIGHTBLUE = "\x1b[1;34m"
-C_LIGHTGRAY = "\x1b[0;37m"
-C_DARKGRAY = "\x1b[1;30m"
+# font types
+BOLD = 0b01
+UNDERLINE = 0b10
+class OutputError(Exception):
+ pass
+
class Output(object):
- def __init__(self, output=sys.stdout, colors=True, encoding=None, verbose=False):
+ def __init__(self, output=sys.stdout, colors=True, encoding="utf-8",
+ verbose=False):
+
self.output = output
+ if not hasattr(self.output, "write"):
+ raise OutputError, "output does not support write()"
+
self.is_flushable = hasattr(self.output, "flush")
self.colors = colors
- if encoding is None:
- encoding = "utf-8"
self.encoding = encoding
-
self.verbose = verbose
- def write(self, s, color=C_RESET, bold=False, underline=False):
- self.output.write(self.compose(s, color=color, bold=bold, underline=underline))
+ self.__indent_level = 0
+
+ def write(self, s, color=C_RESET, type=None):
+ s = self.format(s, color=color, type=type)
+ self.output.write(s)
if self.is_flushable:
self.output.flush()
- def compose(self, s, color=C_RESET, bold=False, underline=False):
+ def format(self, s, color=C_RESET, type=None):
s = s.encode(self.encoding)
if self.colors:
- if bold:
+ if type is not None and (type & BOLD):
s = "%s%s" % (C_BOLD, s)
- if underline:
+ if type is not None and (type & UNDERLINE):
s = "%s%s" % (C_UNDERLINE, s)
s = "%s%s%s" % (color, s, C_RESET)
return s
- def writeline(self, s, color=C_RESET, bold=False, underline=False):
- self.write("%s\n" % (s,), color=color, bold=bold, underline=underline)
+ def writeline(self, s, color=C_RESET, type=None):
+ s = "%s%s\n" % (" " * self.__indent_level, s)
+ self.write(s, color=color, type=type)
- def banner(self, s):
- self.writeline(s, color=C_BLUE, bold=True)
+ def indent(self):
+ self.__indent_level += 1
- def header(self, s):
- self.writeline(s, bold=True)
+ def unindent(self):
+ if self.__indent_level > 0:
+ self.__indent_level -= 1
- def info(self, s):
+ def newline(self):
+ self.output.write("\n")
+
+ def banner(self, s, indent_level=0):
+ self.writeline(s, color=C_GREEN, type=BOLD)
+
+ def header(self, s, indent_level=0):
+ self.writeline(s, type=BOLD)
+
+ def info(self, s, indent_level=0):
self.writeline(s)
- def error(self, s):
- self.writeline(s, color=C_RED, bold=True)
+ def error(self, s, indent_level=0):
+ self.writeline(s, color=C_RED, type=BOLD)
- def debug(self, s):
+ def warning(self, s, indent_level=0):
+ self.writeline(s, color=C_RED)
+
+ def debug(self, s, indent_level=0):
if self.verbose:
self.writeline(s)
diff --git a/src/pylorax/template.py b/src/pylorax/template.py
new file mode 100644
index 00000000..ce4efb00
--- /dev/null
+++ b/src/pylorax/template.py
@@ -0,0 +1,113 @@
+#
+# template.py
+# initrd template class
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# 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 .
+#
+# Red Hat Author(s): Martin Gracik
+#
+
+import sys
+import os
+import re
+
+
+class TemplateError(Exception):
+ pass
+
+class Template(object):
+ def __init__(self):
+ self._actions = []
+
+ self.lines = []
+ self.included_files = []
+
+ def preparse(self, filename):
+ try:
+ f = open(filename, 'r')
+ except IOError as why:
+ sys.stderr.write("ERROR: Unable to open template file '%s': %s\n" % (filename, why))
+ return False
+ else:
+ lines = f.readlines()
+ f.close()
+
+ self.included_files.append(filename)
+
+ for line in lines:
+ line = line.strip()
+
+ if line.startswith('#include'):
+ file_to_include = line.split()[1]
+ path = os.path.join(os.path.dirname(filename), file_to_include)
+ if path not in self.included_files:
+ self.preparse(path)
+ else:
+ self.lines.append(line)
+
+ def parse(self, supported_actions, variables):
+ lines = self.lines
+
+ # append next line if line ends with '\'
+ temp = []
+ for line in lines:
+ line = line.strip()
+ if line.endswith('\\'):
+ line = line[:-1]
+ line = line.rstrip()
+ line = line + ' '
+ else:
+ line = line + '\n'
+ temp.append(line)
+ temp = ''.join(temp)
+ lines = temp.splitlines()
+
+ # check template variables
+ for lineno, line in enumerate(lines, start=1):
+ for var in filter(lambda var: var not in variables, re.findall(r'@(.*?)@', line)):
+ raise TemplateError, "unknown variable '%s' on line %d" % (var, lineno)
+
+ # parse the template
+ for lineno, line in enumerate(lines, start=1):
+ line, sep, comment = line.partition('#')
+ if not line:
+ continue
+
+ # expand variables
+ for var, value in variables.items():
+ line = re.sub(r'@%s@' % var, value, line)
+
+ # get the command
+ command, line = line.split(None, 1)
+ if command not in supported_actions:
+ raise TemplateError, "unknown command '%s' on line %d" % (command, lineno)
+
+ # create the action object
+ regex = supported_actions[command].REGEX
+ m = re.match(regex, line)
+ if m:
+ new_action = supported_actions[command](**m.groupdict())
+ self._actions.append(new_action)
+ else:
+ # didn't match the regex
+ raise TemplateError, "invalid command format '%s' on line %d" % (line, lineno)
+
+ return True
+
+ @property
+ def actions(self):
+ return self._actions
+
diff --git a/src/pylorax/utils/fileutils.py b/src/pylorax/utils/fileutils.py
index 842864b4..a63211d2 100644
--- a/src/pylorax/utils/fileutils.py
+++ b/src/pylorax/utils/fileutils.py
@@ -37,25 +37,25 @@ def normalize(src_root, src_path, dst_root, dst_path):
return src, dst
-def rm(target, verbose=False):
+def remove(target, verbose=False):
for fname in glob.iglob(target):
if verbose:
- print "removing '%s'" % fname
+ print "removing '%s'" % (fname,)
- if os.path.isdir(fname):
- shutil.rmtree(fname, ignore_errors=True)
- else:
+ if os.path.islink(fname) or os.path.isfile(fname):
os.unlink(fname)
+ else:
+ shutil.rmtree(fname, ignore_errors=True)
def touch(filename, verbose=False):
if verbose:
- print "touching '%s'" % filename
+ print "touching '%s'" % (filename,)
if os.path.exists(filename):
os.utime(filename, None)
else:
try:
- f = open(filename, 'w')
+ f = open(filename, "w")
except IOError as why:
print >> sys.stderr, "cannot create '%s': %s" % (filename, why)
return False
@@ -64,49 +64,56 @@ def touch(filename, verbose=False):
return True
-def cp(src_path, dst_path, src_root='/', dst_root='/', nolinks=False, ignore_errors=False, verbose=False):
+def copy(src_path, dst_path, src_root="/", dst_root="/",
+ nolinks=False, ignore_errors=False, verbose=False):
+
filecopy = Copy(ignore_errors, verbose)
src = os.path.join(src_root, src_path)
for fname in glob.iglob(src):
- fname = fname.replace(src_root, '', 1)
+ fname = fname.replace(src_root, "", 1)
- if src_path[0] != '/' and fname[0] == '/':
+ if src_path[0] != "/" and fname[0] == "/":
fname = fname[1:]
filecopy.copy(fname, dst_path, src_root, dst_root, nolinks)
return filecopy.errors
-def mv(src_path, dst_path, src_root='/', dst_root='/', nolinks=False, ignore_errors=False, verbose=False):
- errors = cp(src_path, dst_path, src_root, dst_root, ignore_errors, verbose)
+def move(src_path, dst_path, src_root="/", dst_root="/",
+ nolinks=False, ignore_errors=False, verbose=False):
- # if everything was copied, remove the source
+ errors = copy(src_path, dst_path, src_root, dst_root,
+ nolinks, ignore_errors, verbose)
+
+ # if everything was copied ok, remove the source
if not errors:
src, dst = normalize(src_root, src_path, dst_root, dst_path)
- rm(src, verbose)
+ remove(src, verbose)
return errors
def chmod(target, mode, recursive=False, verbose=False):
+ mode = int(mode)
+
for fname in glob.iglob(target):
if verbose:
- print "changing permissions on '%s'" % fname
+ print "changing permissions on '%s'" % (fname,)
- os.chmod(fname, int(mode))
+ os.chmod(fname, mode)
if recursive and os.path.isdir(fname):
for nested in os.listdir(fname):
nested = os.path.join(fname, nested)
- chmod(nested, mode)
+ chmod(nested, mode, recursive, verbose)
def edit(filename, text, append=False, verbose=False):
- mode = 'w'
+ mode = "w"
if append:
- mode = 'a'
+ mode = "a"
if verbose:
- print "editing '%s'" % filename
+ print "editing '%s'" % (filename,)
try:
f = open(filename, mode)
@@ -144,13 +151,13 @@ class Copy(object):
self.errors = []
- def copy(self, src_path, dst_path, src_root='/', dst_root='/', nolinks=False):
+ def copy(self, src_path, dst_path, src_root="/", dst_root="/", nolinks=False):
# normalize the source and destination paths
src, dst = normalize(src_root, src_path, dst_root, dst_path)
# check if the source exists
if not os.path.exists(src):
- err_msg = "cannot stat '%s': No such file or directory" % src
+ err_msg = "cannot stat '%s': No such file or directory" % (src,)
if not self.ignore_errors:
raise self.Error, err_msg
else:
@@ -171,7 +178,7 @@ class Copy(object):
# overwrite file
try:
if self.verbose:
- print "overwriting '%s'" % dst
+ print "overwriting '%s'" % (dst,)
os.unlink(dst)
except OSError as why:
err_msg = "cannot overwrite file '%s': %s" % (dst, why)
@@ -185,7 +192,8 @@ class Copy(object):
elif os.path.isdir(dst):
# do not overwrite directory with a file
- err_msg = "cannot overwrite directory '%s' with non-directory" % dst
+ err_msg = "cannot overwrite directory '%s' with non-directory" \
+ % (dst,)
if not self.ignore_errors:
raise self.Error, err_msg
else:
@@ -198,7 +206,8 @@ class Copy(object):
if nolinks:
self.__copy_file(os.path.realpath(src), dst)
else:
- self.__copy_link(src_path, dst_path, src_root, dst_root, src, dst)
+ self.__copy_link(src_path, dst_path, src_root, dst_root,
+ src, dst)
else:
@@ -227,7 +236,8 @@ class Copy(object):
dst = os.path.join(new_dst, os.path.basename(fname))
shutil.copytree(fname, dst, symlinks=False)
else:
- self.__copy_link(src_path, dst_path, src_root, dst_root, src, new_dst)
+ self.__copy_link(src_path, dst_path, src_root, dst_root,
+ src, new_dst)
else:
@@ -236,7 +246,8 @@ class Copy(object):
os.makedirs(new_dst)
if os.path.isfile(new_dst):
- err_msg = "cannot overwrite file '%s' with a directory" % new_dst
+ err_msg = "cannot overwrite file '%s' with a directory" \
+ % (new_dst,)
if not self.ignore_errors:
raise self.Error, err_msg
else:
diff --git a/src/pylorax/utils/genmodinfo.py b/src/pylorax/utils/genmodinfo.py
deleted file mode 100644
index e0205c57..00000000
--- a/src/pylorax/utils/genmodinfo.py
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# genmodinfo.py
-# generation of modinfo
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# 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 .
-#
-# Red Hat Author(s): Martin Gracik
-#
-
-import sys
-import os
-import commands
-
-
-def genmodinfo(path, output):
- 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:
- list[modtype] = {}
- for file in modules[modtype]:
- try:
- filename = os.path.join(path, 'modules.%s' % file)
- f = open(filename, 'r')
- except IOError:
- sys.stderr.write('cannot open file %s\n', filename)
- continue
- else:
- lines = f.readlines()
- f.close()
-
- for line in lines:
- line = line.strip()
- if line in mods:
- modname, ext = os.path.splitext(line)
- if modname in blacklist:
- continue
-
- outtext = commands.getoutput('modinfo -F description %s' % mods[line])
- desc = outtext.split('\n')[0]
- desc = desc.strip()
- desc = desc[:65]
-
- if not desc:
- desc = '%s driver' % modname
- modinfo = '%s\n\t%s\n\t"%s"\n' % (modname, modtype, desc)
- list[modtype][modname] = modinfo
-
- f = open(output, 'a')
- f.write('Version 0\n')
- for type in list:
- modlist = list[type].keys()
- modlist.sort()
- for m in modlist:
- f.write('%s\n' %list[type][m])
- f.close()
diff --git a/src/pylorax/utils/ldd.py b/src/pylorax/utils/ldd.py
index 261033e5..10ddd7e3 100644
--- a/src/pylorax/utils/ldd.py
+++ b/src/pylorax/utils/ldd.py
@@ -21,48 +21,68 @@
#
import os
-import commands
import re
+import commands
class LDD(object):
- def __init__(self, libroots=['/lib', '/usr/lib']):
- f = open('/usr/bin/ldd', 'r')
+
+ def __init__(self, libroots=["/lib", "/usr/lib"]):
+ f = open("/usr/bin/ldd", "r")
for line in f.readlines():
line = line.strip()
- if line.startswith('RTLDLIST='):
- rtldlist, sep, ld_linux = line.partition('=')
+ if line.startswith("RTLDLIST="):
+ rtldlist, sep, ld_linux = line.partition("=")
break
f.close()
- self._ldd = 'LD_LIBRARY_PATH="%s" %s --list' % (':'.join(libroots), ld_linux)
+ self._lddcmd = "LD_LIBRARY_PATH=%s %s --list" % (":".join(libroots),
+ ld_linux)
+
+ pattern = r"^([a-zA-Z0-9.]*\s=>\s)(?P[a-zA-Z0-9./-]*)\s\(0x[0-9a-f]*\)$"
+ self.pattern = re.compile(pattern)
+
self._deps = set()
- def getDeps(self, filename):
- rc, output = commands.getstatusoutput('%s %s' % (self._ldd, filename))
+ self._errors = []
- if rc:
+ def is_elf(self, filename):
+ cmd = "file --brief %s" % (filename)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ return False
+
+ if not out.split()[0] == "ELF":
+ return False
+
+ return True
+
+ def getDeps(self, filename):
+ # skip no elf files
+ if not self.is_elf(filename):
return
- lines = output.splitlines()
+ cmd = "%s %s" % (self._lddcmd, filename)
+ err, out = commands.getstatusoutput(cmd)
+ if err:
+ self._errors.append((filename, out))
+ return
+
+ lines = out.splitlines()
for line in lines:
line = line.strip()
- m = re.match(r'^[a-zA-Z0-9.]*\s=>\s(?P[a-zA-Z0-9./]*)\s\(0x[0-9a-f]*\)$', line)
+ m = self.pattern.match(line)
if m:
- lib = m.group('lib')
+ lib = m.group("lib")
if lib not in self._deps:
self._deps.add(lib)
self.getDeps(lib)
- def getLinks(self):
- targets = set()
- for lib in self._deps:
- if os.path.islink(lib):
- targets.add(os.path.realpath(lib))
-
- self._deps.update(targets)
-
@property
def deps(self):
return self._deps
+
+ @property
+ def errors(self):
+ return self._errors
diff --git a/src/pylorax/utils/rpmutils.py b/src/pylorax/utils/rpmutils.py
deleted file mode 100644
index 99f2ec8b..00000000
--- a/src/pylorax/utils/rpmutils.py
+++ /dev/null
@@ -1,199 +0,0 @@
-#
-# rpmutils.py
-# yum and rpm wrappers
-#
-# Copyright (C) 2009 Red Hat, Inc.
-#
-# 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 .
-#
-# Red Hat Author(s): Martin Gracik
-#
-
-import sys
-import os
-import stat
-import yum
-import urlgrabber
-import shutil
-import commands
-
-import yum.callbacks
-import yum.rpmtrans
-
-from rpmUtils.miscutils import rpm2cpio
-from cpioarchive import CpioArchive
-
-
-def seq(arg):
- if type(arg) not in (type([]), type(())):
- return [arg]
- else:
- return arg
-
-
-def getConsoleSize():
- err, output = commands.getstatusoutput('stty size')
- if not err:
- height, width = output.split()
- else:
- # set defaults
- height, width = 24, 80
-
- return int(height), int(width)
-
-
-class Callback(yum.rpmtrans.SimpleCliCallBack):
- def __init__(self):
- yum.rpmtrans.SimpleCliCallBack.__init__(self)
- self.height, self.width = getConsoleSize()
-
- def event(self, package, action, te_current, te_total, ts_current, ts_total):
- # XXX crazy output format stuff
- progress = float(te_current) / float(te_total)
-
- percentage = int(progress * 100)
-
- bar_length = 20
- bar = int(percentage / (100/bar_length))
-
- total_progress_str = '[%s/%s] ' % (ts_current, ts_total)
- package_progress_str = ' [%s%s] %3d%%' % ('#' * bar, '-' * (bar_length - bar), percentage)
-
- action_str = '%s %s' % (self.action[action], package)
- chars_left = self.width - len(total_progress_str) - len(package_progress_str)
-
- if len(action_str) > chars_left:
- action_str = action_str[:chars_left-3]
- action_str = action_str + '...'
- else:
- action_str = action_str + ' ' * (chars_left - len(action_str))
-
- msg = total_progress_str + action_str + package_progress_str
-
- sys.stdout.write(msg)
- sys.stdout.write('\r')
-
- if percentage == 100:
- sys.stdout.write('\n')
-
- sys.stdout.flush()
-
-
-class Yum(object):
- def __init__(self, yumconf='/etc/yum/yum.conf', installroot='/', err_file='/dev/null'):
- self.yb = yum.YumBase()
-
- self.yumconf = os.path.abspath(yumconf)
- self.installroot = os.path.abspath(installroot)
- self.err_file = err_file
-
- self.yb.preconf.fn = self.yumconf
- self.yb.preconf.root = self.installroot
- self.yb._getConfig()
-
- self.yb._getRpmDB()
- self.yb._getRepos()
- self.yb._getSacks()
-
- def find(self, patterns):
- pl = self.yb.doPackageLists(patterns=seq(patterns))
- return pl.installed, pl.available
-
- def download(self, packages):
- for package in seq(packages):
- print("Downloading package %s" % package)
- fn = urlgrabber.urlgrab(package.remote_url)
- shutil.copy(fn, self.installroot)
-
- return os.path.join(self.installroot, os.path.basename(fn))
-
- def addPackages(self, patterns):
- for pattern in seq(patterns):
- print("Adding package matching %s" % pattern)
- try:
- self.yb.install(name=pattern)
- except yum.Errors.InstallError:
- try:
- self.yb.install(pattern=pattern)
- except yum.Errors.InstallError:
- sys.stderr.write("ERROR: No package matching %s available\n" % pattern)
-
- def install(self):
- self.yb.resolveDeps()
- self.yb.buildTransaction()
-
- cb = yum.callbacks.ProcessTransBaseCallback()
- #cb = yum.callbacks.ProcessTransNoOutputCallback()
- rpmcb = Callback()
-
- # XXX ugly error output hack
- # we redirect the error output from rpm to err_file,
- # so it does not show up in our "nice" output :)
- standard_err = os.dup(2)
- my_err = open(self.err_file, 'a')
- os.dup2(my_err.fileno(), 2)
- # now process the transactions without errors showing up
- self.yb.processTransaction(callback=cb, rpmDisplay=rpmcb)
- # and put the standard error output back
- os.dup2(standard_err, 2)
- my_err.close()
-
- self.yb.closeRpmDB()
- self.yb.close()
-
-
-def extractRPM(rpmfile, destdir):
- if not os.path.isdir(destdir):
- os.makedirs(destdir)
-
- rpm = os.open(rpmfile, os.O_RDONLY)
- output = open(os.path.join(destdir, 'CONTENT.cpio'), 'w')
-
- rpm2cpio(rpm, output)
- output.close()
-
- cwd = os.getcwd()
- os.chdir(destdir)
-
- cpio = CpioArchive(name=output.name)
- for entry in cpio:
- path = os.path.abspath(entry.name)
- isdir = stat.S_ISDIR(entry.mode)
-
- if isdir:
- if not os.path.isdir(path):
- os.makedirs(path)
- else:
- print("Extracting %s" % entry.name)
- dir = os.path.dirname(path)
- if not os.path.isdir(dir):
- os.makedirs(dir)
-
- try:
- f = open(path, 'w')
- except IOError:
- sys.stderr.write("ERROR: Unable to extract file %s\n" % path)
- else:
- f.write(entry.read())
- f.close()
-
- os.chmod(path, entry.mode)
- os.chown(path, entry.uid, entry.gid)
-
- cpio.close()
- os.unlink(output.name)
-
- os.chdir(cwd)
-
- return True
diff --git a/src/pylorax/utils/yumwrapper.py b/src/pylorax/utils/yumwrapper.py
new file mode 100644
index 00000000..53adfdf3
--- /dev/null
+++ b/src/pylorax/utils/yumwrapper.py
@@ -0,0 +1,129 @@
+#
+# yumwrapper.py
+# yum wrapper
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# 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 .
+#
+# Red Hat Author(s): Martin Gracik
+#
+
+import sys
+import os
+import yum
+import yum.callbacks
+import yum.rpmtrans
+
+from pylorax.misc import seq, get_console_size
+
+
+class Callback(yum.rpmtrans.SimpleCliCallBack):
+
+ def __init__(self):
+ yum.rpmtrans.SimpleCliCallBack.__init__(self)
+ self.height, self.width = get_console_size()
+
+ def event(self, package, action, te_current, te_total, ts_current, ts_total):
+ progress = float(te_current) / float(te_total)
+ percentage = int(progress * 100)
+
+ bar_length = 20
+ bar = int(percentage / (100 / bar_length))
+
+ total_progress_str = "[%s/%s] " % (ts_current, ts_total)
+ package_progress_str = " [%s%s] %3d%%" % ("#" * bar, "-" * (bar_length - bar),
+ percentage)
+
+ action_str = "%s %s" % (self.action[action], package)
+ chars_left = self.width - len(total_progress_str) - len(package_progress_str)
+
+ if len(action_str) > chars_left:
+ action_str = action_str[:chars_left-3]
+ action_str = action_str + "..."
+ else:
+ action_str = action_str + " " * (chars_left - len(action_str))
+
+ msg = total_progress_str + action_str + package_progress_str
+
+ sys.stdout.write(msg)
+ sys.stdout.write("\r")
+
+ if percentage == 100:
+ sys.stdout.write("\n")
+
+ sys.stdout.flush()
+
+
+class Yum(object):
+
+ def __init__(self, yumconf="/etc/yum/yum.conf", installroot="/",
+ errfile="/dev/null"):
+
+ self.yb = yum.YumBase()
+
+ self.yumconf = os.path.abspath(yumconf)
+ self.installroot = os.path.abspath(installroot)
+ self.errfile = errfile
+
+ self.yb.preconf.fn = self.yumconf
+ self.yb.preconf.root = self.installroot
+ self.yb._getConfig()
+
+ self.yb._getRpmDB()
+ self.yb._getRepos()
+ self.yb._getSacks()
+
+ def find(self, patterns):
+ pl = self.yb.doPackageLists(patterns=seq(patterns))
+ return pl.installed, pl.available
+
+ def add_package(self, pattern):
+ try:
+ self.yb.install(name=pattern)
+ except yum.Errors.InstallError:
+ # didn't find an exact package name match
+ try:
+ self.yb.install(pattern=pattern)
+ except yum.Errors.InstallError:
+ # no package found
+ return False
+
+ return True
+
+ def install(self):
+ self.yb.resolveDeps()
+ self.yb.buildTransaction()
+
+ cb = yum.callbacks.ProcessTransBaseCallback()
+ #cb = yum.callbacks.ProcessTransNoOutputCallback()
+ rpmcb = Callback()
+
+ # XXX ATTENTION! ugly rpm error output hack
+ # we redirect the error output from rpm to errfile,
+ # so it does not show up in our "nice" output
+ # 2 = err descriptor
+ standard_err = os.dup(2)
+ my_err = open(self.errfile, "a")
+ os.dup2(my_err.fileno(), 2)
+
+ # now we process the transactions without errors showing up in the output
+ self.yb.processTransaction(callback=cb, rpmDisplay=rpmcb)
+
+ # and we put the standard error output back, so nobody will notice
+ os.dup2(standard_err, 2)
+ my_err.close()
+
+ self.yb.closeRpmDB()
+ self.yb.close()