From 7d29728cf4898d5365105cdd72bcc270ebdbe0e5 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 10 Nov 2018 16:21:13 -0500 Subject: [PATCH] added install script --- .gitignore | 4 +-- install-kernel | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100755 install-kernel diff --git a/.gitignore b/.gitignore index 5c6836a..b295585 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ * -!install-kernal -!config-history +!install-kernel +!config-history/ diff --git a/install-kernel b/install-kernel new file mode 100755 index 0000000..24b1221 --- /dev/null +++ b/install-kernel @@ -0,0 +1,82 @@ +#! /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" + # kver=$(get_from_buildfile "$BUILDFILE" "_srcname") + source "$BUILDFILE" # get pkgver + oldconf="$PKG_DIR/src/linux-$pkgver/.config" + ## this file does not always exist? + if [ -e "$oldconf" ]; then + echo "found old config" + oldsum=$(md5sum "$oldconf" | awk '{print $1}') + newsum=$(md5sum $(get_latest_config) | awk '{print $1}') + if [ "$oldsum" != "$newsum" ]; then + echo "copying old config to $CONFHIST_DIR" + # cp "$oldconf" "$CONFHIST_DIR/.config-$(date +%Y%m%d%H%M)" + else + echo "config file up to date. nothing to back up" + fi + fi +fi + +if [ -z "$OLD_PKG" ]; then + echo downloading new package + # rm -rf $PKG_DIR + # curl -O "$PKG_URL" + # tar xzf linux-ck.tar.gz + + latest_conf=$(get_latest_config) + echo "copying conf: $latest_conf" + # cp "$latest_conf" "$PKG_DIR/config" + # updpkgsums "$BUILDFILE" +fi + +# cd "$PKG_DIR" +# if [ -n "$DO_CONFIG" ]; then + # sed -i '/_makenconfig=/ s/$/y/' PKGBUILD +# fi +# makepkg -s -r -f -i +# cd ..