summaryrefslogtreecommitdiff
path: root/update-kernel-config
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-07-10 08:19:25 +0200
committerErich Eckner <git@eckner.net>2018-07-10 08:19:25 +0200
commit261e6385c50f8d017460e3fb24f2c3fc22fdb3d6 (patch)
treef7a61eeebd5be061c582a2c5dcb18796e90d0d99 /update-kernel-config
downloaddevops-261e6385c50f8d017460e3fb24f2c3fc22fdb3d6.tar.xz
initial commit
Diffstat (limited to 'update-kernel-config')
-rwxr-xr-xupdate-kernel-config72
1 files changed, 72 insertions, 0 deletions
diff --git a/update-kernel-config b/update-kernel-config
new file mode 100755
index 0000000..37e414c
--- /dev/null
+++ b/update-kernel-config
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]; then
+ >&2 echo 'usage: update-kernel-config [repository] [kernel-name]'
+ exit 2
+fi
+
+old_revision=$(
+ sed -n '
+ s/^# upstream git\( revision\)\?: *//
+ T
+ p
+ ' "/usr/src/archlinux32/packages/$1/$2/PKGBUILD"
+)
+
+if [ -z "${old_revision}" ]; then
+ >&2 echo 'Cannot detemine old upstream git revision.'
+ >&2 echo '"# upstream git revision: ..." line is missing.'
+ exit 1
+fi
+
+diff=$(
+ git -C "/usr/src/archlinux/packages/$2/repos/$1-x86_64" diff "${old_revision}" HEAD -- config | \
+ grep '^[+-].' | \
+ grep -v '^+++\|^---'
+)
+
+if [ -z "${diff}" ]; then
+ >&2 echo 'nothing changed.'
+ exit 1
+fi
+
+{
+ grep -vxF "$(
+ printf '%s\n' "${diff}" | \
+ sed -n '
+ s/^-//
+ T
+ p
+ '
+ )" "/usr/src/archlinux32/packages/$1/$2/config"
+ printf '%s\n' "${diff}" | \
+ sed -n '
+ s/^+//
+ T
+ p
+ '
+} | \
+ sponge "/usr/src/archlinux32/packages/$1/$2/config"
+
+sed -i '
+ 1 s/^#.*$/# upstream git revision: '"$(
+ git -C "/usr/src/archlinux/packages" rev-parse HEAD
+ )"'/
+ s/'"$(
+ git -C "/usr/src/archlinux/packages/$2/repos/$1-x86_64" archive "${old_revision}" -- config | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}'
+ )"'/'"$(
+ git -C "/usr/src/archlinux/packages/$2/repos/$1-x86_64" archive HEAD -- config | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}'
+ )"'/g
+ s/'"$(
+ git -C "/usr/src/archlinux32/packages/$1/$2" archive HEAD -- config | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}'
+ )"'/SKIP/g
+' "/usr/src/archlinux32/packages/$1/$2/PKGBUILD"