kernel-installer/install-kernel

88 lines
1.8 KiB
Plaintext
Raw Normal View History

2018-11-10 16:21:13 -05:00
#! /bin/bash
CONFHIST_DIR=config-history
PKG_DIR=linux-ck
BUILDFILE="$PKG_DIR/PKGBUILD"
PKG_URL=https://aur.archlinux.org/cgit/aur.git/snapshot/linux-ck.tar.gz
ARCH=x86_64
get_latest_config() {
echo "$CONFHIST_DIR/$(ls -Art "$CONFHIST_DIR" | tail -n 1)"
}
help="$(basename "$0") [-o] [-c] [-h]
Downloads and installs new linux-ck kernel. By default will grab the
most recent config file from config-history unless the current config
is different (and exists), in which case it will be assumed more
recent and saved in config history. If old config is used and from an
older kernel, make oldconfig will automatically run.
Options:
-o: use the old package even if new is available
-c: launch make nconfig
-h: show this"
while getopts ":och" OPT; do
case ${OPT} in
o)
OLD_PKG="true"
;;
c)
DO_CONFIG="true"
;;
h)
echo "$help"
exit 0
;;
\?)
echo "$help"
exit 0
;;
esac
done
# pull old config if it exists and is not the most recent
if [ -e "$BUILDFILE" ]; then
echo "checking for old config file"
2018-11-10 16:24:06 -05:00
2018-11-10 16:21:13 -05:00
source "$BUILDFILE" # get pkgver
oldconf="$PKG_DIR/src/linux-$pkgver/.config"
2018-11-10 16:24:06 -05:00
2018-11-10 16:21:13 -05:00
if [ -e "$oldconf" ]; then
echo "found old config"
2018-11-10 16:24:06 -05:00
2018-11-10 16:21:13 -05:00
oldsum=$(md5sum "$oldconf" | awk '{print $1}')
newsum=$(md5sum $(get_latest_config) | awk '{print $1}')
2018-11-10 16:24:06 -05:00
2018-11-10 16:21:13 -05:00
if [ "$oldsum" != "$newsum" ]; then
echo "copying old config to $CONFHIST_DIR"
2018-11-10 16:22:54 -05:00
cp "$oldconf" "$CONFHIST_DIR/.config-$(date +%Y%m%d%H%M)"
2018-11-10 16:21:13 -05:00
else
echo "config file up to date. nothing to back up"
fi
fi
fi
if [ -z "$OLD_PKG" ]; then
echo downloading new package
2018-11-10 16:24:06 -05:00
2018-11-10 16:22:54 -05:00
rm -rf $PKG_DIR
curl -O "$PKG_URL"
tar xzf linux-ck.tar.gz
2018-11-10 16:21:13 -05:00
latest_conf=$(get_latest_config)
2018-11-10 16:24:06 -05:00
2018-11-10 16:21:13 -05:00
echo "copying conf: $latest_conf"
2018-11-10 16:24:06 -05:00
2018-11-10 16:22:54 -05:00
cp "$latest_conf" "$PKG_DIR/config"
updpkgsums "$BUILDFILE"
2018-11-10 16:21:13 -05:00
fi
2018-11-10 16:22:54 -05:00
cd "$PKG_DIR"
if [ -n "$DO_CONFIG" ]; then
sed -i '/_makenconfig=/ s/$/y/' PKGBUILD
fi
makepkg -s -r -f -i
cd ..