Huge commit; moved a lot of stuff around; added code for install.img

This commit is contained in:
Martin Gracik 2009-08-19 16:51:32 +02:00
parent 3325611694
commit 87f9575d8f
75 changed files with 3123 additions and 4151 deletions

View File

@ -1,94 +1,84 @@
#
# Kernel modules for the initrd.img boot image
# One module per line. Lorax will use module-init-utils to resolve
# dependencies and make sure the modules specified here have all of
# the required modules in order to load.
#
=net
=scsi
aes_generic
appletouch
arc4
cbc
cifs
cramfs
crc32c
crypto_blkcipher
dm-crypt
dm-emc
dm-mirror
dm-mod
dm-multipath
dm-round-robin
dm-snapshot
dm-zero
drm
ecb
edd
ehci-hcd
ext2
ext3
ext4dev
fat
firewire-ohci
firewire-sbp2
vfat
nfs
sunrpc
lockd
floppy
cramfs
loop
edd
pcspkr
squashfs
ipv6
virtio_pci
ohci-hcd
uhci-hcd
ehci-hcd
usbhid
mousedev
usb-storage
sd_mod
sr_mod
ub
appletouch
ohci1394
sbp2
fw-ohci
fw-sbp2
gfs2
hid
i810
i82365
i830
i915
firewire-sbp2
firewire-ohci
mmc-block
sdhci
sdhci-pci
ide-cd
ide-cd_mod
ipv6
sr_mod
sg
st
sd_mod
scsi_mod
iscsi_tcp
jfs
linear
lock_nolock
lockd
loop
lrw
mga
mousedev
iscsi_ibft
fat
msdos
nfs
nouveau
ohci-hcd
ohci1394
pcmcia
pcspkr
r128
radeon
vfat
ext2
ext3
ext4
reiserfs
jfs
xfs
gfs2
cifs
fuse
btrfs
dm-mod
dm-zero
dm-snapshot
dm-mirror
dm-multipath
dm-round-robin
dm-crypt
raid0
raid1
raid10
raid456
raid5
raid6
reiserfs
savage
sbp2
scsi_mod
sd_mod
sg
raid456
raid10
linear
sha256_generic
sis
squashfs
sr_mod
st
sunrpc
tcic
tdfx
ub
uhci-hcd
usb-storage
vfat
via
virtio_pci
xfs
cbc
xts
lrw
aes_generic
crypto_blkcipher
crc32c
ecb
arc4
yenta_socket
i82365
tcic
pcmcia
=scsi
=net
=drm

View File

@ -1,22 +1,9 @@
#
# List of packages or files required to build boot and install images.
# One package or filename per line. Dependencies resovled by yum.
#
# Packages may be excluded by prefixing them with a minus (-) sign.
#
# Per-architecture packages can be specified in packages.ARCH files.
# These are added to this list to form the final package set for that
# platform.
#
/etc/gtk-2.0/gtkrc
GConf2
NetworkManager
ORBit2
PolicyKit
VLGothic-fonts
acl
anaconda
#anaconda
anaconda-yum-plugins
at-spi
atk
@ -24,73 +11,57 @@ attr
audit-libs
bash
bitmap-fonts-cjk
booty
busybox-anaconda
btrfs-progs
bzip2
bzip2-libs
cairo
cjkunifonts-ukai
cjkuni-uming-fonts
comps-extras
coreutils
cpio
cracklib
cracklib-dicts
cracklib-python
cryptsetup-luks
db4
dbus
dbus-python
dejavu-fonts
dejavu-sans-fonts
dejavu-sans-mono-fonts
device-mapper
device-mapper-libs
dhclient
dhcpv6-client
dmapi
dmraid
dmraid-libs
dogtail
dosfstools
dump
e2fsprogs
e2fsprogs-libs
echo-icon-theme
ethtool
elfutils-libelf
expat
findutils
firstaidkit-plugin-all
firstboot
fontconfig
fonts-ISO8859-2
fonts-arabic
fonts-bengali
fonts-chinese
fonts-gujarati
fonts-hindi
fonts-indic
fonts-kannada
fonts-korean
fonts-malayalam
fonts-oriya
fonts-punjabi
fonts-sinhala
fonts-tamil
fonts-telugu
freetype
ftp
gail
gawk
gdb-gdbserver
gdk-pixbuf
gfs2-utils
glib2
glibc
glibc-common
gnome-python2-canvas
gnome-python2-gconf
gnome-python2-gtkhtml2
gnome-themes
gpm
grep
gtk2
gtk2-engines
gtkhtml2
gzip
hal
hdparm
hwdata
@ -99,10 +70,8 @@ iproute
iputils
iscsi-initiator-utils
jfsutils
joe
keyutils-libs
krb5-libs
less
libICE
libSM
libX11
@ -130,20 +99,14 @@ libattr
libbdevid
libbdevid-python
libbonobo
libdhcp
libdhcp4client
libdhcp6client
libfontenc
libgcc
libgcrypt
libglade2
libgnomecanvas
libgcrypt
libgpg-error
libidn
libjpeg
liblbxutil
libnl
libpixman
libpng
libselinux
libselinux-python
@ -151,7 +114,6 @@ libsemanage
libsemanage-python
libsepol
libstdc++
libtermcap
libthai
libuser
libuser-python
@ -159,16 +121,26 @@ 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
man
madan-fonts
mdadm
mesa-dri-drivers
mkinitrd
module-init-tools
modutils
mt-st
mtools
mtr
nash
ncurses
neon
@ -178,17 +150,12 @@ newt-python
nfs-utils
nspr
nss
ntfsprogs
open
openssh
openssh-clients
openssl
ntfs-3g
pam
pango
parted
pciutils
pcre
policy
policycoreutils
popt
prelink
@ -199,16 +166,14 @@ pygtk2
pygtk2-libglade
pykickstart
pyparted
pyspi
python
python-bugzilla
python-elementtree
python-decorator
python-libs
python-pyblock
python-sqlite
python-urlgrabber
pyxf86config
raidtools
readline
redhat-artwork
reiserfs-utils
@ -216,67 +181,80 @@ rhpl
rpm
rpm-libs
rpm-python
rsh
rsync
samba-client
sed
selinux-policy-targeted
setup
slang
smartmontools
smc-meera-fonts
specspo
sqlite
synaptics
system-config-date
system-config-keyboard
system-logos
system-release
#${brandpkgname}-logos
#${brandpkgname}-release
taipeifonts
tar
tcp_wrappers
traceroute
ttfonts-bn
ttfonts-gu
ttfonts-hi
ttfonts-ja
ttfonts-ko
ttfonts-pa
ttfonts-ta
ttfonts-zh_CN
ttfonts-zh_TW
tzdata
udev
un-core-fonts-dotum
urw-fonts
util-linux-ng
vnc-libs
vnc-server
tigervnc-server
tigervnc-server-module
vlgothic-fonts
vim-minimal
wpa_supplicant
xkeyboard-config
xfsdump
xfsprogs
xkeyboard-config
xorg-x11
xorg-x11-auth
xorg-x11-base
xorg-x11-drivers
xorg-x11-font-utils
xorg-x11-fonts-100dpi
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-1-75dpi
xorg-x11-fonts-ISO8859-15-75dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ISO8859-9-75dpi
xorg-x11-fonts-cyrillic
xorg-x11-fonts-ethiopic
xorg-x11-fonts-misc
xorg-x11-libs
xorg-x11-libs-data
xorg-x11-server-Xorg
xorg-x11-server-utils
xorg-x11-xfs
xorg-x11-server-Xorg
xorg-x11-xkb-utils
xorg-x11-xkbdata
yum
yum-fedorakmod
xorg-x11-xfs yum
yum-metadata-parser
zenity
zlib
#/etc/gtk-2.0/gtkrc
glibc
openssl
# rescue
bzip2
bzip2-libs
dump
libidn
findutils
ftp
gzip
iputils
joe
krb5-libs
less
man
modutils
mtools
mt-st
mtr
net-tools
smartmontools
openssh
openssh-clients
pciutils
rsh
traceroute
tar
rsync
device-mapper
device-mapper-libs
dmraid
ntfsprogs
samba-client
firstaidkit
firstaidkit-plugin-all
dialog

View File

@ -1,11 +1,11 @@
-glibc
-openssl
dmidecode
efibootmgr
glibc.i386
gpart
grub
memtest86+
openssl.i386
pcmciautils
grub
dmidecode
efibootmgr
gpart
syslinux
memtest86+

View File

@ -0,0 +1,11 @@
-glibc
-openssl
glibc.i586
openssl.i586
pcmciautils
grub
dmidecode
efibootmgr
gpart
syslinux
memtest86+

View File

@ -1,2 +1,3 @@
dmidecode
efibootmgr
elilo

View File

@ -1,6 +1,6 @@
fbset
hfsutils
pcmciautils
pdisk
ppc64-utils
yaboot
hfsutils
fbset
ppc64-utils

1
etc/packages/packages.ppc64 Symbolic link
View File

@ -0,0 +1 @@
packages.ppc

View File

@ -1,21 +1,19 @@
bash
s390utils
binutils
coreutils
gawk
grep
initscripts
libgcc
login
modutils
mount
tcp_wrappers
sed
net-tools
openssh
openssh-server
pam
coreutils
login
initscripts
portmap
s390utils
sed
pam
mount
modutils
s390utils-cmsfs
strace
tcp_wrappers
xorg-x11-libs
xorg-x11-xauth
xorg-x11-libs

1
etc/packages/packages.s390x Symbolic link
View File

@ -0,0 +1 @@
packages.s390

View File

@ -1,2 +1,2 @@
silo
tilo
silo

View File

@ -1,7 +1,7 @@
pcmciautils
grub
dmidecode
efibootmgr
gpart
grub
memtest86+
pcmciautils
syslinux
memtest86+

View File

@ -1,4 +0,0 @@
hfsutils
pcmciautils
pdisk
yaboot

View File

@ -1,21 +0,0 @@
bash
binutils
coreutils
gawk
grep
initscripts
libgcc
login
modutils
mount
net-tools
openssh
openssh-server
pam
portmap
s390utils
sed
strace
tcp_wrappers
xorg-x11-libs
xorg-x11-xauth

View File

@ -3,7 +3,9 @@
# create required directories
makedir @initrd@/modules
makedir @initrd@/firmware
makedir @initrd@/lib/modules
makedir @initrd@/lib
link @initrd@/modules to @initrd@/lib/modules
link @initrd@/firmware to @initrd@/lib/firmware
makedir @initrd@/lib/firmware
makedir @initrd@/sbin
makedir @initrd@/dev
@ -54,18 +56,19 @@ edit @initrd@/etc/arch text "@buildarch@"
copy @instroot@/etc/passwd to @initrd@/etc mode 0644
copy @instroot@/etc/group to @initrd@/etc mode 0644
copy @instroot@/etc/nsswitch.conf to @initrd@/etc mode 0644
copy @instroot@/etc/hosts to @initrd@/etc/ mode 0644
# copy mount/umount
copy @instroot@/bin/mount to @initrd@/sbin
copy @instroot@/bin/umount to @initrd@/sbin
copy @instroot@/sbin/mount.nfs to @initrd@/sbin
link @initrd@/sbin/umount.nfs to mount.nfs
copy @instroot@/sbin/mount.* to @initrd@/sbin
copy @instroot@/sbin/umount.* to @initrd@/sbin
# copy udev
copy @instroot@/sbin/udevd to @initrd@/sbin
copy @instroot@/sbin/udevadm to @initrd@/sbin
link @initrd@/sbin/udevinfo to udevadm
link @initrd@/sbin/udevsettle to udevadm
copy @instroot@/sbin/udevinfo to @initrd@/sbin
copy @instroot@/sbin/udevsettle to @initrd@/sbin
# udev rules
copy @instroot@/etc/udev/udev.conf to @initrd@/etc/udev mode 0644
@ -87,7 +90,15 @@ link @initrd@/etc/init.d to /etc/rc.d/init.d
# dhcp and dhcpv6 client daemons and support programs
copy @instroot@/sbin/dhclient to @initrd@/sbin
copy @instroot@/sbin/dhclient-script to @initrd@/sbin
copy @instroot@/sbin/dhcp6c to @initrd@/sbin
copy @instroot@/sbin/arping to @initrd@/sbin
copy @instroot@/sbin/ifconfig to @initrd@/sbin
copy @instroot@/sbin/ip to @initrd@/sbin
copy @instroot@/bin/ipcalc to @initrd@/sbin
copy @instroot@/bin/hostname to @initrd@/sbin
copy @instroot@/sbin/ethtool to @initrd@/sbin
copy @instroot@/sbin/route to @initrd@/sbin
touch @initrd@/etc/resolv.conf
# hwdata
@ -157,6 +168,20 @@ copy @instroot@/usr/share/terminfo/x/xterm-color to @initrd@/etc/terminfo/x mode
copy @instroot@/usr/share/terminfo/g/gnome to @initrd@/etc/terminfo/g mode 0644
# misc
copy @instroot@/bin/awk to @initrd@/sbin
copy @instroot@/bin/gawk to @initrd@/sbin
copy @instroot@/bin/egrep to @initrd@/sbin
copy @instroot@/bin/fgrep to @initrd@/sbin
copy @instroot@/bin/grep to @initrd@/sbin
copy @instroot@/bin/kill to @initrd@/sbin
copy @instroot@/bin/ln to @initrd@/sbin
copy @instroot@/bin/readlink to @initrd@/sbin
copy @instroot@/bin/rm to @initrd@/sbin
copy @instroot@/bin/rmdir to @initrd@/sbin
copy @instroot@/bin/sed to @initrd@/sbin
copy @instroot@/bin/sleep to @initrd@/sbin
copy @instroot@/bin/touch to @initrd@/sbin
link @initrd@/init to /sbin/init
link @initrd@/etc/mtab to /proc/mounts
link @initrd@/bin to sbin

View File

@ -10,3 +10,6 @@ link @initrd@/sbin/poweroff to init
# screenfont
copy @instroot@/usr/lib/anaconda-runtime/screenfont-@buildarch@.gz to @initrd@/etc/screenfont.gz
# keymaps
copy @instroot@/keymaps to @initrd@/etc/keymaps.gz

View File

@ -13,12 +13,15 @@ copy @instroot@/usr/bin/xauth to @initrd@/sbin
copy @instroot@/usr/sbin/cmsfs* to @initrd@/sbin
copy @instroot@/@libdir@/libpam_misc.so.0.* to @initrd@/@libdir@/libpam_misc.so.0
copy @instroot@/@libdir@/libwrap*.so* to @initrd@/@libdir@
link @initrd@/var/state/xkb to /tmp
# loader
copy @instroot@/usr/lib/anaconda-runtime/loader/shutdown to @initrd@/sbin
copy @instroot@/usr/lib/anaconda-runtime/loader/linuxrc.s390 to @initrd@/sbin/init
copy @instroot@/usr/lib/anaconda-runtime/loader/lsznet.raw to @initrd@/sbin/lsznet
copy @instroot@/usr/lib/anaconda-runtime/loader/controlunits.sh @initrd@/sbin/controlunits
copy @instroot@/usr/sbin/dasdfmt to @initrd@/sbin
# setup shell environment
@ -30,9 +33,9 @@ copy @instroot@/@libdir@/security/pam_unix.so to @initrd@/@libdir@/security
copy @instroot@/@libdir@/security/pam_deny.so to @initrd@/@libdir@/security
copy @instroot@/etc/pam.d/other to @initrd@/etc/pam.d
copy @datadir@/etc/pam.d/login to @initrd@/etc/pam.d/login
copy @datadir@/etc/pam.d/login to @initrd@/etc/pam.d/sshd
copy @datadir@/etc/pam.d/login to @initrd@/etc/pam.d/remote
copy @datadir@/pam.d/login to @initrd@/etc/pam.d/login
copy @datadir@/pam.d/login to @initrd@/etc/pam.d/sshd
copy @datadir@/pam.d/login to @initrd@/etc/pam.d/remote
copy @instroot@/etc/security/limits.conf to @initrd@/etc/security
copy @Instroot@/etc/security/pam_env.conf to @initrd@/etc/security
@ -43,9 +46,8 @@ genkey @initrd@/etc/ssh/ssh_host_key type rsa1
genkey @initrd@/etc/ssh/ssh_host_rsa_key type rsa
genkey @initrd@/etc/ssh/ssh_host_dsa_key type dsa
copy @datadir@/etc/ssh/sshd_config to @initrd@/etc/ssh/sshd_config mode 0600
copy @datadir@/sshd/sshd_config to @initrd@/etc/ssh/sshd_config mode 0600
# copy in the binaries
copy @instroot@/bin/login to @initrd@/sbin/login
copy @instroot@/usr/sbin/sshd to @initrd@/sbin/sshd
copy @instroot@/usr/bin/busybox to @initrd@/sbin/busybox

View File

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

View File

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

View File

@ -1,164 +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/lib/syslinux/syslinux-nomtools
if [ ! -f $SYSLINUX ]; then
echo "Warning: nomtools syslinux doesn't exist"
SYSLINUX=$IMGPATH/usr/bin/syslinux
if [ ! -f $SYSLINUX ]; then
echo "$SYSLINUX doesn't exist"
exit 1
fi
fi
# prepare a directory with the kernel, initrd, and various message files
# used to populate a boot image
prepareBootTree() {
(cd $BOOTDISKDIR; find . -maxdepth 1 ! -name "*.msg" ! -type d | cpio --quiet -p $MBD_BOOTTREE)
cp $MBD_FSIMAGE $MBD_BOOTTREE/initrd.img
cp $KERNELROOT/boot/vmlinuz-* $MBD_BOOTTREE/vmlinuz
if [ -f $IMGPATH/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg $MBD_BOOTTREE/splash.jpg
cp $IMGPATH/usr/lib/syslinux/vesamenu.c32 $MBD_BOOTTREE/vesamenu.c32
sed -i s'/default linux/default vesamenu.c32/g' $MBD_BOOTTREE/syslinux.cfg
sed -i 's/prompt 1/#prompt 1/g' $MBD_BOOTTREE/syslinux.cfg
elif [ -x $IMGPATH/usr/lib/anaconda-runtime/splashtolss.sh ]; then
$IMGPATH/usr/lib/anaconda-runtime/splashtolss.sh $BOOTDISKDIR/syslinux-splash.png $BOOTDISKDIR/splash.lss
if [ $? != 0 ]; then
echo $0: Failed to create splash.lss
exit 1
fi
cp $BOOTDISKDIR/splash.lss $MBD_BOOTTREE/splash.lss
elif [ -f $IMGPATH/usr/lib/anaconda-runtime/splash.lss ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/splash.lss $MBD_BOOTTREE/splash.lss
fi
rm -f $MBD_BOOTTREE/syslinux-splash.png
sed -i "s/@PRODUCT@/$PRODUCT/g" $MBD_BOOTTREE/syslinux.cfg
sed -i "s/@VERSION@/$VERSION/g" $MBD_BOOTTREE/syslinux.cfg
rm -f $MBD_BOOTTREE/memtest*
for file in $BOOTDISKDIR/*.msg; do
filename=`basename $file`
sed -e "s/@VERSION@/$VERSION/g" $file > $MBD_BOOTTREE/$filename
done
if [ $? != 0 ]; then
echo $0: Failed to copy messages from $BOOTDISKDIR to $MBD_BOOTTREE.
umount $MBD_BOOTTREE
rm -rf $MBD_BOOTTREE $MBD_TMPIMAGE
exit 1
fi
}
mkdir -p $TOPDESTPATH/images/pxeboot
cat > $TOPDESTPATH/images/README <<EOF
This directory contains image files that can be used to create media
capable of starting the $PRODUCT installation process.
The boot.iso file is an ISO 9660 image of a bootable CD-ROM. It is useful
in cases where the CD-ROM installation method is not desired, but the
CD-ROM's boot speed would be an advantage.
To use this image file, burn the file onto CD-R (or CD-RW) media as you
normally would.
EOF
makeBootImages() {
local initrd="initrd.img"
local kernelimage="vmlinuz"
if [ "$kernelvers" = "$kernelxen" ] ; then
local tag="${kernelvers#kernel}"
if [ -n "$tag" -a "$tag" != "$kernelvers" ] ; then
initrd="initrd${tag}.img"
kernelimage="vmlinuz${tag}"
fi
fi
echo "Building $initrd"
makeinitrd --initrdto $TOPDESTPATH/images/pxeboot/$initrd \
--initrdsize 8192 \
--loaderbin loader \
--modules "$INITRDMODS"
[ $? = 0 ] || exit 1
if [ "$kernelvers" != "$kernelxen" ] ; then
if [ -f $IMGPATH/usr/lib/syslinux/isolinux.bin ]; then
echo "Building isolinux directory"
MBD_BOOTTREE=$TOPDESTPATH/isolinux
MBD_FSIMAGE=$TOPDESTPATH/images/pxeboot/initrd.img
mkdir $MBD_BOOTTREE
cp $IMGPATH/usr/lib/syslinux/isolinux.bin $MBD_BOOTTREE/isolinux.bin
prepareBootTree
# isolinux needs the config file to be isolinux.cfg
mv $MBD_BOOTTREE/syslinux.cfg $MBD_BOOTTREE/isolinux.cfg
# copy in memtest if present
if [ -f $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* ]; then
cp $IMGPATH/usr/lib/anaconda-runtime/boot/memtest* $MBD_BOOTTREE/memtest
echo -e "label memtest86\n menu label ^Memory test\n kernel memtest\n append -\n" >> $MBD_BOOTTREE/isolinux.cfg
fi
else
echo "No isolinux binaries. Skipping isolinux creation"
fi
# symlink the kernel for pxe dir
ln $TOPDESTPATH/isolinux/vmlinuz $TOPDESTPATH/images/pxeboot/vmlinuz
cat > $TOPDESTPATH/images/pxeboot/README <<EOF
The files in this directory are useful for booting a machine via PXE.
The following files are available:
vmlinuz - the kernel used for the installer
initrd.img - an initrd with support for all install methods and
drivers supported for installation of $PRODUCT
EOF
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$BASEARCH]
kernel = images/pxeboot/vmlinuz
initrd = images/pxeboot/initrd.img
__EOT__
if [ -n "$BOOTISO" ]; then echo "boot.iso = images/$BOOTISO" >> $TOPDESTPATH/.treeinfo ; fi
fi
# set up the boot stuff for the xen guest kernel
if [ -z "$kernelxen" -o "$kernelvers" = "$kernelxen" ] ; then
cp $KERNELROOT/boot/vmlinuz-$version $TOPDESTPATH/images/pxeboot/$kernelimage
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-xen]
kernel = images/pxeboot/$kernelimage
initrd = images/pxeboot/$initrd
__EOT__
fi
}
doPostImages() {
if [ -n "$BOOTISO" ]; then
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -V "$PRODUCT" -T -graft-points isolinux=$TOPDESTPATH/isolinux images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
fi
}

View File

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

View File

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

View File

@ -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"
#}

View File

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

View File

@ -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
}

View File

@ -1,53 +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/generic.prm $TOPDESTPATH/images/generic.prm
cp -v $BOOTDISKDIR/generic.ins $TOPDESTPATH/generic.ins
$MKS390CDBOOT \
-i $TOPDESTPATH/images/kernel.img \
-r $TOPDESTPATH/images/initrd.img \
-p $TOPDESTPATH/images/generic.prm \
-o $TOPDESTPATH/images/cdboot.img
cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = images/kernel.img
initrd = images/initrd.img
initrd.size = images/initrd.size
generic.prm = images/generic.prm
generic.ins = generic.ins
cdboot.img = images/cdboot.img
__EOT__
}

View File

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

View File

@ -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;
}

View File

@ -18,68 +18,76 @@
# 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
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
;;
# 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
;;
# 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
;;
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
;;
--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
;;
*)
if [ -z "$REPO" ]; then
REPO=$1
else
EXTRA_REPOS="$EXTRA_REPOS $1"
fi
shift
;;
esac
done
@ -116,6 +124,10 @@ 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)
@ -167,6 +179,9 @@ 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
@ -180,11 +195,11 @@ 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/
cp -a $UPDATES/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
elif [ ! -f $f ]; then
cp -a $BUILDINSTDIR/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
cp -a $BUILDINSTDIR/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/
else
cp -a $f* $BUILDINSTDIR/
cp -a $f* $BUILDINSTDIR/
fi
done
@ -197,17 +212,19 @@ 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
$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH $UPDATES --imgdir $TREEDIR/install $yumconf || die "upd-instroot failed"
echo "Writing .treeinfo file..."
$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BUILDARCH --outfile=$OUTPUT/.treeinfo
# 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
echo "Making images..."
$MK_IMAGES $DEBUGSTR $NOGRSTR --imgdir $TREEDIR/install --arch $BUILDARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" --output $OUTPUT $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=$BUILDARCH --discNum="ALL" --outfile=$OUTPUT/.discinfo
$MK_STAMP --releasestr="$RELEASESTR" --arch=$BASEARCH --discNum="ALL" --outfile=$OUTPUT/.discinfo
rm -rf $TREEDIR $BUILDINSTDIR
rm -f $yumconf

View File

@ -6,19 +6,28 @@ 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/$LIBDIR/ld*.so* ; do
for ldso in $root/$LDSODIR/ld*.so* ; do
[ -L $ldso ] && continue
[ -x $ldso ] || continue
$ldso --verify $bin >/dev/null 2>&1 || continue
LDSO=$(echo $ldso |sed -e "s,$root,,")
$ldso --verify $bin >/dev/null 2>&1
case $? in
[02]) LDSO=$(echo $ldso |sed -e "s,$root,,") ; break ;;
esac
done
fi
@ -73,9 +82,14 @@ EOF
DSO_DEPS="${FILES[@]}"
for l in $(/usr/sbin/chroot $root find /$LIBDIR -maxdepth 1 -type l -name ld*.so*); do
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"
}
@ -98,13 +112,19 @@ instFile() {
cp -aL $FILE $DESTROOT/`dirname $FILE`
fi
file $FILE | egrep -q ": (setuid )?ELF" && {
get_dso_deps $(pwd) "$FILE"
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() {

69
rewrite/scripts/getkeymaps Executable file
View File

@ -0,0 +1,69 @@
#!/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

View File

@ -0,0 +1,47 @@
#
# 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]))

212
rewrite/scripts/makeupdates Executable file
View File

@ -0,0 +1,212 @@
#!/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)

View File

@ -25,7 +25,7 @@ IMAGEUUID=$(date +%Y%m%d%H%M).$(uname -i)
TMPDIR=${TMPDIR:-/tmp}
usage () {
echo "usage: mk-images <pkgsrc> <toplevel> <template> <imgdir> <buildarch> <productname> <version> [<productpath>]"
echo "usage: mk-images <pkgsrc> <toplevel> <template> <imgdir> <buildarch> <productname> <version> [<productpath>]"
exit 0
}
@ -35,65 +35,54 @@ BOOTISO="boot.iso"
while [ $# -gt 0 ]; do
case $1 in
--debug)
DEBUG="--debug"
shift
;;
--noiso)
BOOTISO=""
shift
;;
--arch)
BUILDARCH=$2
shift; shift
;;
--imgdir)
IMGPATH=$2
shift; shift
;;
--product)
PRODUCT=$2
shift; shift
;;
--version)
VERSION=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
TOPDESTPATH=$2
shift; shift
;;
--nogr)
echo "*** DeprecationWarning: ignoring --nogr option." >&2
shift
;;
--mindir)
echo "*** DeprecationWarning: ignoring --mindir option." >&2
shift; shift
;;
--stg2dir)
echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
shift; shift
;;
*)
yumconf=$1
shift
;;
--debug)
DEBUG="--debug"
shift
;;
--noiso)
BOOTISO=""
shift
;;
--arch)
BUILDARCH=$2
shift; shift
;;
--imgdir)
IMGPATH=$2
shift; shift
;;
--product)
PRODUCT=$2
shift; shift
;;
--version)
VERSION=$2
shift; shift
;;
--bugurl)
BUGURL=$2
shift; shift
;;
--output)
TOPDESTPATH=$2
shift; shift
;;
--nogr)
echo "*** DeprecationWarning: ignoring --nogr option." >&2
shift
;;
--mindir)
echo "*** DeprecationWarning: ignoring --mindir option." >&2
shift; shift
;;
--stg2dir)
echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
shift; shift
;;
*)
yumconf=$1
shift
;;
esac
done
@ -107,126 +96,125 @@ TOPDIR=$(cd $TOPDIR; pwd)
# modules that are needed. this is the generic "needed for every arch" stuff
COMMONMODS="fat vfat nfs sunrpc lockd floppy cramfs loop edd pcspkr squashfs ipv6 virtio_pci"
USBMODS="ohci-hcd uhci-hcd ehci-hcd hid mousedev usb-storage sd_mod sr_mod ub appletouch"
USBMODS="ohci-hcd uhci-hcd ehci-hcd usbhid mousedev usb-storage sd_mod sr_mod ub appletouch"
FIREWIREMODS="ohci1394 sbp2 fw-ohci fw-sbp2 firewire-sbp2 firewire-ohci"
SDMODS="mmc-block sdhci sdhci-pci"
IDEMODS="ide-cd ide-cd_mod"
SCSIMODS="sr_mod sg st sd_mod scsi_mod iscsi_tcp iscsi_ibft"
FSMODS="fat msdos vfat ext2 ext3 ext4dev reiserfs jfs xfs gfs2 cifs"
FSMODS="fat msdos vfat ext2 ext3 ext4 reiserfs jfs xfs gfs2 cifs fuse btrfs"
LVMMODS="dm-mod dm-zero dm-snapshot dm-mirror dm-multipath dm-round-robin dm-crypt"
RAIDMODS="raid0 raid1 raid5 raid6 raid456 raid10 linear"
CRYPTOMODS="sha256_generic cbc xts lrw aes_generic crypto_blkcipher crc32c ecb arc4"
PCMCIASOCKMODS="yenta_socket i82365 tcic pcmcia"
DRMMODS="drm i810 i830 i915 mga nouveau r128 radeon savage sis tdfx via"
INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS $DRMMODS $SDMODS =scsi =net"
INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS $SDMODS =scsi =net =drm"
. $(dirname $0)/buildinstall.functions
# Set, verify, and create paths
IMAGEPATH=$TOPDESTPATH/images
FULLMODPATH=$TMPDIR/instimagemods.$$
FINALFULLMODPATH=$IMGPATH/modules
INSTIMGPATH=$TOPDESTPATH/images
KERNELBASE=$TMPDIR/updboot.kernel.$$
IMAGEPATH=$TOPDESTPATH/images
FULLMODPATH=$TMPDIR/instimagemods.$$
FINALFULLMODPATH=$IMGPATH/modules
INSTIMGPATH=$TOPDESTPATH/images
KERNELBASE=$TMPDIR/updboot.kernel.$$
KERNELNAME=vmlinuz
if [ "$BUILDARCH" = "ia64" ]; then
KERNELDIR="/boot/efi/EFI/redhat"
else
KERNELDIR="/boot"
fi
KERNELNAME=vmlinuz
if [ "$BUILDARCH" = "ia64" ]; then
KERNELDIR="/boot/efi/EFI/redhat"
else
KERNELDIR="/boot"
fi
if [ "$BUILDARCH" = "sparc64" ]; then
BASEARCH=sparc
else
BASEARCH=$BUILDARCH
fi
if [ "$BUILDARCH" = "sparc64" ]; then
BASEARCH=sparc
else
BASEARCH=$BUILDARCH
fi
# explicit block size setting for some arches (FIXME: we compose
# ppc64-ish trees as ppc, so we have to set the "wrong" block size)
if [ "$BUILDARCH" = "sparc64" ]; then
CRAMBS="--blocksize 8192"
elif [ "$BUILDARCH" = "sparc" ]; then
CRAMBS="--blocksize 4096"
else
CRAMBS=""
fi
# explicit block size setting for some arches (FIXME: we compose
# ppc64-ish trees as ppc, so we have to set the "wrong" block size)
if [ "$BUILDARCH" = "sparc64" ]; then
CRAMBS="--blocksize 8192"
elif [ "$BUILDARCH" = "sparc" ]; then
CRAMBS="--blocksize 4096"
else
CRAMBS=""
fi
if [ $BUILDARCH = x86_64 -o $BUILDARCH = s390x ]; then
LIBDIR=lib64
else
LIBDIR=lib
fi
if [ "$BUILDARCH" = "x86_64" -o "$BUILDARCH" = "s390x" -o "$BUILDARCH" = "ppc64" ]; then
LIBDIR=lib64
else
LIBDIR=lib
fi
rm -rf $IMAGEPATH
rm -rf $FULLMODPATH
rm -rf $FINALFULLMODPATH
rm -rf $KERNELBASE
mkdir -p $IMAGEPATH
mkdir -p $FULLMODPATH
mkdir -p $FINALFULLMODPATH
mkdir -p $KERNELBASE
mkdir -p $INSTIMGPATH
rm -rf $IMAGEPATH
rm -rf $FULLMODPATH
rm -rf $FINALFULLMODPATH
rm -rf $KERNELBASE
mkdir -p $IMAGEPATH
mkdir -p $FULLMODPATH
mkdir -p $FINALFULLMODPATH
mkdir -p $KERNELBASE
mkdir -p $INSTIMGPATH
# Stuff that we need
TRIMPCIIDS=$IMGPATH/usr/lib/anaconda-runtime/trimpciids
GETKEYMAPS=$IMGPATH/usr/lib/anaconda-runtime/getkeymaps
GENINITRDSZ=$IMGPATH/usr/lib/anaconda-runtime/geninitrdsz
MKS390CDBOOT=$IMGPATH/usr/lib/anaconda-runtime/mk-s390-cdboot
GENMODINFO=$IMGPATH/usr/lib/anaconda-runtime/genmodinfo
KEYMAPS=$TMPDIR/keymaps-$BUILDARCH.$$
SCREENFONT=$IMGPATH/usr/lib/anaconda-runtime/screenfont-${BASEARCH}.gz
MODLIST=$IMGPATH/usr/lib/anaconda-runtime/modlist
MODINFO=$TMPDIR/modinfo-$BUILDARCH.$$
LOADERBINDIR=$IMGPATH/usr/lib/anaconda-runtime/loader
BOOTDISKDIR=$IMGPATH/usr/lib/anaconda-runtime/boot
LANGTABLE=$IMGPATH/usr/lib/anaconda/lang-table
PCIIDS=$IMGPATH/usr/share/hwdata/pci.ids
XDRIVERS=$IMGPATH/usr/share/hwdata/videoaliases
XDRIVERDESCS=$IMGPATH/usr/share/hwdata/videodrivers
TRIMPCIIDS=$IMGPATH/usr/lib/anaconda-runtime/trimpciids
GETKEYMAPS=$IMGPATH/usr/lib/anaconda-runtime/getkeymaps
GENINITRDSZ=$IMGPATH/usr/lib/anaconda-runtime/geninitrdsz
MKS390CDBOOT=$IMGPATH/usr/lib/anaconda-runtime/mk-s390-cdboot
GENMODINFO=$IMGPATH/usr/lib/anaconda-runtime/genmodinfo
KEYMAPS=$TMPDIR/keymaps-$BUILDARCH.$$
SCREENFONT=$IMGPATH/usr/lib/anaconda-runtime/screenfont-${BASEARCH}.gz
MODLIST=$IMGPATH/usr/lib/anaconda-runtime/modlist
MODINFO=$TMPDIR/modinfo-$BUILDARCH.$$
LOADERBINDIR=$IMGPATH/usr/lib/anaconda-runtime/loader
BOOTDISKDIR=$IMGPATH/usr/lib/anaconda-runtime/boot
LANGTABLE=$IMGPATH/usr/lib/anaconda/lang-table
PCIIDS=$IMGPATH/usr/share/hwdata/pci.ids
XDRIVERS=$IMGPATH/usr/share/hwdata/videoaliases
XDRIVERDESCS=$IMGPATH/usr/share/hwdata/videodrivers
REQUIREMENTS="$TRIMPCIIDS $PCIIDS $XDRIVERDESCS $GENMODINFO
$LANGTABLE $GETKEYMAPS"
REQUIREMENTS="$TRIMPCIIDS $PCIIDS $XDRIVERDESCS $GENMODINFO
$LANGTABLE $GETKEYMAPS"
dieLater=
for n in $REQUIREMENTS; do
if [ ! -f $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
for n in $BOOTDISKDIR; do
if [ ! -d $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
if [ -n "$dieLater" ]; then exit 1; fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
# go ahead and create the keymaps so we only have to do it once
if [ -f $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH ]; then
echo "Found keymap override, using it"
cp $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH $KEYMAPS
else
echo "Running: $GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH"
$GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH
if [ $? != 0 ]; then
echo "Unable to create keymaps and thus can't create initrd."
exit 1
fi
fi
dieLater=
for n in $REQUIREMENTS; do
if [ ! -f $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
for n in $BOOTDISKDIR; do
if [ ! -d $n ]; then
echo "$n doesn't exist"
dieLater=1
fi
done
if [ -n "$dieLater" ]; then exit 1; fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
# go ahead and create the keymaps so we only have to do it once
if [ -f $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH ]; then
echo "Found keymap override, using it"
cp $IMGPATH/usr/lib/anaconda-runtime/keymaps-override-$BUILDARCH $KEYMAPS
else
echo "Running: $GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH"
$GETKEYMAPS $BUILDARCH $KEYMAPS $IMGPATH
if [ $? != 0 ]; then
echo "Unable to create keymaps and thus can't create initrd."
exit 1
fi
fi
fi
findPackage() {
name=$1
pkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" -c $yumconf --archlist=$KERNELARCH $name.$KERNELARCH)
if [ -n "$pkg" ]; then
echo $pkg
return
echo $pkg
return
fi
echo "cannot find package $name" >&2
}
@ -258,13 +246,24 @@ resdeps () {
expandModuleSet() {
SET=""
for name in $1; do
char=$(echo $name | cut -c1)
char=$(echo $name | cut -c1)
if [ $char = '=' ]; then
NAME=$(echo $name | cut -c2-)
SET="$SET $($MODLIST --modinfo-file $MODINFO $NAME)"
else
SET="$SET $name"
fi
if [ "$NAME" = "ata" ]; then
SET="$SET $(egrep '(ata|ahci)' $KERNELROOT/lib/modules/$version/modules.block |sed -e 's/.ko//')"
elif [ "$NAME" = "scsi" ]; then
SET="$SET $(sed -e 's/.ko//' $KERNELROOT/lib/modules/$version/modules.block)"
elif [ "$NAME" = "net" ]; then
SET="$SET $(sed -e 's/.ko//' $KERNELROOT/lib/modules/$version/modules.networking)"
else
# Ignore if group list does not exist
if [ -e $KERNELROOT/lib/modules/$version/modules.$NAME ]; then
SET="$SET $(sed -e 's/.ko//' $KERNELROOT/lib/modules/$version/modules.$NAME)"
fi
fi
else
SET="$SET $name"
fi
done
echo $SET
@ -291,42 +290,48 @@ makemoduletree() {
}
done
# Copy in driver firmware we want during installation. NOTE: This isn't
# the ideal solution, but we'll do this for now. What we really want is
# for the kernel modules to include a modinfo field that names the firmware
# file we should have. If we can get that it would make it even easier to
# push the kernel people to depend on the firmware packages in the kernel,
# but we have to take small steps first.
echo "Copying required firmware..."
find $MMB_DIR/lib/modules/ -name *.ko | while read module ; do
for fw in $(modinfo -F firmware $module); do
dest=$MBD_DIR/firmware/$fw
destdir=$(dirname $dest)
# Some firmware files are expected to be in their own directories.
if [ ! -d $destdir ]; then
mkdir -p $destdir
fi
cp $KERNELROOT/lib/firmware/$fw $dest
done
done
# Copy in driver firmware we know we'll want during installation. This is
# required for modules which still don't (or can't) export information
# about what firmware files they require.
for module in $MODSET ; do
case $module in
ipw2100)
cp $KERNELROOT/lib/firmware/ipw2100* $MBD_DIR/firmware
;;
;;
ipw2200)
cp $KERNELROOT/lib/firmware/ipw2200* $MBD_DIR/firmware
;;
;;
iwl3945)
cp $KERNELROOT/lib/firmware/iwlwifi-3945* $MBD_DIR/firmware
;;
iwl4965)
cp $KERNELROOT/lib/firmware/iwlwifi-4965* $MBD_DIR/firmware
;;
;;
atmel)
cp $KERNELROOT/lib/firmware/atmel_*.bin $MBD_DIR/firmware
;;
;;
zd1211rw)
cp -r $KERNELROOT/lib/firmware/zd1211 $MBD_DIR/firmware
;;
qla2xxx)
cp $KERNELROOT/lib/firmware/ql* $MBD_DIR/firmware
;;
;;
esac
done
# clean up leftover cruft
find -H $MMB_DIR/lib/modules -type d -exec rmdir -f {} \; 2>/dev/null
$MODLIST --modinfo-file $MODINFO --ignore-missing --modinfo \
$MMB_MODULESET > $MMB_DIR/lib/modules/module-info
$MMB_MODULESET > $MMB_DIR/lib/modules/module-info
# compress modules
find -H $MMB_DIR/lib/modules -type f -name *.ko -exec gzip -9 {} \;
rundepmod $MMB_DIR
@ -335,7 +340,7 @@ makemoduletree() {
# create the pci.ids, from modules.alias and the X driver aliases
awk '!/^(\t\t|#)/ { print ;if ($0 == "ffff Illegal Vendor ID") nextfile; }' < $PCIIDS | \
$TRIMPCIIDS $MMB_DIR/lib/modules/*/modules.alias $XDRIVERS/* > ../pci.ids
$TRIMPCIIDS $MMB_DIR/lib/modules/*/modules.alias $XDRIVERS/* > ../pci.ids
}
@ -347,7 +352,7 @@ makeproductfile() {
echo $PRODUCT >> $root/.buildstamp
echo $VERSION >> $root/.buildstamp
if [ -n "$BUGURL" ]; then
echo $BUGURL >> $root/.buildstamp
echo $BUGURL >> $root/.buildstamp
fi
}
@ -357,27 +362,47 @@ instbin() {
DIR=$3
DEST=$4
install -s -m 755 $ROOT/$BIN $DIR/$DEST
get_dso_deps $ROOT "$BIN"
local DEPS="$DSO_DEPS"
mkdir -p $DIR/$LIBDIR
for x in $DEPS ; do
cp -Lfp $ROOT/$x $DIR/$LIBDIR
done
iself="$(file $ROOT/$BIN | grep ELF)"
pushd $DIR/$LIBDIR
if [ -f ld-linux.so.2 ]; then
rm -f ld-linux.so.2
linker="$(ls -1 ld-*.*.*.so)"
found=$(echo $linker | wc -l)
if [ $found -ne 1 ]; then
echo "Found too many dynamic linkers:" >&2
echo $linker >&2
exit 1
if [ -L $ROOT/$BIN ]; then
cp -a $ROOT/$BIN $DIR/$DEST
else
if [ -z "$iself" ]; then
install -m 755 $ROOT/$BIN $DIR/$DEST
else
install -s -m 755 $ROOT/$BIN $DIR/$DEST
get_dso_deps $ROOT "$BIN"
local DEPS="$DSO_DEPS"
mkdir -p $DIR/$LIBDIR
for x in $DEPS ; do
cp -Lfp $ROOT/$x $DIR/$LIBDIR
done
pushd $DIR/$LIBDIR
if [ -f ld-linux.so.2 -a ! -L ld-linux.so.2 ]; then
rm -f ld-linux.so.2
linker="$(ls -1 ld-*.*.*.so)"
if [ -z "$linker" ]; then
linker="$(ls -1 ld-*.*.so)"
fi
found=$(echo $linker | wc -l)
if [ $found -ne 1 ]; then
echo "Found too many dynamic linkers:" >&2
echo $linker >&2
exit 1
fi
ln -s $linker ld-linux.so.2
fi
popd
if [ "$BUILDARCH" = "s390x" ]; then
pushd $DIR/lib
ln -s ../$LIBDIR/ld64.so.1
popd
fi
fi
ln -s $linker ld-linux.so.2
fi
popd
}
setupShellEnvironment() {
@ -385,7 +410,7 @@ setupShellEnvironment() {
# PAM configuration
for i in pam_limits.so pam_env.so pam_unix.so pam_deny.so; do
cp -f $IMGPATH/$LIBDIR/security/$i $MBD_DIR/$LIBDIR/security
cp -f $IMGPATH/$LIBDIR/security/$i $MBD_DIR/$LIBDIR/security
done
cp -f $IMGPATH/etc/pam.d/other $MBD_DIR/etc/pam.d
@ -424,7 +449,6 @@ EOF
chmod 600 ssh_host_key ssh_host_rsa_key ssh_host_dsa_key; \
chmod 644 ssh_host_key.pub ssh_host_rsa_key.pub ssh_host_dsa_key.pub; )
cat > $MBD_DIR/etc/ssh/sshd_config <<EOF
Port 22
HostKey /etc/ssh/ssh_host_key
@ -449,22 +473,6 @@ EOF
# copy in the binaries
instbin $IMGPATH /usr/bin/login $MBD_DIR /sbin/login
instbin $IMGPATH /usr/sbin/sshd $MBD_DIR /sbin/sshd
instbin $IMGPATH /usr/bin/busybox $MBD_DIR /sbin/busybox
# make some symlinks
(cd $MBD_DIR/sbin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]_\.\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
while [ -n "$1" ]; do
if [ $1 != "busybox" -a $1 != "sh" ]; then
# if file doesnt already exist, link to busybox
if [ ! -f "$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
fi
shift
done )
}
@ -478,40 +486,40 @@ makeinitrd() {
MYLANGTABLE=$LANGTABLE
MYLOADERTR=loader.tr
while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
if [ $1 = "--initrdto" ]; then
EXTRAINITRDPATH=$2
shift; shift
continue
elif [ $1 = "--keep" ]; then
KEEP=yes
shift
continue
elif [ $1 = "--initrdsize" ]; then
INITRDSIZE=$2
shift; shift
continue
elif [ $1 = "--loaderbin" ]; then
LOADERBIN=$2
shift; shift
continue
elif [ $1 = "--modules" ]; then
INITRDMODULES=$2
shift; shift
continue
fi
echo "Unknown option passed to makeinitrd"
exit 1
if [ $1 = "--initrdto" ]; then
EXTRAINITRDPATH=$2
shift; shift
continue
elif [ $1 = "--keep" ]; then
KEEP=yes
shift
continue
elif [ $1 = "--initrdsize" ]; then
INITRDSIZE=$2
shift; shift
continue
elif [ $1 = "--loaderbin" ]; then
LOADERBIN=$2
shift; shift
continue
elif [ $1 = "--modules" ]; then
INITRDMODULES=$2
shift; shift
continue
fi
echo "Unknown option passed to makeinitrd"
exit 1
done
if [ -z "$LOADERBIN" ]; then
echo "no loader binary specified!" >&2
exit 1
echo "no loader binary specified!" >&2
exit 1
fi
if [ -z "$INITRDMODULES" ]; then
echo "warning: no loader modules specified!" >&2
echo "warning: no loader modules specified!" >&2
fi
if [ -z "$INITRDSIZE" ]; then
echo "I don't know how big to make the initrd image!" >&2
exit 1
echo "I don't know how big to make the initrd image!" >&2
exit 1
fi
MBD_DIR=$TMPDIR/makebootdisk.dir.$$
@ -536,6 +544,7 @@ makeinitrd() {
mkdir -p $MBD_DIR/var/cache/hald
mkdir -p $MBD_DIR/var/lib/dbus
mkdir -p $MBD_DIR/var/lib/dhclient
mkdir -p $MBD_DIR/etc/dhcp
mkdir -p $MBD_DIR/var/lock/rpm
mkdir -p $MBD_DIR/var/run
mkdir -p $MBD_DIR/var/run/dbus
@ -557,17 +566,18 @@ makeinitrd() {
mkdir -p $MBD_DIR/var/run/wpa_supplicant
if [ "$BUILDARCH" = "s390" -o "$BUILDARCH" = "s390x" ]; then
mkdir -m 111 -p $MBD_DIR/var/empty/sshd
mkdir -p $MBD_DIR/etc/{pam.d,security}
mkdir -p $MBD_DIR/$LIBDIR/security
cp $IMGPATH/$LIBDIR/libpam_misc.so.0.* $MBD_DIR/$LIBDIR/libpam_misc.so.0
ln -s /tmp $MBD_DIR/var/state/xkb
cp $IMGPATH/usr/bin/xauth $MBD_DIR/sbin/xauth
mkdir -m 111 -p $MBD_DIR/var/empty/sshd
mkdir -p $MBD_DIR/etc/{pam.d,security}
mkdir -p $MBD_DIR/$LIBDIR/security
cp $IMGPATH/$LIBDIR/libpam_misc.so.0.* $MBD_DIR/$LIBDIR/libpam_misc.so.0
cp $IMGPATH/$LIBDIR/libwrap*.so* $MBD_DIR/$LIBDIR/
ln -s /tmp $MBD_DIR/var/state/xkb
cp $IMGPATH/usr/bin/xauth $MBD_DIR/sbin/xauth
cp $IMGPATH/usr/sbin/cmsfs* $MBD_DIR/sbin/
fi
if [ -n "$INITRDMODULES" ]; then
MODSET=`expandModuleSet "$INITRDMODULES"`
MODSET=`expandModuleSet "$INITRDMODULES"`
makemoduletree $MBD_DIR "$MODSET"
fi
@ -578,33 +588,45 @@ makeinitrd() {
instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/$LOADERBIN $MBD_DIR /sbin/loader
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
instbin $IMGPATH ${LOADERBINDIR##$IMGPATH}/init $MBD_DIR /sbin/init
ln -s ./init $MBD_DIR/sbin/reboot
ln -s ./init $MBD_DIR/sbin/halt
ln -s ./init $MBD_DIR/sbin/poweroff
ln -s ./init $MBD_DIR/sbin/reboot
ln -s ./init $MBD_DIR/sbin/halt
ln -s ./init $MBD_DIR/sbin/poweroff
else
instbin $IMGPATH ${LOADERBINDIR##IMGPATH}/shutdown $MBD_DIR /sbin/shutdown
instbin $IMGPATH /usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR /sbin/init
instbin $IMGPATH /usr/sbin/dasdfmt $MBD_DIR /sbin/dasdfmt
instbin $IMGPATH ${LOADERBINDIR##IMGPATH}/shutdown $MBD_DIR /sbin/shutdown
instbin $IMGPATH /usr/lib/anaconda-runtime/loader/linuxrc.s390 $MBD_DIR /sbin/init
instbin $IMGPATH /usr/lib/anaconda-runtime/loader/lsznet.raw $MBD_DIR /sbin/lsznet
instbin $IMGPATH /usr/lib/anaconda-runtime/loader/controlunits.sh $MBD_DIR /sbin/controlunits
instbin $IMGPATH /usr/sbin/dasdfmt $MBD_DIR /sbin/dasdfmt
fi
if [ "$BUILDARCH" != "s390" -a "$BUILDARCH" != "s390x" ]; then
install -m 644 $KEYMAPS $MBD_DIR/etc/keymaps.gz
install -m 644 $SCREENFONT $MBD_DIR/etc/screenfont.gz
fi
install -m 644 $MYLANGTABLE $MBD_DIR/etc/lang-table
install -m 644 $IMGPATH/etc/passwd $MBD_DIR/etc/passwd
install -m 644 $IMGPATH/etc/group $MBD_DIR/etc/group
install -m 644 $IMGPATH/etc/nsswitch.conf $MBD_DIR/etc/nsswitch.conf
install -m 644 $IMGPATH/etc/hosts $MBD_DIR/etc/hosts
mkdir -p $MBD_DIR/usr/lib/locale
localedef -c -i en_US -f UTF-8 --prefix $MBD_DIR en_US
instbin $IMGPATH /usr/bin/mount $MBD_DIR /sbin/mount
instbin $IMGPATH /usr/sbin/mount.nfs $MBD_DIR /sbin/mount.nfs
for mountcmd in $IMGPATH/usr/sbin/mount.* ; do
cmd="$(basename $mountcmd)"
instbin $IMGPATH /usr/sbin/$cmd $MBD_DIR /sbin/$cmd
done
instbin $IMGPATH /usr/bin/umount $MBD_DIR /sbin/umount
ln -s mount.nfs $MBD_DIR/sbin/umount.nfs
for umountcmd in $IMGPATH/usr/sbin/umount.* ; do
cmd="$(basename $umountcmd)"
instbin $IMGPATH /usr/sbin/$cmd $MBD_DIR /sbin/$cmd
done
instbin $IMGPATH /usr/sbin/udevd $MBD_DIR /sbin/udevd
instbin $IMGPATH /usr/sbin/udevadm $MBD_DIR /sbin/udevadm
instbin $IMGPATH /usr/bin/udevinfo $MBD_DIR /sbin/udevinfo
ln -s udevadm $MBD_DIR/sbin/udevsettle
instbin $IMGPATH /usr/sbin/udevsettle $MBD_DIR /sbin/udevsettle
instbin $IMGPATH /usr/bin/bash $MBD_DIR /sbin/bash
( cd $MBD_DIR/sbin ; ln -sf bash sh )
@ -624,7 +646,16 @@ makeinitrd() {
# DHCP and DHCPv6 client daemons and support programs
instbin $IMGPATH /usr/sbin/dhclient $MBD_DIR /sbin/dhclient
cp -a $IMGPATH/usr/sbin/dhclient-script $MBD_DIR/sbin/dhclient-script
chmod 0755 $MBD_DIR/sbin/dhclient-script
instbin $IMGPATH /usr/sbin/dhcp6c $MBD_DIR /sbin/dhcp6c
instbin $IMGPATH /usr/sbin/arping $MBD_DIR /sbin/arping
instbin $IMGPATH /usr/sbin/ifconfig $MBD_DIR /sbin/ifconfig
instbin $IMGPATH /usr/sbin/ip $MBD_DIR /sbin/ip
instbin $IMGPATH /usr/bin/ipcalc $MBD_DIR /sbin/ipcalc
instbin $IMGPATH /usr/bin/hostname $MBD_DIR /sbin/hostname
instbin $IMGPATH /usr/sbin/ethtool $MBD_DIR /sbin/ethtool
instbin $IMGPATH /usr/sbin/route $MBD_DIR /sbin/route
touch $MBD_DIR/etc/resolv.conf
# hwdata
@ -680,8 +711,11 @@ makeinitrd() {
cp -a $IMGPATH/etc/dbus-1/system.d/nm-*.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/dbus-1/system.d/NetworkManager.conf $MBD_DIR/etc/dbus-1/system.d
cp -a $IMGPATH/etc/NetworkManager/nm-system-settings.conf $MBD_DIR/etc/NetworkManager
instbin $IMGPATH /usr/$LIBDIR/NetworkManager/libnm-settings-plugin-ifcfg-fedora.so \
$MBD_DIR /usr/$LIBDIR/NetworkManager/libnm-settings-plugin-ifcfg-fedora.so
( cd $IMGPATH/usr/$LIBDIR/NetworkManager
for f in *.so ; do
instbin $IMGPATH /usr/$LIBDIR/NetworkManager/$f $MBD_DIR /usr/$LIBDIR/NetworkManager/$f
done
)
( cd $IMGPATH/usr/libexec
for f in nm-* ; do
instbin $IMGPATH /usr/libexec/$f $MBD_DIR /usr/libexec/$f
@ -692,6 +726,21 @@ makeinitrd() {
cp -a org.freedesktop.nm_dispatcher.service $MBD_DIR/usr/share/dbus-1/system-services
)
# Misc
instbin $IMGPATH /usr/bin/awk $MBD_DIR /sbin/awk
instbin $IMGPATH /usr/bin/egrep $MBD_DIR /sbin/egrep
instbin $IMGPATH /usr/bin/fgrep $MBD_DIR /sbin/fgrep
instbin $IMGPATH /usr/bin/gawk $MBD_DIR /sbin/gawk
instbin $IMGPATH /usr/bin/grep $MBD_DIR /sbin/grep
instbin $IMGPATH /usr/bin/kill $MBD_DIR /sbin/kill
instbin $IMGPATH /usr/bin/ln $MBD_DIR /sbin/ln
instbin $IMGPATH /usr/bin/readlink $MBD_DIR /sbin/readlink
instbin $IMGPATH /usr/bin/rm $MBD_DIR /sbin/rm
instbin $IMGPATH /usr/bin/rmdir $MBD_DIR /sbin/rmdir
instbin $IMGPATH /usr/bin/sed $MBD_DIR /sbin/sed
instbin $IMGPATH /usr/bin/sleep $MBD_DIR /sbin/sleep
instbin $IMGPATH /usr/bin/touch $MBD_DIR /sbin/touch
# Indirect dependencies
install -m 755 $IMGPATH/$LIBDIR/libfreebl3.so $MBD_DIR/$LIBDIR/
install -m 755 $IMGPATH/$LIBDIR/libsoftokn3.so $MBD_DIR/$LIBDIR/
@ -715,14 +764,14 @@ makeinitrd() {
install -m 644 $LOADERBINDIR/$MYLOADERTR $MBD_DIR/etc/loader.tr
for i in a/ansi d/dumb l/linux s/screen v/vt100 v/vt100-nav v/vt102 x/xterm x/xterm-color g/gnome ; do
[ -f $IMGPATH/usr/share/terminfo/$i ] && \
install -m 644 $IMGPATH/usr/share/terminfo/$i $MBD_DIR/etc/terminfo/$i
[ -f $IMGPATH/usr/share/terminfo/$i ] && \
install -m 644 $IMGPATH/usr/share/terminfo/$i $MBD_DIR/etc/terminfo/$i
done
makeproductfile $MBD_DIR
for n in insmod rmmod modprobe; do
instbin $IMGPATH /usr/sbin/$n $MBD_DIR /sbin/$n
instbin $IMGPATH /usr/sbin/$n $MBD_DIR /sbin/$n
done
ln -s /sbin/init $MBD_DIR/init
@ -733,7 +782,7 @@ makeinitrd() {
# s390/s390x need sshd setup
if [ "$BUILDARCH" = "s390" -o "$BUILDARCH" = "s390x" ]; then
setupShellEnvironment
setupShellEnvironment
fi
cat > $MBD_DIR/.profile <<EOF
@ -749,12 +798,12 @@ EOF
echo "Wrote $MBD_FSIMAGE (${size}k compressed)"
if [ -n "$EXTRAINITRDPATH" ]; then
mkdir -p `dirname $EXTRAINITRDPATH`
cp -a $MBD_FSIMAGE $EXTRAINITRDPATH
mkdir -p `dirname $EXTRAINITRDPATH`
cp -a $MBD_FSIMAGE $EXTRAINITRDPATH
fi
if [ -z "$KEEP" ]; then
rm -rf $MBD_FSIMAGE $MBD_BOOTTREE
rm -rf $MBD_FSIMAGE $MBD_BOOTTREE
fi
}
@ -799,12 +848,12 @@ makemainimage () {
if [ $type = "ext2" ]; then
SIZE=$(du -sk $IMGPATH | awk '{ print int($1 * 1.1) }')
if [ -d $IMGPATH/usr/lib/anaconda-runtime ]; then
ERROR=$(du -sk $IMGPATH/usr/lib/anaconda-runtime | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
ERROR=$(du -sk $IMGPATH/usr/lib/anaconda-runtime | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
fi
if [ -d $IMGPATH/usr/lib/syslinux ]; then
ERROR=$(du -sk $IMGPATH/usr/lib/syslinux | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
if [ -d $IMGPATH/usr/share/syslinux ]; then
ERROR=$(du -sk $IMGPATH/usr/share/syslinux | awk '{ print $1 }')
SIZE=$(expr $SIZE - $ERROR)
fi
dd if=/dev/zero bs=1k count=${SIZE} of=$mmi_tmpimage 2>/dev/null
mke2fs -q -F $mmi_tmpimage > /dev/null
@ -812,9 +861,9 @@ makemainimage () {
mount -o loop $mmi_tmpimage $mmi_mntpoint
(cd $IMGPATH; find . |
fgrep -v "./usr/lib/anaconda-runtime" |
fgrep -v "./usr/lib/syslinux"
cpio -H crc -o) | (cd $mmi_mntpoint; cpio -iumd)
fgrep -v "./usr/lib/anaconda-runtime" |
fgrep -v "./usr/share/syslinux"
cpio -H crc -o) | (cd $mmi_mntpoint; cpio -iumd)
makeproductfile $mmi_mntpoint
umount $mmi_mntpoint
rmdir $mmi_mntpoint
@ -855,6 +904,7 @@ doPostImages() {
# this gets overloaded if we're on an EFI-capable arch (... with grub)
makeEfiImages()
{
echo "Not on an EFI capable machine; skipping EFI images."
/bin/true
}
@ -894,70 +944,74 @@ fi
foundakernel=""
for KERNELARCH in $arches; do
for kernelvers in $kerneltags; do
kpackage=$(findPackage $kernelvers)
if [ "$KERNELARCH" = "i586" -a -z "$kpackage" ]; then
echo "No i586 kernel, trying i686..."
KERNELARCH="i686"
kpackage=$(findPackage $kernelvers)
fi
for kernelvers in $kerneltags; do
kpackage=$(findPackage $kernelvers)
if [ "$KERNELARCH" = "i586" -a -z "$kpackage" ]; then
echo "No i586 kernel, trying i686..."
KERNELARCH="i686"
kpackage=$(findPackage $kernelvers)
fi
if [ -z "$kpackage" ]; then
echo "Unable to find kernel package $kernelvers"
continue
fi
if [ -z "$kpackage" ]; then
echo "Unable to find kernel package $kernelvers"
continue
fi
yumdownloader -c $yumconf --archlist=$KERNELARCH $kpackage
kpackage="$kpackage.rpm"
if [ ! -f "$kpackage" ]; then
echo "kernel ($kernelvers) doesn't exist for $KERNELARCH. skipping"
continue
fi
yumdownloader -c $yumconf --archlist=$KERNELARCH $kpackage
kpackage="$kpackage.rpm"
if [ ! -f "$kpackage" ]; then
echo "kernel ($kernelvers) doesn't exist for $KERNELARCH. skipping"
continue
fi
KERNELROOT=$KERNELBASE/$KERNELARCH
mkdir -p $KERNELROOT
KERNELROOT=$KERNELBASE/$KERNELARCH
mkdir -p $KERNELROOT
foundakernel="yes"
foundakernel="yes"
if [ "$BUILDARCH" = "ia64" ]; then
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/efi/EFI/redhat/vmlinuz | head -n 1)
version=${vmlinuz##/boot/efi/EFI/redhat/vmlinuz-}
else
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/vmlinuz | head -n 1)
version=${vmlinuz##/boot/vmlinuz-}
fi
arch=$(rpm --nodigest --nosignature --qf '%{ARCH}\n' -qp $kpackage)
if [ "$BUILDARCH" = "ia64" ]; then
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/efi/EFI/redhat/vmlinuz | head -n 1)
version=${vmlinuz##/boot/efi/EFI/redhat/vmlinuz-}
else
vmlinuz=$(rpm --nodigest --nosignature -qpl $kpackage |grep ^/boot/vmlinuz | head -n 1)
version=${vmlinuz##/boot/vmlinuz-}
fi
arch=$(rpm --nodigest --nosignature --qf '%{ARCH}\n' -qp $kpackage)
rpm2cpio $kpackage | (cd $KERNELROOT; cpio --quiet -iumd)
rm -f $kpackage
# expand out any available firmware too
for p in $(repoquery -c $yumconf '*firmware*') ; do yumdownloader -c $yumconf $p ; rpm2cpio *firmware*.rpm | (cd $KERNELROOT; cpio --quiet -iumd) ; rm -f *firmware*.rpm ; done
rpm2cpio $kpackage | (cd $KERNELROOT; cpio --quiet -iumd)
rm -f $kpackage
# expand out any available firmware too
for p in $(repoquery -c $yumconf '*firmware*') ; do
yumdownloader -c $yumconf $p
rpm2cpio *firmware*.rpm | (cd $KERNELROOT; cpio --quiet -iumd)
rm -f *firmware*.rpm
done
if [ ! -d "$KERNELROOT/lib/modules/$version" ]; then
echo "$KERNELROOT/lib/modules/$version is not a valid modules directory" 2>&1
exit 1
fi
if [ ! -d "$KERNELROOT/lib/modules/$version" ]; then
echo "$KERNELROOT/lib/modules/$version is not a valid modules directory" 2>&1
exit 1
fi
if [ ! -f "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version" ]; then
echo "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version does not exist"
exit 1
fi
if [ ! -f "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version" ]; then
echo "$KERNELROOT/$KERNELDIR/${KERNELNAME}-$version does not exist"
exit 1
fi
allmods=$(find $KERNELROOT/lib/modules/$version -name *.ko)
allmods=$(find $KERNELROOT/lib/modules/$version -name *.ko)
rundepmod $KERNELROOT
$GENMODINFO $KERNELROOT/lib/modules/$version > $MODINFO
rundepmod $KERNELROOT
$GENMODINFO $KERNELROOT/lib/modules/$version > $MODINFO
# make the boot images
makeBootImages
# make the boot images
makeBootImages
makeEfiImages $yumconf
done
makeEfiImages $yumconf
done
done
if [ -n "$foundakernel" ]; then
makeSecondStage
rm -rf $KERNELBASE
makeSecondStage
rm -rf $KERNELBASE
fi
doPostImages

View File

@ -0,0 +1,245 @@
#
# 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
}

View File

@ -1,4 +1,3 @@
#!/bin/bash
#
# mk-images.ia64
#

View File

@ -31,6 +31,7 @@ makeBootImages() {
$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

View File

@ -17,7 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
SYSLINUX=$IMGPATH/usr/lib/syslinux/syslinux-nomtools
SYSLINUX=$IMGPATH/usr/share/syslinux/syslinux-nomtools
CDLABEL=$PRODUCT
if [ ! -f $SYSLINUX ]; then
echo "Warning: nomtools syslinux doesn't exist"
@ -33,12 +34,12 @@ fi
prepareBootTree() {
(cd $BOOTDISKDIR; find . -maxdepth 1 ! -name "*.msg" ! -type d | cpio --quiet -p $MBD_BOOTTREE)
cp $MBD_FSIMAGE $MBD_BOOTTREE/initrd.img
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/lib/syslinux/vesamenu.c32 $MBD_BOOTTREE/vesamenu.c32
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
@ -102,18 +103,21 @@ makeBootImages() {
[ $? = 0 ] || exit 1
if [ "$kernelvers" != "$kernelxen" ] ; then
if [ -f $IMGPATH/usr/lib/syslinux/isolinux.bin ]; 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/lib/syslinux/isolinux.bin $MBD_BOOTTREE/isolinux.bin
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
@ -157,8 +161,21 @@ __EOT__
doPostImages() {
if [ -n "$BOOTISO" ]; then
mkisofs -quiet -o $TOPDESTPATH/images/$BOOTISO -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -V "$PRODUCT" -T -graft-points isolinux=$TOPDESTPATH/isolinux images/install.img=$TOPDESTPATH/images/install.img
implantisomd5 $TOPDESTPATH/images/$BOOTISO
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
}

27
rewrite/scripts/pyrc.py Normal file
View File

@ -0,0 +1,27 @@
#
# 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

View File

@ -34,7 +34,7 @@ p=$1
ARCH=`uname -m | sed -e 's/i.86/i386/'`
if [ $ARCH = x86_64 -o $ARCH = s390x ]; then
if [ $ARCH = x86_64 -o $ARCH = s390x -o $ARCH = ppc64 ]; then
LIBDIR=lib64
else
LIBDIR=lib
@ -53,30 +53,4 @@ if [ $ARCH != s390 -a $ARCH != s390x ]; then
fi
rm $p/etc/ld.so.conf
#
# make sure we have links for programs supplied by busybox
#
# HOWEVER dont clobber existing programs supplied by other packages if exist
#
mv $p/usr/sbin/busybox.anaconda $p/usr/bin/busybox
(cd $p/usr/bin;
set $(./busybox 2>&1| awk '/^\t([[:alnum:]\-_\.\[]+,)+/' | sed 's/,//g' | sed 's/ +//');
dontclobber=(sh busybox reboot shutdown poweroff)
while [ -n "$1" ]; do
save=
for n in ${dontclobber[@]} ; do
if [ "$1" == "$n" ]; then
save=$n
fi
done
# if it's not in our list and it doesn't exist, link to busybox
if [ -z "$save" -a ! -f "$1" -a ! -f "$p/usr/sbin/$1" ]; then
ln -sf ./busybox $1
else
[ -n "$DEBUG" ] && echo "Overriding busybox version of $1"
fi
shift
done
)
umount $p/proc

71
rewrite/scripts/upd-bootimage Executable file
View File

@ -0,0 +1,71 @@
#!/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

43
rewrite/scripts/upd-initrd Executable file
View File

@ -0,0 +1,43 @@
#!/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

View File

@ -24,54 +24,54 @@ ARCH=`uname -m`
while [ $# -gt 0 ]; do
case $1 in
--debug)
DEBUG="--debug"
shift
;;
--debug)
DEBUG="--debug"
shift
;;
--arch)
ARCH=$2
shift; shift
;;
--arch)
ARCH=$2
shift; shift
;;
--imgdir)
DEST=$2
shift; shift
;;
--imgdir)
DEST=$2
shift; shift
;;
# a filesystem tree to use as updates. could be the output
# of 'make install' from anaconda...
--updates)
UPDATES=$2
shift; shift
;;
# a filesystem tree to use as updates. could be the output
# of 'make install' from anaconda...
--updates)
UPDATES=$2
shift; shift
;;
--nogr)
echo "*** DeprecationWarning: ignoring --nogr option." >&2
shift
;;
--nogr)
echo "*** DeprecationWarning: ignoring --nogr option." >&2
shift
;;
--mindir)
echo "*** DeprecationWarning: ignoring --mindir option." >&2
shift; shift
;;
--mindir)
echo "*** DeprecationWarning: ignoring --mindir option." >&2
shift; shift
;;
--stg2dir)
echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
shift; shift
;;
--stg2dir)
echo "*** DeprecationWarning: please use --imgdir instead of --stg2dir." >&2
shift; shift
;;
*)
yumconf=$1
shift
;;
*)
yumconf=$1
shift
;;
esac
done
if [ -z "$yumconf" ]; then
echo "upd-instroot: updates instimage from a Red Hat RPMS directory"
echo "usage: $0 [--debug] [--arch arch] [--imgdir imgdir] [yumconf]"
exit 1
echo "upd-instroot: updates instimage from a Red Hat RPMS directory"
echo "usage: $0 [--debug] [--arch arch] [--imgdir imgdir] [yumconf]"
exit 1
fi
if [ $ARCH = x86_64 -o $ARCH = s390x -o $ARCH = ppc64 ]; then
@ -99,45 +99,47 @@ expandPackageSet() {
KEEPFILES=$5
[ -d $PKGDEST ] || die "ERROR: directory missing: $PKGDEST"
if [ -z "$DEBUG" ]; then outlvl="--quiet" ; else outlvl="--verbose"; fi
[ -z "$DEBUG" ] && outlvl="--quiet" || outlvl="--verbose"
yum $outlvl -c $YUMCONF -y --installroot=$YUMDIR install $RPMS 2>&1 || die "ERROR: could not install packages"
if [ -n "$UPDATES" ]; then
(cd $UPDATES; find) | (cd $UPDATES ; /bin/cpio --quiet -pmdu $YUMDIR)
(cd $UPDATES; find) | (cd $UPDATES ; /bin/cpio --quiet -pmdu $YUMDIR)
fi
# figure out the theme to keep
if [ -f $YUMDIR/etc/gtk-2.0/gtkrc ]; then
gtktheme=$(grep "gtk-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
echo "usr/share/themes/$gtktheme" >> $KEEPFILES
# find gtk engine needed
for engine in `grep engine $YUMDIR/usr/share/themes/$gtktheme/gtk-2.0/gtkrc | awk {'print $2;'} | sed -e 's/"//g' | sort -u` ; do
echo "usr/$LIBDIR/gtk-2.0/*/engines/*$engine*" >> $KEEPFILES
done
gtktheme=$(grep "gtk-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
echo "usr/share/themes/$gtktheme" >> $KEEPFILES
# find gtk engine needed
for engine in `grep engine $YUMDIR/usr/share/themes/$gtktheme/gtk-2.0/gtkrc | awk {'print $2;'} | sed -e 's/"//g' | sort -u` ; do
echo "usr/$LIBDIR/gtk-2.0/*/engines/*$engine*" >> $KEEPFILES
done
theme=$(grep "gtk-icon-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
while [ -n "$theme" ]; do
echo "usr/share/icons/$theme" >> $KEEPFILES
theme=$(grep Inherits $YUMDIR/usr/share/icons/$theme/index.theme | cut -d = -f 2)
done
theme=$(grep "gtk-icon-theme-name" $YUMDIR/etc/gtk-2.0/gtkrc | awk {'print $3;'} | sed -e 's/"//g')
while [ -n "$theme" ]; do
echo "usr/share/icons/$theme" >> $KEEPFILES
theme=$(grep Inherits $YUMDIR/usr/share/icons/$theme/index.theme | cut -d = -f 2)
done
fi
echo `date` "Installing files"
pushd $YUMDIR >/dev/null
cat $KEEPFILES | while read spec ; do
#Pull off path
path=`echo "$spec" | sed 's,\([^[*\?]*\)/.*,\1,'`
for filespec in `find ./$path -path "./$spec" 2> /dev/null` ; do
if [ ! -e $filespec ]; then
continue
elif [ ! -d $filespec ]; then
instFile $filespec $PKGDEST
else
for i in `find $filespec -type f 2> /dev/null` ; do instFile $i $PKGDEST ; done
for i in `find $filespec -type l 2> /dev/null` ; do instFile $i $PKGDEST ; done
for d in `find $filespec -type d 2> /dev/null` ; do instDir $d $PKGDEST ; done
fi
done
#Pull off path
path=`echo "$spec" | sed 's,\([^[*\?]*\)/.*,\1,'`
for filespec in `find ./$path -path "./$spec" 2> /dev/null` ; do
if [ ! -e $filespec ]; then
continue
elif [ ! -d $filespec ]; then
instFile $filespec $PKGDEST
else
for i in `find $filespec -type f 2> /dev/null` ; do instFile $i $PKGDEST ; done
for i in `find $filespec -type l 2> /dev/null` ; do instFile $i $PKGDEST ; done
for d in `find $filespec -type d 2> /dev/null` ; do instDir $d $PKGDEST ; done
fi
done
done
popd >/dev/null
}
@ -148,63 +150,61 @@ die () {
exit 1
}
PACKAGES="GConf2 NetworkManager ORBit2 PolicyKit VLGothic-fonts acl anaconda
anaconda-yum-plugins at-spi atk attr audit-libs bash bitmap-fonts-cjk
booty busybox-anaconda bzip2 bzip2-libs cairo cjkunifonts-ukai
comps-extras coreutils cpio cracklib-dicts cracklib-python
cryptsetup-luks db4 dbus dbus-python dejavu-fonts device-mapper
device-mapper-libs dhclient dhcpv6-client dmapi dmraid dmraid-libs
dogtail dosfstools e2fsprogs e2fsprogs-libs echo-icon-theme
elfutils-libelf expat firstboot fontconfig fonts-arabic fonts-bengali
fonts-chinese fonts-gujarati fonts-hindi fonts-indic fonts-ISO8859-2
fonts-kannada fonts-oriya fonts-punjabi
fonts-sinhala fonts-tamil fonts-telugu freetype gail gdk-pixbuf
gfs2-utils glib2 glibc-common gnome-python2-canvas gnome-python2-gconf
gnome-python2-gtkhtml2 gnome-themes gpm 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 libdhcp libdhcp4client libdhcp6client libfontenc libgcc
libglade2 libgnomecanvas libgcrypt libgpg-error libjpeg liblbxutil libnl
libpixman libpng libselinux libselinux-python libsemanage
libsemanage-python libsepol libstdc++ libtermcap libthai libuser
libuser-python libvolume_id libxcb libxkbfile libxml2 lvm2 mdadm
mesa-dri-drivers mkinitrd module-init-tools nash ncurses neon net-tools
newt newt-python nfs-utils nspr nss pam pango parted pciutils pcre
policy policycoreutils popt prelink procps pycairo pygobject2 pygtk2
pygtk2-libglade pykickstart pyparted pyspi python python-bugzilla
python-elementtree python-libs python-pyblock python-sqlite
python-urlgrabber pyxf86config raidtools readline redhat-artwork
reiserfs-utils rhpl rpm rpm-libs rpm-python sed selinux-policy-targeted
setup slang smc-fonts-meera specspo sqlite synaptics system-config-date
system-config-keyboard system-logos system-release taipeifonts
tcp_wrappers ttfonts-bn ttfonts-gu ttfonts-hi ttfonts-ja ttfonts-ko
ttfonts-pa ttfonts-ta ttfonts-zh_CN ttfonts-zh_TW tzdata udev
un-core-fonts-dotum urw-fonts
util-linux-ng vnc-libs vnc-server wpa_supplicant xkeyboard-config
xfsdump xfsprogs xorg-x11 xorg-x11-auth xorg-x11-base
xorg-x11-drivers xorg-x11-font-utils xorg-x11-fonts-100dpi
xorg-x11-fonts-75dpi xorg-x11-fonts-ISO8859-1-75dpi
xorg-x11-fonts-ISO8859-15-75dpi xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ISO8859-9-75dpi xorg-x11-fonts-cyrillic
xorg-x11-fonts-ethiopic xorg-x11-fonts-misc xorg-x11-libs
xorg-x11-libs-data xorg-x11-server-utils xorg-x11-server-Xorg
xorg-x11-xkb-utils xorg-x11-xkbdata xorg-x11-xfs yum yum-fedorakmod
yum-metadata-parser zenity zlib /etc/gtk-2.0/gtkrc"
PACKAGES="GConf2 NetworkManager ORBit2 PolicyKit acl anaconda
anaconda-yum-plugins at-spi atk attr audit-libs bash bitmap-fonts-cjk
btrfs-progs bzip2 bzip2-libs cairo cjkuni-uming-fonts
comps-extras coreutils cpio cracklib cracklib-dicts cracklib-python
cryptsetup-luks db4 dbus dbus-python dejavu-sans-fonts
dejavu-sans-mono-fonts device-mapper
device-mapper-libs dhclient dhcpv6-client dmraid dmraid-libs
dogtail dosfstools e2fsprogs e2fsprogs-libs echo-icon-theme ethtool
elfutils-libelf expat firstboot fontconfig fonts-ISO8859-2 freetype gail gawk gdb-gdbserver
gdk-pixbuf gfs2-utils glib2 glibc-common gnome-python2-canvas gnome-python2-gconf
gnome-python2-gtkhtml2 gnome-themes gpm grep gtk2 gtk2-engines gtkhtml2 hal
hdparm hwdata initscripts iproute iputils iscsi-initiator-utils
jfsutils keyutils-libs krb5-libs libICE libSM libX11 libXau
libXaw libXcursor libXdmcp libXevie libXext libXfixes libXfont libXft
libXi libXinerama libXmu libXpm libXrandr libXrender libXt libXtst
libXxf86misc libacl libart_lgpl libattr libbdevid libbdevid-python
libbonobo libfontenc libgcc
libglade2 libgnomecanvas libgcrypt libgpg-error libjpeg libnl
libpng libselinux libselinux-python libsemanage
libsemanage-python libsepol libstdc++ libthai libuser
libuser-python libvolume_id libxcb libxkbfile libxml2 lklug-fonts
lohit-assamese-fonts lohit-bengali-fonts lohit-gujarati-fonts lohit-hindi-fonts
lohit-kashmiri-fonts lohit-kannada-fonts lohit-maithili-fonts lohit-marathi-fonts
lohit-oriya-fonts lohit-punjabi-fonts lohit-sindhi-fonts lohit-tamil-fonts
lohit-telugu-fonts lvm2 madan-fonts mdadm
mesa-dri-drivers mkinitrd module-init-tools nash ncurses neon net-tools
newt newt-python nfs-utils nspr nss ntfs-3g pam pango parted pciutils pcre
policycoreutils popt prelink procps pycairo pygobject2 pygtk2
pygtk2-libglade pykickstart pyparted python python-bugzilla python-decorator
python-libs python-pyblock python-sqlite
python-urlgrabber pyxf86config readline redhat-artwork
reiserfs-utils rhpl rpm rpm-libs rpm-python sed selinux-policy-targeted
setup slang smc-meera-fonts specspo sqlite synaptics system-config-date
system-config-keyboard ${brandpkgname}-logos ${brandpkgname}-release taipeifonts tcp_wrappers
tzdata udev un-core-fonts-dotum urw-fonts util-linux-ng tigervnc-server
tigervnc-server-module vlgothic-fonts vim-minimal
wpa_supplicant xkeyboard-config xfsdump xfsprogs xorg-x11-auth
xorg-x11-drivers xorg-x11-font-utils xorg-x11-fonts-ethiopic
xorg-x11-fonts-misc xorg-x11-server-utils
xorg-x11-server-Xorg xorg-x11-xkb-utils xorg-x11-xfs yum
yum-metadata-parser zenity zlib /etc/gtk-2.0/gtkrc"
if [ $ARCH = i386 ]; then
PACKAGES="$PACKAGES glibc.i386 openssl.i386"
elif [ $ARCH = i586 ]; then
PACKAGES="$PACKAGES glibc.i586 openssl.i586"
else
PACKAGES="$PACKAGES glibc openssl"
fi
if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
PACKAGES="$PACKAGES pcmciautils grub"
fi
if [ $ARCH = i386 -o $ARCH = x86_64 -o $ARCH = ia64 ]; then
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 -o $ARCH = ia64 ]; then
PACKAGES="$PACKAGES dmidecode efibootmgr"
fi
@ -216,8 +216,8 @@ fi
if [ $ARCH = s390 -o $ARCH = s390x ]; then
PACKAGES="$PACKAGES s390utils binutils libgcc tcp_wrappers
sed net-tools openssh openssh-server coreutils
login initscripts bash portmap pam
login mount grep modutils gawk
login initscripts portmap pam
login mount modutils s390utils-cmsfs
strace xorg-x11-xauth xorg-x11-libs"
fi
@ -232,12 +232,12 @@ fi
#
PACKAGESRESCUE="bzip2 bzip2-libs dump libidn
findutils ftp gzip iputils joe krb5-libs less man
modutils mtools mt-st mtr net-tools open smartmontools
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-plugin-all"
firstaidkit firstaidkit-plugin-all dialog"
if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
PACKAGESRESCUE="$PACKAGESRESCUE gpart grub"
fi
@ -248,7 +248,7 @@ if [ $ARCH = sparc ]; then
PACKAGES="$PACKAGES tilo silo"
fi
if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
PACKAGES="$PACKAGES syslinux memtest86+ grub"
fi
@ -283,28 +283,53 @@ $LIBDIR/libnsspem.so
$LIBDIR/libsmime3.so
$LIBDIR/libsoftokn3.so
$LIBDIR/libssl3.so
bin/arch
bin/basename
bin/bash
bin/cat
bin/chgrp
bin/chmod
bin/chown
bin/cp
bin/cpio
bin/cut
bin/date
bin/dbus-daemon
bin/dbus-uuidgen
bin/dd
bin/df
bin/dmesg
bin/du
bin/echo
bin/env
bin/false
bin/fdisk*
bin/gawk
bin/*grep
bin/hostname
bin/kill
bin/ln
bin/ls
bin/mkdir
bin/mknod
bin/mktemp
bin/more
bin/mount
bin/mv
bin/ntfs-3g
bin/ps
bin/pwd
bin/rm
bin/rmdir
bin/rpm
bin/sed
bin/sleep
bin/sort
bin/sync
bin/touch
bin/true
bin/umount
bin/vi
boot/*.b
boot/bootlx
boot/efi/EFI/redhat/elilo.efi
@ -321,6 +346,7 @@ etc/fonts
etc/group
etc/gtk-2.0/gtkrc*
etc/hal
etc/hosts
etc/im_palette.pal
etc/imrc
etc/iscsid.conf
@ -349,7 +375,8 @@ lib/udev
sbin/*gfs*
sbin/arping
sbin/badblocks
sbin/busybox.anaconda
sbin/btrfsctl
sbin/btrfsck
sbin/clock
sbin/consoletype
sbin/cryptsetup
@ -359,13 +386,13 @@ sbin/dhclient-script
sbin/dhcp6c
sbin/dosfslabel
sbin/dumpe2fs
sbin/e2fsadm
sbin/fsadm
sbin/e2fsck
sbin/e2label
sbin/ethtool
sbin/fdisk
sbin/fsck
sbin/fsck.ext2
sbin/fsck.ext3
sbin/fsck.ext*
sbin/fsck.jfs
sbin/fsck.reiserfs
sbin/fsck.xfs
@ -381,10 +408,11 @@ sbin/ldconfig
sbin/lspci
sbin/lvm*
sbin/mdadm
sbin/mdmon
sbin/mkdosfs
sbin/mke2fs
sbin/mkfs.ext2
sbin/mkfs.ext3
sbin/mkfs.btrfs
sbin/mkfs.ext*
sbin/mkfs.gfs2
sbin/mkfs.jfs
sbin/mkfs.msdos
@ -394,6 +422,7 @@ sbin/mkraid
sbin/mkreiserfs
sbin/mkswap
sbin/mount.nfs*
sbin/mount.ntfs*
sbin/parted
sbin/pcmcia-socket-startup
sbin/pdisk
@ -401,9 +430,12 @@ sbin/probe
sbin/reiserfsck
sbin/reiserfstune
sbin/resize2fs
sbin/route
sbin/setfiles
sbin/sfdisk
sbin/silo
sbin/swapoff
sbin/swapon
sbin/tune2fs
sbin/udev*
sbin/umount.nfs*
@ -425,32 +457,18 @@ usr/$LIBDIR/hal
usr/$LIBDIR/libuser/*
usr/$LIBDIR/pango
usr/$LIBDIR/python?.?
usr/$LIBDIR/python?.?/email
usr/$LIBDIR/python?.?/site-packages/*.pth
usr/$LIBDIR/python?.?/site-packages/*selinux*
usr/$LIBDIR/python?.?/site-packages/*sqlite*
usr/$LIBDIR/python?.?/site-packages/_dbus*
usr/$LIBDIR/python?.?/site-packages/bdevid.so
usr/$LIBDIR/python?.?/site-packages/block
usr/$LIBDIR/python?.?/site-packages/cElementTree.so
usr/$LIBDIR/python?.?/site-packages/cairo
usr/$LIBDIR/python?.?/site-packages/firstboot
usr/$LIBDIR/python?.?/site-packages/gtk*
usr/$LIBDIR/python?.?/site-packages/gtk*/gtk
usr/$LIBDIR/python?.?/site-packages/ixf86configmodule.so
usr/$LIBDIR/python?.?/site-packages/libusermodule.so
usr/$LIBDIR/python?.?/site-packages/partedmodule.so
usr/$LIBDIR/python?.?/site-packages/rhpl
usr/$LIBDIR/python?.?/site-packages/rpmmodule.so
usr/$LIBDIR/python?.?/site-packages/xf86config.py
usr/$LIBDIR/python?.?/xml/etree/
usr/$LIBDIR/rpm/rpmpopt
usr/$LIBDIR/libiscsi.so*
usr/$LIBDIR/libsqlite3.so*
usr/$LIBDIR/xorg/modules
usr/$LIBDIR/xserver/SecurityPolicy
usr/bin/[
usr/bin/Xorg
usr/bin/Xvnc
usr/bin/chattr*
usr/bin/du
usr/bin/expr
usr/bin/gdb-gdbserver
usr/bin/gdialog
usr/bin/gdk-pixbuf-query-loaders*
usr/bin/gtk-query*
@ -465,18 +483,24 @@ usr/bin/logger
usr/bin/lsattr*
usr/bin/lshal
usr/bin/maketilo
usr/bin/md5sum
usr/bin/mini-wm
usr/bin/mkzimage
usr/bin/pango*
usr/bin/python
usr/bin/python?.?
usr/bin/readlink
usr/bin/reduce-font
usr/bin/setxkbmap
usr/bin/sha1sum
usr/bin/split
usr/bin/syslinux
usr/bin/tac
usr/bin/tail
usr/bin/tee
usr/bin/tilo
usr/bin/udevinfo
usr/bin/wc
usr/bin/udev*
usr/bin/uniq
usr/bin/vncconfig
usr/bin/vncpasswd
@ -488,24 +512,17 @@ usr/lib/anaconda-runtime
usr/lib/anaconda/installclasses
usr/lib/anaconda/iw
usr/lib/anaconda/textw
usr/lib/booty
usr/lib/anaconda/booty
usr/lib/anaconda/storage
usr/lib/anaconda/storage/devicelibs
usr/lib/anaconda/storage/formats
usr/lib/kernel-wrapper
usr/lib/locale
usr/lib/python?.?/site-packages/bugzilla*
usr/lib/python?.?/site-packages/cracklibmodule.so
usr/lib/python?.?/site-packages/dbus
usr/lib/python?.?/site-packages/dbus_bindings.py*
usr/lib/python?.?/site-packages/elementtree
usr/lib/python?.?/site-packages/iniparse
usr/lib/python?.?/site-packages/pykickstart
usr/lib/python?.?/site-packages/repomd
usr/lib/python?.?/site-packages/rpmUtils
usr/lib/python?.?/site-packages/urlgrabber
usr/lib/python?.?/site-packages/yum
usr/lib/python?.?
usr/lib/rpm/macros
usr/lib/rpm/rpmpopt
usr/lib/rpm/rpmrc
usr/lib/syslinux
usr/share/syslinux
usr/lib/yaboot
usr/lib/yum-plugins/blacklist.py*
usr/lib/yum-plugins/fedorakmod.py*
@ -559,22 +576,29 @@ usr/share/anaconda/anaconda.conf
usr/share/cracklib
usr/share/dbus-1
usr/share/fonts/*/lklug.ttf
usr/share/fonts/*/lohit_as.ttf
usr/share/fonts/*/lohit_bn.ttf
usr/share/fonts/*/lohit_gu.ttf
usr/share/fonts/*/lohit_hi.ttf
usr/share/fonts/*/lohit_kn.ttf
usr/share/fonts/*/lohit_ks.ttf
usr/share/fonts/*/lohit_mai.ttf
usr/share/fonts/*/lohit_mr.ttf
usr/share/fonts/*/lohit_or.ttf
usr/share/fonts/*/lohit_pa.ttf
usr/share/fonts/*/lohit_sd.ttf
usr/share/fonts/*/lohit_ta.ttf
usr/share/fonts/*/lohit_te.ttf
usr/share/fonts/VLGothic/VL-Gothic-Regular.ttf
usr/share/fonts/cjkunifonts-uming/uming*.ttf
usr/share/fonts/*/lklug.ttf
usr/share/fonts/cjkuni*/uming*.ttc
usr/share/fonts/dejavu/DejaVuSans-Bold.ttf
usr/share/fonts/dejavu/DejaVuSans.ttf
usr/share/fonts/dejavu/DejaVuSansMono.ttf
usr/share/fonts/kacst/KacstFarsi.ttf
usr/share/fonts/kacst/KacstQura.ttf
usr/share/fonts/madan/Madan.ttf
usr/share/fonts/un-core/UnDotum.ttf
usr/share/fonts/*/VL-Gothic-Regular.ttf
usr/share/fonts/smc/Meera*.ttf
usr/share/hal
usr/share/hwdata/MonitorsDB
@ -583,6 +607,7 @@ usr/share/hwdata/usb.ids
usr/share/hwdata/videoaliases
usr/share/hwdata/videodrivers
usr/share/locale/*/LC_MESSAGES/anaconda.mo
usr/share/locale/*/LC_MESSAGES/cracklib.mo
usr/share/locale/*/LC_MESSAGES/gtk20.mo
usr/share/locale/*/LC_MESSAGES/libc.mo
usr/share/locale/*/LC_MESSAGES/parted.mo
@ -613,7 +638,7 @@ usr/share/terminfo/x/xterm
usr/share/xorg/extramodes
usr/share/xorg/vesamodes
usr/share/zenity
usr/share/zoneinfo/zone.tab
usr/share/zoneinfo
var/cache/hald
var/lib/PolicyKit*
var/lib/dbus
@ -636,31 +661,15 @@ usr/share/terminfo/x/xterm
usr/share/terminfo/x/xterm-color
usr/bin/strace
usr/bin/ldd
usr/sbin/chroot
usr/sbin/sshd
usr/sbin/glibc_post_upgrade
sbin/cmsfslst
sbin/cmsfscat
sbin/busybox.anaconda
sbin/ifconfig
sbin/route
sbin/portmap
sbin/fdasd
sbin/dasdfmt
sbin/swapon
sbin/swapoff
sbin/mkswap
bin/bash
bin/dd
bin/gawk
bin/mount
bin/umount
bin/mknod
bin/sleep
bin/login
bin/cat
bin/chmod
bin/sort
bin/ipcalc
lib/modules/ibm
etc/pam.d/sshd
etc/pam.d/other
@ -668,6 +677,7 @@ etc/security/limits.conf
etc/security/pam_env.conf
lib/security
$LIBDIR/security/pam_*
$LIBDIR/libwrap*.so*
usr/bin/xauth
EOF
fi
@ -793,9 +803,11 @@ usr/sbin/smartctl
usr/sbin/traceroute
usr/$LIBDIR/firstaidkit/plugins/
usr/lib/python?.?/site-packages/pyfirstaidkit/
usr/bin/dialog
usr/bin/firstaidkit-qs
EOF
if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
cat >> $KEEPFILERESCUE <<-EOF
sbin/grub
usr/bin/gpart
@ -854,11 +866,12 @@ cat $DEST/usr/lib/anaconda/lang-table* | awk '
}
' | sed -e 's/latn/Latn/g' | LC_ALL=C sort -u > $DEST/locales
for p in lib share; do (
cd $DEST/usr/$p/locale && {
ls | grep -v locale.alias | grep -v locale-archive | LC_ALL=C sort > $DEST/locales.list
LC_ALL=C comm -13 $DEST/locales $DEST/locales.list | xargs rm -rf
}
cd $DEST/usr/$p/locale && {
ls | grep -v locale.alias | grep -v locale-archive | LC_ALL=C sort > $DEST/locales.list
LC_ALL=C comm -13 $DEST/locales $DEST/locales.list | xargs rm -rf
}
); done
rm -f $DEST/locales $DEST/locales.list
# fixup joe links
@ -908,6 +921,7 @@ sed -i 's|\(installforallkernels\) = 0|\1 = 1|' $DEST/etc/yum/pluginconf.d/fedor
# they will be soft links to /mnt/sysimage.
#
echo "Fixing up /etc/man.config to point into /mnt/sysimage"
#
# Lets avoid the lines with MANPATH_MAP for now
#
@ -942,8 +956,10 @@ find $DEST -type d | xargs chmod 755
if [ -f $DEST/bin/bash ]; then
rm -f $DEST/bin/ash
ln -s bash $DEST/bin/sh
else
ln -sf busybox $DEST/bin/sh
fi
if [ -f $DEST/bin/gawk ]; then
ln -sf awk $DEST/bin/gawk
fi
[ -d $DEST/bin ] || die "ERROR: directory missing: $DEST/bin"
@ -993,7 +1009,7 @@ if [ $ARCH = ia64 ]; then
fi
# copy bootloader files for i386/x86_64
if [ $ARCH = i386 -o $ARCH = x86_64 ]; then
if [ $ARCH = i386 -o $ARCH = i586 -o $ARCH = x86_64 ]; then
mkdir -p $DEST/usr/lib/anaconda-runtime/boot
cp -af $DEST/boot/memtest* $DEST/usr/lib/anaconda-runtime/boot
fi

77
rewrite/scripts/upd-kernel Executable file
View File

@ -0,0 +1,77 @@
#!/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

112
rewrite/scripts/upd-updates Executable file
View File

@ -0,0 +1,112 @@
#!/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

View File

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

59
rewrite/utils/mapshdr.c Normal file
View File

@ -0,0 +1,59 @@
/*
* 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;
}

View File

@ -122,7 +122,8 @@ int main (int argc, char **argv) {
printf("writing kernel...\n");
while (1) {
rc = fread(buffer, BUFFER_LEN, 1, fd2);
rc = fread(buffer, 1, 1, fd2);
if (rc == 0) {
break;
}
@ -132,17 +133,23 @@ int main (int argc, char **argv) {
abort();
}
wc = fwrite(buffer, BUFFER_LEN, 1, fd1);
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, BUFFER_LEN, 1, fd3);
rc = fread(buffer, 1, 1, fd3);
if (rc == 0) {
break;
}
@ -152,11 +159,16 @@ int main (int argc, char **argv) {
abort();
}
wc = fwrite(buffer, BUFFER_LEN, 1, fd1);
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) {
@ -175,12 +187,17 @@ int main (int argc, char **argv) {
abort();
}
wc = fwrite(&start_psw_address, 4, 1, fd1);
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);
@ -190,23 +207,33 @@ int main (int argc, char **argv) {
abort();
}
wc = fwrite(&initrd_start, 8, 1, fd1);
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, 8, 1, fd1);
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));
@ -215,6 +242,7 @@ int main (int argc, char **argv) {
while (1) {
rc = fread(buffer, 1, 1, fd4);
if (rc == 0) {
break;
}
@ -229,6 +257,11 @@ int main (int argc, char **argv) {
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) {

119
rewrite/utils/readmap.c Normal file
View File

@ -0,0 +1,119 @@
/*
* 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;
}

69
rewrite/utils/snarffont.c Normal file
View File

@ -0,0 +1,69 @@
/*
* 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;
}

View File

@ -7,4 +7,3 @@ 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.

View File

@ -4,4 +4,3 @@ 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@

View File

@ -4,7 +4,10 @@ mailspooldir = /mnt/sysimage/var/mail
crypt_style = md5
modules = files shadow
create_modules = files shadow
[files]
directory = /mnt/sysimage/etc
[shadow]
directory = /mnt/sysimage/etc

View File

@ -1,2 +1,3 @@
SELINUX=permissive
SELINUXTYPE=targeted

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python
# lorax
import sys
import os
@ -10,7 +9,7 @@ import pylorax
if __name__ == '__main__':
version = '%s 0.1' % os.path.basename(sys.argv[0])
usage = '%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUT REPOSITORY'
usage = '%prog -p PRODUCT -v VERSION -r RELEASE -o OUTPUTDIR REPOSITORY'
parser = OptionParser(usage=usage)
@ -18,42 +17,42 @@ if __name__ == '__main__':
if os.path.isdir(value):
setattr(parser.values, option.dest, value)
else:
parser.error('%s is not a directory.' % value)
parser.error('%s is not a directory' % value)
# XXX "options" should not be required
# required
# XXX "options" should not be required
group = OptionGroup(parser, 'Required')
group.add_option('-p', '--product', help='Product name.',
group.add_option('-p', '--product', help='Product name',
metavar='STRING')
group.add_option('-v', '--version', help='Version identifier.',
group.add_option('-v', '--version', help='Version identifier',
metavar='STRING')
group.add_option('-r', '--release', help='Release information or comment.',
group.add_option('-r', '--release', help='Release information or comment',
metavar='STRING')
group.add_option('-o', '--output', help='Destination directory.',
group.add_option('-o', '--output', help='Destination directory',
metavar='PATHSPEC')
parser.add_option_group(group)
# XXX are all of these used?
# optional
# XXX are all of these used?
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)
group.add_option('-t', '--variant', help='Variant name.',
group.add_option('-t', '--variant', help='Variant name',
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.')
group.add_option('-u', '--updates', help='Path to find updated RPMS.',
group.add_option('-u', '--updates', help='Directory containing updates',
metavar='PATHSPEC')
group.add_option('-m', '--mirrorlist',
help='Mirror list repository, may be listed multiple times.',
help='Mirror list repository (may be listed multiple times)',
metavar='REPOSITORY', action='append', default=[])
group.add_option('-c', '--confdir', help='Path to config files (default: /etc/lorax).',
metavar='PATHSPEC', action='callback', callback=check_dir,
type='string', default='/etc/lorax')
group.add_option('-C', '--cleanup', help='Cleanup on exit.',
group.add_option('-C', '--cleanup', help='Cleanup on exit',
action='store_true', default=False)
group.add_option('-V', help='Print version and exit.',
group.add_option('-V', help='Print version and exit',
action='store_true', default=False, dest='printver')
parser.add_option_group(group)
@ -70,10 +69,10 @@ if __name__ == '__main__':
sys.exit(0)
if not opts.product or not opts.version or not opts.release or not opts.output:
parser.error('Missing required argument.')
parser.error('Missing required argument')
if not args:
parser.error('Missing repository to use for image generation.')
parser.error('Missing repository')
config = pylorax.Config()
config.set(confdir=opts.confdir,
@ -86,6 +85,7 @@ if __name__ == '__main__':
release=opts.release,
outdir=opts.output,
repos=args)
# optional
config.set(variant=opts.variant,
bugurl=opts.bugurl,

View File

@ -1,17 +1,21 @@
# pylorax/__init__.py
import sys
import os
import stat
import commands
import shutil
import tempfile
import time
import datetime
import ConfigParser
import re
import fnmatch
import pwd
import grp
from errors import LoraxError
from config import Container
from utils.rpmutils import Yum
from utils.fileutils import rm
from utils.fileutils import cp, mv, rm, touch, edit, replace
import images
@ -67,49 +71,63 @@ class Lorax(object):
def run(self):
bold = ('\033[1m', '\033[0m')
print('%sCollecting repos%s' % bold)
self.collectRepos()
print("%sCollecting repos%s" % bold)
self.collect_repos()
# check if we have at least one valid repository
if not self.conf.repo:
sys.stderr.write('ERROR: No valid repository\n')
sys.stderr.write("ERROR: No valid repository\n")
sys.exit(1)
print('%sInitializing directories%s' % bold)
self.initDirs()
print("%sInitializing temporary directories%s" % bold)
self.init_dirs()
print('%sInitializing yum%s' % bold)
self.initYum()
print("%sInitializing yum%s" % bold)
self.init_yum()
print('%sSetting build architecture%s' % bold)
self.setBuildArch()
print("%sSetting build architecture%s" % bold)
self.set_buildarch()
print('%sWriting .treeinfo%s' % bold)
self.writeTreeInfo()
print("%sWriting .treeinfo%s" % bold)
self.write_treeinfo()
print('%sWriting .discinfo%s' % bold)
self.writeDiscInfo()
print("%sWriting .discinfo%s" % bold)
self.write_discinfo()
print('%sPreparing the install tree%s' % bold)
self.prepareInstRoot()
print("%sPreparing the install tree%s" % bold)
self.prepare_treedir()
print('%sCreating the images%s' % bold)
self.makeImages()
print("%sScrubbing the install tree%s" % bold)
self.scrub_treedir()
print("%sWriting .buildstamp%s" % bold)
self.write_buildstamp()
print("%sInitializing output directories%s" % bold)
self.init_outputdirs()
print("%sCreating the initrd.img%s" % bold)
self.create_initrd()
print("%sCreating the install.img%s" % bold)
self.create_installimg()
if self.conf.cleanup:
print('%sCleaning up%s' % bold)
self.cleanUp()
print("%sCleaning up%s" % bold)
self.clean_up()
def collectRepos(self):
def collect_repos(self):
repolist = []
for repospec in self.conf.repos:
if repospec.startswith('/'):
repo = 'file://%s' % repospec
print('Adding local repo: %s' % repo)
print("Adding local repo: %s" % repo)
repolist.append(repo)
elif repospec.startswith('http://') or repospec.startswith('ftp://'):
print('Adding remote repo: %s' % repospec)
print("Adding remote repo: %s" % repospec)
repolist.append(repospec)
else:
print("Invalid repo path: %s" % repospec)
if not repolist:
repo, extrarepos = None, []
@ -119,10 +137,10 @@ class Lorax(object):
self.conf.addAttr(['repo', 'extrarepos'])
self.conf.set(repo=repo, extrarepos=extrarepos)
# remove repos attribute, to get a traceback, if we use it later
# remove repos attribute, to get a traceback, if we use it later accidentaly
self.conf.delAttr('repos')
def initDirs(self):
def init_dirs(self):
if not os.path.isdir(self.conf.outdir):
os.makedirs(self.conf.outdir, mode=0755)
@ -133,22 +151,22 @@ class Lorax(object):
initrddir = os.path.join(self.conf.tempdir, 'initrddir')
os.makedirs(initrddir)
print('Working directories:')
print(' tempdir = %s' % self.conf.tempdir)
print(' treedir = %s' % treedir)
print(' cachedir = %s' % cachedir)
print(' initrddir = %s' % initrddir)
print("Working directories:")
print(" tempdir = %s" % self.conf.tempdir)
print(" treedir = %s" % treedir)
print(" cachedir = %s" % cachedir)
print(" initrddir = %s" % initrddir)
self.conf.addAttr(['treedir', 'cachedir', 'initrddir'])
self.conf.set(treedir=treedir, cachedir=cachedir, initrddir=initrddir)
def initYum(self):
def init_yum(self):
yumconf = os.path.join(self.conf.tempdir, 'yum.conf')
try:
f = open(yumconf, 'w')
except IOError as why:
sys.stderr.write('ERROR: Unable to write yum.conf file: %s\n' % why)
sys.stderr.write("ERROR: Unable to write yum.conf file: %s\n" % why)
sys.exit(1)
else:
f.write('[main]\n')
@ -187,7 +205,7 @@ class Lorax(object):
# remove not needed attributes
self.conf.delAttr(['repo', 'extrarepos', 'mirrorlist', 'cachedir'])
def setBuildArch(self):
def set_buildarch(self):
unamearch = os.uname()[4]
self.conf.addAttr('buildarch')
@ -197,9 +215,16 @@ class Lorax(object):
try:
self.conf.set(buildarch=available[0].arch)
except:
# FIXME specify what exceptions can we get here
pass
# set basearch
self.conf.addAttr('basearch')
self.conf.set(basearch=self.conf.buildarch)
if re.match(r'i.86', self.conf.basearch):
self.conf.set(basearch='i386')
elif self.conf.buildarch == 'sparc64':
self.conf.set(basearch='sparc')
# set the libdir
self.conf.addAttr('libdir')
self.conf.set(libdir='lib')
@ -207,7 +232,7 @@ class Lorax(object):
if self.conf.buildarch.endswith('64') or self.conf.buildarch == 's390x':
self.conf.set(libdir='lib64')
def writeTreeInfo(self, discnum=1, totaldiscs=1, packagedir=''):
def write_treeinfo(self, discnum=1, totaldiscs=1, packagedir=''):
outfile = os.path.join(self.conf.outdir, '.treeinfo')
# don't print anything instead of None, if variant is not specified
@ -218,7 +243,7 @@ class Lorax(object):
data = { 'timestamp': time.time(),
'family': self.conf.product,
'version': self.conf.version,
'arch': self.conf.buildarch,
'arch': self.conf.basearch,
'variant': variant,
'discnum': str(discnum),
'totaldiscs': str(totaldiscs),
@ -231,17 +256,11 @@ class Lorax(object):
for key, value in data.items():
c.set(section, key, value)
section = 'images-%s' % self.conf.buildarch
section = 'images-%s' % self.conf.basearch
c.add_section(section)
c.set(section, 'kernel', 'images/pxeboot/vmlinuz')
c.set(section, 'initrd', 'images/pxeboot/initrd.img')
# XXX actually create the boot iso somewhere before calling writeTreeInfo(),
# and set up this attribute properly
self.conf.addAttr('bootiso')
if self.conf.bootiso:
c.set(section, 'boot.iso', 'images/%s' % self.conf.bootiso)
c.set(section, 'boot.iso', 'images/boot.iso')
try:
f = open(outfile, 'w')
@ -252,7 +271,7 @@ class Lorax(object):
f.close()
return True
def writeDiscInfo(self, discnum=0):
def write_discinfo(self, discnum='ALL'):
outfile = os.path.join(self.conf.outdir, '.discinfo')
try:
@ -262,25 +281,610 @@ class Lorax(object):
else:
f.write('%f\n' % time.time())
f.write('%s\n' % self.conf.release)
f.write('%s\n' % self.conf.buildarch)
f.write('%d\n' % discnum)
f.write('%s\n' % self.conf.basearch)
f.write('%s\n' % discnum)
f.close()
return True
def prepareInstRoot(self):
# XXX do we need this?
def prepare_treedir(self):
# required packages
self.yum.addPackages(['anaconda', 'anaconda-runtime', 'kernel', '*firmware*', 'syslinux',
'/etc/gtk-2.0/gtkrc'])
# get packages from confdir
packages_files = []
packages_files.append(os.path.join(self.conf.confdir, 'packages', 'packages.all'))
packages_files.append(os.path.join(self.conf.confdir, 'packages', 'packages.%s' % self.conf.buildarch))
packages = set()
for pfile in packages_files:
if os.path.isfile(pfile):
f = open(pfile, 'r')
for line in f.readlines():
line, sep, comment = line.partition('#')
line = line.strip()
if not line:
continue
if line.startswith('-'):
packages.discard(line[1:])
else:
packages.add(line)
f.close()
self.yum.addPackages(list(packages))
# add logos
self.yum.addPackages(['%s-logos' % self.conf.product.lower(),
'%s-release' % self.conf.product.lower()])
# XXX why do we need this?
os.symlink(os.path.join(os.path.sep, 'tmp'),
os.path.join(self.conf.treedir, 'var', 'lib', 'xkb'))
def makeImages(self):
i = images.Images(self.conf, self.yum)
i.run()
# install packages
self.yum.install()
def cleanUp(self, trash=[]):
# copy updates
if self.conf.updates and os.path.isdir(self.conf.updates):
cp(os.path.join(self.conf.updates, '*'), self.conf.treedir)
self.conf.delAttr('updates')
# XXX here comes a lot of crazy tree modification stuff, beware! XXX
# create dogtail conf files
dogtailconf = os.path.join(self.conf.datadir, 'dogtail', '%gconf.xml')
if os.path.isfile(dogtailconf):
dst = os.path.join(self.conf.treedir, '.gconf', 'desktop', 'gnome', 'interface')
os.makedirs(dst)
cp(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)
cp(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')
mv(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)
mv(src, 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'):
rm(os.path.join(self.conf.treedir, 'usr', 'sbin', 'ldconfig'))
rm(os.path.join(self.conf.treedir, 'etc', 'ld.so.conf'))
os.system('umount %s' % procdir)
def scrub_treedir(self):
# XXX another part of crazy tree modification XXX
# figure out the gtk+ theme to keep
gtkrc = os.path.join(self.conf.treedir, 'etc', 'gtk-2.0', 'gtkrc')
gtk_theme_name = None
gtk_engine = None
gtk_icon_themes = []
if os.path.isfile(gtkrc):
f = open(gtkrc, 'r')
lines = f.readlines()
f.close()
for line in lines:
line = line.strip()
if line.startswith('gtk-theme-name'):
gtk_theme_name = line[line.find('=') + 1:]
gtk_theme_name = gtk_theme_name.replace('"', '').strip()
# find the engine for this theme
gtkrc = os.path.join(self.conf.treedir, 'usr', 'share', 'themes',
gtk_theme_name, 'gtk-2.0', 'gtkrc')
if os.path.isfile(gtkrc):
f = open(gtkrc, 'r')
engine_lines = f.readlines()
f.close()
for engine_line in engine_lines:
engine_line = engine_line.strip()
if engine_line.find('engine') != -1:
gtk_engine = engine_line[engine_line.find('"') + 1:]
gtk_engine = gtk_engine.replace('"', '').strip()
break
elif line.startswith('gtk-icon-theme-name'):
icon_theme = line[line.find('=') + 1:]
icon_theme = icon_theme.replace('"', '').strip()
gtk_icon_themes.append(icon_theme)
# bring in all inherited themes
while True:
icon_theme_index = os.path.join(self.conf.treedir, 'usr', 'share', 'icons',
icon_theme, 'index.theme')
if os.path.isfile(icon_theme_index):
inherits = False
f = open(icon_theme_index, 'r')
icon_lines = f.readlines()
f.close()
for icon_line in icon_lines:
icon_line = icon_line.strip()
if icon_line.startswith('Inherits='):
inherits = True
icon_theme = icon_line[icon_line.find('=') + 1:]
icon_theme = icon_theme.replace('"', '').strip()
gtk_icon_themes.append(icon_theme)
break
if not inherits:
break
else:
break
# remove themes we don't need
theme_path = os.path.join(self.conf.treedir, 'usr', 'share', 'themes')
if os.path.isdir(theme_path):
for theme in filter(lambda theme: theme != gtk_theme_name, os.listdir(theme_path)):
theme = os.path.join(theme_path, theme)
shutil.rmtree(theme, ignore_errors=True)
# remove icons we don't need
icon_path = os.path.join(self.conf.treedir, 'usr', 'share', 'icons')
if os.path.isdir(icon_path):
for icon in filter(lambda icon: icon not in gtk_icon_themes, os.listdir(icon_path)):
icon = os.path.join(icon_path, icon)
shutil.rmtree(icon, ignore_errors=True)
# remove engines we don't need
tmp_path = os.path.join(self.conf.treedir, 'usr', self.conf.libdir, 'gtk-2.0')
if os.path.isdir(tmp_path):
fnames = map(lambda fname: os.path.join(tmp_path, fname, 'engines'), os.listdir(tmp_path))
dnames = filter(lambda fname: os.path.isdir(fname), fnames)
for dir in dnames:
engines = filter(lambda engine: engine.find(gtk_engine) == -1, os.listdir(dir))
for engine in engines:
engine = os.path.join(dir, engine)
os.unlink(engine)
# remove locales
langtable = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda', 'lang-table')
localepath = os.path.join(self.conf.treedir, 'usr', 'share', 'locale')
if os.path.isfile(langtable):
locales = set()
all_locales = set()
f = open(langtable, 'r')
lines = f.readlines()
f.close()
for line in lines:
line = line.strip()
if not line or line.startswith('#'):
continue
fields = line.split('\t')
if os.path.isdir(os.path.join(localepath, fields[1])):
locales.add(fields[1])
locale = fields[3].split('.')[0]
if os.path.isdir(os.path.join(localepath, locale)):
locales.add(locale)
for locale in os.listdir(localepath):
all_locales.add(locale)
locales_to_remove = list(all_locales.difference(locales))
for locale in locales_to_remove:
rmpath = os.path.join(localepath, locale)
shutil.rmtree(rmpath, ignore_errors=True)
# fixup joe links
joedir = os.path.join(self.conf.treedir, 'etc', 'joe')
if os.path.isdir(joedir):
os.symlink('jpicorc', os.path.join(joedir, 'picorc'))
os.symlink('jpicorc', os.path.join(joedir, 'jnanorc'))
os.symlink('jpicorc', os.path.join(joedir, 'nanorc'))
os.symlink('jmacsrc', os.path.join(joedir, 'emacsrc'))
os.symlink('jmacs', os.path.join(self.conf.treedir, 'usr', 'bin', 'emacs'))
os.symlink('jpico', os.path.join(self.conf.treedir, 'usr', 'bin', 'pico'))
os.symlink('jpico', os.path.join(self.conf.treedir, 'usr', 'bin', 'nano'))
# fix up some links for man page related stuff
for file in ['nroff', 'groff', 'iconv', 'geqn', 'gtbl', 'gpic', 'grefer']:
src = os.path.join('mnt', 'sysimage', 'usr', 'bin', file)
dst = os.path.join(self.conf.treedir, 'usr', 'bin', file)
if not os.path.isfile(dst):
os.symlink(src, dst)
# create selinux config
if os.path.exists(os.path.join(self.conf.treedir, 'etc', 'selinux', 'targeted')):
src = os.path.join(self.conf.datadir, 'selinux', 'config')
dst = os.path.join(self.conf.treedir, 'etc', 'selinux', 'config')
cp(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')
cp(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')
mv(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)
cp(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)
cp(src, dst)
elif self.conf.buildarch in ('ppc', 'ppc64'):
src = os.path.join(self.conf.treedir, 'boot', 'efika.forth')
cp(src, bootpath)
elif self.conf.buildarch in ('alpha',):
src = os.path.join(self.conf.treedir, 'boot', 'bootlx')
cp(src, bootpath)
elif self.conf.buildarch in ('ia64',):
src = os.path.join(self.conf.treedir, 'boot', 'efi', 'EFI', 'redhat', '*')
cp(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))
def write_buildstamp(self):
outfile = os.path.join(self.conf.treedir, '.buildstamp')
# make imageuuid
now = datetime.datetime.now()
arch = self.conf.buildarch
imageuuid = '%s.%s' % (now.strftime('%Y%m%d%H%M'), arch)
try:
f = open(outfile, 'w')
except IOError:
return False
else:
f.write('%s\n' % imageuuid)
f.write('%s\n' % self.conf.product)
f.write('%s\n' % self.conf.version)
f.write('%s\n' % self.conf.bugurl)
f.close()
return True
def init_outputdirs(self):
# create the destination directories
imagesdir = os.path.join(self.conf.outdir, 'images')
if os.path.exists(imagesdir):
rm(imagesdir)
os.makedirs(imagesdir)
pxebootdir = os.path.join(imagesdir, 'pxeboot')
os.makedirs(pxebootdir)
# create the isolinux directory
isolinuxdir = os.path.join(self.conf.outdir, 'isolinux')
if os.path.exists(isolinuxdir):
rm(isolinuxdir)
os.makedirs(isolinuxdir)
self.conf.addAttr(['imagesdir', 'pxebootdir', 'isolinuxdir'])
self.conf.set(imagesdir=imagesdir, pxebootdir=pxebootdir, isolinuxdir=isolinuxdir)
# write the images/README
src = os.path.join(self.conf.datadir, 'images', 'README')
dst = os.path.join(self.conf.imagesdir, 'README')
cp(src, dst)
replace(dst, r'@PRODUCT@', self.conf.product)
# write the images/pxeboot/README
src = os.path.join(self.conf.datadir, 'images', 'pxeboot', 'README')
dst = os.path.join(self.conf.pxebootdir, 'README')
cp(src, dst)
replace(dst, r'@PRODUCT@', self.conf.product)
# populate the isolinux directory
# XXX don't see this used anywhere...
syslinux = os.path.join(self.conf.treedir, 'usr', 'lib', 'syslinux', 'syslinux-nomtools')
if not os.path.isfile(syslinux):
sys.stderr.write('WARNING: %s does not exist\n' % syslinux)
syslinux = os.path.join(self.conf.treedir, 'usr', 'bin', 'syslinux')
if not os.path.isfile(syslinux):
sys.stderr.write('ERROR: %s does not exist\n' % syslinux)
sys.exit(1)
# set up some dir variables for further use
anacondadir = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime')
bootdiskdir = os.path.join(anacondadir, 'boot')
syslinuxdir = os.path.join(self.conf.treedir, 'usr', 'lib', 'syslinux')
isolinuxbin = os.path.join(syslinuxdir, 'isolinux.bin')
if not os.path.isfile(isolinuxbin):
sys.stderr.write('ERROR: %s does not exist\n' % isolinuxbin)
sys.exit(1)
if os.path.exists(isolinuxbin):
# copy the isolinux.bin
cp(isolinuxbin, self.conf.isolinuxdir)
# copy the syslinux.cfg to isolinux/isolinux.cfg
isolinuxcfg = os.path.join(self.conf.isolinuxdir, 'isolinux.cfg')
cp(os.path.join(bootdiskdir, 'syslinux.cfg'), isolinuxcfg)
# set the product and version in isolinux.cfg
replace(isolinuxcfg, r'@PRODUCT@', self.conf.product)
replace(isolinuxcfg, r'@VERSION@', self.conf.version)
# set up the label for finding stage2 with a hybrid iso
replace(isolinuxcfg, r'initrd=initrd.img', 'initrd=initrd.img stage2=hd:LABEL=%s' % self.conf.product)
# copy the grub.conf
cp(os.path.join(bootdiskdir, 'grub.conf'), self.conf.isolinuxdir)
# copy the splash files
vesasplash = os.path.join(anacondadir, 'syslinux-vesa-splash.jpg')
if os.path.isfile(vesasplash):
cp(vesasplash, os.path.join(self.conf.isolinuxdir, 'splash.jpg'))
vesamenu = os.path.join(syslinuxdir, 'vesamenu.c32')
cp(vesamenu, self.conf.isolinuxdir)
replace(isolinuxcfg, r'default linux', r'default vesamenu.c32')
replace(isolinuxcfg, r'prompt 1', r'#prompt 1')
else:
splashtools = os.path.join(anacondadir, 'splashtools.sh')
splashlss = os.path.join(bootdiskdir, 'splash.lss')
if os.path.isfile(splashtools):
cmd = '%s %s %s' % (splashtools,
os.path.join(bootdiskdir, 'syslinux-splash.jpg'),
splashlss)
os.system(cmd)
if os.path.isfile(splashlss):
cp(splashlss, self.conf.isolinuxdir)
# copy the .msg files
for file in os.listdir(bootdiskdir):
if file.endswith('.msg'):
cp(os.path.join(bootdiskdir, file), self.conf.isolinuxdir)
replace(os.path.join(self.conf.isolinuxdir, file), r'@VERSION@', self.conf.version)
# if present, copy the memtest
cp(os.path.join(self.conf.treedir, 'boot', 'memtest*'),
os.path.join(self.conf.isolinuxdir, 'memtest'))
if os.path.isfile(os.path.join(self.conf.isolinuxdir, 'memtest')):
text = "label memtest86\n"
text = text + " menu label ^Memory test\n"
text = text + " kernel memtest\n"
text = text + " append -\n"
edit(isolinuxcfg, text, append=True)
else:
sys.stderr.write('No isolinux binaries found\n')
def create_initrd(self):
# get installed kernel file
kernelfile = None
kerneldir = os.path.join(self.conf.treedir, 'boot')
if self.conf.buildarch in ('ia64',):
kerneldir = os.path.join(self.conf.treedir, 'boot', 'efi', 'EFI', 'redhat')
for file in os.listdir(kerneldir):
if fnmatch.fnmatch(file, 'vmlinuz-*'):
kernelfile = os.path.join(self.conf.treedir, 'boot', file)
if not kernelfile:
sys.stderr.write('ERROR: No kernel image found\n')
sys.exit(1)
initrd = images.InitRD(self.conf, self.yum, kernelfile)
# install needed packages
packages = initrd.get_packages()
self.yum.addPackages(list(packages))
self.yum.install()
# copy the kernel file
cp(kernelfile, os.path.join(self.conf.isolinuxdir, 'vmlinuz'))
cp(kernelfile, os.path.join(self.conf.pxebootdir, 'vmlinuz'))
# create the initrd.img
initrd.create(os.path.join(self.conf.isolinuxdir, 'initrd.img'))
initrd.clean_up()
cp(os.path.join(self.conf.isolinuxdir, 'initrd.img'), self.conf.pxebootdir)
# XEN
if self.conf.buildarch in ('i386',):
self.yum.addPackages('kernel-PAE')
self.yum.install()
xenkernel = None
for file in os.listdir(kerneldir):
if fnmatch.fnmatch(file, 'vmlinuz-*.PAE'):
xenkernel = os.path.join(self.conf.treedir, 'boot', file)
if not xenkernel:
sys.stderr.write('ERROR: No XEN kernel image found\n')
sys.exit(1)
initrd = images.InitRD(self.conf, self.yum, xenkernel)
cp(xenkernel, os.path.join(self.conf.pxebootdir, 'vmlinuz-PAE'))
initrd.create(os.path.join(self.conf.pxebootdir, 'initrd-PAE.img'))
#initrd.clean_up()
# add xen kernel files to .treeinfo
text = '[images-xen]\n'
text += 'kernel = images/pxeboot/vmlinuz-PAE\n'
text += 'initrd = images/pxeboot/initrd-PAE.img\n'
edit(os.path.join(self.conf.outdir, '.treeinfo'), append=True, text=text)
def create_installimg(self, type='squashfs'):
print('Removing not needed files from install tree')
i = images.Install(self.conf)
i.scrub()
i.fix_links()
print('Creating the image file')
if type == 'squashfs':
cmd = 'mksquashfs %s %s -all-root -no-fragments -no-progress' % (self.conf.treedir,
os.path.join(self.conf.imagesdir, 'install.img'))
err, output = commands.getstatusoutput(cmd)
elif type == 'cramfs':
if self.conf.buildarch == 'sparc64':
crambs = '--blocksize 8192'
elif self.conf.buildarch == 'sparc':
crambs = '--blocksize 4096'
else:
crambs = ''
cmd = 'mkfs.cramfs %s %s %s' % (crambs, self.conf.treedir, os.path.join(self.conf.imagesdir, 'install.img'))
err, output = commands.getstatusoutput(cmd)
elif type == 'ext2':
# TODO
pass
text = '\n[stage2]\n'
text += 'mainimage = %s/install.img\n' % self.conf.imagesdir
edit(os.path.join(self.conf.outdir, '.treeinfo'), append=True, text=text)
def clean_up(self, trash=[]):
for item in trash:
if os.path.exists(item):
rm(item)
# remove the whole lorax tempdir
if os.path.isdir(self.conf.tempdir):
# remove the whole lorax temp directory
if os.path.exists(self.conf.tempdir):
rm(self.conf.tempdir)

View File

@ -1,610 +1,3 @@
#
# pylorax instroot module
# Install image and tree support data generation tool -- Python module.
#
# Copyright (C) 2008, 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/>.
#
# Author(s): David Cantrell <dcantrell@redhat.com>
# Martin Gracik <mgracik@redhat.com>
#
import sys
import os
import stat
import shutil
import glob
import fnmatch
import re
import fileinput
import subprocess
import pwd
import grp
import tempfile
from fileutils import cp, mv, touch
from yumutils import extract_rpm
import utils
class InstRoot:
"""InstRoot(config, options, yum)
Create a instroot tree for the specified architecture. The list of
packages to install are specified in the /etc/lorax/packages and
/etc/lorax/ARCH/packages files.
yumconf is the path to the yum configuration file created for this run of
lorax. arch is the platform name we are building for, treedir is
the location where the instroot tree should go
(will be treedir + '/install'). updates is an optional path to a
directory of updated RPM packages for the instroot.
The conf, yumconf, arch, and treedir parameters are all required.
On success, this function returns True. On failure, False is
returned or the program is aborted immediately.
"""
def __init__(self, config, options, yum):
self.conf = config
self.opts = options
self.yum = yum
self.destdir = self.conf.treedir
def run(self):
"""run()
Generate the instroot tree and prepare it for building images.
"""
self.packages = self.__getPackageList()
self.__installPackages()
if not self.__installKernel():
sys.exit(1)
# XXX
#self.__scrubInstRoot()
def __getPackageList(self):
packages = set()
packages_files = []
packages_files.append(os.path.join(self.conf.confdir, 'packages'))
packages_files.append(os.path.join(self.conf.confdir, self.opts.buildarch, 'packages'))
for pfile in packages_files:
if os.path.isfile(pfile):
f = open(pfile, 'r')
for line in f.readlines():
line = line.strip()
if not line or line.startswith('#'):
continue
if line.startswith('-'):
packages.discard(line[1:])
else:
packages.add(line)
f.close()
packages = list(packages)
packages.sort()
return packages
def __installPackages(self):
# XXX i don't think this is needed
# do some prep work on the destdir before calling yum
#os.makedirs(os.path.join(self.destdir, 'boot'))
#os.makedirs(os.path.join(self.destdir, 'usr', 'sbin'))
#os.makedirs(os.path.join(self.destdir, 'usr', 'lib', 'debug'))
#os.makedirs(os.path.join(self.destdir, 'usr', 'src', 'debug'))
#os.makedirs(os.path.join(self.destdir, 'tmp'))
#os.makedirs(os.path.join(self.destdir, 'var', 'log'))
#os.makedirs(os.path.join(self.destdir, 'var', 'lib', 'yum'))
# XXX maybe only this...
#os.makedirs(os.path.join(self.destdir, 'var', 'lib'))
os.symlink(os.path.join(os.path.sep, 'tmp'), os.path.join(self.destdir, 'var', 'lib', 'xkb'))
self.yum.install(self.packages)
# copy updates to treedir
if self.opts.updates and os.path.isdir(self.opts.updates):
cp(os.path.join(self.opts.updates, '*'), self.destdir)
# XXX
def __installKernel(self):
arches = [self.opts.buildarch]
efiarch = []
kerneltags = ['kernel']
kernelxen = []
if self.opts.buildarch == 'ppc':
arches = ['ppc64', 'ppc']
elif self.opts.buildarch == 'i386':
arches = ['i586']
efiarch = ['ia32']
kerneltags = ['kernel', 'kernel-PAE']
kernelxen = ['kernel-PAE']
elif self.opts.buildarch == 'x86_64':
efiarch = ['x64']
elif self.opts.buildarch == 'ia64':
efiarch = ['ia64']
kpackages = self.yum.find(kerneltags)
if not kpackages:
sys.stderr.write('ERROR: Unable to find any kernel package\n')
return False
# create the modinfo file
(fd, modinfo) = tempfile.mkstemp(prefix='modinfo-%s.' % self.opts.buildarch,
dir=self.conf.tempdir)
self.conf.addAttr('modinfo')
self.conf.set(modinfo=modinfo)
for kernel in kpackages:
fn = self.yum.download(kernel)
kernelroot = os.path.join(self.conf.kernelbase, kernel.arch)
extract_rpm(fn, kernelroot)
os.unlink(fn)
# get vmlinuz and version
dir = os.path.join(kernelroot, 'boot')
if self.opts.buildarch == 'ia64':
dir = os.path.join(dir, 'efi', 'EFI', 'redhat')
vmlinuz = None
for file in os.listdir(dir):
if file.startswith('vmlinuz'):
vmlinuz = file
prefix, sep, version = file.partition('-')
if not vmlinuz:
sys.stderr.write('ERROR: vmlinuz file not found\n')
return False
modules_dir = os.path.join(kernelroot, 'lib', 'modules', version)
if not os.path.isdir(modules_dir):
sys.stderr.write('ERROR: modules directory not found\n')
return False
allmods = []
for file in os.listdir(modules_dir):
if file.endswith('.ko'):
allmods.append(os.path.join(modules_dir, file))
# install firmware
fpackages = self.yum.find('*firmware*')
for firmware in fpackages:
fn = self.yum.download(firmware)
extract_rpm(fn, kernelroot)
os.unlink(fn)
utils.genmodinfo(modules_dir, self.conf.modinfo)
return True
def __scrubInstRoot(self):
self.__createConfigFiles()
self.__removeGtkThemes()
self.__removeLocales()
self.__fixManPages()
self.__installStubs()
self.__copyBootloaders()
self.__moveYumRepos()
self.__configureKmod()
self.__moveAnacondaFiles()
self.__setShellLinks()
#self.__moveBins()
self.__removeUnwanted()
self.__changeDestDirPermissions()
self.__createLDConfig()
self.__setBusyboxLinks()
self.__strip()
#self.__fixBrokenLinks()
def __createConfigFiles(self):
# create %gconf.xml
dogtailconf = os.path.join(self.conf.datadir, 'dogtail-%gconf.xml')
if os.path.isfile(dogtailconf):
os.makedirs(os.path.join(self.destdir, '.gconf', 'desktop', 'gnome', 'interface'))
touch(os.path.join(self.destdir, '.gconf', 'desktop', '%gconf.xml'))
touch(os.path.join(self.destdir, '.gconf', 'desktop', 'gnome', '%gconf.xml'))
dst = os.path.join(self.destdir, '.gconf', 'desktop', 'gnome', 'interface', '%gconf.xml')
cp(dogtailconf, dst)
# create selinux config
if os.path.isfile(os.path.join(self.destdir, 'etc', 'selinux', 'targeted')):
selinuxconf = os.path.join(self.conf.datadir, 'selinux-config')
if os.path.isfile(selinuxconf):
dst = os.path.join(self.destdir, 'etc', 'selinux', 'config')
cp(selinuxconf, dst)
# create libuser.conf
libuserconf = os.path.join(self.conf.datadir, 'libuser.conf')
if os.path.isfile(libuserconf):
dst = os.path.join(self.destdir, 'etc', 'libuser.conf')
cp(libuserconf, dst)
def __removeGtkThemes(self):
# figure out the gtk+ theme to keep
gtkrc = os.path.join(self.destdir, '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.destdir, '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.destdir, '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.destdir, '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.destdir, '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.destdir, 'usr', self.opts.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)
def __removeLocales(self):
langtable = os.path.join(self.destdir, 'usr', 'lib', 'anaconda', 'lang-table')
localepath = os.path.join(self.destdir, '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)
def __fixManPages(self):
for file in ['nroff', 'groff', 'iconv', 'geqn', 'gtbl', 'gpic', 'grefer']:
src = os.path.join('mnt', 'sysimage', 'usr', 'bin', file)
dst = os.path.join(self.destdir, 'usr', 'bin', file)
if not os.path.isfile(dst):
os.symlink(src, dst)
# fix /etc/man.config to point to /mnt/sysimage
manconfig = os.path.join(self.destdir, 'etc', 'man.config')
# XXX WHY?
# don't change MANPATH_MAP lines now
fin = fileinput.input(manconfig, inplace=1)
for line in fin:
line = re.sub(r'^MANPATH[^_MAP][ \t]*', r'&/mnt/sysimage', line)
sys.stdout.write(line)
fin.close()
# change MANPATH_MAP lines
fin = fileinput.input(manconfig, inplace=1)
for line in fin:
line = re.sub(r'^MANPATH_MAP[ \t]*[a-zA-Z0-9/]*[ \t]*', r'&/mnt/sysimage', line)
sys.stdout.write(line)
fin.close()
def __installStubs(self):
for subdir in ['lib', 'firmware']:
subdir = os.path.join(self.destdir, subdir)
if not os.path.isdir(subdir):
os.makedirs(subdir)
for subdir in ['modules', 'firmware']:
src = os.path.join(os.path.sep, subdir)
dst = os.path.join(self.destdir, 'lib', subdir)
shutil.rmtree(dst, ignore_errors=True)
os.symlink(src, dst)
for prog in ['raidstart', 'raidstop', 'losetup', 'list-harddrives', 'loadkeys', 'mknod',
'syslogd']:
stub = "%s-stub" % (prog,)
src = os.path.join(self.destdir, 'usr', 'lib', 'anaconda', stub)
dst = os.path.join(self.destdir, 'usr', 'bin', prog)
if os.path.isfile(src) and not os.path.isfile(dst):
cp(src, dst)
def __copyBootloaders(self):
bootpath = os.path.join(self.destdir, 'usr', 'lib', 'anaconda-runtime', 'boot')
if not os.path.isdir(bootpath):
os.makedirs(bootpath)
if self.opts.buildarch == 'i386' or self.opts.buildarch == 'x86_64':
for bootfile in os.listdir(os.path.join(self.destdir, 'boot')):
if bootfile.startswith('memtest'):
src = os.path.join(self.destdir, 'boot', bootfile)
dst = os.path.join(bootpath, bootfile)
cp(src, dst)
elif self.opts.buildarch.startswith('sparc'):
for bootfile in os.listdir(os.path.join(self.destdir, 'boot')):
if bootfile.endswith('.b'):
src = os.path.join(self.destdir, 'boot', bootfile)
dst = os.path.join(bootpath, bootfile)
cp(src, dst)
elif self.opts.buildarch.startswith('ppc'):
src = os.path.join(self.destdir, 'boot', 'efika.forth')
dst = os.path.join(bootpath, 'efika.forth')
cp(src, dst)
elif self.opts.buildarch == 'alpha':
src = os.path.join(self.destdir, 'boot', 'bootlx')
dst = os.path.join(bootpath, 'bootlx')
cp(src, dst)
elif self.opts.buildarch == 'ia64':
src = os.path.join(self.destdir, 'boot', 'efi', 'EFI', 'redhat')
shutil.rmtree(bootpath, ignore_errors=True)
cp(src, bootpath)
def __moveYumRepos(self):
src = os.path.join(self.destdir, 'etc', 'yum.repos.d')
dst = os.path.join(self.destdir, 'etc', 'anaconda.repos.d')
if os.path.isdir(src):
shutil.rmtree(dst, ignore_errors=True)
mv(src, dst)
def __configureKmod(self):
fedorakmodconf = os.path.join(self.destdir, 'etc', 'yum', 'pluginconf.d', 'fedorakmod.conf')
# XXX this file does not exist, what package provides it?
if not os.path.exists(fedorakmodconf):
return
fin = fileinput.input(fedorakmodconf, inplace=1)
for line in fin:
line = re.sub(r'\(installforallkernels\) = 0', r'\1 = 1', line)
sys.stdout.write(line)
fin.close()
def __moveAnacondaFiles(self):
# move executable
src = os.path.join(self.destdir, 'usr', 'sbin', 'anaconda')
dst = os.path.join(self.destdir, 'usr', 'bin', 'anaconda')
mv(src, dst)
# move libraries
src = os.path.join(self.destdir, 'usr', 'lib', 'anaconda-runtime', 'lib')
dst = os.path.join(self.destdir, 'usr', self.libdir)
for fname in glob.glob(src + '*'):
mv(fname, dst)
def __setShellLinks(self):
bash = os.path.join(self.destdir, 'bin', 'bash')
ash = os.path.join(self.destdir, 'bin', 'ash')
sh = os.path.join(self.destdir, 'bin', 'sh')
busybox = os.path.join(self.destdir, 'bin', 'busybox')
if os.path.exists(bash):
# XXX is this needed? i don't have ash in the tree...
try:
os.unlink(ash)
except OSError:
pass
os.unlink(sh)
os.symlink(bash, sh)
else:
os.unlink(sh)
os.symlink(busybox, sh)
def __moveBins(self):
# XXX why do we want to move everything to /usr when in mk-images we copy it back?
bin = os.path.join(self.destdir, 'bin')
sbin = os.path.join(self.destdir, 'sbin')
if not os.path.exists(bin) or not os.path.exists(sbin):
raise Error, 'bin or sbin directory missing'
dst = os.path.join(self.destdir, 'usr')
for src in (bin, sbin):
mv(src, dst)
def __removeUnwanted(self):
for subdir in ['boot', 'home', 'root', 'tmp']:
shutil.rmtree(os.path.join(self.destdir, subdir), ignore_errors=True)
for subdir in ['doc', 'info']:
shutil.rmtree(os.path.join(self.destdir, 'usr', 'share', subdir), ignore_errors=True)
for libname in glob.glob(os.path.join(self.destdir, 'usr', self.libdir, 'libunicode-lite*')):
shutil.rmtree(libname, ignore_errors=True)
to_remove = set()
for root, files, dirs in os.walk(self.destdir):
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.append(path)
elif fnmatch.fnmatch(path, 'lib*.la'):
if path.find('usr/' + self.libdir + '/gtk-2.0') == -1:
to_remove.append(path)
elif fnmatch.fnmatch(path, '*.py'):
to_remove.append(path + 'o')
to_remove.append(path + 'c')
os.symlink('/dev/null', path + 'c')
for file in to_remove:
if os.path.isdir(file):
shutil.rmtree(file)
else:
os.unlink(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']:
path = os.path.join(self.destdir, fname)
if os.path.isdir(path):
shutil.rmtree(path)
else:
try:
os.unlink(path)
except OSError:
pass
for fname in ['distutils', 'lib-dynload/japanese', 'encodings', 'compiler', 'email/test',
'curses', 'pydoc.py']:
path = os.path.join(self.destdir, 'usr', self.libdir, 'python?.?', 'site-packages',
fname)
for item in glob.glob(path):
if os.path.isdir(item):
shutil.rmtree(item)
else:
os.unlink(item)
def __changeDestDirPermissions(self):
root_uid = pwd.getpwnam('root')[2]
root_gid = grp.getgrnam('root')[2]
for root, files, dirs in os.walk(self.destdir):
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)
def __createLDConfig(self):
ldsoconf = os.path.join(self.destdir, 'etc', 'ld.so.conf')
touch(ldsoconf)
proc_dir = os.path.join(self.destdir, 'proc')
if not os.path.isdir(proc_dir):
os.makedirs(proc_dir)
os.system('mount -t proc proc %s' % proc_dir)
f = open(ldsoconf, 'w')
x11_libdir = os.path.join(self.destdir, 'usr', 'X11R6', self.opts.libdir)
if os.path.exists(x11_libdir):
f.write('/usr/X11R6/%s\n' % self.opts.libdir)
f.write('/usr/kerberos/%s\n' % self.opts.libdir)
cwd = os.getcwd()
os.chdir(self.destdir)
os.system('/usr/sbin/chroot %s /sbin/ldconfig' % self.destdir)
os.chdir(cwd)
if self.opts.buildarch not in ('s390', 's390x'):
os.unlink(os.path.join(self.destdir, 'sbin', 'ldconfig'))
os.unlink(os.path.join(self.destdir, 'etc', 'ld.so.conf'))
os.system('umount %s' % proc_dir)
def __setBusyboxLinks(self):
src = os.path.join(self.destdir, 'sbin', 'busybox.anaconda')
dst = os.path.join(self.destdir, 'bin', 'busybox')
@ -679,29 +72,3 @@ class InstRoot:
p = subprocess.Popen(cmd + arglist)
p.wait()
def __fixBrokenLinks(self):
for dir in ['bin', 'sbin']:
dir = os.path.join(self.destdir, 'usr', dir)
brokenlinks = []
for root, fnames, dnames in os.walk(dir):
for fname in fnames:
fname = os.path.join(root, fname)
if os.path.islink(fname) and not os.path.lexists(fname):
brokenlinks.append(fname)
for link in brokenlinks:
target = os.readlink(link)
for dir in ['bin', 'sbin']:
newtarget = re.sub(r'^\.\./\.\./%s/\(.*\)' % dir, r'\.\./%s/\1' % dir, target)
if newtarget != target:
os.symlink(newtarget, link)
def __makeAdditionalDirs(self):
os.makedirs(os.path.join(self.destdir, 'modules'))
os.makedirs(os.path.join(self.destdir, 'tmp'))
for dir in ('a', 'b', 'd', 'l', 's', 'v', 'x'):
os.makedirs(os.path.join(self.destdir, 'etc', 'terminfo', dir))
os.makedirs(os.path.join(self.destdir, 'var', 'lock', 'rpm'))

View File

@ -35,59 +35,6 @@ def filtermoddeps(input):
return lines
# XXX what are the inputs for this thing?
def trimpciids(pciids, *paths):
vendors = []
devices = []
for file in paths:
try:
f = open(file, 'r')
except IOError:
logger.error('cannot open file %s', file)
continue
else:
pcitable = f.readlines()
f.close()
for line in pcitable:
if line.startswith('alias pci:'):
vend = '0x%s' % line[15:19]
dev = '0x%s' % line[24:28]
elif line.startswith('alias pcivideo:'):
vend = '0x%s' % line[20:24]
dev = '0x%s' % line[29:33]
else:
continue
vend = vend.upper()
dev = dev.upper()
if vend not in vendors:
vendors.append(vend)
if (vend, dev) not in devices:
devices.append((vend, dev))
current_vend = 0
for line in pciids:
if line.startswith('#') or line.startswith('\t\t') or line == '\n':
continue
# XXX print or return?
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
# XXX print or return?
dev = '0x%s' % line.split()[0]
dev = dev.upper()
if (current_vend, dev) in devices:
print line,
# XXX what is this whole thing for?
def geninitrdsz(size, filename):
size = socket.htonl(size)

View File

@ -1,5 +1,3 @@
# pylorax/config.py
import sys
import os
import re

View File

@ -1,5 +1,3 @@
# pylorax/errors.py
class LoraxError(Exception):
pass

View File

@ -1,11 +1,10 @@
# pylorax/images.py
import sys
import os
import commands
import re
import datetime
import fnmatch
import datetime
import glob
import actions
import actions.base
@ -17,13 +16,19 @@ from utils.genmodinfo import genmodinfo
class InitRD(object):
def __init__(self, config, yum):
def __init__(self, config, yum, kernelfile):
self.conf = config
self.yum = yum
self.kernelfile = kernelfile
# get the kernel version
m = re.match(r'.*vmlinuz-(?P<ver>.*)', self.kernelfile)
self.kernelver = m.group('ver')
# get supported actions
supported_actions = actions.getActions()
# vars supported in template
vars = { 'instroot': self.conf.treedir,
'initrd': self.conf.initrddir,
'libdir': self.conf.libdir,
@ -31,27 +36,32 @@ class InitRD(object):
'confdir' : self.conf.confdir,
'datadir': self.conf.datadir }
initrd_template = (os.path.join(self.conf.confdir, 'templates',
'initrd.%s' % self.conf.buildarch))
initrd_template = os.path.join(self.conf.confdir, 'templates',
'initrd.%s' % self.conf.buildarch)
self.template = Template()
self.template.preparse(initrd_template)
self.template.parse(supported_actions, vars)
# additional actions that need to be processed
self._actions = []
def getPackages(self):
packages = []
if not os.path.isdir(self.conf.initrddir):
os.makedirs(self.conf.initrddir)
def get_packages(self):
packages = set()
for action in filter(lambda action: action.install, self.template.actions):
m = re.match(r'%s(.*)' % self.conf.treedir, action.install)
if m:
packages.append(m.group(1))
packages.add(m.group(1))
return packages
def getDeps(self):
def get_deps(self):
libroots = []
libroots.append(os.path.join(self.conf.treedir, self.conf.libdir))
libroots.append(os.path.join(self.conf.treedir, 'usr', self.conf.libdir))
# on 64 bit systems, add also normal lib directories
if self.conf.libdir.endswith('64'):
libroots.append(os.path.join(self.conf.treedir, self.conf.libdir[:-2]))
@ -75,23 +85,39 @@ class InitRD(object):
new_action = actions.base.Copy(**kwargs)
self._actions.append(new_action)
def processActions(self):
if os.path.isdir(self.conf.initrddir):
rm(self.conf.initrddir)
os.makedirs(self.conf.initrddir)
def process_actions(self):
for action in self.template.actions + self._actions:
action.execute()
def getModules(self):
def get_keymaps(self):
override = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime',
'keymaps-override-%s' % self.conf.buildarch)
if os.path.exists(override):
print('Found keymap override, using it')
cp(override, os.path.join(self.conf.treedir, 'keymaps'))
else:
cmd = '%s %s %s %s' % \
(os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'getkeymaps'),
self.conf.buildarch, os.path.join(self.conf.treedir, 'keymaps'), self.conf.treedir)
rc = commands.getstatus(cmd)
if rc != 0:
sys.stderr.write('Unable to create keymaps and thus can\'t create initrd\n')
sys.exit(1)
def create_locales(self):
os.makedirs(os.path.join(self.conf.initrddir, 'usr', 'lib', 'locale'))
rc, output = commands.getstatusoutput('localedef -c -i en_US -f UTF-8 --prefix %s en_US' % self.conf.initrddir)
def get_modules(self):
modlist = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime', 'modlist')
modinfo = os.path.join(self.conf.tempdir, 'modinfo')
genmodinfo(os.path.join(self.conf.treedir, 'lib', 'modules', self.conf.kernelver), modinfo)
genmodinfo(os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver), modinfo)
modfiles = []
modfiles.append(os.path.join(self.conf.confdir, 'modules', 'modules'))
modfiles.append(os.path.join(self.conf.confdir, 'modules', self.conf.buildarch, 'modules'))
# expand modules
modules = set()
for file in modfiles:
if os.path.isfile(file):
@ -100,8 +126,12 @@ class InitRD(object):
f.close()
for line in lines:
line = line.strip()
line, sep, comment = line.partition('#')
line = line.strip()
if not line:
continue
if line.startswith('-'):
modules.discard(line[1:])
elif line.startswith('='):
@ -113,7 +143,7 @@ class InitRD(object):
modules.add(line)
# resolve deps
depfile = os.path.join(self.conf.treedir, 'lib', 'modules', self.conf.kernelver, 'modules.dep')
depfile = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver, 'modules.dep')
f = open(depfile, 'r')
lines = f.readlines()
f.close()
@ -133,16 +163,26 @@ class InitRD(object):
print('Adding module dependency %s' % m.group('name'))
modules.add(m.group('name'))
srcdir = os.path.join(self.conf.treedir, 'lib', 'modules')
srcdir = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver)
dstdir = os.path.join(self.conf.initrddir, 'lib', 'modules')
cp(os.path.join(srcdir, '*'), dstdir)
for root, dirs, files in os.walk(dstdir):
for file in files:
name, ext = os.path.splitext(file)
if ext == '.ko' and name not in modules:
print('Removing %s module' % name)
rm(os.path.join(root, file))
if ext == '.ko':
if name not in modules:
rm(os.path.join(root, file))
else:
# copy the required firmware
output = commands.getoutput('modinfo -F firmware %s' % os.path.join(root, name + ext))
for fw in output.split():
dst = os.path.join(self.conf.initrddir, 'lib', 'firmware', fw)
dir = os.path.dirname(dst)
if not os.path.exists(dir):
os.makedirs(dir)
cp(os.path.join(self.conf.treedir, 'lib', 'firmware', fw), dst)
# copy firmware
srcdir = os.path.join(self.conf.treedir, 'lib', 'firmware')
@ -158,7 +198,7 @@ class InitRD(object):
for module, file in fw:
if module in modules:
print('Copying %s firmware' % module)
print('Copying firmware %s' % module)
cp(os.path.join(srcdir, file), dstdir)
# create modinfo
@ -174,218 +214,251 @@ class InitRD(object):
# run depmod
cmd = '/sbin/depmod -a -F %s -b %s %s' % \
(os.path.join(self.conf.treedir, 'boot', 'System.map-%s' % self.conf.kernelver),
self.conf.initrddir, self.conf.kernelver)
(os.path.join(self.conf.treedir, 'boot', 'System.map-%s' % self.kernelver),
self.conf.initrddir, self.kernelver)
commands.getoutput(cmd)
# remove leftovers
rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.conf.kernelver, 'modules.*map'))
rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.conf.kernelver, 'source'))
rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.conf.kernelver, 'build'))
rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.kernelver, 'modules.*map'))
rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.kernelver, 'source'))
rm(os.path.join(self.conf.initrddir, 'lib', 'modules', self.kernelver, 'build'))
# trim pci ids
vendors = set()
devices = set()
modulesalias = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver, 'modules.alias')
f = open(modulesalias)
pcitable = f.readlines()
f.close()
for line in pcitable:
if not line.startswith('alias pci:'):
continue
vend = '0x%s' % line[15:19]
vend.upper()
dev = '0x%s' % line[24:28]
dev = dev.upper()
vendors.add(vend)
devices.add((vend, dev))
videoaliases = os.path.join(self.conf.treedir, 'usr', 'share', 'hwdata', 'videoaliases', '*')
for file in glob.iglob(videoaliases):
f = open(file)
pcitable = f.readlines()
f.close()
for line in pcitable:
if not line.startswith('alias pcivideo:'):
continue
vend = '0x%s' % line[20:24]
vend = vend.upper()
dev = '0x%s' % line[29:33]
dev = dev.upper()
vendors.add(vend)
devices.add((vend, dev))
# create pci.ids
src = os.path.join(self.conf.treedir, 'usr', 'share', 'hwdata', 'pci.ids')
dst = os.path.join(self.conf.initrddir, 'pci.ids')
input = open(src, 'r')
pcitable = input.readlines()
input.close()
output = open(dst, 'w')
current_vend = 0
for line in pcitable:
# skip lines that start with 2 tabs or #
if line.startswith('\t\t') or line.startswith('#'):
continue
# skip empty lines
if line == '\n':
continue
# end of file
if line == 'ffff Illegal Vendor ID':
break
if not line.startswith('\t'):
current_vend = '0x%s' % line.split()[0]
current_vend = current_vend.upper()
if current_vend in vendors:
output.write(line)
continue
dev = '0x%s' % line.split()[0]
dev = dev.upper()
if (current_vend, dev) in devices:
output.write(line)
output.close()
def create(self, dst):
# create the productfile
text = '%s\n' % self.conf.imageuuid
text = text + '%s\n' % self.conf.product
text = text + '%s\n' % self.conf.version
text = text + '%s\n' % self.conf.bugurl
edit(os.path.join(self.conf.initrddir, '.buildstamp'), text)
# copy the productfile
cp(os.path.join(self.conf.treedir, '.buildstamp'),
os.path.join(self.conf.initrddir, '.buildstamp'))
# get modules
self.getModules()
print('Getting dependencies')
self.get_deps()
print('Processing actions')
self.process_actions()
print('Getting keymaps')
self.get_keymaps()
print('Creating locales')
self.create_locales()
print('Getting modules')
self.get_modules()
# create the initrd
print('Creating the %s' % dst)
err, output = commands.getstatusoutput('find %s | cpio --quiet -c -o | gzip -9 > %s' %
(self.conf.initrddir, dst))
def cleanUp(self):
def clean_up(self):
rm(self.conf.initrddir)
class Images(object):
def __init__(self, config, yum):
class Install(object):
def __init__(self, config):
self.conf = config
self.yum = yum
# make imageuuid
now = datetime.datetime.now()
arch = os.uname()[4] # XXX system arch, or build arch?
imageuuid = '%s.%s' % (now.strftime('%Y%m%d%H%M'), arch)
self.conf.addAttr('imageuuid')
self.conf.set(imageuuid=imageuuid)
def scrub(self):
# move bin to usr/bin
cp(os.path.join(self.conf.treedir, 'bin', '*'),
os.path.join(self.conf.treedir, 'usr', 'bin'))
rm(os.path.join(self.conf.treedir, 'bin'))
self.initrd = InitRD(self.conf, self.yum)
# move sbin to /usr/sbin
cp(os.path.join(self.conf.treedir, 'sbin', '*'),
os.path.join(self.conf.treedir, 'usr', 'sbin'))
rm(os.path.join(self.conf.treedir, 'sbin'))
# XXX don't see this used anywhere... maybe in some other script, have to check...
#syslinux = os.path.join(self.conf.treedir, 'usr', 'lib', 'syslinux', 'syslinux-nomtools')
#if not os.path.isfile(syslinux):
# print('WARNING: %s does not exist' % syslinux)
# syslinux = os.path.join(self.conf.treedir, 'usr', 'bin', 'syslinux')
# if not os.path.isfile(syslinux):
# print('ERROR: %s does not exist' % syslinux)
# sys.exit(1)
# 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))
def run(self):
bold = ('\033[1m', '\033[0m')
# remove dirs from usr
dirs = ('etc', 'games', 'include', 'kerberos', 'local', 'tmp')
for dir in dirs:
rm(os.path.join(self.conf.treedir, 'usr', dir))
print('%sInstalling needed packages%s' % bold)
self.installPackages()
# 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))
print('%sCopying updates%s' % bold)
self.copyUpdates()
# remove modules and firmware
rm(os.path.join(self.conf.treedir, 'lib', 'modules'))
rm(os.path.join(self.conf.treedir, 'lib', 'firmware'))
print('%sInitializing output directory%s' % bold)
self.initOutputDirs()
# 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))
print('%sPopulating the isolinux directory%s' % bold)
self.populateIsolinuxDir()
# 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))
# XXX a lot of other stuff needs to be done here
pass
# 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))
print('%sDONE%s' % bold)
# 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))
def installPackages(self):
# required packages
self.yum.addPackages(['anaconda', 'anaconda-runtime', 'kernel', '*firmware*', 'syslinux'])
# remove dirs from lib
dirs = ('i686', 'kbd', 'rtkaio', 'security', 'tls', 'xtables')
for dir in dirs:
rm(os.path.join(self.conf.treedir, 'lib', dir))
# optional packages from confdir
packages_files = []
packages_files.append(os.path.join(self.conf.confdir, 'packages', 'packages'))
packages_files.append(os.path.join(self.conf.confdir, 'packages', self.conf.buildarch,
'packages'))
# 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))
packages = set()
for pfile in packages_files:
if os.path.isfile(pfile):
f = open(pfile, 'r')
for line in f.readlines():
line = line.strip()
# 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'))
if not line or line.startswith('#'):
continue
# remove dirs from var/cache
dirs = ('dirmngr', 'fontconfig', 'man', 'yum')
map(lambda dir: rm(os.path.join(self.conf.treedir, 'var', 'cache', dir)), dirs)
if line.startswith('-'):
packages.discard(line[1:])
else:
packages.add(line)
# 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)
f.close()
# 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)
self.yum.addPackages(list(packages))
# 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)
# packages required for initrd image
packages = self.initrd.getPackages()
self.yum.addPackages(packages)
# remove dirs from usr/share/pixmaps
dirs = ('redhat', 'splash')
map(lambda dir: rm(os.path.join(self.conf.treedir, 'usr', 'share', 'pixmaps', dir)), dirs)
# install all packages
self.yum.install()
# 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)
def copyUpdates(self):
if self.conf.updates and os.path.isdir(self.conf.updates):
cp(os.path.join(self.conf.updates, '*'), self.conf.treedir)
self.conf.delAttr('updates')
# 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)
def initOutputDirs(self):
# create the destination directories
self.imgdir = os.path.join(self.conf.outdir, 'images')
if os.path.exists(self.imgdir):
rm(self.imgdir)
os.makedirs(self.imgdir)
# 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)
self.pxedir = os.path.join(self.imgdir, 'pxeboot')
os.makedirs(self.pxedir)
def fix_links(self):
print("Fixing broken links")
for dir in ('bin', 'sbin'):
dir = os.path.join(self.conf.treedir, 'usr', dir)
# write the images/README
src = os.path.join(self.conf.datadir, 'images', 'README')
dst = os.path.join(self.imgdir, 'README')
cp(src, dst)
replace(dst, r'@PRODUCT@', self.conf.product)
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)
# write the images/pxeboot/README
src = os.path.join(self.conf.datadir, 'images', 'pxeboot', 'README')
dst = os.path.join(self.pxedir, 'README')
cp(src, dst)
replace(dst, r'@PRODUCT@', self.conf.product)
# create the isolinux directory
self.isodir = os.path.join(self.conf.outdir, 'isolinux')
if os.path.exists(self.isodir):
rm(self.isodir)
os.makedirs(self.isodir)
def populateIsolinuxDir(self):
# set up some dir variables for further use
anacondadir = os.path.join(self.conf.treedir, 'usr', 'lib', 'anaconda-runtime')
bootdiskdir = os.path.join(anacondadir, 'boot')
syslinuxdir = os.path.join(self.conf.treedir, 'usr', 'lib', 'syslinux')
isolinuxbin = os.path.join(syslinuxdir, 'isolinux.bin')
if os.path.isfile(isolinuxbin):
# copy the isolinux.bin
cp(isolinuxbin, self.isodir)
# copy the syslinux.cfg to isolinux/isolinux.cfg
isolinuxcfg = os.path.join(self.isodir, 'isolinux.cfg')
cp(os.path.join(bootdiskdir, 'syslinux.cfg'), isolinuxcfg)
# set the product and version in isolinux.cfg
replace(isolinuxcfg, r'@PRODUCT@', self.conf.product)
replace(isolinuxcfg, r'@VERSION@', self.conf.version)
# copy the grub.conf
cp(os.path.join(bootdiskdir, 'grub.conf'), self.isodir)
# copy the vmlinuz
self.conf.addAttr('kernelver')
for file in os.listdir(os.path.join(self.conf.treedir, 'boot')):
if fnmatch.fnmatch(file, 'vmlinuz-*'):
vmlinuz = os.path.join(self.conf.treedir, 'boot', file)
m = re.match(r'.*vmlinuz-(?P<ver>.*)', vmlinuz)
self.conf.set(kernelver=m.group('ver'))
cp(vmlinuz, os.path.join(self.isodir, 'vmlinuz'))
# XXX do we want this here?
# create the initrd.img
print('Creating the initrd.img')
self.initrd.getDeps()
self.initrd.processActions()
self.initrd.create(os.path.join(self.isodir, 'initrd.img'))
#self.initrd.cleanUp()
# copy the splash files
vesasplash = os.path.join(anacondadir, 'syslinux-vesa-splash.jpg')
if os.path.isfile(vesasplash):
cp(vesasplash, os.path.join(self.isodir, 'splash.jpg'))
vesamenu = os.path.join(syslinuxdir, 'vesamenu.c32')
cp(vesamenu, self.isodir)
replace(isolinuxcfg, r'default linux', r'default vesamenu.c32')
replace(isolinuxcfg, r'prompt 1', r'#prompt 1')
else:
splashtools = os.path.join(anacondadir, 'splashtools.sh')
splashlss = os.path.join(bootdiskdir, 'splash.lss')
if os.path.isfile(splashtools):
cmd = '%s %s %s' % (splashtools,
os.path.join(bootdiskdir, 'syslinux-splash.jpg'),
splashlss)
os.system(cmd)
if os.path.isfile(splashlss):
cp(splashlss, self.isodir)
# copy the .msg files
for file in os.listdir(bootdiskdir):
if file.endswith('.msg'):
cp(os.path.join(bootdiskdir, file), self.isodir)
replace(os.path.join(self.isodir, file), r'@VERSION@', self.conf.version)
# if present, copy the memtest
cp(os.path.join(self.conf.treedir, 'boot', 'memtest*'),
os.path.join(self.isodir, 'memtest'))
if os.path.isfile(os.path.join(self.isodir, 'memtest')):
text = "label memtest86\n"
text = text + " menu label ^Memory test\n"
text = text + " kernel memtest\n"
text = text + " append -\n"
edit(isolinuxcfg, text, append=True)
else:
sys.stderr.write('No isolinux binary found, skipping isolinux creation\n')
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)

View File

@ -1,5 +1,3 @@
# pylorax/utils/fileutil.py
import sys
import os
import shutil
@ -13,7 +11,7 @@ def cp(src, dst, mode=None, verbose=False):
for name in glob.iglob(src):
rc = __copy(name, dst, verbose=verbose)
if not rc:
errors.append('unable to copy "%s" to "%s"' % (name, dst))
errors.append("unable to copy '%s' to '%s'" % (name, dst))
else:
if mode:
os.chmod(dst, int(mode))
@ -25,7 +23,7 @@ def mv(src, dst, mode=None, verbose=False):
for name in glob.iglob(src):
rc = __copy(name, dst, verbose=verbose, remove=True)
if not rc:
errors.append('unable to move "%s" to "%s"' % (name, dst))
errors.append("unable to move '%s' to '%s'" % (name, dst))
else:
if mode:
os.chmod(dst, int(mode))
@ -34,20 +32,24 @@ def mv(src, dst, mode=None, verbose=False):
def rm(target, verbose=False):
for name in glob.iglob(target):
if os.path.isdir(name):
if verbose:
print('removing directory "%s"' % name)
shutil.rmtree(name, ignore_errors=True)
else:
if verbose:
print('removing file "%s"' % name)
if os.path.islink(name):
os.unlink(name)
else:
if os.path.isdir(name):
if verbose:
print("removing directory '%s'" % name)
shutil.rmtree(name, ignore_errors=True)
else:
if verbose:
print("removing file '%s'" % name)
os.unlink(name)
return True
def __copy(src, dst, verbose=False, remove=False):
if not os.path.exists(src):
sys.stderr.write('cannot stat "%s": No such file or directory\n' % src)
sys.stderr.write("cannot stat '%s': No such file or directory\n" % src)
return False
if os.path.isdir(dst):
@ -56,7 +58,7 @@ def __copy(src, dst, verbose=False, remove=False):
if os.path.isdir(src):
if os.path.isfile(dst):
sys.stderr.write('omitting directory "%s"\n' % src)
sys.stderr.write("omitting directory '%s'\n" % src)
return False
if not os.path.isdir(dst):
@ -67,20 +69,24 @@ def __copy(src, dst, verbose=False, remove=False):
__copy(name, dst, verbose=verbose, remove=remove)
else:
if os.path.isdir(dst):
sys.stderr.write('cannot overwrite directory "%s" with non-directory\n' % dst)
sys.stderr.write("cannot overwrite directory '%s' with non-directory\n" % dst)
return False
try:
if verbose:
print('copying "%s" to "%s"' % (src, dst))
print("copying '%s' to '%s'" % (src, dst))
if os.path.exists(dst):
os.unlink(dst)
shutil.copy2(src, dst)
except (shutil.Error, IOError) as why:
sys.stderr.write('cannot copy "%s" to "%s": %s\n' % (src, dst, why))
sys.stderr.write("cannot copy '%s' to '%s': %s\n" % (src, dst, why))
return False
else:
if remove:
if verbose:
print('removing "%s"' % src)
print("removing '%s'" % src)
os.unlink(src)
return True
@ -89,13 +95,13 @@ def __copy(src, dst, verbose=False, remove=False):
def touch(filename, verbose=False):
if os.path.exists(filename):
if verbose:
print('touching file "%s"' % filename)
print("touching file '%s'" % filename)
os.utime(filename, None)
return True
try:
if verbose:
print('creating file "%s"' % filename)
print("creating file '%s'" % filename)
f = open(filename, 'w')
except IOError:
return False
@ -110,7 +116,7 @@ def edit(filename, text, append=False, verbose=False):
try:
if verbose:
print('editing file "%s"' % filename)
print("editing file '%s'" % filename)
f = open(filename, mode)
except IOError:
return False
@ -121,7 +127,7 @@ def edit(filename, text, append=False, verbose=False):
def replace(filename, find, replace, verbose=False):
if verbose:
print('replacing "%s" for "%s" in file "%s"' % (find, replace, filename))
print("replacing '%s' for '%s' in file '%s'" % (find, replace, filename))
fin = fileinput.input(filename, inplace=1)
for line in fin:
line = re.sub(find, replace, line)

View File

@ -1,5 +1,3 @@
# pylorax/utils/rpmutils.py
import sys
import os
import stat
@ -39,7 +37,7 @@ class Callback(yum.rpmtrans.SimpleCliCallBack):
self.height, self.width = getConsoleSize()
def event(self, package, action, te_current, te_total, ts_current, ts_total):
# XXX crazy output stuff
# XXX crazy output format stuff
progress = float(te_current) / float(te_total)
percentage = int(progress * 100)
@ -62,7 +60,7 @@ class Callback(yum.rpmtrans.SimpleCliCallBack):
msg = total_progress_str + action_str + package_progress_str
sys.stdout.write(msg)
sys.stdout.write('\b' * len(msg))
sys.stdout.write('\r')
if percentage == 100:
sys.stdout.write('\n')
@ -91,7 +89,7 @@ class Yum(object):
def download(self, packages):
for package in seq(packages):
print('Downloading package %s' % package)
print("Downloading package %s" % package)
fn = urlgrabber.urlgrab(package.remote_url)
shutil.copy(fn, self.installroot)
@ -99,14 +97,14 @@ class Yum(object):
def addPackages(self, patterns):
for pattern in seq(patterns):
print('Adding package matching %s' % pattern)
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)
sys.stderr.write("ERROR: No package matching %s available\n" % pattern)
def install(self):
self.yb.resolveDeps()
@ -142,7 +140,7 @@ def extractRPM(rpmfile, destdir):
if not os.path.isdir(path):
os.makedirs(path)
else:
print('Extracting %s' % entry.name)
print("Extracting %s" % entry.name)
dir = os.path.dirname(path)
if not os.path.isdir(dir):
os.makedirs(dir)
@ -150,7 +148,7 @@ def extractRPM(rpmfile, destdir):
try:
f = open(path, 'w')
except IOError:
sys.stderr.write('ERROR: Unable to extract file %s\n' % path)
sys.stderr.write("ERROR: Unable to extract file %s\n" % path)
else:
f.write(entry.read())
f.close()