-
-
Save riptidewave93/8838758 to your computer and use it in GitHub Desktop.
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/bash | |
NumCPU=$(grep -c ^processor /proc/cpuinfo) | |
NumJobs=$(calc -p "ceil(2*$NumCPU+1)") | |
export CONCURRENCY_LEVEL=$NumJobs | |
baseURL="https://www.kernel.org/pub/linux/kernel/v3.x/" | |
latest="$(curl -s $baseURL | sed -n 's|\(.*\)\(linux-\)\(.*\)\(\.tar\.xz<\)\(.*\)|\3|p' | sort --version-sort | tail -n1)" | |
[ ! "$latest" ] && { echo "Are we offline?" >&2; exit 1; } | |
echo "latest version: $latest" | |
echo -n "Build this? [(y)/n] " | |
read -n1 ans | |
echo | |
if [ ! "$ans" ] || [ "$ans" = y ] || [ "$ans" = Y ] || [ "$ans" = j ] || [ "$ans" = J ] | |
then | |
version="$latest" | |
else | |
echo -n "Enter kernel version to build: " | |
read version | |
echo | |
fi | |
stableURL="${baseURL}linux-${version}.tar.xz" | |
testingURL="${baseURL}testing/linux-${version}.tar.xz" | |
prevDir="$(pwd)" | |
cd /tmp | |
echo attempting to download "${stableURL}" | |
echo | |
if ! wget -c "${stableURL}" | |
then | |
echo "error downloading ${stableURL}" | |
echo "Now trying to retrieve from ${testingURL} ..." | |
echo | |
wget -c "${testingURL}" || { echo "error downloading ${testingURL}" >&2; exit 1; } | |
fi | |
echo Extract... | |
tar -xJf linux-${version}.tar.xz || { echo "error extracting linux-${version}.tar.xz" >&2; exit 1; } | |
cd linux-${version} | |
make-kpkg clean || { echo "error out" >&2; exit 1; } | |
echo | |
echo -n "Start with build config from $(uname -r)? [(y)/n] " | |
read -n1 ans | |
echo | |
if [ ! "$ans" ] || [ "$ans" = y ] || [ "$ans" = Y ] || [ "$ans" = j ] || [ "$ans" = J ] | |
then | |
cp /boot/config-$(uname -r) .config | |
else | |
echo -n "Enter a full path to the desired base config file: " | |
read ans | |
[ -f "$ans" ] || { echo "File does not exist" >&2; exit 1; } | |
echo "cp \"$ans\" .config" | |
cp "$ans" .config | |
fi | |
make xconfig || { echo "error with xconfig" >&2; exit 1; } | |
#make menuconfig || { echo "error with menuconfig" >&2; exit 1; } | |
echo -n "what to append to kernel version? " | |
read buildName | |
[ "$buildName" ] || { echo "You must provide a string." >&2; exit 1; } | |
echo -n "Kernel revision? (choose a number) " | |
read myRevision | |
[ "$myRevision" ] || { echo "You must provide a string." >&2; exit 1; } | |
# Compile with some kind of minimal priority for I/O and CPU (ionice/schedtool). | |
# | |
# "eatmydata" does what it says in case of power blackout or so, because data | |
# is not necessarily written to disk (but still only in RAM). The benefit however | |
# is speed, because we do not need to wait for fsyncs()s. | |
ionice -c2 -n7 schedtool -D -n19 -e fakeroot eatmydata make-kpkg --append-to-version "-${buildName}" --revision "$myRevision" --initrd kernel_image kernel_headers || { echo "error during build" >&2; exit 1; } | |
# find . -type f -exec cachedel '{}' \; &> /dev/null | |
cd .. | |
echo "install anything from $(ls -1 linux*${buildName}*.deb) (on your Desktop)" | |
mv linux*${buildName}*.deb ${HOME}/Desktop | |
# remove kernel source directory | |
[ -d linux-${version} ] && rm -rf linux-${version} | |
cd "$prevDir" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment