Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Forked from azbesthu/get-kernel-source.sh
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamemomonga/c4a348236b21143e28d9 to your computer and use it in GitHub Desktop.
Save mamemomonga/c4a348236b21143e28d9 to your computer and use it in GitHub Desktop.
#!/bin/bash
REV=`zcat /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | grep '* firmware as of' | head -n 1 | sed -e 's/\ \*\ firmware as of \(.*\)$/\1/'`
rm -rf rasp-tmp
mkdir -p rasp-tmp
mkdir -p rasp-tmp/linux
wget https://raw.github.com/raspberrypi/firmware/$REV/extra/git_hash -O rasp-tmp/git_hash
wget https://raw.github.com/raspberrypi/firmware/$REV/extra/Module.symvers -O rasp-tmp/Module.symvers
SOURCEHASH=`cat rasp-tmp/git_hash`
wget https://github.com/raspberrypi/linux/tarball/$SOURCEHASH -O rasp-tmp/linux.tar.gz
cd rasp-tmp
tar -xzf linux.tar.gz
OSVERSION=`uname -r`
mv raspberrypi-linux* /usr/src/linux-source-$OSVERSION
ln -s /usr/src/linux-source-$OSVERSION /lib/modules/$OSVERSION/build
cp Module.symvers /usr/src/linux-source-$OSVERSION/
zcat /proc/config.gz > /usr/src/linux-source-$OSVERSION/.config
cd /usr/src/linux-source-$OSVERSION/
make oldconfig
make prepare
make scripts
cd ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment