Compare commits

...

4 Commits

  1. 10
      README.org
  2. 89
      kernel.sh

10
README.org

@ -8,6 +8,12 @@ Disables incomplete reports in ~i2c-hid-code.c~ to stop logging spam.
* Build instructions * Build instructions
#+BEGIN_SRC sh #+BEGIN_SRC sh
$ mkdir build $ mkdir build
$ ./kernel.sh $ ./kernel.sh
#+END_SRC
* Install
#+BEGIN_SRC sh
$ ./kernel.sh install
#+END_SRC #+END_SRC

89
kernel.sh

@ -5,7 +5,7 @@
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
# #
# Build the Linux kernel # Build the Linux kernel
# Depends: asp, base-devel # Depends: asp, base-devel, coreutils
# Setup # Setup
# -------------------------------------- # --------------------------------------
@ -16,19 +16,51 @@ blue="$(tput setf 1)"
red="$(tput setf 4)" red="$(tput setf 4)"
n="$(tput sgr0)" n="$(tput sgr0)"
if [ "$(dirname "$0")" != "." ]; then error()
echo "${b}${red}Error:${n} please run this script from the directory it resides." >&2 {
echo "${b}${red}Error:${n} $1" >&2
exit 1 exit 1
}
if [ "$(dirname "$0")" != "." ]; then
error "please run this script from the directory it resides."
fi 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 # Main functionality
# -------------------------------------- # --------------------------------------
cdSafe() cdSafe()
{ {
if ! cd "$1" 2> /dev/null; then if ! cd "$1" 2> /dev/null; then
echo "${b}${red}Error:${n} no such file or directory: $1" >&2 error "no such file or directory: $1"
exit 1 fi
}
fileExist()
{
if [ ! -f "$1" ] ; then
error "no such file or directory: $1"
fi fi
} }
@ -37,12 +69,12 @@ checkDependencies()
dependencies=" dependencies="
asp asp
base-devel base-devel
coreutils
" "
for dependency in $dependencies; do for dependency in $dependencies; do
if ! pacman -Qs "$dependency" > /dev/null; then if ! pacman -Qs "$dependency" > /dev/null; then
echo "${b}${red}Error:${n} required dependency '$dependency' is missing." >&2 error "required dependency '$dependency' is missing."
exit 1
fi fi
done done
} }
@ -54,14 +86,14 @@ build()
rm -rf "./linux" rm -rf "./linux"
asp update linux asp update linux
asp export linux asp export linux
[ -f linux/config ] && mv linux/config . fileExist linux/config && mv linux/config .
[ -f linux/PKGBUILD ] && mv linux/PKGBUILD . fileExist linux/PKGBUILD && mv linux/PKGBUILD .
rm -rf "./linux" rm -rf "./linux"
patch --forward --strip=1 config < ../patch/config.patch patch --forward --strip=1 config < ../patch/config.patch
patch --forward --strip=1 PKGBUILD < ../patch/pkgbuild.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 updpkgsums
@ -74,8 +106,43 @@ build()
time makepkg -s 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 # Execute
# -------------------------------------- # --------------------------------------
checkDependencies 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

Loading…
Cancel
Save