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-10-09 18:04:22 +02:00
|
|
|
gen_boot_args(){
|
|
|
|
local args=(quiet)
|
|
|
|
if ${plymouth_boot};then
|
|
|
|
args+=(splash)
|
|
|
|
fi
|
|
|
|
echo ${args[@]}
|
|
|
|
}
|
|
|
|
|
2016-03-04 00:02:55 +01:00
|
|
|
set_silent_switch_root(){
|
2016-10-06 20:53:10 +02:00
|
|
|
sed -e 's|"$@"|"$@" >/dev/null 2>&1|' -i $1/usr/lib/initcpio/init
|
2016-03-04 00:02:55 +01:00
|
|
|
}
|
|
|
|
|
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 \
|
2016-10-09 00:40:25 +02:00
|
|
|
-g /boot/initramfs.img
|
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-09 18:04:22 +02:00
|
|
|
prepare_dir "$1/efiboot/EFI/miso"
|
|
|
|
local miso_efi=$1/efiboot/EFI/miso boot=$1/iso/${iso_name}/boot
|
|
|
|
cp ${boot}/x86_64/vmlinuz $1/efiboot/EFI/miso/vmlinuz.efi
|
|
|
|
cp ${boot}/x86_64/initramfs.img $1/efiboot/EFI/miso/initramfs.img
|
2016-10-06 12:09:14 +02:00
|
|
|
|
2016-10-09 18:04:22 +02:00
|
|
|
if [[ -f ${boot}/intel_ucode.img ]] ; then
|
|
|
|
cp ${boot}/intel_ucode.img $1/efiboot/EFI/miso/intel_ucode.img
|
2016-10-03 21:29:34 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-10-09 09:08:30 +02:00
|
|
|
vars_to_boot_conf(){
|
2016-10-07 08:25:08 +02:00
|
|
|
sed -e "s|@ISO_NAME@|${iso_name}|g" \
|
|
|
|
-e "s|@ISO_LABEL@|${iso_label}|g" \
|
2016-10-09 09:08:30 +02:00
|
|
|
-e "s|@DIST_NAME@|${dist_name}|g" \
|
|
|
|
-e "s|@ARCH@|${target_arch}|g" \
|
2016-10-07 08:25:08 +02:00
|
|
|
-e "s|@DRV@|$2|g" \
|
|
|
|
-e "s|@SWITCH@|$3|g" \
|
|
|
|
-e "s|@BOOT_ARGS@|$(gen_boot_args)|g" \
|
|
|
|
-i $1
|
2015-03-04 00:40:44 +01:00
|
|
|
}
|
2015-03-04 01:44:52 +01:00
|
|
|
|
2016-10-09 18:04:22 +02:00
|
|
|
prepare_efi_loader(){
|
|
|
|
prepare_dir "$2/EFI/boot"
|
|
|
|
|
|
|
|
msg2 "Copying efi loaders ..."
|
|
|
|
cp $1/usr/share/efitools/efi/PreLoader.efi $2/EFI/boot/bootx64.efi
|
|
|
|
cp $1/usr/share/efitools/efi/HashTool.efi $2/EFI/boot
|
|
|
|
cp $1${DATADIR}/efiboot/gummibootx64.efi $2/EFI/boot/loader.efi
|
|
|
|
cp $1${DATADIR}/efiboot/shellx64_v{1,2}.efi $2/EFI
|
|
|
|
|
|
|
|
prepare_dir "$2/loader/entries"
|
|
|
|
|
|
|
|
cp $1${DATADIR}/efiboot/loader.conf $2/loader/loader.conf
|
|
|
|
vars_to_boot_conf $2/loader/loader.conf
|
|
|
|
cp $1${DATADIR}/efiboot/uefi-shell-v{1,2}-x86_64.conf $2/loader/entries
|
|
|
|
|
2016-10-07 08:25:08 +02:00
|
|
|
local drv='free' switch="no"
|
2016-10-09 18:04:22 +02:00
|
|
|
cp $1${DATADIR}/efiboot/entry-x86_64-$3.conf $2/loader/entries/${iso_name}-x86_64.conf
|
|
|
|
vars_to_boot_conf "$2/loader/entries/${iso_name}-x86_64.conf" "$drv" "$switch"
|
2016-09-15 23:58:18 +02:00
|
|
|
if ${nonfree_mhwd};then
|
2016-10-07 08:25:08 +02:00
|
|
|
drv='nonfree' switch="yes"
|
2016-10-09 18:04:22 +02:00
|
|
|
cp $1${DATADIR}/efiboot/entry-x86_64-$3.conf $2/loader/entries/${iso_name}-x86_64-nonfree.conf
|
|
|
|
vars_to_boot_conf "$2/loader/entries/${iso_name}-x86_64-nonfree.conf" "$drv" "$switch"
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2015-03-04 13:11:50 +01:00
|
|
|
}
|
|
|
|
|
2016-10-07 08:25:08 +02:00
|
|
|
prepare_syslinux(){
|
2016-10-09 09:08:30 +02:00
|
|
|
local syslinux=/usr/lib/syslinux/bios
|
|
|
|
msg2 "Copying syslinux binaries ..."
|
|
|
|
cp ${syslinux}/{*.c32,lpxelinux.0,memdisk,{isolinux,isohdpfx}.bin} $1
|
2016-10-09 00:40:25 +02:00
|
|
|
msg2 "Copying syslinux theme ..."
|
2016-10-09 09:08:30 +02:00
|
|
|
cp ${DATADIR}/syslinux-theme/* $1
|
|
|
|
for conf in ${syslinux}/*.cfg; do
|
|
|
|
vars_to_boot_conf "$1/${conf##*/}"
|
2016-10-07 08:25:08 +02:00
|
|
|
done
|
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 '' >> ${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
|
|
|
}
|