2015-03-04 00:40:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# 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; version 2 of the License.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2015-06-20 00:19:51 +02:00
|
|
|
set_mkinicpio_hooks(){
|
2016-09-15 23:58:18 +02:00
|
|
|
if ! ${pxe_boot};then
|
|
|
|
msg2 "Removing pxe hooks"
|
|
|
|
sed -e 's/miso_pxe_common miso_pxe_http //' \
|
|
|
|
-e 's/memdisk //' -i $1
|
|
|
|
fi
|
|
|
|
if ! ${plymouth_boot};then
|
|
|
|
msg2 "Removing plymouth hook"
|
|
|
|
sed -e 's/plymouth //' -i $1
|
|
|
|
fi
|
|
|
|
if ${use_overlayfs};then
|
|
|
|
sed -e 's/miso /miso_overlayfs /' -i $1
|
|
|
|
fi
|
2015-06-20 00:46:05 +02:00
|
|
|
}
|
|
|
|
|
2016-03-04 00:02:55 +01:00
|
|
|
set_silent_switch_root(){
|
|
|
|
sed -e 's|"$@"|"$@" >/dev/null 2>&1|' -i $1/usr/lib/initcpio/init
|
|
|
|
}
|
|
|
|
|
2015-06-20 00:46:05 +02:00
|
|
|
copy_initcpio(){
|
2016-09-15 23:58:18 +02:00
|
|
|
msg2 "Copying initcpio ..."
|
|
|
|
cp /usr/lib/initcpio/hooks/miso* $2/usr/lib/initcpio/hooks
|
|
|
|
cp /usr/lib/initcpio/install/miso* $2/usr/lib/initcpio/install
|
|
|
|
cp $1/mkinitcpio.conf $2/etc/mkinitcpio-${iso_name}.conf
|
|
|
|
set_mkinicpio_hooks "$2/etc/mkinitcpio-${iso_name}.conf"
|
|
|
|
set_silent_switch_root "$2"
|
2015-06-20 00:19:51 +02:00
|
|
|
}
|
|
|
|
|
2015-03-04 10:42:15 +01:00
|
|
|
# $1: work_dir
|
|
|
|
gen_boot_image(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local _kernver=$(cat $1/usr/lib/modules/*/version)
|
|
|
|
chroot-run $1 \
|
|
|
|
/usr/bin/mkinitcpio -k ${_kernver} \
|
|
|
|
-c /etc/mkinitcpio-${iso_name}.conf \
|
|
|
|
-g /boot/${iso_name}.img
|
2015-03-04 10:42:15 +01:00
|
|
|
}
|
|
|
|
|
2016-10-03 01:39:19 +02:00
|
|
|
copy_preloader_efi(){
|
2016-09-15 23:58:18 +02:00
|
|
|
msg2 "Copying efi loaders ..."
|
|
|
|
cp $1/usr/share/efitools/efi/PreLoader.efi $2/bootx64.efi
|
|
|
|
cp $1/usr/share/efitools/efi/HashTool.efi $2/
|
2016-10-03 01:39:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
copy_loader_efi(){
|
2016-10-03 01:17:25 +02:00
|
|
|
cp $1/usr/lib/systemd/boot/efi/systemd-bootx64.efi $2/loader.efi
|
2015-03-04 10:42:15 +01:00
|
|
|
}
|
|
|
|
|
2016-10-06 12:09:14 +02:00
|
|
|
is_intel_ucode(){
|
|
|
|
if [[ -f $1/iso/${iso_name}/boot/intel_ucode.img ]] ; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2015-03-04 10:42:15 +01:00
|
|
|
}
|
|
|
|
|
2015-05-29 00:13:54 +02:00
|
|
|
copy_ucode(){
|
2016-09-15 23:58:18 +02:00
|
|
|
cp $1/boot/intel-ucode.img $2/intel_ucode.img
|
|
|
|
cp $1/usr/share/licenses/intel-ucode/LICENSE $2/intel_ucode.LICENSE
|
2015-05-29 00:13:54 +02:00
|
|
|
}
|
|
|
|
|
2016-10-06 12:09:14 +02:00
|
|
|
copy_boot_images(){
|
|
|
|
msg2 "Copying boot images ..."
|
2016-10-06 14:08:53 +02:00
|
|
|
cp $1/iso/${iso_name}/boot/x86_64/${iso_name} $1/efiboot/EFI/miso/${iso_name}.efi
|
|
|
|
cp $1/iso/${iso_name}/boot/x86_64/${iso_name}.img $1/efiboot/EFI/miso/${iso_name}.img
|
2016-10-06 12:09:14 +02:00
|
|
|
if $(is_intel_ucode "$1"); then
|
|
|
|
cp $1/iso/${iso_name}/boot/intel_ucode.img $1/efiboot/EFI/miso/intel_ucode.img
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
write_efi_loader_conf(){
|
|
|
|
prepare_dir "$1"
|
2016-09-15 23:58:18 +02:00
|
|
|
local fn=loader.conf
|
|
|
|
local conf=$1/${fn}
|
|
|
|
msg2 "Writing %s ..." "${fn}"
|
|
|
|
echo 'timeout 3' > ${conf}
|
2016-10-02 20:20:11 +02:00
|
|
|
echo "default ${iso_name}-${target_arch}-free" >> ${conf}
|
2015-03-04 00:40:44 +01:00
|
|
|
}
|
|
|
|
|
2016-10-03 21:29:34 +02:00
|
|
|
gen_boot_args(){
|
|
|
|
local args=(quiet)
|
|
|
|
if ${plymouth_boot};then
|
|
|
|
args+=(splash)
|
|
|
|
fi
|
|
|
|
echo ${args[@]}
|
|
|
|
}
|
|
|
|
|
2016-10-06 12:09:14 +02:00
|
|
|
write_usb_efi_loader_entry(){
|
|
|
|
prepare_dir "$1/iso/loader/entries"
|
2016-10-03 01:17:25 +02:00
|
|
|
local drv='free' switch="$2"
|
2016-10-02 20:20:11 +02:00
|
|
|
[[ ${switch} == 'yes' ]] && drv='nonfree'
|
|
|
|
local fn=${iso_name}-${target_arch}-${drv}.conf
|
2016-10-05 09:54:50 +02:00
|
|
|
local conf=$1/iso/loader/entries/${fn}
|
2016-09-15 23:58:18 +02:00
|
|
|
msg2 "Writing %s ..." "${fn}"
|
2016-10-02 20:20:11 +02:00
|
|
|
echo "title ${dist_name} Linux ${target_arch} UEFI USB (${drv})" > ${conf}
|
2016-10-02 16:53:34 +02:00
|
|
|
echo "linux /${iso_name}/boot/${target_arch}/${iso_name}" >> ${conf}
|
2016-10-05 09:54:50 +02:00
|
|
|
if $(is_intel_ucode "$1") ; then
|
2016-10-02 16:53:34 +02:00
|
|
|
echo "initrd /${iso_name}/boot/intel_ucode.img" >> ${conf}
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2016-10-02 16:53:34 +02:00
|
|
|
echo "initrd /${iso_name}/boot/${target_arch}/${iso_name}.img" >> ${conf}
|
2016-10-03 21:29:34 +02:00
|
|
|
echo "options misobasedir=${iso_name} misolabel=${iso_label} nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo overlay=${drv} nonfree=${switch} $(gen_boot_args)" >> ${conf}
|
2015-03-04 00:40:44 +01:00
|
|
|
}
|
|
|
|
|
2016-10-06 12:09:14 +02:00
|
|
|
write_dvd_efi_loader_entry(){
|
|
|
|
prepare_dir "$1/efiboot/loader/entries"
|
2016-10-03 01:17:25 +02:00
|
|
|
local drv='free' switch="$2"
|
2016-10-02 20:20:11 +02:00
|
|
|
[[ ${switch} == 'yes' ]] && drv='nonfree'
|
|
|
|
local fn=${iso_name}-${target_arch}-${drv}.conf
|
2016-10-05 09:54:50 +02:00
|
|
|
local conf=$1/efiboot/loader/entries/${fn}
|
2016-09-15 23:58:18 +02:00
|
|
|
msg2 "Writing %s ..." "${fn}"
|
2016-10-02 20:20:11 +02:00
|
|
|
echo "title ${dist_name} Linux ${target_arch} UEFI DVD (${drv})" > ${conf}
|
2016-09-15 23:58:18 +02:00
|
|
|
echo "linux /EFI/miso/${iso_name}.efi" >> ${conf}
|
2016-10-05 09:54:50 +02:00
|
|
|
if $(is_intel_ucode "$1") ; then
|
2016-09-15 23:58:18 +02:00
|
|
|
echo "initrd /EFI/miso/intel_ucode.img" >> ${conf}
|
|
|
|
fi
|
|
|
|
echo "initrd /EFI/miso/${iso_name}.img" >> ${conf}
|
2016-10-03 21:29:34 +02:00
|
|
|
echo "options misobasedir=${iso_name} misolabel=${iso_label} nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo overlay=${drv} nonfree=${switch} $(gen_boot_args)" >> ${conf}
|
2015-03-04 00:40:44 +01:00
|
|
|
}
|
|
|
|
|
2015-03-04 13:11:50 +01:00
|
|
|
copy_isolinux_bin(){
|
2016-10-06 14:08:53 +02:00
|
|
|
msg2 "Copying isolinux bios binaries ..."
|
2016-10-05 09:54:50 +02:00
|
|
|
cp $1/usr/lib/syslinux/bios/{{isolinux,isohdpfx}.bin,{ldlinux,gfxboot,whichsys,mboot,hdt,chain,libcom32,libmenu,libutil,libgpl}.c32} $2/iso/isolinux
|
2015-03-04 13:11:50 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 00:56:46 +01:00
|
|
|
gen_initrd_arg(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local path="/${iso_name}/boot/${target_arch}/${iso_name}.img"
|
|
|
|
local arg="initrd=${path}"
|
2016-10-05 09:54:50 +02:00
|
|
|
if $(is_intel_ucode "$1") ; then
|
2016-09-15 23:58:18 +02:00
|
|
|
arg="initrd=/${iso_name}/boot/intel_ucode.img,${path}"
|
|
|
|
fi
|
|
|
|
echo $arg
|
2016-02-29 00:56:46 +01:00
|
|
|
}
|
|
|
|
|
2015-03-04 00:40:44 +01:00
|
|
|
write_isolinux_cfg(){
|
2016-10-05 21:25:33 +02:00
|
|
|
local conf=$1/iso/isolinux/isolinux.cfg
|
2016-10-06 12:09:14 +02:00
|
|
|
msg2 "Writing %s ..." "${conf##*/}"
|
2016-09-15 23:58:18 +02:00
|
|
|
echo "default start" > ${conf}
|
|
|
|
echo "implicit 1" >> ${conf}
|
|
|
|
echo "display isolinux.msg" >> ${conf}
|
|
|
|
echo "ui gfxboot bootlogo isolinux.msg" >> ${conf}
|
|
|
|
echo "prompt 1" >> ${conf}
|
|
|
|
echo "timeout 200" >> ${conf}
|
|
|
|
echo '' >> ${conf}
|
|
|
|
echo "label start" >> ${conf}
|
|
|
|
echo " kernel /${iso_name}/boot/${target_arch}/${iso_name}" >> ${conf}
|
2016-02-29 00:56:46 +01:00
|
|
|
|
2016-10-05 09:54:50 +02:00
|
|
|
local initrd_arg=$(gen_initrd_arg "$1")
|
2016-02-29 00:56:46 +01:00
|
|
|
|
2016-10-03 21:29:34 +02:00
|
|
|
echo " append ${initrd_arg} misobasedir=${iso_name} misolabel=${iso_label} nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo overlay=free $(gen_boot_args) showopts" >> ${conf}
|
2016-02-29 00:56:46 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
echo '' >> ${conf}
|
|
|
|
if ${nonfree_mhwd};then
|
|
|
|
echo "label nonfree" >> ${conf}
|
|
|
|
echo " kernel /${iso_name}/boot/${target_arch}/${iso_name}" >> ${conf}
|
2016-10-03 21:29:34 +02:00
|
|
|
echo " append ${initrd_arg} misobasedir=${iso_name} misolabel=${iso_label} nouveau.modeset=0 i915.modeset=1 radeon.modeset=0 nonfree=yes logo.nologo overlay=nonfree $(gen_boot_args) showopts" >> ${conf}
|
2016-09-15 23:58:18 +02:00
|
|
|
echo '' >> ${conf}
|
|
|
|
fi
|
|
|
|
echo "label harddisk" >> ${conf}
|
|
|
|
echo " com32 whichsys.c32" >> ${conf}
|
|
|
|
echo " append -iso- chain.c32 hd0" >> ${conf}
|
|
|
|
echo '' >> ${conf}
|
|
|
|
echo "label hdt" >> ${conf}
|
|
|
|
echo " kernel hdt.c32" >> ${conf}
|
|
|
|
echo '' >> ${conf}
|
|
|
|
echo "label memtest" >> ${conf}
|
|
|
|
echo " kernel memtest" >> ${conf}
|
2015-03-04 00:40:44 +01:00
|
|
|
}
|
2015-03-04 01:44:52 +01:00
|
|
|
|
2015-03-04 21:10:34 +01:00
|
|
|
write_isolinux_msg(){
|
2016-10-05 21:25:33 +02:00
|
|
|
local conf=$1/iso/isolinux/isolinux.msg
|
2016-10-06 12:09:14 +02:00
|
|
|
msg2 "Writing %s ..." "${conf##*/}"
|
2016-09-15 23:58:18 +02:00
|
|
|
echo "Welcome to ${dist_name} Linux!" > ${conf}
|
|
|
|
echo '' >> ${conf}
|
|
|
|
echo "To start the system enter 'start' and press <return>" >> ${conf}
|
|
|
|
echo '' >> ${conf}
|
|
|
|
echo '' >> ${conf}
|
|
|
|
echo "Available boot options:" >> ${conf}
|
|
|
|
echo "start - Start ${dist_name} Live System" >> ${conf}
|
|
|
|
if ${nonfree_mhwd};then
|
|
|
|
echo "nonfree - Start with proprietary drivers" >> ${conf}
|
|
|
|
fi
|
|
|
|
echo "harddisk - Boot from local hard disk" >> ${conf}
|
|
|
|
echo "hdt - Run Hardware Detection Tool" >> ${conf}
|
|
|
|
echo "memtest - Run Memory Test" >> ${conf}
|
2015-03-04 21:10:34 +01:00
|
|
|
}
|
|
|
|
|
2015-03-04 13:11:50 +01:00
|
|
|
update_isolinux_cfg(){
|
2016-10-06 12:09:14 +02:00
|
|
|
local conf=$1/iso/isolinux/isolinux.cfg
|
|
|
|
msg2 "Updating %s ..." "${conf##*/}"
|
|
|
|
sed -e "s|%ISO_LABEL%|${iso_label}|g;
|
2016-09-15 23:58:18 +02:00
|
|
|
s|%ISO_NAME%|${iso_name}|g;
|
2016-10-06 12:09:14 +02:00
|
|
|
s|%ARCH%|${target_arch}|g" -i ${conf}
|
2015-03-04 13:11:50 +01:00
|
|
|
}
|
|
|
|
|
2015-03-04 21:10:34 +01:00
|
|
|
update_isolinux_msg(){
|
2016-10-06 12:09:14 +02:00
|
|
|
local conf=$1/iso/isolinux/isolinux.msg
|
|
|
|
msg2 "Updating %s ..." "${conf##*/}"
|
|
|
|
sed -e "s|%DIST_NAME%|${dist_name}|g" -i ${conf}
|
2015-03-04 21:10:34 +01:00
|
|
|
}
|
|
|
|
|
2015-03-04 01:44:52 +01:00
|
|
|
write_isomounts(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local file=$1/isomounts
|
|
|
|
echo '# syntax: <img> <arch> <mount point> <type> <kernel argument>' > ${file}
|
|
|
|
echo '# Sample kernel argument in syslinux: overlay=extra,extra2' >> ${file}
|
|
|
|
echo '' >> ${file}
|
|
|
|
msg2 "Writing live entry ..."
|
|
|
|
echo "${target_arch}/live-image.sqfs ${target_arch} / squashfs" >> ${file}
|
|
|
|
if [[ -f ${packages_mhwd} ]] ; then
|
|
|
|
msg2 "Writing mhwd entry ..."
|
|
|
|
echo "${target_arch}/mhwd-image.sqfs ${target_arch} / squashfs" >> ${file}
|
|
|
|
fi
|
|
|
|
if [[ -f "${packages_custom}" ]] ; then
|
|
|
|
msg2 "Writing %s entry ..." "${profile}"
|
|
|
|
echo "${target_arch}/${profile}-image.sqfs ${target_arch} / squashfs" >> ${file}
|
|
|
|
fi
|
|
|
|
msg2 "Writing root entry ..."
|
|
|
|
echo "${target_arch}/root-image.sqfs ${target_arch} / squashfs" >> ${file}
|
2015-03-04 01:44:52 +01:00
|
|
|
}
|
2016-10-06 12:09:14 +02:00
|
|
|
|
|
|
|
################################# testing syslinux efi ####################################
|
|
|
|
|
|
|
|
copy_syslinux_efi(){
|
|
|
|
msg2 "Copying syslinux efi binaries ..."
|
|
|
|
cp $1/usr/lib/syslinux/efi64/{ldlinux.e64,*.c32} $2
|
|
|
|
cp $1/usr/lib/syslinux/efi64/syslinux.efi $2/bootx64.efi
|
|
|
|
cp ${DATADIR}/isolinux/back800x600.jpg $2/splash.jpg
|
|
|
|
}
|
|
|
|
|
|
|
|
write_syslinux_cfg(){
|
|
|
|
local conf=$1/syslinux.cfg
|
|
|
|
msg2 "Writing %s ..." "syslinux.cfg"
|
|
|
|
echo "DEFAULT free" > $conf
|
|
|
|
echo "PROMPT 1" >> $conf
|
|
|
|
echo "TIMEOUT 200" >> $conf
|
|
|
|
echo "#KBDMAP de.ktl" >> $conf
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "UI vesamenu.c32" >> $conf
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "MENU TITLE ${dist_name} Linux" >> $conf
|
|
|
|
echo "MENU BACKGROUND splash.jpg" >> $conf
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "MENU COLOR border 30;44 #40ffffff #a0000000 std" >> $conf
|
|
|
|
echo "MENU COLOR title 1;36;44 #9033ccff #a0000000 std" >> $conf
|
|
|
|
echo "MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all" >> $conf
|
|
|
|
echo "MENU COLOR unsel 37;44 #50ffffff #a0000000 std" >> $conf
|
|
|
|
echo "MENU COLOR help 37;40 #c0ffffff #a0000000 std" >> $conf
|
|
|
|
echo "MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std" >> $conf
|
|
|
|
echo "MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std" >> $conf
|
|
|
|
echo "MENU COLOR msg07 37;40 #90ffffff #a0000000 std" >> $conf
|
|
|
|
echo "MENU COLOR tabmsg 31;40 #30ffffff #00000000 std" >> $conf
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "LABEL free" >> $conf
|
|
|
|
echo " MENU LABEL ${dist_name} Linux ${target_arch}" >> $conf
|
|
|
|
case $2 in
|
|
|
|
usb)
|
|
|
|
echo " LINUX /EFI/miso/${iso_name}.efi" >> $conf
|
|
|
|
echo " INITRD /EFI/miso/${iso_name}.img" >> $conf
|
|
|
|
;;
|
|
|
|
dvd)
|
|
|
|
echo " LINUX /${iso_name}/boot/${target_arch}/${iso_name}" >> $conf
|
|
|
|
echo " INITRD /${iso_name}/boot/${target_arch}/${iso_name}.img" >> $conf
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if ${nonfree_mhwd};then
|
|
|
|
echo " APPEND misobasedir=${iso_name} misolabel=${iso_label} nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo nonfree=yes overlay=nonfree $(gen_boot_args)" >> $conf
|
|
|
|
else
|
|
|
|
echo " APPEND misobasedir=${iso_name} misolabel=${iso_label} nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo nonfree=no overlay=nonfree $(gen_boot_args)" >> $conf
|
|
|
|
fi
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "LABEL hdt" >> $conf
|
|
|
|
echo " MENU LABEL HDT (Hardware Detection Tool)" >> $conf
|
|
|
|
echo " COM32 hdt.c32" >> $conf
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "LABEL reboot" >> $conf
|
|
|
|
echo " MENU LABEL Reboot" >> $conf
|
|
|
|
echo " COM32 reboot.c32" >> $conf
|
|
|
|
echo "" >> $conf
|
|
|
|
echo "LABEL poweroff" >> $conf
|
|
|
|
echo " MENU LABEL Poweroff" >> $conf
|
|
|
|
echo " COM32 poweroff.c32" >> $conf
|
|
|
|
}
|