Last active
November 26, 2016 14:28
-
-
Save nihilismus/12a10ec3152dadd069ff to your computer and use it in GitHub Desktop.
Script to download, verify (sha256sum), uncompress and prepare a Linux kernel source tarball.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright © 2016 Antonio Hernández Blas <hba.nihilismus@gmail.com> | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://www.wtfpl.net/ for more details. | |
me=$(basename $0) | |
mayor_version=$(echo $1 | cut -d '.' -f 1) | |
minor_version=$(echo $1 | cut -d '.' -f 2) | |
bugfix_version=$(echo $1 | cut -d '.' -f 3 | sed 's/-.*//') | |
newfix_version=$(echo $1 | sed 's/.*-//') | |
old_version=${mayor_version}.${minor_version}.${bugfix_version} | |
new_version=${mayor_version}.${minor_version}.${newfix_version} | |
old_source=linux-${mayor_version}.${minor_version}.${bugfix_version} | |
new_source=linux-${mayor_version}.${minor_version}.${newfix_version} | |
patch_name=patch-$1 | |
if [ "${old_source}" = "linux-" ]; then | |
echo " $me: Error, version must be specified, example: 3.18.13-14" | |
exit 1 | |
fi | |
if ! $(echo $1 | grep -q '\-'); then | |
echo " $me: Error, version must be *corrrectly* specified, example: 3.18.13-14" | |
exit 1 | |
fi | |
if [ ! -d "${old_source}" ]; then | |
echo " $me: Error, directory '"${old_source}"' does not exists" | |
exit 1 | |
fi | |
if [ -d "${new_source}" ]; then | |
echo " $me: Error, directory '"${new_source}"' already exists" | |
exit 1 | |
fi | |
set -u | |
set -e | |
set -x | |
wget -c https://cdn.kernel.org/pub/linux/kernel/v${mayor_version}.x/incr/${patch_name}.xz && \ | |
wget -c https://cdn.kernel.org/pub/linux/kernel/v${mayor_version}.x/incr/sha256sums.asc -O sha256sums.asc && \ | |
grep -a ${patch_name}.xz sha256sums.asc > ${patch_name}.xz.sha256 && \ | |
sha256sum -c ${patch_name}.xz.sha256 && \ | |
rm sha256sums.asc && \ | |
cp -rf ${old_source} ${new_source} && \ | |
xzcat ${patch_name}.xz > ${new_source}/${patch_name}.diff && \ | |
cd ${new_source} && \ | |
patch -p1 < ${patch_name}.diff && \ | |
make oldconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright © 2016 Antonio Hernández Blas <hba.nihilismus@gmail.com> | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://www.wtfpl.net/ for more details. | |
me=$(basename $0) | |
source="https://www.kernel.org" | |
identify_release() { | |
while read release; do | |
if $(echo "$(uname -r)" | grep -qE "^${release}"); then | |
echo "** ${release}" | |
continue | |
fi | |
echo " ${release}" | |
done | |
echo "** $(uname -r)" | |
} | |
set -u | |
set -e | |
wget -o /dev/null ${source} -O - | \ | |
grep '<td><strong>' | \ | |
grep '</strong></td>' | \ | |
sed 's:.*<td><strong>::' | \ | |
sed 's:</strong></td>.*::' | \ | |
sed 's: .*$::' | \ | |
sed 's:^: :' | \ | |
identify_release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright © 2015 Antonio Hernández Blas <hba.nihilismus@gmail.com> | |
# This program is free software. It comes without any warranty, to | |
# the extent permitted by applicable law. You can redistribute it | |
# and/or modify it under the terms of the Do What The Fuck You Want | |
# To Public License, Version 2, as published by Sam Hocevar. See | |
# http://www.wtfpl.net/ for more details. | |
me=$(basename $0) | |
version=$1 | |
mainline=$(echo $1 | cut -d '.' -f 1) | |
if [ -z "${version}" ]; then | |
echo " $me: Error, version must be specified. Example: 3.18.13" | |
exit 1 | |
fi | |
set -u | |
set -e | |
set -x | |
wget -c https://www.kernel.org/pub/linux/kernel/v${mainline}.x/linux-${version}.tar.xz && \ | |
wget -c https://www.kernel.org/pub/linux/kernel/v${mainline}.x/sha256sums.asc && \ | |
grep "\-${version}.tar.xz" sha256sums.asc > linux-${version}.tar.xz.sha256 && \ | |
sha256sum -c linux-${version}.tar.xz.sha256 && \ | |
rm sha256sums.asc && \ | |
tar xf linux-${version}.tar.xz && \ | |
cat /boot/config > linux-${version}/.config && \ | |
cd linux-${version} && \ | |
make oldconfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment