xcat-core/xCAT-genesis-builder/buildrpm

105 lines
5.4 KiB
Plaintext
Executable File

# Build the xCAT-genesis-base rpm on a host system.
# Option 1: install the xCAT-genesis-builder rpm (that includes this file) on a system installed with
# the distro you want to use to build xCAT-genesis-base.
# Option 2: untar the root file system of the distro you want to use and then chroot into it and copy
# this whole dir into it somewhere (like /tmp).
# Then run this script. The optional 1st arg should be mcp if you are building against mcp.
HOSTOS="$1"
DIR=`dirname $0`
#DIR=`realpath $DIR`
DIR=`readlink -f $DIR`
# get the input files for dracut in the right place
# Fedora 20 ppc64 uses /usr/lib/dracut/modules.d
# CentOS 7 probably uses /usr/lib/dracut/modules.d also
if [ -f "/usr/share/dracut/modules.d/97xcat" ]
then
DRACUTMODDIR=/usr/share/dracut/modules.d/97xcat
else
DRACUTMODDIR=/usr/lib/dracut/modules.d/97xcat
fi
mkdir -p $DRACUTMODDIR
cp $DIR/* $DRACUTMODDIR
# For ppc64 platform, needs to remove some files,
# and some files are in different directories
if [ `uname -m` = "ppc64" ]; then
sed -i 's/dracut_install efibootmgr//' $DRACUTMODDIR/install
sed -i 's/ dmidecode//' $DRACUTMODDIR/install
sed -i 's/\/lib\/libncurses.so.5.7/\/lib64\/libncurses.so.5.7/' $DRACUTMODDIR/install
sed -i 's/\/usr\/lib\/libstdc++.so.6.0.13/\/usr\/lib64\/libstdc++.so.6.0.13/' $DRACUTMODDIR/install
sed -i 's/\/lib\/libgcc_s.so.1/\/lib64\/libgcc_s.so.1/' $DRACUTMODDIR/install
sed -i 's/\/lib\/libtinfo.so.5.7/\/lib64\/libtinfo.so.5.7/' $DRACUTMODDIR/install
# following changes are required on Fedora 20 ppc64
sed -i 's/\/lib64\/libnss_dns-2.12.so/\/lib64\/libnss_dns-2.18.so/' $DRACUTMODDIR/install
sed -i 's/\/lib\/libc.so.6/\/lib64\/libc.so.6/' $DRACUTMODDIR/install
sed -i 's/\/lib\/ld-linux.so.2/\/lib64\/ld-2.18.so/' $DRACUTMODDIR/install
sed -i 's/\/lib\/libdl.so.2/\/lib64\/libdl.so.2/' $DRACUTMODDIR/install
sed -i 's/\/lib\/libm.so.6/\/lib64\/libm.so.6/' $DRACUTMODDIR/install
sed -i 's/\/lib\/libpthread.so.0/\/lib64\/libpthread.so.0/' $DRACUTMODDIR/install
sed -i 's/\/lib64\/libncurses.so.5.7/\/lib64\/libncurses.so.5.9/' $DRACUTMODDIR/install
sed -i 's/\/usr\/lib64\/libstdc++.so.6.0.13/\/usr\/lib64\/libstdc++.so.6.0.19/' $DRACUTMODDIR/install
sed -i 's/\/lib64\/libtinfo.so.5.7/\/lib64\/libtinfo.so.5.9/' $DRACUTMODDIR/install
sed -i 's/\/usr\/lib64\/libsasl2.so.2/\/usr\/lib64\/libsasl2.so.3/' $DRACUTMODDIR/install
sed -i 's/\/lib64\/libnss_dns-2.12.so/\/lib64\/libnss_dns-2.18.so/' $DRACUTMODDIR/install
sed -i 's/\/lib\/terminfo\/l\/linux/\/usr\/share\/terminfo\/l\/linux/g' $DRACUTMODDIR/install
sed -i 's/\/lib\/terminfo\/v\/vt100/\/usr\/share\/terminfo\/v\/vt100/g' $DRACUTMODDIR/install
fi
if [ "$HOSTOS" = "mcp" ]; then
sed -i 's/mkfs.btrfs//' $DRACUTMODDIR/install
sed -i 's/\/etc\/redhat-release/\/etc\/base-release \/etc\/system-release/' $DRACUTMODDIR/install
sed -i 's/btrfs//' $DRACUTMODDIR/installkernel
# these are needed for sysclone, but are not yet in mcp
sed -i 's/ bc//' $DRACUTMODDIR/install
sed -i 's/ mkdosfs//' $DRACUTMODDIR/install
sed -i 's/ rsync//' $DRACUTMODDIR/install
sed -i 's/ kexec//' $DRACUTMODDIR/install
sed -i 's/ klogd//' $DRACUTMODDIR/install
sed -i 's/ mdadm//' $DRACUTMODDIR/install
# These timezone files are not available in the latest mcp build
sed -i 's/dracut_install \/usr\/share\/zoneinfo\/posix\/Asia\/Riyadh87//' $DRACUTMODDIR/install
sed -i 's/dracut_install \/usr\/share\/zoneinfo\/posix\/Asia\/Riyadh88//' $DRACUTMODDIR/install
sed -i 's/dracut_install \/usr\/share\/zoneinfo\/posix\/Asia\/Riyadh89//' $DRACUTMODDIR/install
sed -i 's/dracut_install \/usr\/share\/zoneinfo\/posix\/Mideast\/Riyadh87//' $DRACUTMODDIR/install
sed -i 's/dracut_install \/usr\/share\/zoneinfo\/posix\/Mideast\/Riyadh88//' $DRACUTMODDIR/install
sed -i 's/dracut_install \/usr\/share\/zoneinfo\/posix\/Mideast\/Riyadh89//' $DRACUTMODDIR/install
fi
mkdir -p /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs
# run dracut
if [ "$HOSTOS" = "mcp" ]; then
KPATH=`/bin/ls -d /lib/modules/*.x86_64`
KERNELVERSION=`basename $KPATH`
echo Creating the initramfs in /tmp/xcatgenesis.$$.rfs using dracut and kernel $KERNELVERSION ...
else
echo Creating the initramfs in /tmp/xcatgenesis.$$.rfs using dracut ...
fi
dracut -m "xcat base" -N -f /tmp/xcatgenesis.$$.rfs $KERNELVERSION
echo Expanding the initramfs into /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs ...
cd /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs
zcat /tmp/xcatgenesis.$$.rfs|cpio -dumi
# add the kernel
if [ "$HOSTOS" = "mcp" ]; then
echo Adding kernel /boot/vmlinuz-* ...
cp /boot/vmlinuz-*.x86_64 /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel
else
echo Adding kernel /boot/vmlinuz-`uname -r` ...
cp /boot/vmlinuz-`uname -r` /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel
fi
cd -
# create tar file
echo Tarring /tmp/xcatgenesis.$$/opt into ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 ...
cd /tmp/xcatgenesis.$$
tar jcf ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 opt
# build the rpm
echo Building xCAT-genesis-base rpm from ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 and $DIR/xCAT-genesis-base.spec ...
rpmbuild -ba $DIR/xCAT-genesis-base.spec
rm -rf $DRACUTMODDIR