Compare commits
4
Commits
ce7b561f0e
...
9e9e017aa9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e9e017aa9 | ||
|
|
63effa3927 | ||
|
|
19fc765477 | ||
|
|
68470003a1 |
+8
-2
@@ -8,6 +8,12 @@ Disables incomplete reports in ~i2c-hid-code.c~ to stop logging spam.
|
||||
* Build instructions
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
$ mkdir build
|
||||
$ ./kernel.sh
|
||||
$ mkdir build
|
||||
$ ./kernel.sh
|
||||
#+END_SRC
|
||||
|
||||
* Install
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
$ ./kernel.sh install
|
||||
#+END_SRC
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Build the Linux kernel
|
||||
# Depends: asp, base-devel
|
||||
# Depends: asp, base-devel, coreutils
|
||||
|
||||
# Setup
|
||||
# --------------------------------------
|
||||
@@ -16,19 +16,51 @@ blue="$(tput setf 1)"
|
||||
red="$(tput setf 4)"
|
||||
n="$(tput sgr0)"
|
||||
|
||||
if [ "$(dirname "$0")" != "." ]; then
|
||||
echo "${b}${red}Error:${n} please run this script from the directory it resides." >&2
|
||||
error()
|
||||
{
|
||||
echo "${b}${red}Error:${n} $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$(dirname "$0")" != "." ]; then
|
||||
error "please run this script from the directory it resides."
|
||||
fi
|
||||
|
||||
help()
|
||||
{
|
||||
cat << EOF
|
||||
${b}NAME${n}
|
||||
kernel.sh - build the Linux kernel
|
||||
|
||||
${b}SYNOPSIS${n}
|
||||
${u}kernel.sh${n} [${u}OPTION${n}] ${u}COMMAND${n}
|
||||
|
||||
${b}OPTIONS${n}
|
||||
${b}-h${n}, ${b}--help${n} Display usage message and exit.
|
||||
|
||||
${b}COMMANDS${n}
|
||||
${b}build${n}
|
||||
Build the kernel, this is the default.
|
||||
|
||||
${b}install${n}
|
||||
Install the kernel.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Main functionality
|
||||
# --------------------------------------
|
||||
|
||||
cdSafe()
|
||||
{
|
||||
if ! cd "$1" 2> /dev/null; then
|
||||
echo "${b}${red}Error:${n} no such file or directory: $1" >&2
|
||||
exit 1
|
||||
error "no such file or directory: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
fileExist()
|
||||
{
|
||||
if [ ! -f "$1" ] ; then
|
||||
error "no such file or directory: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -37,12 +69,12 @@ checkDependencies()
|
||||
dependencies="
|
||||
asp
|
||||
base-devel
|
||||
coreutils
|
||||
"
|
||||
|
||||
for dependency in $dependencies; do
|
||||
if ! pacman -Qs "$dependency" > /dev/null; then
|
||||
echo "${b}${red}Error:${n} required dependency '$dependency' is missing." >&2
|
||||
exit 1
|
||||
error "required dependency '$dependency' is missing."
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -54,14 +86,14 @@ build()
|
||||
rm -rf "./linux"
|
||||
asp update linux
|
||||
asp export linux
|
||||
[ -f linux/config ] && mv linux/config .
|
||||
[ -f linux/PKGBUILD ] && mv linux/PKGBUILD .
|
||||
fileExist linux/config && mv linux/config .
|
||||
fileExist linux/PKGBUILD && mv linux/PKGBUILD .
|
||||
rm -rf "./linux"
|
||||
|
||||
patch --forward --strip=1 config < ../patch/config.patch
|
||||
patch --forward --strip=1 PKGBUILD < ../patch/pkgbuild.patch
|
||||
|
||||
ln -s ../patch/i2c-hid-disable-incomplete-reports.patch .
|
||||
ln -s ../patch/i2c-hid-disable-incomplete-reports.patch . 2> /dev/null
|
||||
|
||||
updpkgsums
|
||||
|
||||
@@ -74,8 +106,43 @@ build()
|
||||
time makepkg -s
|
||||
}
|
||||
|
||||
install()
|
||||
{
|
||||
cdSafe build
|
||||
|
||||
packages="$(find . -name "*.tar.zst" -type f)"
|
||||
|
||||
found="$(echo "$packages" | wc -l)"
|
||||
if [ "$found" -ne 2 ]; then
|
||||
error "kernel was not build yet."
|
||||
fi
|
||||
|
||||
if ! sudo -v; then
|
||||
error "you cannot perform this operation uness you are root."
|
||||
fi
|
||||
|
||||
echo "$packages" | xargs --open-tty sudo pacman -U --needed
|
||||
}
|
||||
|
||||
# Execute
|
||||
# --------------------------------------
|
||||
|
||||
checkDependencies
|
||||
build
|
||||
|
||||
script="$(basename "$0")"
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
help
|
||||
;;
|
||||
build | "")
|
||||
build
|
||||
;;
|
||||
install)
|
||||
install
|
||||
;;
|
||||
*)
|
||||
echo "$script: invalid option '$1'" >&2
|
||||
echo "Try '$script -h' for more information." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user