Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Benes <mbenes@suse.cz>2014-11-06 13:55:43 +0100
committerMiroslav Benes <mbenes@suse.cz>2014-11-06 13:55:43 +0100
commit54c95953c34b91c28e6f4f4abee31bfd5124c221 (patch)
tree81877756f39d9e0c40c958223041499dcd3106eb
parent51fd9ddd24922402823cd898702e30a466769d03 (diff)
Add top git commit hash to uname -v
Add top git commit hash to version part of uname. This makes the identification of current patch level easy (even in crash: p kgr_tag). References: fate#317769 Signed-off-by: Miroslav Benes <mbenes@suse.cz>
-rw-r--r--rpm/kgraft-patch.spec4
-rw-r--r--uname_patch/kgr_patch_uname.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/rpm/kgraft-patch.spec b/rpm/kgraft-patch.spec
index f3c0988..79aee76 100644
--- a/rpm/kgraft-patch.spec
+++ b/rpm/kgraft-patch.spec
@@ -45,6 +45,10 @@ cp %_sourcedir/Makefile .
set -- *
sed -i 's/@@RPMRELEASE@@/%module_num/g' Makefile
sed -i 's/@@RPMRELEASE@@/%module_num/g' kgr_patch_main.c
+
+commit=$(sed -n 's/GIT Revision: //p' %_sourcedir/source-timestamp)
+sed -i "s/@@GITREV@@/${commit:0:7}/g" uname_patch/kgr_patch_uname.c
+
for flavor in %flavors_to_build; do
mkdir -p "obj/$flavor"
cp -r "$@" "obj/$flavor"
diff --git a/uname_patch/kgr_patch_uname.c b/uname_patch/kgr_patch_uname.c
index 9a20a34..88a9df1 100644
--- a/uname_patch/kgr_patch_uname.c
+++ b/uname_patch/kgr_patch_uname.c
@@ -57,7 +57,7 @@ static int override_release(char __user *release, size_t len)
return ret;
}
-#define KGR_TAG "/kGraft"
+char *kgr_tag="/kGraft-@@GITREV@@";
static struct rw_semaphore *kgr_uts_sem;
@@ -67,7 +67,7 @@ static int override_version(char __user *version, size_t len, char *kgr_version)
char *right_brace;
size_t newlen;
- newlen = strlen(kgr_version) + strlen(KGR_TAG);
+ newlen = strlen(kgr_version) + strlen(kgr_tag);
if (newlen >= len) {
WARN_ONCE(1, "kgraft-patch: not enough space for utsname.version extension");
goto out;
@@ -79,9 +79,9 @@ static int override_version(char __user *version, size_t len, char *kgr_version)
goto out;
}
- memmove(right_brace + strlen(KGR_TAG), right_brace,
+ memmove(right_brace + strlen(kgr_tag), right_brace,
strlen(right_brace) + 1);
- memcpy(right_brace, KGR_TAG, strlen(KGR_TAG));
+ memcpy(right_brace, kgr_tag, strlen(kgr_tag));
ret = copy_to_user(version, kgr_version, newlen + 1);