Skip to content

Instantly share code, notes, and snippets.

@felipec
Created May 31, 2017 07:17
#!/bin/bash
v=$1
o=$2
d=$4
loaders=('grub')
test -r /etc/default/installkernel &&
source /etc/default/installkernel
install_efi () {
mkdir -p $d/EFI/linux/ || return 1
cp -v $o $d/EFI/linux/vmlinuz.efi
cp -v /tmp/initramfs.img $d/EFI/linux/initramfs.img
}
install_grub () {
local f
test -d $d/grub/ || return 1
cp -v $o $d/vmlinuz-$v
cp -v /tmp/initramfs.img $d/initramfs-$v.img
if test -f $d/EFI/grub/grub.cfg
then
f=$d/EFI/grub/grub.cfg
elif test -f $d/grub/grub.cfg
then
f=$d/grub/grub.cfg
fi
test -n $f && grub-mkconfig -o $f
}
install_common () {
mkdir -p $d/EFI/arch/ || return 1
cp -v $o $d/EFI/arch/vmlinuz-$v.efi
cp -v /tmp/initramfs.img $d/EFI/arch/initramfs-$v.img
}
install_refind () {
install_common
}
install_gummiboot () {
install_common || return 1
test -f $d/loader/entries/arch.conf &&
echo "Generating arch-linux-$v.conf" &&
{
cat <<-EOF
title Arch Linux ($v)
linux /EFI/arch/vmlinuz-$v.efi
initrd /EFI/arch/initramfs-$v.img
EOF
grep '^options\s' $d/loader/entries/arch.conf
} > $d/loader/entries/arch-linux-$v.conf
}
# mkinitcpio -k $v -g /tmp/initramfs.img -S autodetect
mkinitcpio -k $v -g /tmp/initramfs.img
for x in ${loaders[*]}
do
install_$x
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment