123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #!/bin/sh --
- set -ue
- # update kernel
- SRC=/usr/src
- cd "${SRC}"
- DELETE=1
- while getopts n opt; do
- case "${opt}" in
- n) DELETE=0;;
- *)
- echo 'invalid flag' 1>&2
- exit 1
- esac
- done
- select="$(
- for k in ./linux-*; do echo "${k##*/}"; done \
- | sort -rV \
- | sk --margin=30%,30% --height=30 --reverse
- )"
- prev="$(readlink -f -- ./linux)"
- [ "${prev##*/}" != "${select}" ]
- echo "updating '${prev##*/}' -> '${select}'"
- [ "${DELETE}" -eq 1 ] || echo 'and not deleting old sources'
- # shellcheck disable=2016
- {
- cmd='install -Tvm644 -- "${2:?}/.config" ./.config'\
- '; install -Tvm644 -- ./.config "${1:?}/.config"'\
- '; eselect kernel set "${1##*/}"'
- [ "${DELETE}" -eq 1 ] && cmd="${cmd}"'; rm -rf -- "${2}"'
- }
- doas -- sh -uec "${cmd}" sh "${SRC}/${select}" "${prev}"
- eselect kernel show
|