Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mjechow committed Jul 3, 2024
0 parents commit 36ab0ff
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
config*
build.log
linux-modules*
linux-headers*
linux-image*
linux-upstream*

linux/
old/

24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
YACKS
======

YACS is yet another compile the kernel script. It is specifically developed for building a Ubuntu kernel and tested on Linux Mint.

It uses the Ubuntu mainline kernel config from https://kernel.ubuntu.com/~kernel-ppa/mainline/ found in the Linux modules generic dep package for configuration of the kernel.
Afterward it downloads the kernel sources (linux-rolling-lts branch) from the official sources: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/.

It modifies the kernel config for O3 optimizations and disables all debugging before compiling the sources.

At last, it offers the installation of the new build kernel dep packages.

## Requirements

* installed git
* installed classic gcc tool chain

## Constraints

* It only compiles amd64 architecture source code.
* Atm the Linux source code has to be checked out and available in the directory "linux" next to the script


## Todo

68 changes: 68 additions & 0 deletions buildKernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

#set -x

cd linux || exit 1
printf "cleanup and checkout...\n"
make distclean
git reset --hard
git clean -d -f
git pull origin linux-rolling-lts || exit 1
#git pull origin linux-rolling-stable || exit 1

kernelVersionDir=$(git describe --tags --abbrev=0)
kernelVersion=${kernelVersionDir#v} # remove character "v"
cd ..

kernelUrl=https://kernel.ubuntu.com/~kernel-ppa/mainline/${kernelVersionDir}
kernelVersionLong=$(echo "$kernelVersion" | awk 'BEGIN {FS="."}{printf "%02d%02d%02d", $1, $2, $3;}')
kernelFileName=$(curl -sL "$kernelUrl" | grep -iEo "linux-modules-${kernelVersion}-${kernelVersionLong}-generic_${kernelVersion}-${kernelVersionLong}.[0-9]{12}_amd64.deb" | head -1)
kernelDeb=${kernelUrl}/amd64/${kernelFileName}
if [[ ! -f "${kernelFileName}" ]]; then
printf "downloading kernel %s sources from Ubuntu...\n" "$kernelVersion}"
if ! wget -q "${kernelDeb}"; then
printf "Problem downloading kernel % sources from Ubuntu mainline: %s, exiting!\n" "$kernelVersion" "$kernelDeb"
exit 1
fi
fi

printf "extracting config...\n"
dpkg-deb --fsys-tarfile "${kernelFileName}" | tar xOf - ./boot/config-"${kernelVersion}"-"${kernelVersionLong}"-generic >config-"${kernelVersion}" || exit 1

cd linux || exit 1
git log -1 --pretty=oneline
echo "Do you wish to compile this kernel?"
echo "$ARCH"
select yn in "Yes" "No"; do
case $yn in
Yes) break ;;
No) exit 1 ;;
esac
done

cp ../config-"${kernelVersion}" .config

export KCFLAGS="-march=native -mtune=native -O3 -pipe" KCPPFLAGS="-march=native -mtune=native -O3 -pipe"

printf "modify kernel options...\n"
scripts/config --enable DEBUG_INFO_NONE
scripts/config --disable CONFIG_DEBUG_INFO
scripts/config --disable CONFIG_DEBUG_INFO_DWARF5
scripts/config --disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
scripts/config --disable DEBUG_INFO_DWARF4
scripts/config --disable DEBUG_INFO_DWARF5
scripts/config --disable CONFIG_MODULE_SIG_ALL
scripts/config --set-str SYSTEM_TRUSTED_KEYS ""
scripts/config --set-str SYSTEM_REVOCATION_KEYS ""

printf "modify optimizations in Makefile...\n"
sed -i 's/-O2/-O3/g' Makefile

printf "make clean build...\n"
make clean
make ARCH=x86_64 oldconfig
time nice make -j$(($(nproc) + 1)) bindeb-pkg LOCALVERSION=-"$(whoami)"-"$(hostname)" >>../build.log || exit 1

cd .. || exit 1
printf "done!\nYou can install now using:\nsudo dpkg -i linux-*%s*.deb\n" "$(whoami)"

0 comments on commit 36ab0ff

Please sign in to comment.