-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
307 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
###################################### | ||
## LINUX-CK-AUTOBUILD CONFIGURATION ## | ||
###################################### | ||
|
||
# Preferred editor for editing this file. | ||
#editor="$EDITOR" | ||
editor="nano" | ||
|
||
# The base directory on this system where the directories to sync are located. Don't add a slash at the end! | ||
BUILDDIR="/home/$USER/tmp/AUR" | ||
|
||
# 1. AMD Opteron/Athlon64/Hammer/K8 (MK8) | ||
# 2. AMD Opteron/Athlon64/Hammer/K8 with SSE3 (MK8SSE3) | ||
# 3. AMD 61xx/7x50/PhenomX3/X4/II/K10 (MK10) | ||
# 4. AMD Barcelona (MBARCELONA) | ||
# 5. AMD Bobcat (MBOBCAT) | ||
# 6. AMD Jaguar (MJAGUAR) | ||
# 7. AMD Bulldozer (MBULLDOZER) | ||
# 8. AMD Piledriver (MPILEDRIVER) | ||
# 9. AMD Steamroller (MSTEAMROLLER) | ||
# 10. AMD Excavator (MEXCAVATOR) | ||
# 11. AMD Zen (MZEN) | ||
# 12. AMD Zen 2 (MZEN2) | ||
# 13. Intel P4 / older Netburst based Xeon (MPSC) | ||
# 14. Intel Atom (MATOM) | ||
# 15. Intel Core 2 (MCORE2) | ||
# 16. Intel Nehalem (MNEHALEM) | ||
# 17. Intel Westmere (MWESTMERE) | ||
# 18. Intel Silvermont (MSILVERMONT) | ||
# 19. Intel Goldmont (MGOLDMONT) | ||
# 20. Intel Goldmont Plus (MGOLDMONTPLUS) | ||
# 21. Intel Sandy Bridge (MSANDYBRIDGE) | ||
# 22. Intel Ivy Bridge (MIVYBRIDGE) | ||
# 23. Intel Haswell (MHASWELL) | ||
# 24. Intel Broadwell (MBROADWELL) | ||
# 25. Intel Skylake (MSKYLAKE) | ||
# 26. Intel Skylake X (MSKYLAKEX) | ||
# 27. Intel Cannon Lake (MCANNONLAKE) | ||
# 28. Intel Ice Lake (MICELAKE) | ||
# 29. Intel Cascade Lake (MCASCADELAKE) | ||
# 30. Intel Cooper Lake (MCOOPERLAKE) | ||
# 31. Intel Tiger Lake (MTIGERLAKE) | ||
# 32. Generic-x86-64 (GENERIC_CPU) | ||
# 33. Native optimizations autodetected by GCC (MNATIVE) | ||
|
||
# List the sub architecture you want to build : ( 15 ) | ||
# In case of multiple architectures separate them with a space like so: ( 15 8 ) | ||
SUBARCH=( 33 ) | ||
|
||
# If you have the modprobe-db package installed and wish to use it, change to 'y' otherwise leave empty. | ||
# With the modprobe-db package only the modules that were listed by modprobe-db get build, significantly | ||
# reducing build times. | ||
USE_MODPROBE_DB="" | ||
|
||
# Controls the maximum load on the CPU('s) | ||
# Uncomment your preferred option, the default is maximum. Alternatively you can choose a percentage with maxload. | ||
maxload=$(( $(nproc)*90/100 )) | ||
#makeflags="-j$maxload" | ||
makeflags="-j$(nproc)" | ||
#makeflags="-j2" | ||
|
||
# Sets the interval with which the watchdog monitors for a new kernel | ||
WATCHDOG_INTERVAL="3h" | ||
|
||
# Options for update dialog, timeout sets the dialog confirmation timeout (update will start after that). | ||
# Postponed sets the time for which an update is postponed after canceling. | ||
TIMEOUT="10" | ||
TIMOUT_UNIT="m" | ||
POSTPONED="3h" | ||
|
||
# User commands to run after compiling kernels, example: 'echo "Autobuild done" | mail -s "Autobuild done" [email protected]' | ||
#$USER_COMMAND1="" | ||
#$USER_COMMAND2="" | ||
#$USER_COMMAND3="" | ||
|
||
############################ | ||
## END OF CONFIGURATION ## | ||
############################ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/bin/bash | ||
# linux-ck-autobuild | ||
VERSION=0.1 | ||
# Author: Jochum D, jooch (at) gmx (dot) com | ||
# License: GPL3 | ||
# About: This script will automatically build specified ck kernels | ||
# Usage: Run 'linux-ck-autobuild' or 'linux-ck-autobuild -h' for more details. | ||
# URL: https://github.com/j00ch/linux-ck-autobuild | ||
|
||
program_name="linux-ck-autobuild" | ||
|
||
function print_help { | ||
echo " | ||
$program_name, version $VERSION | ||
A tool to automatically build ck kernels. | ||
Options: | ||
-h, --help Display this help | ||
-c, Create and/or set options | ||
--enable-autostart Enable daemon to fully automate build | ||
--disable-autostart Disable daemon (default) | ||
If you don't have a graphical environment you can use the systemd option: | ||
'systemctl enable $program_name@<username>.service' | ||
" | ||
exit 1 | ||
} | ||
|
||
function enable_daemon { | ||
check_service="$(systemctl is-active $program_name.service)" | ||
[[ $check_service = "active" ]] && echo "ERROR: systemd service is currently enabled, you should disable that first." && exit 1 || false | ||
yes_or_no "$msg This will install the daemon into the user's autostart folder, proceed?" && | ||
cp /etc/$program_name/$program_name-daemon.desktop /home/$USER/.config/autostart/$program_name-daemon.desktop | ||
echo "Installed $program_name-daemon.desktop in /home/$USER/.config/autostart" | ||
exit 1 | ||
} | ||
|
||
function disable_daemon { | ||
yes_or_no "$msg This will remove the daemon from user's autostart folder, proceed?" && | ||
rm /home/$USER/.config/autostart/$program_name-daemon.desktop | ||
echo "Removed $program_name-daemon.desktop from /home/$USER/.config/autostart" | ||
exit 1 | ||
} | ||
|
||
function yes_or_no { | ||
while true; do | ||
read -p "$* [y/n]: " yn | ||
case $yn in | ||
[Yy]*) return ;; | ||
[Nn]*) echo "Aborted" ; exit 1 ;; | ||
esac | ||
done | ||
} | ||
|
||
function load_config { | ||
if [ -r /home/$USER/.config/$program_name/$program_name.conf ]; then | ||
. /home/$USER/.config/$program_name/$program_name.conf | ||
else | ||
. /etc/$program_name/default.conf | ||
yes_or_no "$msg Configuration not found, copy default config?" && | ||
mkdir /home/$USER/.config/$program_name/ | ||
cp /etc/$program_name/default.conf /home/$USER/.config/$program_name/$program_name.conf | ||
edit_config | ||
fi | ||
} | ||
|
||
function edit_config { | ||
if [ -r /usr/bin/$editor ]; then | ||
$editor /home/$USER/.config/$program_name/$program_name.conf | ||
. /home/$USER/.config/$program_name/$program_name.conf | ||
else | ||
echo "Please setup your config and restart: | ||
/home/$USER/.config/$program_name/$program_name.conf" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function check_build_dir { | ||
if [ -r $BUILDDIR/linux-ck/PKGBUILD ]; then | ||
git -C $BUILDDIR/linux-ck reset --hard --quiet | ||
git -C $BUILDDIR/linux-ck pull --quiet | ||
else | ||
yes_or_no "$msg PKGBUILD not found at configured location, set up now?" $$ | ||
mkdir -p $BUILDDIR | ||
echo "Cloning AUR package" | ||
git -C $BUILDDIR/linux-ck clone https://aur.archlinux.org/linux-ck.git --quiet | ||
fi | ||
} | ||
function main_program { | ||
load_config | ||
check_build_dir | ||
. /etc/$program_name/subarches | ||
latest_version=$(curl -s https://aur.archlinux.org/packages/linux-ck | grep -A 1 'pkgdetails" class="box' | grep -Po '\d.\d.\d.') | ||
sed -i '/^build().*/a MAKEFLAGS="'$makeflags'"' $BUILDDIR/linux-ck/PKGBUILD | ||
for element in "${SUBARCH[@]}"; do | ||
subarch_name="arch_$element" | ||
if [ -z "$USE_MODPROBE_DB" ]; then | ||
sed -i '/pkgbase=/c\pkgbase=linux-ck-'${!subarch_name}'' $BUILDDIR/linux-ck/PKGBUILD | ||
else | ||
sed -i '/pkgbase=/c\pkgbase=linux-ck-'${!subarch_name}'-modprobed' $BUILDDIR/linux-ck/PKGBUILD | ||
fi | ||
sed -i '/pkgver=/c\pkgver='$latest_version'' $BUILDDIR/linux-ck/PKGBUILD | ||
sed -i '/_localmodcfg=/c\_localmodcfg='$USE_MODPROBE_DB'' $BUILDDIR/linux-ck/PKGBUILD | ||
sed -i '/_subarch=/c\_subarch='$element'' $BUILDDIR/linux-ck/PKGBUILD | ||
echo "$(date +"%Y-%m-%d_%H:%M") Starting kernel build ${!subarch_name}-$latest_version" | ||
(cd $BUILDDIR/linux-ck && makepkg -C) > $BUILDDIR/linux-ck/linux-ck-${!subarch_name}-$latest_version.log | ||
echo "$(date +"%Y-%m-%d_%H:%M") End kernel build ${!subarch_name}-$latest_version" | ||
done | ||
echo "$latest_version" > $BUILDDIR/linux-ck/.last_build | ||
} | ||
|
||
[[ $1 = "-h" ]] && print_help || | ||
[[ $1 = "--help" ]] && print_help || | ||
[[ $1 = "--enable_autostart" ]] && enable_autostart || | ||
[[ $1 = "--disable-autostart" ]] && disable_autostart || | ||
[[ $1 = "-c" ]] && load_config && edit_config || | ||
|
||
main_program | ||
$USER_COMMAND1 | ||
$USER_COMMAND2 | ||
$USER_COMMAND3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# linux-ck-autobuild-daemon.sh | ||
VERSION=0.1 | ||
# Author: Jochum D, jooch (at) gmx (dot) com | ||
# License: GPL3 | ||
# About: This script is part of linux-ck-autobuild, checks for new versions and automatically | ||
# starts the build script. | ||
# Usage: Setup configuration parameters and run 'linux-ck-autobuild --enable-daemon' to enable. | ||
|
||
program_name="linux-ck-autobuild" | ||
window_title="Linux-ck autobuild" | ||
|
||
function dialog { | ||
( | ||
increasefactor=$(echo "${TIMEOUT}"/100|bc -l) | ||
counter=0 | ||
while [ "$counter" -le 100 ]; do | ||
echo $counter; sleep "${increasefactor}""${TIMEOUT_UNIT}" | ||
counter=$(( $counter + 1 )) | ||
done | ||
) | | ||
if zenity --text="New kernel version detected ($latest_version), build wil start in $TIMEOUT$TIMEOUT_UNIT" --title="$window_title" --progress --percentage=0 --auto-close; then | ||
./linux-ck-autobuild | ||
else | ||
zenity --info --width=350 --title="$window_title" --text="Update postponed for $postponed" | ||
sleep $postponed | ||
fi | ||
return | ||
} | ||
|
||
if [ -r /home/$USER/.config/$program_name/$program_name.conf ]; then | ||
. /home/$USER/.config/$program_name/$program_name.conf | ||
while true | ||
do | ||
latest_version=$(curl -s https://aur.archlinux.org/packages/linux-ck | grep -A 1 'pkgdetails" class="box' | grep -Po '\d.\d.\d.') | ||
last_build=$(cat $BUILDDIR/linux-ck/.last_build) | ||
|
||
echo "Checking latest kernel version" | ||
if [[ $latest_version == $last_build ]]; then | ||
echo "Kernel is up to date" | ||
sleep $WATCHDOG_INTERVAL | ||
else | ||
[[ $check_service = "active" ]] && linux-ck-autobuild && return || false | ||
dialog | ||
fi | ||
done | ||
else | ||
echo "ERROR: no configuration found, run '$program_name -c'" | ||
exit | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Desktop Entry] | ||
Version=0.1 | ||
Name=Linux-ck Autobuild Daemon | ||
Terminal=false | ||
Type=Application | ||
NoDisplay=true | ||
GenericName=linux-ck-autobuild | ||
Comment=A tool to automatically build ck kernels | ||
Exec=linux-ck-autobuild-daemon | ||
Icon=update-manager |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Linux-ck Autobuild Daemon | ||
|
||
[Service] | ||
User=%I | ||
Type=simple | ||
ExecStart=/usr/bin/linux-ck-autobuild-daemon | ||
StandardOutput=null | ||
PrivateTmp=true | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
arch_1="k8" | ||
arch_2="kx" | ||
arch_3="k10" | ||
arch_4="barcelona" | ||
arch_5="bobcat" | ||
arch_6="jaguar" | ||
arch_7="bulldozer" | ||
arch_8="piledriver" | ||
arch_9="steamroller" | ||
arch_10="excavator" | ||
arch_11="zen" | ||
arch_12="zen2" | ||
arch_13="p4" | ||
arch_14="atom" | ||
arch_15="core2" | ||
arch_16="nehalem" | ||
arch_17="westmere" | ||
arch_18="silvermont" | ||
arch_19="goldmont" | ||
arch_20="goldmontplus" | ||
arch_21="sandybridge" | ||
arch_22="ivybridge" | ||
arch_23="haswell" | ||
arch_24="broadwell" | ||
arch_25="skylake" | ||
arch_26="skylakex" | ||
arch_27="cannonlake" | ||
arch_28="icelake" | ||
arch_29="cascadelake" | ||
arch_30="cooperlake" | ||
arch_31="tigerlake" | ||
arch_32="generic" | ||
arch_33="native" |