Skip to content

Instantly share code, notes, and snippets.

@xerpi
Last active May 2, 2017 16:47
Show Gist options
  • Save xerpi/257c4393c7c8fe1ff79373b3c26bd654 to your computer and use it in GitHub Desktop.
Save xerpi/257c4393c7c8fe1ff79373b3c26bd654 to your computer and use it in GitHub Desktop.
#!/bin/bash
#wget https://aur.archlinux.org/cgit/aur.git/plain/config.x86_64?h=linux-drm-tip-git -O ./.config
zcat /proc/config.gz > ./.config
rm ./arch/x86_64/boot/bzImage
commit="$(git rev-parse --short HEAD)"
echo "commit: $commit"
# set localversion to git commit
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"-${commit##*.}\"|g" ./.config
sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
make prepare
# get kernel version
kernver="$(make LOCALVERSION= kernelrelease)"
echo "kernver: $kernver"
make oldconfig
# build
make -j4 LOCALVERSION= bzImage modules
echo "commit: $commit"
echo "kernver: $kernver"
# install modules
echo "Installing modules ..."
sudo make modules_install
echo "Copying ./arch/x86_64/boot/bzImage to /boot/vmlinuz-linux-$kernver ..."
sudo cp ./arch/x86_64/boot/bzImage "/boot/vmlinuz-linux-$kernver"
# set mkinitcpio preset file for kernel
cp /etc/mkinitcpio.d/linux.preset "./linux-$kernver.preset"
sed \
-e "1s|'linux.*'|'${pkgbase}'|" \
-e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-linux-$kernver\"|" \
-e "s|default_image=.*|default_image=\"/boot/initramfs-$kernver.img\"|" \
-e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-$kernver-fallback.img\"|" \
-i "./linux-$kernver.preset"
# generate initramfs
echo "Generating the initramfs ..."
sudo depmod -F System.map -a "$kernver"
sudo mkinitcpio -p "./linux-$kernver.preset"
echo "Now edit /boot/loader/entries/arch.conf as follows:"
echo "linux /vmlinuz-linux-$kernver"
echo "initrd /initramfs-$kernver.img"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment