makedist/obsoleted/functions-obsoleted.sh
2011-05-04 02:30:35 +02:00

337 lines
10 KiB
Bash

#
# generate_cd_content: generates CD content given a list of
# packages
#
# $1: disktag
# $2: media
# $3: (optional) file list
function generate_cd_content() {
local tmpfile
tmpfile=`mktemp -q -t ${0##*/}.XXXXXXXX` ||
{ echo "${0##*/}: error: cannot create temporary files." >&2
{ (exit 1); exit 1; }; }
RELEASE_RPM=`make ARCH=$arch -C $UTILSDIR CHROOTCMD="$CHROOTCMD" \
INSTALLED="$INSTALLED" TARGET="$MAKEFILE_TARGET" PLATFORM="$PLATFORM" -s qilinux-release 2>$tmpfile`
RELEASE_RPM_FILE=`expand_rpm_names $RELEASE_RPM`
[ "$RELEASE_RPM_FILE" ] || {
echo "FATAL ERROR: missing qilinux-release file for platform $PLATFORM; aborting."
exit 1
}
mkdir -p $LOCALSTATEDIR/qilinux-release.tmp
pushd $LOCALSTATEDIR/qilinux-release.tmp >/dev/null
rpm2cpio $RELEASE_RPM_FILE | cpio -id 2>/dev/null
qilinux_release=`cat $LOCALSTATEDIR/qilinux-release.tmp/etc/qilinux-release`
popd >/dev/null
rm -rf $LOCALSTATEDIR/qilinux-release.tmp
echo "Release: $qilinux_release"
DISKTAG=$1
MEDIA=$2
[ "$DISKTAG" ] || exit 1
# copying RPMS dir
#
echo "Copying RPMs to the $DISKTAG root..."
DESTRPMSDIR=$LOCALSTATEDIR/$DISKTAG/QILINUX
rm -rf $LOCALSTATEDIR/$DISKTAG/*
mkdir -p $DESTRPMSDIR/RPMS/$arch
if [ "$3" ]; then
CDFILENAMES="$3"
else
[ -e "$SOURCEDIR/packages.$DISKTAG" ] || {
echo "FATAL ERROR: missing packages list file $SOURCEDIR/packages.$DISKTAG."
exit 1
}
CDPACKAGES=`cat $SOURCEDIR/packages.$DISKTAG`
PREFERRED_RPMDIR=""
CDFILENAMES=`expand_rpm_names "$CDPACKAGES"` ||
{ echo "FATAL ERROR: error while expanding packages."
{ (exit 1); exit 1; }; }
fi
for cpfile in $CDFILENAMES; do
case $cpfile in
*.noarch.rpm)
cp $cpfile $DESTRPMSDIR/RPMS/$arch/ ;;
*.$arch.rpm)
cp $cpfile $DESTRPMSDIR/RPMS/$arch/ ;;
esac
done
# generate apt basedir
pushd $DESTRPMSDIR >/dev/null
ln -s RPMS/$arch $DESTRPMSDIR/RPMS.base
# ln -s SRPMS $DESTRPMSDIR/SRPMS.base
mkdir -p $DESTRPMSDIR/base
cat > $DESTRPMSDIR/base/release << _EOF
Origin: www.qilinux.it
Label: $qilinux_release $MEDIA
Suite: $qilinux_release
Architectures: $arch
Components: base
Description: $qilinux_release $MEDIA
_EOF
genbasedir $DESTRPMSDIR
# creating info file for APT
mkdir -p $LOCALSTATEDIR/$DISKTAG/.disk
echo "$qilinux_release $MEDIA" > $LOCALSTATEDIR/$DISKTAG/.disk/info
# copy CDnth basedir to first cd
#[ $CDNUM -gt 1 ] && cp -r $MOUNTDIR/base $LOCALSTATEDIR/cd1/QILINUX/base$CDNUM
# copying licenses
echo "Copying GPL licenses files..."
cp $TOPDIR/gpl.it.txt $TOPDIR/gpl.txt $LOCALSTATEDIR/$DISKTAG
# mark the CD as a distribution CD
echo "Creating the file $DISTRONAME.$DISKTAG..."
echo "$qilinux_release" > $LOCALSTATEDIR/$DISKTAG/$DISTRONAME.$DISKTAG
test -e $LOCALSTATEDIR/$DISKTAG/$DISTRONAME.$DISKTAG ||
{ echo "FATAL ERROR: cannot create $DISTRONAME.$DISKTAG file"; exit 1; }
popd >/dev/null
[ -e "$tmpfile" ] && rm -f $tmpfile
}
function create_livecd() {
# copy halt-static to /static to allow a reboot after cdrom eject
#
echo "*** livecd post install operations"
# echo "Creating /etc/sysconfig/dna file..."
#
# echo "DIST_NAME=\"$DISTRONAME\"
#DIST_TARGET=\"$MAKEDIST_TARGET\"
#DIST_PLATFORM=\"$PLATFORM\"
#DIST_CODENAME=\"$CODENAME\"
#DIST_BUILD=\"`date -R` on `hostname`\"" > $MOUNTDIR/etc/sysconfig/dna
echo "Installing halt-static..."
cp $MOUNTDIR/sbin/halt-static $INITRDDIR/static/halt
ln -sf halt $INITRDDIR/static/reboot
echo -e "\n*** Making initrd for Kernel ${KERNEL_VER}${KERNEL_EXTRAVER}"
make_initrd ${KERNEL_VER}${KERNEL_EXTRAVER} $MOUNTDIR2/isolinux/initrd
# creating isolinux
#
echo -e "\nInstalling isolinux and vmlinuz..."
test -d $ISOLINUXDIR || mkdir -p $ISOLINUXDIR
mv $MOUNTDIR/boot/vmlinuz-${KERNEL_VER}${KERNEL_EXTRAVER} \
$ISOLINUXDIR/vmlinuz
rdev $ISOLINUXDIR/vmlinuz /dev/ram1
# install memtest
#
[ -e /boot/memtest.bin ] && cp /boot/memtest.bin $ISOLINUXDIR/memtest ||
{ echo "$makedist_me: /boot/memtest.bin not found. Please install the memtest86 package." >&2
{ (exit 1); exit 1; }; }
# make symlink to RPMS dir
#[ "$DISTRIBUTION" = "1" ] && ln -s /cdrom/openmamba/RPMS $MOUNTDIR/RPMS
#echo "Copying files from $MOUNTDIR to loop drive $MOUNTFS"
#cp -a $MOUNTDIR/* $MOUNTFS
# compressing live filesystem
#
#UNCOMPRESSED_SIZE=`du -b -s $MOUNTFS | gawk '{ print $1 }'`
#echo "Compressing root filesystem ($UNCOMPRESSED_SIZE bytes)..."
#
#mksquashfs $MOUNTFS $COMPRESSEDIMAGE
#umount $MOUNTFS
#rm -rf $MOUNTFS
#losetup -d /dev/loop2
#create_compressed_fs $FSIMAGE 65536 > $COMPRESSEDIMAGE 2>/dev/null ||
#{ echo "$makedist_me: fatal error creating compressed fs" >&2
# { (exit 1); exit 1; }; }
#rm $FSIMAGE
# copying licenses
echo "Copying Licensing/Documentation files to CD root..."
if [ -d $TARGETDIR/rootfiles ]; then
cp -R $TARGETDIR/rootfiles/* $MOUNTDIR2
else
cp $TOPDIR/gpl.it.txt $TOPDIR/gpl.txt $MOUNTDIR2
fi
# remove any CVS directory in CD root
find $MOUNTDIR2 -name CVS -print | xargs -r rm -rf
# setting root permissions
#
echo "Setting root permissions..."
chown root.root $ISOLINUXDIR/* $MOUNTDIR2
echo "*** Creating the livecd ISO image..."
[ "$CD_LABEL" ] && LABEL="$CD_LABEL $MEDIA" || LABEL=$DISKTAG
generate_iso_image $MOUNTDIR2 $DISKTAG "$LABEL" 1
}
# make_initrd()
#
# parameters:
# $1 : $KERNEL_VER$KERNEL_EXTRAVER
# $2 : INITRD image path
function make_initrd() {
# Preparing initrddir
mkdir -p $MOUNTDIR2/isolinux/
cp -a $TARGETDIR/isolinux/* $MOUNTDIR2/isolinux/
rm -rf $INITRDDIR/*
# FIXME: create empty dir that are sometimes deleted by cvs
cp -a $TOPDIR/initrd/* $INITRDDIR
mkdir -p $INITRDDIR/{media,mnt,proc}
# copy install scripts to initrd
echo "Installing the install scripts..."
mkdir -p $INITRDDIR/install/
cp -r $UTILSDIR/* $INITRDDIR/install/
rm -rf $INITRDDIR/install/po
rm -rf $INITRDDIR/install/Makefile.*
cp $UTILSDIR/Makefile.qilinux $INITRDDIR/install
echo "DIST_TARGET=\"$MAKEDIST_TARGET\"" >> $INITRDDIR/install/defs
echo "DIST_PLATFORM=\"$PLATFORM\"" >> $INITRDDIR/install/defs
echo "DIST_CODENAME=\"$CODENAME\"" >> $INITRDDIR/install/defs
echo "DIST_BUILD=\"`date -R` on `hostname`\"" >> $INITRDDIR/install/defs
# remove any CVS directory in initrddir
find $INITRDDIR -name CVS -print | xargs -r rm -rf
# copy needed drivers to initrd modules dir
if [ ${1:0:3} = "2.6" ]; then
INITRDMODULES='
drivers/cdrom/cdrom.ko
drivers/ide/ide-cd.ko
fs/isofs/isofs.ko
fs/squashfs/squashfs.ko
lib/zlib_inflate/zlib_inflate.ko
drivers/usb/host/uhci-hcd.ko
drivers/usb/host/ohci-hcd.ko
drivers/usb/host/ehci-hcd.ko
drivers/usb/storage/usb-storage.ko
drivers/char/rtc.ko
drivers/block/ub.ko'
INITRDSCSIMODULES='
sr_mod.ko
aic7xxx/aic7xxx.ko BusLogic.ko
NCR53c406a.ko
aha1740.ko aha1542.ko aha152x.ko
atp870u.ko dtc.ko eata.ko fdomain.ko gdth.ko
megaraid/megaraid_mm.ko megaraid/megaraid_mbox.ko pas16.ko psi240i.ko
qlogicfas.ko qlogicfc.ko
t128.ko tmscsim.ko u14-34f.ko ultrastor.ko wd7000.ko
a100u2w.ko 3w-xxxx.ko'
echo "Copying linuxrc and ash for 2.6 kernel..."
cp $TOPDIR/initrd/linuxrc $INITRDDIR/init
rm $INITRDDIR/linuxrc
cp $TOPDIR/initrd/static/ash $INITRDDIR/static/ash
rm $INITRDDIR/static/ash
echo "Creating /sys dir in initrd for 2.6 kernel..."
mkdir -p $INITRDDIR/sys
else
echo "Kernel 2.4 is not supported any longer. Aborting."
exit 1
fi
echo "Installing drivers to $INITRDDIR/modules..."
pushd $MOUNTDIR/lib/modules/$1/kernel/ >/dev/null
cp $INITRDMODULES $INITRDDIR/modules
popd >/dev/null
# copy SCSI drivers
# note: aic7xxx, ncr53c8xx missing
echo "Installing SCSI drivers to $INITRDDIR/modules/scsi..."
mkdir -p $INITRDDIR/modules/scsi
pushd $MOUNTDIR/lib/modules/$1/kernel/drivers/scsi/ >/dev/null
cp $INITRDSCSIMODULES $INITRDDIR/modules/scsi
popd >/dev/null
echo "Building initrd..."
chown -R root.root $INITRDDIR/*
#test -d /mnt/loop1 || mkdir -p /mnt/loop1
#dd if=/dev/zero of=$2 bs=1k count=4096
#losetup /dev/loop/1 $2
#mkfs -t ext2 -m 0 /dev/loop/1 > /dev/null
#mount /dev/loop1 /mnt/loop1 || exit 1
#pushd $INITRDDIR >/dev/null
#tar cf - . | ( cd /mnt/loop1 ; tar xf - ) >/dev/null
#popd >/dev/null
#umount /mnt/loop1
#losetup -d /dev/loop/1
echo "Adding splash screen stuff to initrd..."
splash_geninitramfs -c $INITRDDIR --all
(cd $INITRDDIR; find . | cpio --quiet --dereference -o -H newc) | gzip -9 > $2 || {
echo "$makedist_me: fatal error creating initramfs image" >&2
exit 1
}
#echo "Compressing the initrd file..."
#[ -e "$2.gz" ] && rm -f $2.gz
#gzip -f $2
#echo "Adding splash screen stuff to initrd..."
#chroot $MOUNTDIR /sbin/splash -s -f \
# /etc/bootsplash/themes/current/config/bootsplash-800x600.cfg \
# >> $2.gz ||
#{ echo "$makedist_me: fatal error adding splash screen to initrd" >&2
# { (exit 1); exit 1; }; }
}
# create non bootable CD ISO image
#
# $1: cdrom filesystem root directory
# $2: disk tag
# $3: disk label
# $4: 0: non bootable CD
# 1: bootable CD
#
function generate_iso_image() {
DISKTAG=$2
[ "$DISKTAG" ] ||
{ echo "${0##*/}: error: empty disktag, cannot create iso image." >&2
{ (exit 1); exit 1; }; }
rm -f $LOCALSTATEDIR/$DISTRONAME-$DISKTAG-*.iso
DATESTAMP=`date +%d%m%Y`
ISONAME=$DISTRONAME-$PLATFORM-$DISKTAG-$DATESTAMP.$arch.iso
ISOLINKPATHNAME=$LOCALSTATEDIR/$DISTRONAME-$DISKTAG.$arch.iso
[ "$4" = "1" ] && {
sed "s|^|$1/|" mkisofs.sort > $LOCALSTATEDIR/mkisofs.sort
BOOTOPTIONS="-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -sort $LOCALSTATEDIR/mkisofs.sort"
}
[ "$3" ] && CD_LABEL=$3 || CD_LABEL="$DISTRONAME-$DISKTAG-$DATESTAMP.$arch"
mkisofs -quiet -joliet \
-o $LOCALSTATEDIR/$ISONAME \
-V "$CD_LABEL" \
$BOOTOPTIONS -l -R -r $1
# create iso image symlink
#
ln -fs $ISONAME $ISOLINKPATHNAME
echo "ISO image written to disk: $LOCALSTATEDIR/$ISONAME"
#[ -f "$LOCALSTATEDIR/mkisofs.sort" ] && rm $LOCALSTATEDIR/mkisofs.sort
}