New version
I fixed a lot of bugs with copying files to the initrd, and getting the symlinks. Also I moved some of the code around, to get a clearer flow.
This commit is contained in:
parent
6a6be7ef01
commit
272ec190c7
@ -1,6 +1,6 @@
|
|||||||
# initrd template
|
# initrd template
|
||||||
|
|
||||||
#include includes/initrd/initrd.common
|
#include includes/initrd.common
|
||||||
|
|
||||||
# loader
|
# loader
|
||||||
copy @instroot@ usr/lib/anaconda-runtime/loader/init to @initrd@ sbin/init
|
copy @instroot@ usr/lib/anaconda-runtime/loader/init to @initrd@ sbin/init
|
@ -1,6 +1,6 @@
|
|||||||
# initrd template
|
# initrd template
|
||||||
|
|
||||||
#include includes/initrd/initrd.common
|
#include includes/initrd.common
|
||||||
|
|
||||||
# create required directories
|
# create required directories
|
||||||
makedir @initrd@/var/empty/sshd mode 0111
|
makedir @initrd@/var/empty/sshd mode 0111
|
@ -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
|
joe
|
||||||
krb5-libs
|
gnome-icon-theme
|
||||||
less
|
fedora-icon-theme
|
||||||
man
|
xorg-x11-server-Xorg
|
||||||
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
|
||||||
firstaidkit-plugin-all
|
bzip2
|
||||||
dialog
|
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
|
@ -1,7 +1,3 @@
|
|||||||
-glibc
|
|
||||||
-openssl
|
|
||||||
glibc.i386
|
|
||||||
openssl.i386
|
|
||||||
pcmciautils
|
pcmciautils
|
||||||
grub
|
grub
|
||||||
dmidecode
|
dmidecode
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
-glibc
|
|
||||||
-openssl
|
|
||||||
glibc.i586
|
|
||||||
openssl.i586
|
|
||||||
pcmciautils
|
|
||||||
grub
|
|
||||||
dmidecode
|
|
||||||
efibootmgr
|
|
||||||
gpart
|
|
||||||
syslinux
|
|
||||||
memtest86+
|
|
1
etc/packages/packages.i586
Symbolic link
1
etc/packages/packages.i586
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
packages.i386
|
@ -1,7 +0,0 @@
|
|||||||
pcmciautils
|
|
||||||
grub
|
|
||||||
dmidecode
|
|
||||||
efibootmgr
|
|
||||||
gpart
|
|
||||||
syslinux
|
|
||||||
memtest86+
|
|
1
etc/packages/packages.x86_64
Symbolic link
1
etc/packages/packages.x86_64
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
packages.i386
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
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 <version> --product <product> --release <comment> [--output outputdir] [--discs <discstring>] <root>" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
PRODUCTPATH="anaconda"
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case $1 in
|
|
||||||
# general options affecting how we build things
|
|
||||||
--nogr)
|
|
||||||
NOGRSTR="--nogr"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--debug)
|
|
||||||
DEBUGSTR="--debug"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
# release information
|
|
||||||
--version)
|
|
||||||
VERSION=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--release)
|
|
||||||
RELEASESTR=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--product)
|
|
||||||
PRODUCTSTR=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--variant)
|
|
||||||
VARIANT=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--bugurl)
|
|
||||||
BUGURL=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--output)
|
|
||||||
OUTPUT=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--updates)
|
|
||||||
UPDATES=$2
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
--mirrorlist)
|
|
||||||
MIRRORLIST="$MIRRORLIST $2"
|
|
||||||
shift; shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
if [ -z "$REPO" ]; then
|
|
||||||
REPO=$1
|
|
||||||
else
|
|
||||||
EXTRA_REPOS="$EXTRA_REPOS $1"
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$PRODUCTSTR" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$VERSION" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$REPO" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$RELEASESTR" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$BUGURL" ]; then
|
|
||||||
BUGURL="your distribution provided bug reporting tool."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$REPO" =~ ^/ ]]; then
|
|
||||||
[ -n "$OUTPUT" ] || OUTPUT=$REPO
|
|
||||||
REPO="file://$REPO"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$OUTPUT" ]; then
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$OUTPUT" ]; then
|
|
||||||
mkdir -p $OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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 <<EOF
|
|
||||||
[main]
|
|
||||||
cachedir=$CACHEDIR
|
|
||||||
keepcache=0
|
|
||||||
gpgcheck=0
|
|
||||||
plugins=0
|
|
||||||
reposdir=
|
|
||||||
tsflags=nodocs
|
|
||||||
|
|
||||||
[anacondarepo]
|
|
||||||
name=anaconda repo
|
|
||||||
baseurl=$REPO
|
|
||||||
enabled=1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
n=1
|
|
||||||
for r in $EXTRA_REPOS; do
|
|
||||||
if [[ $r =~ ^/ ]]; then
|
|
||||||
r="file://$r"
|
|
||||||
fi
|
|
||||||
cat >> $yumconf <<EOF
|
|
||||||
|
|
||||||
[anaconda-extrarepo-$n]
|
|
||||||
name=anaconda extra repo $n
|
|
||||||
baseurl=$r
|
|
||||||
enabled=1
|
|
||||||
EOF
|
|
||||||
let n++
|
|
||||||
done
|
|
||||||
|
|
||||||
n=1
|
|
||||||
for l in $MIRRORLIST; do
|
|
||||||
cat >> $yumconf <<EOF
|
|
||||||
|
|
||||||
[anaconda-mirrorlistrepo-$n]
|
|
||||||
name=anaconda mirrorlist repo $n
|
|
||||||
mirrorlist=$l
|
|
||||||
enabled=1
|
|
||||||
EOF
|
|
||||||
let n++
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Running buildinstall..."
|
|
||||||
|
|
||||||
pushd $BUILDINSTDIR
|
|
||||||
BUILDARCH=`repoquery -c $yumconf --qf "%{ARCH}\n" anaconda`
|
|
||||||
# This is a crappy implementation but x86 is the only place we currently see
|
|
||||||
# BUILDARCH != BASEARCH (e.g. i586 != i386) so it'll suffice.
|
|
||||||
BASEARCH=`echo $BUILDARCH | sed -e 's/i.86/i386/'`
|
|
||||||
yumdownloader -c $yumconf anaconda || exit 1
|
|
||||||
rpm2cpio anaconda*rpm | cpio --quiet -iumd './usr*'
|
|
||||||
rm -f anaconda*rpm
|
|
||||||
popd
|
|
||||||
|
|
||||||
UPD_INSTROOT=./upd-instroot
|
|
||||||
MK_IMAGES=./mk-images
|
|
||||||
MK_TREEINFO=./maketreeinfo.py
|
|
||||||
MK_STAMP=./makestamp.py
|
|
||||||
BUILDINSTALL=./buildinstall
|
|
||||||
|
|
||||||
for f in $UPD_INSTROOT $MK_IMAGES $MK_STAMP $MK_TREEINFO $BUILDINSTALL; do
|
|
||||||
if [ -n "$UPDATES" -a -f $UPDATES/usr/lib/anaconda-runtime/$f ]; then
|
|
||||||
cp -a $UPDATES/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
|
|
||||||
elif [ ! -f $f ]; then
|
|
||||||
cp -a $BUILDINSTDIR/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
|
|
||||||
else
|
|
||||||
cp -a $f* $BUILDINSTDIR/
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
UPD_INSTROOT=$BUILDINSTDIR/upd-instroot
|
|
||||||
MK_IMAGES=$BUILDINSTDIR/mk-images
|
|
||||||
MK_TREEINFO=$BUILDINSTDIR/maketreeinfo.py
|
|
||||||
MK_STAMP=$BUILDINSTDIR/makestamp.py
|
|
||||||
BUILDINSTALL=$BUILDINSTDIR/buildinstall
|
|
||||||
|
|
||||||
if [ -n "$UPDATES" ]; then UPDATES="--updates $UPDATES"; fi
|
|
||||||
|
|
||||||
echo "Building images..."
|
|
||||||
$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH $UPDATES --imgdir $TREEDIR/install $yumconf || die "upd-instroot failed"
|
|
||||||
|
|
||||||
echo "Writing .treeinfo file..."
|
|
||||||
# NOTE --arch must match MK_IMAGES or the resulting treeinfo will be invalid
|
|
||||||
$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BASEARCH --outfile=$OUTPUT/.treeinfo
|
|
||||||
|
|
||||||
# FIXME: need to update mk-images to take the yumconf
|
|
||||||
MKIMGCMD="$MK_IMAGES $DEBUGSTR $NOGRSTR --imgdir $TREEDIR/install --arch $BASEARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" --output $OUTPUT $yumconf"
|
|
||||||
echo "Making images: $PWD\$ $MKIMGCMD"
|
|
||||||
$MKIMGCMD || die "image creation failed"
|
|
||||||
|
|
||||||
echo "Writing .discinfo file"
|
|
||||||
$MK_STAMP --releasestr="$RELEASESTR" --arch=$BASEARCH --discNum="ALL" --outfile=$OUTPUT/.discinfo
|
|
||||||
|
|
||||||
rm -rf $TREEDIR $BUILDINSTDIR
|
|
||||||
rm -f $yumconf
|
|
@ -1,140 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# pulled right out of mkinitrd....
|
|
||||||
DSO_DEPS=""
|
|
||||||
LDSO=""
|
|
||||||
get_dso_deps() {
|
|
||||||
root="$1" ; shift
|
|
||||||
bin="$1" ; shift
|
|
||||||
LDSODIR="$1" ; shift
|
|
||||||
DSO_DEPS=""
|
|
||||||
|
|
||||||
declare -a FILES
|
|
||||||
declare -a NAMES
|
|
||||||
[ -z "$LDSODIR" ] && LDSODIR=$LIBDIR
|
|
||||||
|
|
||||||
# this is a hack, but the only better way requires binutils or elfutils
|
|
||||||
# be installed. i.e., we need readelf to find the interpretter.
|
|
||||||
$LDSO --verify $bin >/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 <<EOF
|
|
||||||
There are missing files on your system. The dynamic object $bin
|
|
||||||
requires ${NAMES[$n]} n order to properly function. mkinitrd cannot continue.
|
|
||||||
EOF
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
case "$FILE" in
|
|
||||||
/lib*)
|
|
||||||
TLIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'`
|
|
||||||
BASE=`basename "$FILE"`
|
|
||||||
# Prefer nosegneg libs over direct segment accesses on i686.
|
|
||||||
if [ -f "$TLIBDIR/i686/nosegneg/$BASE" ]; then
|
|
||||||
FILE="$TLIBDIR/i686/nosegneg/$BASE"
|
|
||||||
# Otherwise, prefer base libraries rather than their optimized
|
|
||||||
# variants.
|
|
||||||
elif [ -f "$TLIBDIR/$BASE" ]; then
|
|
||||||
FILE="$TLIBDIR/$BASE"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
dynamic="yes"
|
|
||||||
let n++
|
|
||||||
done
|
|
||||||
|
|
||||||
DSO_DEPS="${FILES[@]}"
|
|
||||||
|
|
||||||
for l in $(/usr/sbin/chroot $root find /$LDSODIR -maxdepth 1 -type l -name ld*.so*); do
|
|
||||||
[ "$(/usr/sbin/chroot $root readlink -f $l)" == "$LDSO" ] && DSO_DEPS="$DSO_DEPS $l"
|
|
||||||
done
|
|
||||||
if [ "$(uname -m)" == "s390x" ]; then
|
|
||||||
for l in $(/usr/sbin/chroot $root find /lib -maxdepth 1 -type 1 -name ld*.so*); do
|
|
||||||
[ "$(/usr/sbin/chroot $root readlink -f $l)" == "$LDSO" ] && DSO_DEPS="$DSO_DEPS $l"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -n "$DEBUG" ] && echo "DSO_DEPS for $bin are $DSO_DEPS"
|
|
||||||
}
|
|
||||||
|
|
||||||
instFile() {
|
|
||||||
FILE=$1
|
|
||||||
DESTROOT=$2
|
|
||||||
|
|
||||||
[ -n "$DEBUG" ] && echo "Installing $FILE"
|
|
||||||
if [ -e $DESTROOT/$FILE -o -L $DESTROOT/$FILE ]; then
|
|
||||||
return
|
|
||||||
elif [ ! -d $DESTROOT/`dirname $FILE` ]; then
|
|
||||||
mkdir -p $DESTROOT/`dirname $FILE`
|
|
||||||
fi
|
|
||||||
if [ -L $FILE ]; then
|
|
||||||
cp -al $FILE $DESTROOT/`dirname $FILE`
|
|
||||||
instFile ./`dirname $FILE`/`readlink $FILE` $DESTROOT
|
|
||||||
return
|
|
||||||
else
|
|
||||||
cp -aL $FILE $DESTROOT/`dirname $FILE`
|
|
||||||
fi
|
|
||||||
|
|
||||||
f=$(file $FILE)
|
|
||||||
echo $f | egrep -q ": (setuid )?ELF" && {
|
|
||||||
if echo $f | grep -q " 64-bit " ; then
|
|
||||||
get_dso_deps $(pwd) "$FILE" lib64
|
|
||||||
else
|
|
||||||
get_dso_deps $(pwd) "$FILE" lib
|
|
||||||
fi
|
|
||||||
local DEPS="$DSO_DEPS"
|
|
||||||
for x in $DEPS ; do
|
|
||||||
instFile ./$x $DESTROOT
|
|
||||||
done
|
|
||||||
}
|
|
||||||
unset f
|
|
||||||
}
|
|
||||||
|
|
||||||
instDir() {
|
|
||||||
DIR=$1
|
|
||||||
DESTROOT=$2
|
|
||||||
|
|
||||||
[ -n "$DEBUG" ] && echo "Installing $DIR"
|
|
||||||
if [ -d $DESTROOT/$DIR -o -h $DESTROOT/$DIR ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
cp -a --parents $DIR $DESTROOT/
|
|
||||||
}
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# getkeymaps
|
|
||||||
#
|
|
||||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
ARCH=$1
|
|
||||||
if [ -z "$ARCH" ]; then
|
|
||||||
echo "usage: $0 <arch>"
|
|
||||||
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
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
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]))
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
import os,sys,string
|
|
||||||
import getopt
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
args = ""
|
|
||||||
for key in data:
|
|
||||||
args = "%s [--%s=%s]" %(args, key, key)
|
|
||||||
print("%s: %s" % (sys.argv[0], args))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
data = {"timestamp": None,
|
|
||||||
"releasestr": None,
|
|
||||||
"arch": None,
|
|
||||||
"discNum": None,
|
|
||||||
"outfile": None}
|
|
||||||
allDiscs = None
|
|
||||||
|
|
||||||
opts = []
|
|
||||||
for key in data.keys():
|
|
||||||
opts.append("%s=" % (key,))
|
|
||||||
opts.append("allDiscs")
|
|
||||||
|
|
||||||
(args, extra) = getopt.getopt(sys.argv[1:], '', opts)
|
|
||||||
if len(extra) > 0:
|
|
||||||
print("had extra args: %s" % extra)
|
|
||||||
usage()
|
|
||||||
|
|
||||||
for (str, arg) in args:
|
|
||||||
if str[2:] in data.keys():
|
|
||||||
data[str[2:]] = arg
|
|
||||||
elif str == "--allDiscs":
|
|
||||||
allDiscs = 1
|
|
||||||
else:
|
|
||||||
print("unknown str of ", str)
|
|
||||||
usage()
|
|
||||||
|
|
||||||
if data["timestamp"] is None:
|
|
||||||
sys.stderr.write("timestamp not specified; using the current time\n")
|
|
||||||
data["timestamp"] = time.time()
|
|
||||||
else:
|
|
||||||
data["timestamp"] = float(data["timestamp"])
|
|
||||||
|
|
||||||
if data["releasestr"] is None:
|
|
||||||
print("What should be the release name associated with this disc?\n")
|
|
||||||
data["releasestr"] = sys.stdin.readline()[:-1]
|
|
||||||
|
|
||||||
if data["arch"] is None:
|
|
||||||
print("What arch is this disc for?")
|
|
||||||
data["arch"] = sys.stdin.readline()[:-1]
|
|
||||||
|
|
||||||
if data["discNum"] is None and allDiscs is None:
|
|
||||||
sys.stderr.write("No disc number specified; assuming disc 1\n")
|
|
||||||
data["discNum"] = "1"
|
|
||||||
|
|
||||||
if data["outfile"] is None:
|
|
||||||
f = sys.stdout
|
|
||||||
else:
|
|
||||||
f = open(data["outfile"], "w")
|
|
||||||
|
|
||||||
f.write("%f\n" % data["timestamp"])
|
|
||||||
f.write("%s\n" % data["releasestr"])
|
|
||||||
f.write("%s\n" % data["arch"])
|
|
||||||
if allDiscs is None:
|
|
||||||
f.write("%s\n" % data["discNum"])
|
|
||||||
else:
|
|
||||||
f.write("0\n")
|
|
||||||
|
|
||||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Author(s): Will Woods <wwoods@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
import os,sys,string
|
|
||||||
import getopt
|
|
||||||
import time
|
|
||||||
import ConfigParser
|
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
args = ""
|
|
||||||
for key in data:
|
|
||||||
args = "%s [--%s=%s]" %(args, key, key)
|
|
||||||
print("%s: %s" % (sys.argv[0], args))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# TODO: add composeid, images, etc.
|
|
||||||
# TODO: take releasestr as an option and break it up into family/variant/version?
|
|
||||||
|
|
||||||
data = {"timestamp": time.time(),
|
|
||||||
"family": None,
|
|
||||||
"variant": None,
|
|
||||||
"version": None,
|
|
||||||
"arch": None,
|
|
||||||
"discnum": None,
|
|
||||||
"totaldiscs": None,
|
|
||||||
"packagedir": None,
|
|
||||||
"outfile": None}
|
|
||||||
allDiscs = None
|
|
||||||
|
|
||||||
opts = []
|
|
||||||
for key in data.keys():
|
|
||||||
opts.append("%s=" % (key,))
|
|
||||||
opts.append("allDiscs")
|
|
||||||
|
|
||||||
(args, extra) = getopt.getopt(sys.argv[1:], '', opts)
|
|
||||||
if len(extra) > 0:
|
|
||||||
print("had extra args: %s" % extra)
|
|
||||||
usage()
|
|
||||||
|
|
||||||
for (str, arg) in args:
|
|
||||||
if str[2:] in data.keys():
|
|
||||||
data[str[2:]] = arg
|
|
||||||
elif str == "--allDiscs":
|
|
||||||
allDiscs = 1
|
|
||||||
else:
|
|
||||||
print("unknown str of ", str)
|
|
||||||
usage()
|
|
||||||
|
|
||||||
# Make sure timestamp is actually a float
|
|
||||||
if type(data["timestamp"]) != float:
|
|
||||||
data["timestamp"] = float(data["timestamp"])
|
|
||||||
|
|
||||||
if data["family"] is None:
|
|
||||||
sys.stderr.write("--family missing! This is probably bad!\n")
|
|
||||||
data["family"] = ""
|
|
||||||
|
|
||||||
if data["variant"] is None:
|
|
||||||
sys.stderr.write("--variant missing, but that's OK.\n")
|
|
||||||
data["variant"] = ""
|
|
||||||
|
|
||||||
if data["version"] is None:
|
|
||||||
sys.stderr.write("--version missing! This is probably bad!\n")
|
|
||||||
data["version"] = ""
|
|
||||||
|
|
||||||
if data["arch"] is None:
|
|
||||||
sys.stderr.write("--arch missing! This is probably bad!\n")
|
|
||||||
data["arch"] = ""
|
|
||||||
|
|
||||||
if data["discnum"] is None and allDiscs is None:
|
|
||||||
sys.stderr.write("--discnum missing; assuming disc 1\n")
|
|
||||||
data["discnum"] = "1"
|
|
||||||
|
|
||||||
if data["totaldiscs"] is None and allDiscs is None:
|
|
||||||
sys.stderr.write("--totaldiscs missing; assuming 1\n")
|
|
||||||
data["totaldiscs"] = "1"
|
|
||||||
|
|
||||||
if data["packagedir"] is None:
|
|
||||||
sys.stderr.write("--packagedir missing. This might cause some weirdness.\n")
|
|
||||||
data["packagedir"] = ""
|
|
||||||
|
|
||||||
|
|
||||||
if data["outfile"] is None:
|
|
||||||
f = sys.stdout
|
|
||||||
else:
|
|
||||||
f = open(data["outfile"], "w")
|
|
||||||
|
|
||||||
section='general'
|
|
||||||
c=ConfigParser.ConfigParser()
|
|
||||||
c.add_section(section)
|
|
||||||
for k,v in data.items():
|
|
||||||
if k != 'outfile':
|
|
||||||
c.set(section,k,v)
|
|
||||||
c.write(f)
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Author: David Cantrell <dcantrell@redhat.com>
|
|
||||||
|
|
||||||
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)
|
|
File diff suppressed because it is too large
Load Diff
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
INITRDMODS="tgafb crc32 $INITRDMODS"
|
|
||||||
|
|
||||||
###FSMODS="msdos vfat ext3 reiserfs jfs xfs"
|
|
||||||
###IDEMODS="cdrom ide-cd"
|
|
||||||
###SCSIMODS="cdrom scsi_mod sd_mod sg sr_mod st"
|
|
||||||
###USBMODS="ohci-hcd uhci-hcd hid usb-storage sd_mod sr_mod"
|
|
||||||
###LATEUSBMODS="mousedev usb-storage"
|
|
||||||
###SECSTAGE="md raid0 raid1 raid5 dm-mod srm_env $FSMODS $IDEMODS $SCSIMODS $LATEUSBMODS"
|
|
||||||
NETMODULES="e100 tulip 8139too tulip 3c509 3c59x dl2k eepro epic100 ewrk3 hamachi natsemi ne2k-pci ns83820 starfire yellowfin de4x5 depca acenic tg3"
|
|
||||||
|
|
||||||
SCSIMODULES="$SCSIMODS qlogicisp DAC960 cpqfc BusLogic 3w-xxxx dmx3191d dpt_i2o megaraid ncr53c8xx sym53c8xx qlogicfc qla2x00 qla1280 cciss cpqarray aic7xxx aha1740 megaraid"
|
|
||||||
|
|
||||||
###ISOMODULES="ehci-hcd ieee1394 ohci1394 sbp2"
|
|
||||||
|
|
||||||
prepareBootImage() {
|
|
||||||
echo "ALPHA: prepareBootImage() is called"
|
|
||||||
dd if=/dev/zero of=$MBD_TMPIMAGE bs=1k count=$BOOTDISKSIZE 2>/dev/null
|
|
||||||
echo y | /sbin/mke2fs -b 1024 -r 0 -O none $MBD_TMPIMAGE > /dev/null 2>/dev/null
|
|
||||||
LODEV=`findloopdevice $MBD_TMPIMAGE`
|
|
||||||
e2writeboot $LODEV $BOOTDISKDIR/bootlx
|
|
||||||
mount $LODEV -t ext2 $MBD_BOOTTREE
|
|
||||||
mkdir -p $MBD_BOOTTREE/etc
|
|
||||||
cat > $MBD_BOOTTREE/etc/aboot.conf <<EOF
|
|
||||||
#
|
|
||||||
# Fedora Linux aboot configuration options:
|
|
||||||
#
|
|
||||||
# 0 - Boot the Fedora Linux installer using a 2.6 kernel
|
|
||||||
# 1 - Boot the Fedora Linux installer in non graphical mode
|
|
||||||
# 2 - Boot the Fedora Linux installer in text only mode on ttyS0
|
|
||||||
# for installation control via the serial port
|
|
||||||
# 3 - Boot in rescue mode
|
|
||||||
#
|
|
||||||
0:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 root=/dev/fd0
|
|
||||||
1:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 text root=/dev/fd0
|
|
||||||
2:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=ttyS0 text root=/dev/fd0
|
|
||||||
3:vmlinux.gz load_ramdisk=1 prompt_ramdisk=1 console=tty0 rescue root=/dev/fd0
|
|
||||||
|
|
||||||
EOF
|
|
||||||
cat > $MBD_BOOTTREE/etc/milo.conf <<EOF
|
|
||||||
image=/vmlinux.gz
|
|
||||||
label=linux
|
|
||||||
root=/dev/fd0
|
|
||||||
append="load_ramdisk=1 prompt_ramdisk=1"
|
|
||||||
EOF
|
|
||||||
zcat $KERNELROOT/boot/vmlinuz-* | gzip -9 > $MBD_BOOTTREE/vmlinux.gz
|
|
||||||
umount $LODEV
|
|
||||||
losetup -d $LODEV
|
|
||||||
mount -o loop -t ext2 $MBD_TMPIMAGE $MBD_BOOTTREE
|
|
||||||
}
|
|
||||||
|
|
||||||
makeBootImages() {
|
|
||||||
echo "Building boot images for kernel $kernelvers"
|
|
||||||
|
|
||||||
mkdir -p $TOPDESTPATH/boot
|
|
||||||
cp $BOOTDISKDIR/bootlx $TOPDESTPATH/boot
|
|
||||||
|
|
||||||
mkdir -p $TOPDESTPATH/etc
|
|
||||||
cat > $TOPDESTPATH/etc/aboot.conf <<EOF
|
|
||||||
#
|
|
||||||
# Fedora Linux aboot configuration options:
|
|
||||||
#
|
|
||||||
# 0 - Boot the Fedora Linux installer using a 2.6 kernel
|
|
||||||
# 1 - Boot the Fedora Linux installer with kernel messages sent to ttyS0
|
|
||||||
# 2 - Boot the Fedora Linux installer in text only mode
|
|
||||||
# 3 - Boot the Fedora Linux installer in text only rescue mode
|
|
||||||
#
|
|
||||||
0:/kernels/vmlinux.gz initrd=/images/initrd.img
|
|
||||||
1:/kernels/vmlinux.gz initrd=/images/initrd.img console=ttyS0
|
|
||||||
2:/kernels/vmlinux.gz initrd=/images/initrd.img text
|
|
||||||
3:/kernels/vmlinux.gz initrd=/images/initrd.img rescue
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
mkdir -p $TOPDESTPATH/kernels
|
|
||||||
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/kernels/vmlinux.gz
|
|
||||||
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/images/ramdisk.img \
|
|
||||||
--initrdsize 8192 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$NETMODULES $SCSIMODULES"
|
|
||||||
|
|
||||||
echo "List of init modules: $INITRDMODS"
|
|
||||||
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
|
|
||||||
--initrdsize 8192 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS"
|
|
||||||
|
|
||||||
# makebootdisk --bootdisksize 4096 --kernelto $TOPDESTPATH/kernels/vmlinux.gz \
|
|
||||||
# --imagename generic.img
|
|
||||||
|
|
||||||
|
|
||||||
if [ -f $KERNELPATH/kernel-jensen-*.rpm ]; then
|
|
||||||
KJ_PKG=$KERNELPATH/kernel-jensen-*.rpm
|
|
||||||
KJ_DIR=/tmp/kernelj.dir.$$
|
|
||||||
mkdir -p $KJ_DIR
|
|
||||||
rpm2cpio $KJ_PKG | (cd $KJ_DIR; cpio --quiet -iumd ./boot/vmlinuz-*)
|
|
||||||
cp $KJ_DIR/boot/vmlinuz-* $TOPDESTPATH/kernels/vmlinuz.j
|
|
||||||
rm -rf $KJ_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# makedriverdisk --padsize 1440 "Supplemental Block Device Drivers" "drvblock" "$SCSIMODULES $EXTRASCSI +scsi"
|
|
||||||
# makedriverdisk --padsize 1440 "Supplemental Network Device Drivers" "drvnet" "$NETMODULES $EXTRANET +net"
|
|
||||||
}
|
|
||||||
|
|
||||||
#makeSecondStage() {
|
|
||||||
# makeinstimage "netstg" "$SECSTAGE $SCSIMODULES $IDEMODS =scsi"
|
|
||||||
# makeinstimage "hdstg" "$SECSTAGE $NETMODULES $IDEMODS =net"
|
|
||||||
# makemainmodules "$SECSTAGE $NETMODULES $SCSIMODULES $IDEMODS =scsi =net"
|
|
||||||
# makemainimage "install" "cramfs"
|
|
||||||
#}
|
|
||||||
|
|
@ -1,245 +0,0 @@
|
|||||||
#
|
|
||||||
# mk-images.efi
|
|
||||||
#
|
|
||||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
makeefibootdisk()
|
|
||||||
{
|
|
||||||
partimg=$1
|
|
||||||
target=$2
|
|
||||||
|
|
||||||
if [ ! -f $1 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
local partsize=$(ls -l $1 | awk '{ print $5; }')
|
|
||||||
local disksize=$((17408 + $partsize + 17408))
|
|
||||||
disksize=$(($disksize + $(($disksize % 512))))
|
|
||||||
local diskimg=$(mktemp /tmp/efidisk.img.XXXXXX)
|
|
||||||
dd if=/dev/zero of=$diskimg count=1 bs=$disksize
|
|
||||||
local loop=$(losetup -v -f $diskimg | awk '{ print $4 }')
|
|
||||||
dmsetup create efiboot$$ --table "0 $(($disksize / 512)) linear $loop 0"
|
|
||||||
parted --script /dev/mapper/efiboot$$ mklabel gpt unit b mkpart '"EFI System Partition"' fat32 17408 $((17408 + $partsize)) set 1 boot on
|
|
||||||
dd if=$partimg of=/dev/mapper/efiboot$$p1
|
|
||||||
dmsetup remove /dev/mapper/efiboot$$p1
|
|
||||||
dmsetup remove /dev/mapper/efiboot$$
|
|
||||||
losetup -d $loop
|
|
||||||
|
|
||||||
mv -v $diskimg $target
|
|
||||||
chmod a+r $target
|
|
||||||
}
|
|
||||||
|
|
||||||
#makeefibootimage required for EFI bootloader dosfs image
|
|
||||||
makeefibootimage() {
|
|
||||||
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
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
#makebootdisk required for EFI bootloader dosfs image
|
|
||||||
makebootdisk() {
|
|
||||||
EXTRAKERNELPATH=""
|
|
||||||
INITRDFLAGS=""
|
|
||||||
MBD_FILENAME=""
|
|
||||||
INITRDFILE=""
|
|
||||||
MBD_TMPIMAGE=${TMPDIR:-/tmp}/makebootdisk.image.$$
|
|
||||||
MBD_BOOTTREE=${TMPDIR:-/tmp}/makebootdisk.tree.$$
|
|
||||||
MBD_BOOTTREE_TMP=$MBD_BOOTTREE'_tmp'
|
|
||||||
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
|
|
||||||
if [ $1 = "--kernelto" ]; then
|
|
||||||
EXTRAKERNELPATH=$2
|
|
||||||
shift; shift
|
|
||||||
continue
|
|
||||||
elif [ $1 = "--initrdflags" ]; then
|
|
||||||
INITRDFLAGS=$2
|
|
||||||
shift; shift
|
|
||||||
continue
|
|
||||||
elif [ $1 = "--initrd" ]; then
|
|
||||||
INITRDFILE=$2
|
|
||||||
shift; shift
|
|
||||||
continue
|
|
||||||
elif [ $1 = "--imagename" ]; then
|
|
||||||
MBD_FILENAME=$IMAGEPATH/$2
|
|
||||||
shift; shift
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo "Unknown option passed to makebootdisk"
|
|
||||||
exit 1
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$MBD_FILENAME" ]; then
|
|
||||||
echo "No imagename passed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$INITRDFILE" ]; then
|
|
||||||
MBD_FSIMAGE="$INITRDFILE"
|
|
||||||
elif [ -n "$INITRDFLAGS" ]; then
|
|
||||||
eval makeinitrd --keep $INITRDFLAGS
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p $MBD_BOOTTREE
|
|
||||||
mkdir -p $MBD_BOOTTREE_TMP
|
|
||||||
rm -rf $MBD_BOOTTREE_TMP
|
|
||||||
mkdir -p $MBD_TMPIMAGE
|
|
||||||
|
|
||||||
# provided by the mk-image.$ARCH file
|
|
||||||
prepareBootImage
|
|
||||||
|
|
||||||
left=$(df $MBD_BOOTTREE | tail -n1)
|
|
||||||
left=$(echo $left | awk '{print $4'})
|
|
||||||
|
|
||||||
umount $MBD_BOOTTREE
|
|
||||||
|
|
||||||
if [ -n "$EXTRAKERNELPATH" ]; then
|
|
||||||
mkdir -p `dirname $EXTRAKERNELPATH`
|
|
||||||
cp -f $KERNELROOT/$KERNELDIR/${KERNELNAME}-* $EXTRAKERNELPATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p `dirname $MBD_FILENAME`
|
|
||||||
rm -rf $MBD_TMPIMAGE $MBD_MNTPOINT $MBD_BOOTTREE
|
|
||||||
if [ -z "$INITRDFILE" ]; then
|
|
||||||
rm -f $MBD_FSIMAGE
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Wrote $MBD_FILENAME (${left}k free)"
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareBootImage() {
|
|
||||||
|
|
||||||
prepareBootTree
|
|
||||||
|
|
||||||
# dynamically calculate the size of the dosfs
|
|
||||||
BOOTDISKSIZE=$(du -kcs $MBD_BOOTTREE_TMP | tail -n1 | awk '{print $1}')
|
|
||||||
BOOTDISKSIZE=$(expr $BOOTDISKSIZE + 100)
|
|
||||||
echo "The size of the boot.img dosfs is $BOOTDISKSIZE"
|
|
||||||
mkdosfs -n ANACONDA -C $MBD_FILENAME $BOOTDISKSIZE >/dev/null
|
|
||||||
mount -o loop -t vfat $MBD_FILENAME $MBD_BOOTTREE
|
|
||||||
cp -R $MBD_BOOTTREE_TMP/* $MBD_BOOTTREE
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareBootTree() {
|
|
||||||
mkdir -p $MBD_BOOTTREE_TMP/EFI/boot
|
|
||||||
cp $MBD_FSIMAGE $MBD_BOOTTREE_TMP/EFI/boot/initrd.img
|
|
||||||
|
|
||||||
cp -a $BOOTDISKDIR/* $MBD_BOOTTREE_TMP/EFI/boot/
|
|
||||||
cp $KERNELROOT/boot/efi/EFI/redhat/vmlinuz-* $MBD_BOOTTREE_TMP/EFI/boot/vmlinuz
|
|
||||||
|
|
||||||
cp $MBD_BOOTTREE_TMP/EFI/boot/elilo.efi $MBD_BOOTTREE_TMP/EFI/boot/bootia64.efi
|
|
||||||
cat > $MBD_BOOTTREE_TMP/EFI/boot/elilo.conf << EOF
|
|
||||||
prompt
|
|
||||||
timeout=50
|
|
||||||
relocatable
|
|
||||||
|
|
||||||
image=vmlinuz
|
|
||||||
label=linux
|
|
||||||
read-only
|
|
||||||
initrd=initrd.img
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# make a copy in the root of the image
|
|
||||||
cp $MBD_BOOTTREE_TMP/EFI/boot/* $MBD_BOOTTREE_TMP
|
|
||||||
}
|
|
||||||
|
|
||||||
makeBootImages() {
|
|
||||||
# Because ia64 boxes use EFI there needs to be a boot.img dosfs.
|
|
||||||
echo "making boot.img for EFI bootloader"
|
|
||||||
makebootdisk --kernelto $TOPDESTPATH/kernels/vmlinuz \
|
|
||||||
--imagename boot.img \
|
|
||||||
--initrdflags '--initrdto $TOPDESTPATH/images/ramdisk.img \
|
|
||||||
--initrdsize 12288 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS sgiioc4" '
|
|
||||||
|
|
||||||
|
|
||||||
mkdir -p $TOPDESTPATH/images/pxeboot
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/initrd.img \
|
|
||||||
--initrdsize 12288 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS sgiioc4"
|
|
||||||
[ $? = 0 ] || exit 1
|
|
||||||
mv $TOPDESTPATH/kernels/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
|
|
||||||
rmdir $TOPDESTPATH/kernels
|
|
||||||
|
|
||||||
# make a pxe dir with kernel + initrd
|
|
||||||
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
|
|
||||||
The files in this directory are useful for booting a machine via PXE.
|
|
||||||
|
|
||||||
The following files are available:
|
|
||||||
vmlinuz - the kernel used for the installer
|
|
||||||
initrd.img - an initrd with support for all install methods and
|
|
||||||
drivers supported for installation of $PRODUCT
|
|
||||||
EOF
|
|
||||||
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
|
|
||||||
[images-$KERNELARCH]
|
|
||||||
kernel = images/pxeboot/vmlinuz
|
|
||||||
initrd = images/pxeboot/initrd.img
|
|
||||||
boot.img = images/boot.img
|
|
||||||
|
|
||||||
[images-xen]
|
|
||||||
kernel = images/pxeboot/vmlinuz
|
|
||||||
initrd = images/pxeboot/initrd.img
|
|
||||||
|
|
||||||
__EOT__
|
|
||||||
}
|
|
||||||
|
|
||||||
doPostImages() {
|
|
||||||
if [ -n "$BOOTISO" ]; then
|
|
||||||
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b boot.img -no-emul-boot -R -J -V "$PRODUCT" -T -graft-points boot.img=$TOPDESTPATH/images/boot.img images/install.img=$TOPDESTPATH/images/install.img
|
|
||||||
implantisomd5 $TOPDESTPATH/images/$BOOTISO
|
|
||||||
fi
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
makeBootImages() {
|
|
||||||
echo "Building boot images for kernel $kernelvers"
|
|
||||||
FAKEARCH=""
|
|
||||||
|
|
||||||
if [ "$KERNELARCH" = "ppc64" ]; then
|
|
||||||
mkdir -p $TOPDESTPATH/ppc/ppc64
|
|
||||||
echo "Building $KERNELARCH initrd"
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
|
|
||||||
--initrdsize 8192 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS spufs viocd gpio_mdio"
|
|
||||||
|
|
||||||
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc64/vmlinuz
|
|
||||||
sed -e "s/%BITS%/64/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
|
|
||||||
$BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc64/yaboot.conf
|
|
||||||
|
|
||||||
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
|
|
||||||
[images-$KERNELARCH]
|
|
||||||
kernel = ppc/ppc64/vmlinuz
|
|
||||||
initrd = ppc/ppc64/ramdisk.image.gz
|
|
||||||
__EOT__
|
|
||||||
|
|
||||||
if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
|
|
||||||
mkdir -p $TOPDESTPATH/images/netboot
|
|
||||||
pushd $TOPDESTPATH/ppc/ppc64
|
|
||||||
cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc64/zImage.lds
|
|
||||||
$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc64/vmlinuz no no $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc64.img
|
|
||||||
rmdir $TOPDESTPATH/images/netboot || :
|
|
||||||
rm -f $TOPDESTPATH/ppc/ppc64/zImage.lds
|
|
||||||
popd
|
|
||||||
echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
|
|
||||||
elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
|
|
||||||
mkdir -p $TOPDESTPATH/images/netboot
|
|
||||||
$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc64.img \
|
|
||||||
-i $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
|
|
||||||
-D $IMGPATH/usr/lib/kernel-wrapper \
|
|
||||||
$TOPDESTPATH/ppc/ppc64/vmlinuz
|
|
||||||
rmdir $TOPDESTPATH/images/netboot || :
|
|
||||||
echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo >> $TOPDESTPATH/.treeinfo
|
|
||||||
|
|
||||||
|
|
||||||
elif [ "$KERNELARCH" = "ppc" ]; then
|
|
||||||
FAKEARCH="ppc"
|
|
||||||
mkdir -p $TOPDESTPATH/ppc/ppc32
|
|
||||||
mkdir -p $TOPDESTPATH/ppc/mac
|
|
||||||
|
|
||||||
echo "Building ppc initrd"
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
|
|
||||||
--initrdsize 8192 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS"
|
|
||||||
|
|
||||||
cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc32/vmlinuz
|
|
||||||
sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
|
|
||||||
$BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc32/yaboot.conf
|
|
||||||
|
|
||||||
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
|
|
||||||
[images-$KERNELARCH]
|
|
||||||
kernel = ppc/ppc32/vmlinuz
|
|
||||||
initrd = ppc/ppc32/ramdisk.image.gz
|
|
||||||
__EOT__
|
|
||||||
if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
|
|
||||||
mkdir -p $TOPDESTPATH/images/netboot
|
|
||||||
pushd $TOPDESTPATH/ppc/ppc32
|
|
||||||
cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc32/zImage.lds
|
|
||||||
$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc32/vmlinuz no no $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc32.img
|
|
||||||
rmdir $TOPDESTPATH/images/netboot || :
|
|
||||||
rm -f $TOPDESTPATH/ppc/ppc32/zImage.lds
|
|
||||||
popd
|
|
||||||
echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
|
|
||||||
elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
|
|
||||||
$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc32.img \
|
|
||||||
-i $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
|
|
||||||
-D $IMGPATH/usr/lib/kernel-wrapper \
|
|
||||||
$TOPDESTPATH/ppc/ppc32/vmlinuz
|
|
||||||
rmdir $TOPDESTPATH/images/netboot || :
|
|
||||||
popd
|
|
||||||
echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
|
|
||||||
fi
|
|
||||||
echo >> $TOPDESTPATH/.treeinfo
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "Unknown kernel arch: $KERNELARCH"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
doPostImages() {
|
|
||||||
mkdir -p $TOPDESTPATH/etc
|
|
||||||
mkdir -p $TOPDESTPATH/ppc/chrp
|
|
||||||
|
|
||||||
# Create ofboot.b and bootinfo.txt files, and yaboot binaries for Mac and CHRP
|
|
||||||
cp $BOOTDISKDIR/bootinfo.txt $TOPDESTPATH/ppc/bootinfo.txt
|
|
||||||
cp $IMGPATH/usr/lib/anaconda-runtime/boot/efika.forth $TOPDESTPATH/ppc/efika.forth
|
|
||||||
|
|
||||||
if [ -d $TOPDESTPATH/ppc/mac ]; then
|
|
||||||
cp $BOOTDISKDIR/ofboot.b $TOPDESTPATH/ppc/mac/ofboot.b
|
|
||||||
cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/mac/yaboot
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d $TOPDESTPATH/ppc/chrp ]; then
|
|
||||||
cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/chrp/yaboot
|
|
||||||
$IMGPATH/usr/lib/yaboot/addnote $TOPDESTPATH/ppc/chrp/yaboot
|
|
||||||
fi
|
|
||||||
|
|
||||||
# IBM firmware can't handle boot scripts properly, so for biarch installs
|
|
||||||
# we use a yaboot.conf which asks the user to select 32-bit or 64-bit kernel.
|
|
||||||
if [ -r $TOPDESTPATH/ppc/ppc32/yaboot.conf -a -r $TOPDESTPATH/ppc/ppc64/yaboot.conf ]; then
|
|
||||||
# Both kernels exist. Copy the biarch yaboot.conf into place.
|
|
||||||
sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
|
|
||||||
$BOOTDISKDIR/yaboot.conf.3264 > $TOPDESTPATH/etc/yaboot.conf
|
|
||||||
else
|
|
||||||
# Copy the one that exists, assuming one does exist
|
|
||||||
cp $TOPDESTPATH/ppc/ppc??/yaboot.conf $TOPDESTPATH/etc
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$BOOTISO" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy it all into the isopath for the boot CD
|
|
||||||
mkdir -p $TOPDESTPATH/isopath
|
|
||||||
cp -r $TOPDESTPATH/{ppc,etc} $TOPDESTPATH/isopath
|
|
||||||
|
|
||||||
# We want the ppc32 prep image in the boot.iso too.
|
|
||||||
if [ -d $TOPDESTPATH/images/netboot ]; then
|
|
||||||
mkdir -p $TOPDESTPATH/isopath/images
|
|
||||||
cp -r $TOPDESTPATH/images/netboot $TOPDESTPATH/isopath/images
|
|
||||||
rm -f $TOPDESTPATH/isopath/images/ppc64.img
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -r $TOPDESTPATH/isopath/images/netboot/ppc32.img ]; then
|
|
||||||
PREPBOOT="-prep-boot images/netboot/ppc32.img"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d $TOPDESTPATH/isopath/ppc/mac ]; then
|
|
||||||
MACBOOT="-hfs-volid $VERSION -hfs-bless $TOPDESTPATH/isopath/ppc/mac"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the boot.iso
|
|
||||||
mkisofs -o $TOPDESTPATH/images/$BOOTISO -chrp-boot -U $PREPBOOT \
|
|
||||||
-part -hfs -T -r -l -J -A "$PRODUCT $VERSION" -sysid PPC \
|
|
||||||
-V "PBOOT" -volset "$VERSION" -volset-size 1 -volset-seqno 1 \
|
|
||||||
$MACBOOT \
|
|
||||||
-map $BOOTDISKDIR/mapping -magic $BOOTDISKDIR/magic \
|
|
||||||
-no-desktop -allow-multidot -graft-points $TOPDESTPATH/isopath \
|
|
||||||
images/install.img=$TOPDESTPATH/images/install.img
|
|
||||||
implantisomd5 $TOPDESTPATH/images/$BOOTISO
|
|
||||||
rm -rf $TOPDESTPATH/isopath
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
S390SCSIMODS="zfcp tape390"
|
|
||||||
S390DASDMODS=" dasd_diag_mod dasd_eckd_mod dasd_fba_mod dasd_mod"
|
|
||||||
S390NETMODS="ctc netiucv smsgiucv lcs qdio qeth ccwgroup crypto_api xfrm_nalgo"
|
|
||||||
S390MODS="$S390SCSIMODS $S390DASDMODS $S390NETMODS"
|
|
||||||
|
|
||||||
makeBootImages() {
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
|
|
||||||
--initrdsize 20000 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS $S390MODS"
|
|
||||||
sz=$(ls -l $TOPDESTPATH/images/initrd.img | awk '{print $5}')
|
|
||||||
$GENINITRDSZ $sz $TOPDESTPATH/images/initrd.size
|
|
||||||
cp -vf $KERNELROOT/boot/${KERNELNAME}-${version} $TOPDESTPATH/images/kernel.img
|
|
||||||
|
|
||||||
cp -v $BOOTDISKDIR/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__
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
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 <<EOF
|
|
||||||
This directory contains image files that can be used to create media
|
|
||||||
capable of starting the $PRODUCT installation process.
|
|
||||||
|
|
||||||
The boot.iso file is an ISO 9660 image of a bootable CD-ROM. It is useful
|
|
||||||
in cases where the CD-ROM installation method is not desired, but the
|
|
||||||
CD-ROM's boot speed would be an advantage.
|
|
||||||
|
|
||||||
To use this image file, burn the file onto CD-R (or CD-RW) media as you
|
|
||||||
normally would.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
makeBootImages() {
|
|
||||||
local initrd="initrd.img"
|
|
||||||
local kernelimage="vmlinuz"
|
|
||||||
|
|
||||||
if [ "$kernelvers" = "$kernelxen" ] ; then
|
|
||||||
local tag="${kernelvers#kernel}"
|
|
||||||
if [ -n "$tag" -a "$tag" != "$kernelvers" ] ; then
|
|
||||||
initrd="initrd${tag}.img"
|
|
||||||
kernelimage="vmlinuz${tag}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Building $initrd"
|
|
||||||
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/$initrd \
|
|
||||||
--initrdsize 8192 \
|
|
||||||
--loaderbin loader \
|
|
||||||
--modules "$INITRDMODS"
|
|
||||||
[ $? = 0 ] || exit 1
|
|
||||||
|
|
||||||
if [ "$kernelvers" != "$kernelxen" ] ; then
|
|
||||||
if [ -f $IMGPATH/usr/share/syslinux/isolinux.bin ]; then
|
|
||||||
echo "Building isolinux directory"
|
|
||||||
MBD_BOOTTREE=$TOPDESTPATH/isolinux
|
|
||||||
MBD_FSIMAGE=$TOPDESTPATH/images/pxeboot/initrd.img
|
|
||||||
mkdir $MBD_BOOTTREE
|
|
||||||
cp $IMGPATH/usr/share/syslinux/isolinux.bin $MBD_BOOTTREE/isolinux.bin
|
|
||||||
|
|
||||||
prepareBootTree
|
|
||||||
|
|
||||||
# isolinux needs the config file to be isolinux.cfg
|
|
||||||
mv $MBD_BOOTTREE/syslinux.cfg $MBD_BOOTTREE/isolinux.cfg
|
|
||||||
|
|
||||||
# set up the label for finding stage2 with a hybrid iso
|
|
||||||
sed -i 's/initrd=initrd.img/initrd=initrd.img stage2=hd:LABEL=$CDLABEL/' $MBD_BOOTTREE/isolinux.cfg
|
|
||||||
|
|
||||||
# copy in memtest if present
|
|
||||||
if [ -f $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* ]; then
|
|
||||||
cp $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* $MBD_BOOTTREE/memtest
|
|
||||||
echo -e "label memtest86\n menu label ^Memory test\n kernel memtest\n append -\n" >> $MBD_BOOTTREE/isolinux.cfg
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "No isolinux binaries. Skipping isolinux creation"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# symlink the kernel for pxe dir
|
|
||||||
ln $TOPDESTPATH/isolinux/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
|
|
||||||
|
|
||||||
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
|
|
||||||
The files in this directory are useful for booting a machine via PXE.
|
|
||||||
|
|
||||||
The following files are available:
|
|
||||||
vmlinuz - the kernel used for the installer
|
|
||||||
initrd.img - an initrd with support for all install methods and
|
|
||||||
drivers supported for installation of $PRODUCT
|
|
||||||
EOF
|
|
||||||
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
|
|
||||||
[images-$BASEARCH]
|
|
||||||
kernel = images/pxeboot/vmlinuz
|
|
||||||
initrd = images/pxeboot/initrd.img
|
|
||||||
__EOT__
|
|
||||||
if [ -n "$BOOTISO" ]; then echo "boot.iso = images/$BOOTISO" >> $TOPDESTPATH/.treeinfo ; fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set up the boot stuff for the xen guest kernel
|
|
||||||
if [ -z "$kernelxen" -o "$kernelvers" = "$kernelxen" ] ; then
|
|
||||||
cp $KERNELROOT/boot/vmlinuz-$version $TOPDESTPATH/images/pxeboot/$kernelimage
|
|
||||||
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
|
|
||||||
[images-xen]
|
|
||||||
kernel = images/pxeboot/$kernelimage
|
|
||||||
initrd = images/pxeboot/$initrd
|
|
||||||
|
|
||||||
__EOT__
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
doPostImages() {
|
|
||||||
if [ -n "$BOOTISO" ]; then
|
|
||||||
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
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
try:
|
|
||||||
import readline
|
|
||||||
import rlcompleter
|
|
||||||
readline.parse_and_bind("tab: complete")
|
|
||||||
del rlcompleter
|
|
||||||
del readline
|
|
||||||
except:
|
|
||||||
pass
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
DEBUG=""
|
|
||||||
|
|
||||||
if [ "$1" == "--debug" ]; then
|
|
||||||
DEBUG="--debug"
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "Usage: $0 /path/to/tree"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
p=$1
|
|
||||||
|
|
||||||
ARCH=`uname -m | sed -e 's/i.86/i386/'`
|
|
||||||
|
|
||||||
if [ $ARCH = x86_64 -o $ARCH = s390x -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
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "$0: <image> <binary> [<initrdpath>]"
|
|
||||||
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
|
|
@ -1,43 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Updates an installer initrd with a new loader binary
|
|
||||||
# Usage: upd-initrd <initrd> <binary> <outfile>
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Author(s): Jeremy Katz <katzj@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ $# -ne 3 ]; then
|
|
||||||
echo "Usage: $0 <initrd> <binary> <outfile>"
|
|
||||||
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
|
|
File diff suppressed because it is too large
Load Diff
@ -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 <olddir> <newdir> <newkernelrpm>
|
|
||||||
#
|
|
||||||
# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
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 <olddir> <newdir> <newkernelrpm>"
|
|
||||||
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
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
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 <updates.img> [<file0> [<file1> [...]]]"
|
|
||||||
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
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
perl -e 'while (<>) { if (/\\\n/) { chop; s/\\$//; print;} else { print $_; } }' | grep ':.*ko' | sed -e '
|
|
||||||
s/\.ko//g
|
|
||||||
s,/[^: ]*/,,g
|
|
||||||
s/[ ][ ]*/ /g'
|
|
||||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int main(int argc,char **argv) {
|
|
||||||
unsigned int zero = 0;
|
|
||||||
int fd;
|
|
||||||
unsigned int size;
|
|
||||||
mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
|
|
||||||
|
|
||||||
if (argc != 3) {
|
|
||||||
printf("Usage: %s [integer size] [output file]\n", basename(argv[0]));
|
|
||||||
printf("Example: %s 12288475 initrd.size\n", basename(argv[0]));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = htonl(atoi(argv[1]));
|
|
||||||
fd = open(argv[2], O_CREAT | O_RDWR, mode);
|
|
||||||
|
|
||||||
if (write(fd, &zero, sizeof(int)) == -1) {
|
|
||||||
perror("writing initrd.size (zero)");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (write(fd, &size, sizeof(int)) == -1) {
|
|
||||||
perror("writing initrd.size (size)");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
import commands
|
|
||||||
import os
|
|
||||||
import string
|
|
||||||
import sys
|
|
||||||
|
|
||||||
uname = os.uname()[2]
|
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
|
||||||
path = sys.argv[1]
|
|
||||||
else:
|
|
||||||
path = '/lib/modules/%s' % (uname,)
|
|
||||||
|
|
||||||
mods = {}
|
|
||||||
for root, dirs, files in os.walk(path):
|
|
||||||
for file in files:
|
|
||||||
mods[file] = os.path.join(root,file)
|
|
||||||
|
|
||||||
modules = { 'scsi_hostadapter' : [ 'block' ], 'eth' : [ 'networking'] }
|
|
||||||
blacklist = ("floppy", "scsi_mod", "libiscsi")
|
|
||||||
|
|
||||||
list = {}
|
|
||||||
|
|
||||||
for modtype in modules.keys():
|
|
||||||
list[modtype] = {}
|
|
||||||
for file in modules[modtype]:
|
|
||||||
try:
|
|
||||||
f = open('%s/modules.%s' % (path,file),'r')
|
|
||||||
except:
|
|
||||||
continue
|
|
||||||
lines = f.readlines()
|
|
||||||
f.close()
|
|
||||||
for line in lines:
|
|
||||||
line = line.strip()
|
|
||||||
if mods.has_key(line):
|
|
||||||
desc = commands.getoutput("modinfo -F description %s" % (mods[line])).split("\n")[0]
|
|
||||||
desc = desc.strip()
|
|
||||||
modname = line[:-3]
|
|
||||||
if modname in blacklist:
|
|
||||||
continue
|
|
||||||
if desc and len(desc) > 65:
|
|
||||||
desc = desc[:65]
|
|
||||||
if not desc:
|
|
||||||
desc = "%s driver" % (modname,)
|
|
||||||
modinfo = """
|
|
||||||
%s
|
|
||||||
%s
|
|
||||||
"%s"
|
|
||||||
""" % (modname, modtype, desc)
|
|
||||||
list[modtype][modname] = modinfo
|
|
||||||
|
|
||||||
print "Version 0"
|
|
||||||
for type in list.keys():
|
|
||||||
modlist = list[type].keys()
|
|
||||||
modlist.sort()
|
|
||||||
for m in modlist:
|
|
||||||
print list[type][m]
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -1,284 +0,0 @@
|
|||||||
/*
|
|
||||||
* mk-s390-cdboot -- creates one big image using a kernel, a ramdisk and
|
|
||||||
* a parmfile
|
|
||||||
*
|
|
||||||
* 2003-07-24 Volker Sameske <sameske@de.ibm.com>
|
|
||||||
* 2008-09-22 Updated by David Cantrell <dcantrell@redhat.com>
|
|
||||||
*
|
|
||||||
* compile with:
|
|
||||||
* gcc -Wall -o mk-s390-cdboot mk-s390-cdboot.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#define BUFFER_LEN 1024
|
|
||||||
#define INITRD_START 0x0000000000800000LL
|
|
||||||
#define START_PSW_ADDRESS 0x80010000
|
|
||||||
|
|
||||||
static struct option getopt_long_options[]= {
|
|
||||||
{ "image", 1, 0, 'i'},
|
|
||||||
{ "ramdisk", 1, 0, 'r'},
|
|
||||||
{ "parmfile", 1, 0, 'p'},
|
|
||||||
{ "outfile", 1, 0, 'o'},
|
|
||||||
{ "help", 0, 0, 'h'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void usage(char *cmd) {
|
|
||||||
printf("%s [-h] [-v] -i <kernel> -r <ramdisk> -p <parmfile> -o <outfile>\n", cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main (int argc, char **argv) {
|
|
||||||
char *cmd = basename(argv[0]);
|
|
||||||
FILE *fd1 = NULL;
|
|
||||||
FILE *fd2 = NULL;
|
|
||||||
FILE *fd3 = NULL;
|
|
||||||
FILE *fd4 = NULL;
|
|
||||||
char buffer[BUFFER_LEN];
|
|
||||||
int wc, rc, oc, index;
|
|
||||||
unsigned long long initrd_start = INITRD_START;
|
|
||||||
unsigned long long initrd_size;
|
|
||||||
char *image = NULL;
|
|
||||||
char *ramdisk = NULL;
|
|
||||||
char *parmfile = NULL;
|
|
||||||
char *outfile = NULL;
|
|
||||||
int image_specified = 0;
|
|
||||||
int ramdisk_specified = 0;
|
|
||||||
int parmfile_specified = 0;
|
|
||||||
int outfile_specified = 0;
|
|
||||||
int start_psw_address = START_PSW_ADDRESS;
|
|
||||||
|
|
||||||
opterr = 0;
|
|
||||||
while (1) {
|
|
||||||
oc = getopt_long(argc, argv, "i:r:p:o:h?", getopt_long_options, &index);
|
|
||||||
if (oc == -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (oc) {
|
|
||||||
case '?':
|
|
||||||
case 'h':
|
|
||||||
usage(cmd);
|
|
||||||
exit(0);
|
|
||||||
case 'i':
|
|
||||||
image = strdup(optarg);
|
|
||||||
image_specified = 1;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
ramdisk = strdup(optarg);
|
|
||||||
ramdisk_specified = 1;
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
parmfile = strdup(optarg);
|
|
||||||
parmfile_specified = 1;
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
outfile = strdup(optarg);
|
|
||||||
outfile_specified = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage(cmd);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!image_specified || !ramdisk_specified ||
|
|
||||||
!parmfile_specified || !outfile_specified) {
|
|
||||||
usage(cmd);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Creating bootable CD-ROM image...\n");
|
|
||||||
printf("kernel is : %s\n", image);
|
|
||||||
printf("ramdisk is : %s\n", ramdisk);
|
|
||||||
printf("parmfile is: %s\n", parmfile);
|
|
||||||
printf("outfile is : %s\n", outfile);
|
|
||||||
|
|
||||||
if ((fd1 = fopen(outfile, "w")) == NULL) {
|
|
||||||
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd2 = fopen(image, "r")) == NULL) {
|
|
||||||
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd3 = fopen(ramdisk, "r")) == NULL) {
|
|
||||||
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd4 = fopen(parmfile, "r")) == NULL) {
|
|
||||||
fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("writing kernel...\n");
|
|
||||||
while (1) {
|
|
||||||
rc = fread(buffer, 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;
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <popt.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "../isys/isys.h"
|
|
||||||
#include "moduleinfo.h"
|
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
|
||||||
poptContext optCon;
|
|
||||||
char * modInfoFile = "/boot/module-info";
|
|
||||||
enum driverMajor major;
|
|
||||||
const char * type;
|
|
||||||
const char * mod;
|
|
||||||
struct moduleInfo * list, * m;
|
|
||||||
int rc, i;
|
|
||||||
int showModInfo = 0;
|
|
||||||
int ignoreMissing = 0;
|
|
||||||
moduleInfoSet mis;
|
|
||||||
struct moduleInfo * mi;
|
|
||||||
struct poptOption optionTable[] = {
|
|
||||||
{ "ignore-missing", 'I', POPT_ARG_NONE, &ignoreMissing, 0,
|
|
||||||
"Ignore modules not in modinfo file for --modinfo" },
|
|
||||||
{ "modinfo", 'm', POPT_ARG_NONE, &showModInfo, 0,
|
|
||||||
"Give output in module-info file for listed args" },
|
|
||||||
{ "modinfo-file", 'f', POPT_ARG_STRING, &modInfoFile, 0,
|
|
||||||
"Module info file to use"},
|
|
||||||
POPT_AUTOHELP
|
|
||||||
{ 0, 0, 0, 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
optCon = poptGetContext(NULL, argc, (const char **) argv, optionTable, 0);
|
|
||||||
|
|
||||||
if ((rc = poptGetNextOpt(optCon)) < -1) {
|
|
||||||
fprintf(stderr, "bad option %s: %s\n",
|
|
||||||
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
||||||
poptStrerror(rc));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
mis = newModuleInfoSet();
|
|
||||||
if (readModuleInfo(modInfoFile, mis, NULL, 0)) {
|
|
||||||
fprintf(stderr, "Failed to read %s\n", modInfoFile);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showModInfo) {
|
|
||||||
printf("Version 0\n");
|
|
||||||
while ((mod = poptGetArg(optCon))) {
|
|
||||||
mi = findModuleInfo(mis, mod);
|
|
||||||
if (mi) {
|
|
||||||
printf("%s\n", mi->moduleName);
|
|
||||||
switch (mi->major) {
|
|
||||||
case DRIVER_CDROM: printf("\tcdrom\n"); break;
|
|
||||||
case DRIVER_SCSI: printf("\tscsi\n"); break;
|
|
||||||
case DRIVER_FS: printf("\tfs\n"); break;
|
|
||||||
case DRIVER_PCMCIA: printf("\tpcmcia\n"); break;
|
|
||||||
case DRIVER_IDE: printf("\tide\n"); break;
|
|
||||||
case DRIVER_OTHER: printf("\tother\n"); break;
|
|
||||||
case DRIVER_NET:
|
|
||||||
switch (mi->minor) {
|
|
||||||
case DRIVER_MINOR_ETHERNET: printf("\teth\n"); break;
|
|
||||||
case DRIVER_MINOR_TR: printf("\ttr\n"); break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr, "unknown net minor type for %s\n",
|
|
||||||
mi->moduleName);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr, "unknown device type for %s (%d)\n",
|
|
||||||
mi->moduleName, mi->major);
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
}
|
|
||||||
printf("\t\"%s\"\n", mi->description);
|
|
||||||
for (i = 0; i < mi->numArgs; i++) {
|
|
||||||
printf("\t%s \"%s\"\n", mi->args[i].arg,
|
|
||||||
mi->args[i].description);
|
|
||||||
}
|
|
||||||
} else if (!ignoreMissing) {
|
|
||||||
fprintf(stderr, "I know nothing about %s\n", mod);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while ((type = poptGetArg(optCon))) {
|
|
||||||
if (!strcasecmp(type, "scsi")) {
|
|
||||||
major = DRIVER_SCSI;
|
|
||||||
} else if (!strcasecmp(type, "net")) {
|
|
||||||
major = DRIVER_NET;
|
|
||||||
} else if (!strcasecmp(type, "fs")) {
|
|
||||||
major = DRIVER_FS;
|
|
||||||
} else if (!strcasecmp(type, "cdrom")) {
|
|
||||||
major = DRIVER_CDROM;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "type must be one of scsi, net, fs, cdrom\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
list = getModuleList(mis, major);
|
|
||||||
for (m = list; m && m->moduleName; m++)
|
|
||||||
printf("%s\n", m->moduleName);
|
|
||||||
free(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <linux/keyboard.h>
|
|
||||||
#ifdef NR_KEYS
|
|
||||||
#undef NR_KEYS
|
|
||||||
#define NR_KEYS 128
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <linux/kd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/kd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import string
|
|
||||||
|
|
||||||
vendors = []
|
|
||||||
devices = []
|
|
||||||
|
|
||||||
f = open(sys.argv[1])
|
|
||||||
if f:
|
|
||||||
pcitable = f.readlines()
|
|
||||||
f.close()
|
|
||||||
for line in pcitable:
|
|
||||||
if not line.startswith("alias pci:"):
|
|
||||||
continue
|
|
||||||
vend = "0x%s" % (line[15:19],)
|
|
||||||
dev = "0x%s" % (line[24:28],)
|
|
||||||
vend = vend.upper()
|
|
||||||
dev = dev.upper()
|
|
||||||
if vend not in vendors:
|
|
||||||
vendors.append(vend)
|
|
||||||
if (vend, dev) not in devices:
|
|
||||||
devices.append( (vend, dev) )
|
|
||||||
|
|
||||||
for file in sys.argv[2:]:
|
|
||||||
if not os.path.exists(file):
|
|
||||||
sys.stderr.write("WARNING: non-existent file %s for trimpciids\n" %(file,))
|
|
||||||
continue
|
|
||||||
f = open(file)
|
|
||||||
if f:
|
|
||||||
pcitable = f.readlines()
|
|
||||||
f.close()
|
|
||||||
for line in pcitable:
|
|
||||||
if not line.startswith("alias pcivideo:"):
|
|
||||||
continue
|
|
||||||
vend = "0x%s" % (line[20:24],)
|
|
||||||
dev = "0x%s" % (line[29:33],)
|
|
||||||
vend = vend.upper()
|
|
||||||
dev = dev.upper()
|
|
||||||
if vend not in vendors:
|
|
||||||
vendors.append(vend)
|
|
||||||
if (vend, dev) not in devices:
|
|
||||||
devices.append( (vend, dev) )
|
|
||||||
|
|
||||||
pciids = sys.stdin.readlines()
|
|
||||||
current_vend = 0
|
|
||||||
for line in pciids:
|
|
||||||
if line.startswith("#") or line == "\n":
|
|
||||||
continue
|
|
||||||
if line.startswith("\t\t"):
|
|
||||||
continue
|
|
||||||
if not line.startswith("\t"):
|
|
||||||
current_vend = "0x%s" % line.split()[0]
|
|
||||||
current_vend = current_vend.upper()
|
|
||||||
if current_vend in vendors:
|
|
||||||
print line,
|
|
||||||
continue
|
|
||||||
dev = "0x%s" % line.split()[0]
|
|
||||||
dev = dev.upper()
|
|
||||||
if (current_vend, dev) in devices:
|
|
||||||
print line,
|
|
@ -30,9 +30,9 @@ from optparse import OptionParser, OptionGroup
|
|||||||
import pylorax
|
import pylorax
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
version = '%s 0.1' % os.path.basename(sys.argv[0])
|
version = "%s 0.1" % (os.path.basename(sys.argv[0]),)
|
||||||
usage = '%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUTDIR REPOSITORY'
|
usage = "%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUTDIR REPOSITORY"
|
||||||
|
|
||||||
parser = OptionParser(usage=usage)
|
parser = OptionParser(usage=usage)
|
||||||
|
|
||||||
@ -40,49 +40,50 @@ if __name__ == '__main__':
|
|||||||
if os.path.isdir(value):
|
if os.path.isdir(value):
|
||||||
setattr(parser.values, option.dest, value)
|
setattr(parser.values, option.dest, value)
|
||||||
else:
|
else:
|
||||||
parser.error('%s is not a directory' % value)
|
parser.error("'%s' is not a directory" % (value,))
|
||||||
|
|
||||||
|
|
||||||
# required
|
# required
|
||||||
# XXX "options" should not be required
|
# XXX "options" should not be required
|
||||||
group = OptionGroup(parser, 'Required')
|
group = OptionGroup(parser, "Required")
|
||||||
group.add_option('-p', '--product', help='Product name',
|
group.add_option("-p", "--product", help="Product name",
|
||||||
metavar='STRING')
|
metavar="STRING")
|
||||||
group.add_option('-v', '--version', help='Version identifier',
|
group.add_option("-v", "--version", help="Version identifier",
|
||||||
metavar='STRING')
|
metavar="STRING")
|
||||||
group.add_option('-r', '--release', help='Release information or comment',
|
group.add_option("-r", "--release", help="Release information or comment",
|
||||||
metavar='STRING')
|
metavar="STRING")
|
||||||
group.add_option('-o', '--output', help='Destination directory',
|
group.add_option("-o", "--output", help="Destination directory",
|
||||||
metavar='PATHSPEC')
|
metavar="PATHSPEC")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
# optional
|
# optional
|
||||||
# XXX are all of these used?
|
# XXX are all of these used?
|
||||||
group = OptionGroup(parser, 'Optional')
|
group = OptionGroup(parser, "Optional")
|
||||||
group.add_option('-d', '--debug', help='Enable debugging messages',
|
group.add_option("-d", "--debug", help="Enable debugging messages",
|
||||||
action='store_true', default=False)
|
action="store_true", default=False)
|
||||||
group.add_option('-t', '--variant', help='Variant name',
|
group.add_option("-t", "--variant", help="Variant name",
|
||||||
metavar='STRING')
|
metavar="STRING")
|
||||||
group.add_option('-b', '--bugurl', help='Bug reporting URL for the product',
|
group.add_option("-b", "--bugurl", help="Bug reporting URL for the product",
|
||||||
metavar='URL', default='your distribution provided bug reporting tool.')
|
metavar="URL",
|
||||||
group.add_option('-u', '--updates', help='Directory containing updates',
|
default="your distribution provided bug reporting tool")
|
||||||
metavar='PATHSPEC')
|
group.add_option("-u", "--updates", help="Directory containing updates",
|
||||||
group.add_option('-m', '--mirrorlist',
|
metavar="PATHSPEC")
|
||||||
help='Mirror list repository (may be listed multiple times)',
|
group.add_option("-m", "--mirrorlist",
|
||||||
metavar='REPOSITORY', action='append', default=[])
|
help="Mirror list repository (may be listed multiple times)",
|
||||||
group.add_option('-c', '--confdir', help='Path to config files (default: /etc/lorax).',
|
metavar="REPOSITORY", action="append", default=[])
|
||||||
metavar='PATHSPEC', action='callback', callback=check_dir,
|
group.add_option("-c", "--confdir", help="Path to config files (default: /etc/lorax)",
|
||||||
type='string', default='/etc/lorax')
|
metavar="PATHSPEC", action="callback", callback=check_dir,
|
||||||
group.add_option('-C', '--cleanup', help='Cleanup on exit',
|
type="string", default="/etc/lorax")
|
||||||
action='store_true', default=False)
|
group.add_option("-C", "--cleanup", help="Clean up on exit",
|
||||||
group.add_option('-V', help='Print version and exit',
|
action="store_true", default=False)
|
||||||
action='store_true', default=False, dest='printver')
|
group.add_option("-V", help="Print version and exit",
|
||||||
|
action="store_true", default=False, dest="printver")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
# additional information
|
# additional information
|
||||||
group = OptionGroup(parser, 'Additional information',
|
group = OptionGroup(parser, "Additional information",
|
||||||
'A "REPOSITORY" specification is a valid yum repository path.\n'
|
"A 'REPOSITORY' specification is a valid yum repository path.\n"
|
||||||
'See the man page lorax(8) for more information.')
|
"See the man page lorax(8) for more information.")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
@ -92,10 +93,10 @@ if __name__ == '__main__':
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if not opts.product or not opts.version or not opts.release or not opts.output:
|
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:
|
if not args:
|
||||||
parser.error('Missing repository')
|
parser.error("Missing repository")
|
||||||
|
|
||||||
config = pylorax.Config()
|
config = pylorax.Config()
|
||||||
config.set(confdir=opts.confdir,
|
config.set(confdir=opts.confdir,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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<warning>\.gnu\.warning\.[^ ]*) .*$', line)
|
|
||||||
if m:
|
|
||||||
arglist.extend(['-R', m.group('warning')])
|
|
||||||
|
|
||||||
p = subprocess.Popen(cmd + arglist)
|
|
||||||
p.wait()
|
|
@ -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)
|
|
341
src/pylorax/_rewrite/__init__.py
Normal file
341
src/pylorax/_rewrite/__init__.py
Normal file
@ -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))
|
168
src/pylorax/_rewrite/images.py
Normal file
168
src/pylorax/_rewrite/images.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
@ -32,17 +32,17 @@ def getActions(verbose=False):
|
|||||||
|
|
||||||
modules = set()
|
modules = set()
|
||||||
for filename in os.listdir(os.path.join(root, actions_dir)):
|
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)
|
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:
|
for module in modules:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Loading actions from module '%s'" % module)
|
print("Loading actions from module '%s'" % (module,))
|
||||||
imported = __import__(module, globals(), locals(), [module], -1)
|
imported = __import__(module, globals(), locals(), [module], -1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
commands = getattr(imported, 'COMMANDS')
|
commands = getattr(imported, "COMMANDS")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("No actions found")
|
print("No actions found")
|
||||||
|
@ -26,7 +26,7 @@ import pwd
|
|||||||
import grp
|
import grp
|
||||||
import glob
|
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
|
# command:action mapping
|
||||||
@ -123,9 +123,9 @@ class Copy(LoraxAction):
|
|||||||
self._attrs['nolinks'] = False
|
self._attrs['nolinks'] = False
|
||||||
|
|
||||||
def execute(self, verbose=False):
|
def execute(self, verbose=False):
|
||||||
cp(src_root=self.src_root, src_path=self.src_path,
|
copy(src_root=self.src_root, src_path=self.src_path,
|
||||||
dst_root=self.dst_root, dst_path=self.dst_path,
|
dst_root=self.dst_root, dst_path=self.dst_path,
|
||||||
nolinks=self.nolinks, ignore_errors=True, verbose=verbose)
|
nolinks=self.nolinks, ignore_errors=False, verbose=verbose)
|
||||||
self._attrs['success'] = True
|
self._attrs['success'] = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -176,9 +176,9 @@ class Copy(LoraxAction):
|
|||||||
|
|
||||||
class Move(Copy):
|
class Move(Copy):
|
||||||
def execute(self, verbose=False):
|
def execute(self, verbose=False):
|
||||||
mv(src_root=self.src_root, src_path=self.src_path,
|
move(src_root=self.src_root, src_path=self.src_path,
|
||||||
dst_root=self.dst_root, dst_path=self.dst_path,
|
dst_root=self.dst_root, dst_path=self.dst_path,
|
||||||
nolinks=self.nolinks, ignore_errors=True, verbose=verbose)
|
nolinks=self.nolinks, ignore_errors=False, verbose=verbose)
|
||||||
self._attrs['success'] = True
|
self._attrs['success'] = True
|
||||||
|
|
||||||
|
|
||||||
@ -191,8 +191,7 @@ class Remove(LoraxAction):
|
|||||||
self._attrs['filename'] = kwargs.get('filename')
|
self._attrs['filename'] = kwargs.get('filename')
|
||||||
|
|
||||||
def execute(self, verbose=False):
|
def execute(self, verbose=False):
|
||||||
for f in glob.iglob(self.filename):
|
remove(self.filename, verbose=verbose)
|
||||||
rm(f)
|
|
||||||
self._attrs['success'] = True
|
self._attrs['success'] = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -20,18 +20,14 @@
|
|||||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
from misc import seq
|
||||||
import os
|
|
||||||
import re
|
|
||||||
from errors import TemplateError
|
|
||||||
|
|
||||||
from utils.rpmutils import seq
|
|
||||||
|
|
||||||
|
|
||||||
class Container(object):
|
class Container(object):
|
||||||
|
|
||||||
def __init__(self, attrs=None):
|
def __init__(self, attrs=None):
|
||||||
self.__dict__['__internal'] = {}
|
self.__dict__["__internal"] = {}
|
||||||
self.__dict__['__internal']['attrs'] = set()
|
self.__dict__["__internal"]["attrs"] = set()
|
||||||
|
|
||||||
if attrs:
|
if attrs:
|
||||||
self.addAttr(attrs)
|
self.addAttr(attrs)
|
||||||
@ -46,29 +42,29 @@ class Container(object):
|
|||||||
self.__checkInternal(attr)
|
self.__checkInternal(attr)
|
||||||
|
|
||||||
if attr not in self.__dict__:
|
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]
|
return self.__dict__[attr]
|
||||||
|
|
||||||
def __setattr__(self, attr, value):
|
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):
|
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):
|
def addAttr(self, attrs):
|
||||||
for attr in filter(lambda attr: attr not in self.__dict__, seq(attrs)):
|
for attr in filter(lambda attr: attr not in self.__dict__, seq(attrs)):
|
||||||
self.__checkInternal(attr)
|
self.__checkInternal(attr)
|
||||||
|
|
||||||
self.__dict__[attr] = None
|
self.__dict__[attr] = None
|
||||||
self.__dict__['__internal']['attrs'].add(attr)
|
self.__dict__["__internal"]["attrs"].add(attr)
|
||||||
|
|
||||||
def delAttr(self, attrs):
|
def delAttr(self, attrs):
|
||||||
for attr in filter(lambda attr: attr in self.__dict__, seq(attrs)):
|
for attr in filter(lambda attr: attr in self.__dict__, seq(attrs)):
|
||||||
self.__checkInternal(attr)
|
self.__checkInternal(attr)
|
||||||
|
|
||||||
del self.__dict__[attr]
|
del self.__dict__[attr]
|
||||||
self.__dict__['__internal']['attrs'].discard(attr)
|
self.__dict__["__internal"]["attrs"].discard(attr)
|
||||||
|
|
||||||
def set(self, **kwargs):
|
def set(self, **kwargs):
|
||||||
unknown = set()
|
unknown = set()
|
||||||
@ -84,95 +80,11 @@ class Container(object):
|
|||||||
|
|
||||||
def __makeDict(self):
|
def __makeDict(self):
|
||||||
d = {}
|
d = {}
|
||||||
for attr in self.__dict__['__internal']['attrs']:
|
for attr in self.__dict__["__internal"]["attrs"]:
|
||||||
d[attr] = self.__dict__[attr]
|
d[attr] = self.__dict__[attr]
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def __checkInternal(self, attr):
|
def __checkInternal(self, attr):
|
||||||
if attr.startswith('__'):
|
if attr.startswith("__"):
|
||||||
raise AttributeError, "do not mess with internal objects"
|
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
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
149
src/pylorax/insttree.py
Normal file
149
src/pylorax/insttree.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
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()
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# errors.py
|
# misc.py
|
||||||
# lorax errors
|
# miscellaneous functions
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Red Hat, Inc.
|
# Copyright (C) 2009 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
@ -20,8 +20,22 @@
|
|||||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
class LoraxError(Exception):
|
import commands
|
||||||
pass
|
|
||||||
|
|
||||||
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
|
@ -39,57 +39,80 @@ C_LIGHTRED = "\x1b[1;31m"
|
|||||||
C_LIGHTGREEN = "\x1b[1;32m"
|
C_LIGHTGREEN = "\x1b[1;32m"
|
||||||
C_LIGHTBLUE = "\x1b[1;34m"
|
C_LIGHTBLUE = "\x1b[1;34m"
|
||||||
|
|
||||||
C_LIGHTGRAY = "\x1b[0;37m"
|
# font types
|
||||||
C_DARKGRAY = "\x1b[1;30m"
|
BOLD = 0b01
|
||||||
|
UNDERLINE = 0b10
|
||||||
|
|
||||||
|
|
||||||
|
class OutputError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class Output(object):
|
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
|
self.output = output
|
||||||
|
if not hasattr(self.output, "write"):
|
||||||
|
raise OutputError, "output does not support write()"
|
||||||
|
|
||||||
self.is_flushable = hasattr(self.output, "flush")
|
self.is_flushable = hasattr(self.output, "flush")
|
||||||
|
|
||||||
self.colors = colors
|
self.colors = colors
|
||||||
if encoding is None:
|
|
||||||
encoding = "utf-8"
|
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
|
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
||||||
def write(self, s, color=C_RESET, bold=False, underline=False):
|
self.__indent_level = 0
|
||||||
self.output.write(self.compose(s, color=color, bold=bold, underline=underline))
|
|
||||||
|
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:
|
if self.is_flushable:
|
||||||
self.output.flush()
|
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)
|
s = s.encode(self.encoding)
|
||||||
|
|
||||||
if self.colors:
|
if self.colors:
|
||||||
if bold:
|
if type is not None and (type & BOLD):
|
||||||
s = "%s%s" % (C_BOLD, s)
|
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" % (C_UNDERLINE, s)
|
||||||
s = "%s%s%s" % (color, s, C_RESET)
|
s = "%s%s%s" % (color, s, C_RESET)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def writeline(self, s, color=C_RESET, bold=False, underline=False):
|
def writeline(self, s, color=C_RESET, type=None):
|
||||||
self.write("%s\n" % (s,), color=color, bold=bold, underline=underline)
|
s = "%s%s\n" % (" " * self.__indent_level, s)
|
||||||
|
self.write(s, color=color, type=type)
|
||||||
|
|
||||||
def banner(self, s):
|
def indent(self):
|
||||||
self.writeline(s, color=C_BLUE, bold=True)
|
self.__indent_level += 1
|
||||||
|
|
||||||
def header(self, s):
|
def unindent(self):
|
||||||
self.writeline(s, bold=True)
|
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)
|
self.writeline(s)
|
||||||
|
|
||||||
def error(self, s):
|
def error(self, s, indent_level=0):
|
||||||
self.writeline(s, color=C_RED, bold=True)
|
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:
|
if self.verbose:
|
||||||
self.writeline(s)
|
self.writeline(s)
|
||||||
|
|
||||||
|
113
src/pylorax/template.py
Normal file
113
src/pylorax/template.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
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
|
||||||
|
|
@ -37,25 +37,25 @@ def normalize(src_root, src_path, dst_root, dst_path):
|
|||||||
return src, dst
|
return src, dst
|
||||||
|
|
||||||
|
|
||||||
def rm(target, verbose=False):
|
def remove(target, verbose=False):
|
||||||
for fname in glob.iglob(target):
|
for fname in glob.iglob(target):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "removing '%s'" % fname
|
print "removing '%s'" % (fname,)
|
||||||
|
|
||||||
if os.path.isdir(fname):
|
if os.path.islink(fname) or os.path.isfile(fname):
|
||||||
shutil.rmtree(fname, ignore_errors=True)
|
|
||||||
else:
|
|
||||||
os.unlink(fname)
|
os.unlink(fname)
|
||||||
|
else:
|
||||||
|
shutil.rmtree(fname, ignore_errors=True)
|
||||||
|
|
||||||
def touch(filename, verbose=False):
|
def touch(filename, verbose=False):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "touching '%s'" % filename
|
print "touching '%s'" % (filename,)
|
||||||
|
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
os.utime(filename, None)
|
os.utime(filename, None)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
f = open(filename, 'w')
|
f = open(filename, "w")
|
||||||
except IOError as why:
|
except IOError as why:
|
||||||
print >> sys.stderr, "cannot create '%s': %s" % (filename, why)
|
print >> sys.stderr, "cannot create '%s': %s" % (filename, why)
|
||||||
return False
|
return False
|
||||||
@ -64,49 +64,56 @@ def touch(filename, verbose=False):
|
|||||||
|
|
||||||
return True
|
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)
|
filecopy = Copy(ignore_errors, verbose)
|
||||||
|
|
||||||
src = os.path.join(src_root, src_path)
|
src = os.path.join(src_root, src_path)
|
||||||
for fname in glob.iglob(src):
|
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:]
|
fname = fname[1:]
|
||||||
|
|
||||||
filecopy.copy(fname, dst_path, src_root, dst_root, nolinks)
|
filecopy.copy(fname, dst_path, src_root, dst_root, nolinks)
|
||||||
|
|
||||||
return filecopy.errors
|
return filecopy.errors
|
||||||
|
|
||||||
def mv(src_path, dst_path, src_root='/', dst_root='/', nolinks=False, ignore_errors=False, verbose=False):
|
def move(src_path, dst_path, src_root="/", dst_root="/",
|
||||||
errors = cp(src_path, dst_path, src_root, dst_root, ignore_errors, verbose)
|
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:
|
if not errors:
|
||||||
src, dst = normalize(src_root, src_path, dst_root, dst_path)
|
src, dst = normalize(src_root, src_path, dst_root, dst_path)
|
||||||
rm(src, verbose)
|
remove(src, verbose)
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
def chmod(target, mode, recursive=False, verbose=False):
|
def chmod(target, mode, recursive=False, verbose=False):
|
||||||
|
mode = int(mode)
|
||||||
|
|
||||||
for fname in glob.iglob(target):
|
for fname in glob.iglob(target):
|
||||||
if verbose:
|
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):
|
if recursive and os.path.isdir(fname):
|
||||||
for nested in os.listdir(fname):
|
for nested in os.listdir(fname):
|
||||||
nested = os.path.join(fname, nested)
|
nested = os.path.join(fname, nested)
|
||||||
chmod(nested, mode)
|
chmod(nested, mode, recursive, verbose)
|
||||||
|
|
||||||
def edit(filename, text, append=False, verbose=False):
|
def edit(filename, text, append=False, verbose=False):
|
||||||
mode = 'w'
|
mode = "w"
|
||||||
if append:
|
if append:
|
||||||
mode = 'a'
|
mode = "a"
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "editing '%s'" % filename
|
print "editing '%s'" % (filename,)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open(filename, mode)
|
f = open(filename, mode)
|
||||||
@ -144,13 +151,13 @@ class Copy(object):
|
|||||||
|
|
||||||
self.errors = []
|
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
|
# normalize the source and destination paths
|
||||||
src, dst = normalize(src_root, src_path, dst_root, dst_path)
|
src, dst = normalize(src_root, src_path, dst_root, dst_path)
|
||||||
|
|
||||||
# check if the source exists
|
# check if the source exists
|
||||||
if not os.path.exists(src):
|
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:
|
if not self.ignore_errors:
|
||||||
raise self.Error, err_msg
|
raise self.Error, err_msg
|
||||||
else:
|
else:
|
||||||
@ -171,7 +178,7 @@ class Copy(object):
|
|||||||
# overwrite file
|
# overwrite file
|
||||||
try:
|
try:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "overwriting '%s'" % dst
|
print "overwriting '%s'" % (dst,)
|
||||||
os.unlink(dst)
|
os.unlink(dst)
|
||||||
except OSError as why:
|
except OSError as why:
|
||||||
err_msg = "cannot overwrite file '%s': %s" % (dst, why)
|
err_msg = "cannot overwrite file '%s': %s" % (dst, why)
|
||||||
@ -185,7 +192,8 @@ class Copy(object):
|
|||||||
elif os.path.isdir(dst):
|
elif os.path.isdir(dst):
|
||||||
|
|
||||||
# do not overwrite directory with a file
|
# 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:
|
if not self.ignore_errors:
|
||||||
raise self.Error, err_msg
|
raise self.Error, err_msg
|
||||||
else:
|
else:
|
||||||
@ -198,7 +206,8 @@ class Copy(object):
|
|||||||
if nolinks:
|
if nolinks:
|
||||||
self.__copy_file(os.path.realpath(src), dst)
|
self.__copy_file(os.path.realpath(src), dst)
|
||||||
else:
|
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:
|
else:
|
||||||
|
|
||||||
@ -227,7 +236,8 @@ class Copy(object):
|
|||||||
dst = os.path.join(new_dst, os.path.basename(fname))
|
dst = os.path.join(new_dst, os.path.basename(fname))
|
||||||
shutil.copytree(fname, dst, symlinks=False)
|
shutil.copytree(fname, dst, symlinks=False)
|
||||||
else:
|
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:
|
else:
|
||||||
|
|
||||||
@ -236,7 +246,8 @@ class Copy(object):
|
|||||||
os.makedirs(new_dst)
|
os.makedirs(new_dst)
|
||||||
|
|
||||||
if os.path.isfile(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:
|
if not self.ignore_errors:
|
||||||
raise self.Error, err_msg
|
raise self.Error, err_msg
|
||||||
else:
|
else:
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
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()
|
|
@ -21,48 +21,68 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import commands
|
|
||||||
import re
|
import re
|
||||||
|
import commands
|
||||||
|
|
||||||
|
|
||||||
class LDD(object):
|
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():
|
for line in f.readlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line.startswith('RTLDLIST='):
|
if line.startswith("RTLDLIST="):
|
||||||
rtldlist, sep, ld_linux = line.partition('=')
|
rtldlist, sep, ld_linux = line.partition("=")
|
||||||
break
|
break
|
||||||
f.close()
|
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<lib>[a-zA-Z0-9./-]*)\s\(0x[0-9a-f]*\)$"
|
||||||
|
self.pattern = re.compile(pattern)
|
||||||
|
|
||||||
self._deps = set()
|
self._deps = set()
|
||||||
|
|
||||||
def getDeps(self, filename):
|
self._errors = []
|
||||||
rc, output = commands.getstatusoutput('%s %s' % (self._ldd, filename))
|
|
||||||
|
|
||||||
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
|
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:
|
for line in lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
||||||
m = re.match(r'^[a-zA-Z0-9.]*\s=>\s(?P<lib>[a-zA-Z0-9./]*)\s\(0x[0-9a-f]*\)$', line)
|
m = self.pattern.match(line)
|
||||||
if m:
|
if m:
|
||||||
lib = m.group('lib')
|
lib = m.group("lib")
|
||||||
if lib not in self._deps:
|
if lib not in self._deps:
|
||||||
self._deps.add(lib)
|
self._deps.add(lib)
|
||||||
self.getDeps(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
|
@property
|
||||||
def deps(self):
|
def deps(self):
|
||||||
return self._deps
|
return self._deps
|
||||||
|
|
||||||
|
@property
|
||||||
|
def errors(self):
|
||||||
|
return self._errors
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
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
|
|
129
src/pylorax/utils/yumwrapper.py
Normal file
129
src/pylorax/utils/yumwrapper.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Red Hat Author(s): Martin Gracik <mgracik@redhat.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
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()
|
Loading…
Reference in New Issue
Block a user