# livedvd post script
#
# creates a fake installation aimed at producing a kernel image and initrd
# for livecd boot
# make initramfs
[ -e $MOUNTDIR2/boot/isolinux ] || mkdir -p $MOUNTDIR2/boot/isolinux
[ -e $MOUNTDIR2/boot/grub ] || mkdir -p $MOUNTDIR2/boot/grub
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
chroot $MOUNTDIR depmod -a ${KERNEL_MAJVER}${K}
LANG=${LANGUAGE}_${COUNTRY} chroot $MOUNTDIR dracut \
-a dmsquash-live -o squash-live \
--filesystems "autofs4 ext4 overlay squashfs isofs hfsplus nls_utf8" \
--nomdadmconf --nolvmconf \
/boot/initramfs-${KERNEL_MAJVER}${K}.img.gz \
${KERNEL_MAJVER}${K}
# Note: isolinux requires 8.3 filenames
cp $MOUNTDIR/boot/initramfs-${KERNEL_MAJVER}${K}.img.gz \
$MOUNTDIR2/boot/initrd${ISOID}.gz || {
echo "Error: cannot copy file $MOUNTDIR/boot/initramfs-${KERNEL_MAJVER}${K}.img.gz to $MOUNTDIR2/boot/initrd${ISOID}.gz.";
exit 1; }
cp $MOUNTDIR/boot/vmlinuz-${KERNEL_MAJVER}${K} \
$MOUNTDIR2/boot/vmlinuz${ISOID} || {
echo "Error: cannot copy file $MOUNTDIR/boot/vmlinuz-${KERNEL_MAJVER}${K}.img.gz to $MOUNTDIR2/boot/vmlinuz${ISOID}.gz.";
exit 1; }
ISOID=$(($ISOID + 1))
done
# add buildinfo
buildinfo="`cat $MOUNTDIR/etc/openmamba-release` ${PLATFORM}"
# configure grub boot loader
cat > $MOUNTDIR2/boot/grub/grub.cfg << _EOF
#
# GRUB configuration generated by openmamba makedist
#
font=unicode
set gfxmode=auto
insmod all_video
insmod gfxterm
insmod gettext
insmod iso9660
insmod biosdisk
terminal_output=gfxterm
timeout=10
# theme
insmod=png
set menu_color_normal=white/black
set menu_color_highlight=white/green
_EOF
#
# Boot entries
#
for l in $MULTILANGUAGE; do
case $l in
"en") LABEL="English"; LOCALELANG="en_US.UTF-8"; VCONSOLEKEYMAP="us" ;;
"it") LABEL="Italiano"; LOCALELANG="it_IT.UTF-8"; VCONSOLEKEYMAP="it" ;;
"fr") LABEL="Français"; LOCALELANG="fr_FR.UTF-8"; VCONSOLEKEYMAP="fr" ;;
"es") LABEL="Español"; LOCALELANG="es_ES.UTF-8"; VCONSOLEKEYMAP="es" ;;
"de") LABEL="Deutsch"; LOCALELANG="de_DE.UTF-8"; VCONSOLEKEYMAP="de" ;;
*) LABEL="$l"
esac
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
submenu "${LABEL}" {
_EOF
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
menuentry "openmamba GNU/Linux (${KERNEL_MAJVER}${K} - ${l})" {
echo "Loading /boot/vmlinuz${ISOID}"
linux /boot/vmlinuz${ISOID} root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} selinux=0 quiet splash ro locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP
echo "Loading /boot/initrd${ISOID}.gz"
initrd /boot/initrd${ISOID}.gz
}
_EOF
ISOID=$(($ISOID + 1))
done
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
submenu "Advanced options for openmamba GNU/Linux" {
_EOF
#ISOID=
#for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
# cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
# menuentry "No modeset (${KERNEL_MAJVER}${K})" {
# echo "Loading /boot/vmlinuz${ISOID}"
# linux /boot/vmlinuz${ISOID} root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} selinux=0 quiet splash ro nomodeset
# echo "Loading /boot/initrd${ISOID}.gz"
# initrd /boot/initrd${ISOID}.gz
# }
#_EOF
# ISOID=$(($ISOID + 1))
#done
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
menuentry "Debug mode (${KERNEL_MAJVER}${K} - ${l})" {
echo "Loading /boot/vmlinuz${ISOID}"
linux /boot/vmlinuz${ISOID} root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 rddebug locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP
echo "Loading /boot/initrd${ISOID}.gz"
initrd /boot/initrd${ISOID}.gz
}
_EOF
ISOID=$(($ISOID + 1))
done
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
menuentry "Debug mode with nomodeset (${KERNEL_MAJVER}${K} - ${l})" {
echo "Loading /boot/vmlinuz${ISOID}"
linux /boot/vmlinuz${ISOID} root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 rddebug nomodeset locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP
echo "Loading /boot/initrd${ISOID}.gz"
initrd /boot/initrd${ISOID}.gz
}
_EOF
ISOID=$(($ISOID + 1))
done
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
}
}
_EOF
# configure isolinux boot loader (obsolete)
cat > $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
PROMPT 0
TIMEOUT 20
DEFAULT vesamenu.c32
MENU TITLE ${buildinfo} (${KERNEL_MAJVER} kernel)
MENU BACKGROUND openmamba.png
MENU COLOR TITLE 1;32;49 #ff00993d #00000000 std
LABEL -
MENU LABEL Please select system startup language:
MENU DISABLE
_EOF
ISOID=
for l in $MULTILANGUAGE; do
case $l in
"en") LABEL="English"; LOCALELANG="en_US.UTF-8"; VCONSOLEKEYMAP="us" ;;
"it") LABEL="Italiano"; LOCALELANG="it_IT.UTF-8"; VCONSOLEKEYMAP="it" ;;
"fr") LABEL="Français"; LOCALELANG="fr_FR.UTF-8"; VCONSOLEKEYMAP="fr" ;;
"es") LABEL="Español"; LOCALELANG="es_ES.UTF-8"; VCONSOLEKEYMAP="es" ;;
"de") LABEL="Deutsch"; LOCALELANG="de_DE.UTF-8"; VCONSOLEKEYMAP="de" ;;
*) LABEL="$l"
esac
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
MENU BEGIN $l
MENU LABEL $LABEL
MENU TITLE ${buildinfo} (${KERNEL_MAJVER} kernel)
_EOF
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
LABEL default-${KERNEL_MAJVER}${K}
MENU LABEL default (${KERNEL_MAJVER}${K} $l)
kernel /boot/vmlinuz${ISOID}
append initrd=/boot/initrd${ISOID}.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 quiet splash locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP
_EOF
ISOID=$(($ISOID + 1))
done
echo "MENU SEPARATOR" >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
LABEL vga800-${KERNEL_MAJVER}${K}
MENU LABEL VGA 800x600 no modeset (${KERNEL_MAJVER}${K} $l)
kernel /boot/vmlinuz${ISOID}
append initrd=/boot/initrd${ISOID}.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 quiet splash locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP nomodeset
_EOF
ISOID=$(($ISOID + 1))
done
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
LABEL vga1024-${KERNEL_MAJVER}${K}
MENU LABEL VGA 1024x768 no modeset (${KERNEL_MAJVER}${K} $l)
kernel /boot/vmlinuz${ISOID}
append initrd=/boot/initrd${ISOID}.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 quiet splash locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP nomodeset
_EOF
ISOID=$(($ISOID + 1))
done
echo "MENU SEPARATOR" >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8
ISOID=
for K in $KERNEL_EXTRAVER $KERNEL_MORE_EXTRAVER; do
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
LABEL debug-${KERNEL_MAJVER}${K}
MENU LABEL Debug mode (${KERNEL_MAJVER}${K} $l)
kernel /boot/vmlinuz${ISOID}
append initrd=/boot/initrd${ISOID}.gz root=live:LABEL=${MAKEDIST_TARGET}_${PLATFORM} ro selinux=0 locale.LANG=$LOCALELANG vconsole.keymap=$VCONSOLEKEYMAP rddebug nomodeset
_EOF
ISOID=$(($ISOID + 1))
done
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 << _EOF
MENU END
_EOF
done
# convert isolinux.cfg from UTF-8 to CP437
iconv -f utf-8 -t cp437 $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8 > $MOUNTDIR2/boot/isolinux/isolinux.cfg
rm -f $MOUNTDIR2/boot/isolinux/isolinux.cfg.utf8
# install memtest
if [ -e $MOUNTDIR/boot/memtest86+.bin ]; then
cp $MOUNTDIR/boot/memtest86+.bin $MOUNTDIR2/boot/memtest
cat >> $MOUNTDIR2/boot/grub/grub.cfg << _EOF
menuentry 'Memory test' {
insmod part_gpt
insmod fat
linux16 /boot/memtest
}
_EOF
cat >> $MOUNTDIR2/boot/isolinux/isolinux.cfg << _EOF
MENU SEPARATOR
LABEL memtest
MENU LABEL Memory test
kernel /boot/memtest
MENU SEPARATOR
MENU SEPARATOR
LABEL -
MENU LABEL $PRODUCT_NAME build:`date -R`
MENU DISABLE
_EOF
else
echo "Error: /boot/memtest86+.bin not found. Please install the memtest86 package."
exit 1
fi
# copy static files for specific platform
[ -e $TARGETDIR/platforms/$PLATFORM/root ] &&
cp -a --no-preserve=ownership $TARGETDIR/platforms/$PLATFORM/root/* $MOUNTDIR2/
# copy localized static files for specific platform
[ "$LANGUAGE" -a -e $TARGETDIR/platforms/$PLATFORM/root-$LANGUAGE ] &&
cp -a --no-preserve=ownership $TARGETDIR/platforms/$PLATFORM/root-$LANGUAGE/* $MOUNTDIR2/
# add buildinfo
buildinfo="`cat $MOUNTDIR/etc/openmamba-release` [$PRODUCT_NAME build:`date +%c`]"
sed -i "s|%buildinfo%|$buildinfo|" $MOUNTDIR2/boot/isolinux/menu.txt
#
# EFI support section BEGIN
#
# create EFI grub 32 and 64 bit images
mkdir -p $MOUNTDIR2/EFI/BOOT/
grub-mkimage -o $MOUNTDIR2/EFI/BOOT/bootx64.efi -O x86_64-efi -p /EFI/BOOT \
part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot linux echo \
help gfxterm gettext png efi_gop efi_uga search search_label search_fs_uuid \
iso9660 configfile || {
errorAndExit $"Error: unable to create GRUB x86_64-efi image"
}
#
# EFI support section END
#
#echo "Adding binary packages from pkggroups.db..."
#. $LOCALSTATEDIR/.${MEDIA_NAMES[0]}.distinfo
#LANG=${LANGUAGE:0:2} . $MOUNTDIR/usr/share/openmamba/pkggroups.db
#
#add_binary_packages_to_repository $MOUNTDIR2/openmamba "$ALL_PKGS $EXTRA_PKGS" "$INSTALLED"
#echo "Generating APT database..."
#ln -s RPMS/$arch $MOUNTDIR2/openmamba/RPMS.$arch
#genbasedir $MOUNTDIR2/openmamba
#mkdir $MOUNTDIR2/.disk
#cat $MOUNTDIR/etc/openmamba-release > $MOUNTDIR2/.disk/info
# Finally produce the media
MOUNTDIR=$MOUNTDIR2 produce_media $MEDIA_NAME
for i in $SUBPLATFORM; do
. $TARGETDIR/platforms/$i/settings.inc
CURR_MEDIA_NAME=`PLATFORM=$i media_name`
cat >> $LOCALSTATEDIR/.$MEDIA_NAME.inc.html << _EOF
Root target(s):
_EOF cat $LOCALSTATEDIR/.$CURR_MEDIA_NAME.inc.html >> \ $LOCALSTATEDIR/.$MEDIA_NAME.inc.html echo " |