Blame SOURCES/mcelog-patch-59b8cab3f.patch

09c1d0
From: Prarit Bhargava <prarit@redhat.com>
09c1d0
09c1d0
Subject: mcelog version: Add ability for OS to define version
09c1d0
09c1d0
commit 59b8cab3f607573cb55b6841ece2f2577be6b419
09c1d0
Author: Prarit Bhargava <prarit@redhat.com>
09c1d0
Date:   Mon May 22 10:25:57 2017 -0400
09c1d0
09c1d0
    mcelog version: Add ability for OS to define version
09c1d0
    
09c1d0
    Example usage of this patch:
09c1d0
    
09c1d0
    [root@intel-purley-03 mcelog]# cat .os_version
09c1d0
    mcelog-144-3.94d853b2ea81.el7
09c1d0
    [root@intel-purley-03 mcelog]# make version.tmp
09c1d0
    ( printf "char version[] = \"" ;                        \
09c1d0
    if test -e .os_version; then                            \
09c1d0
            cat .os_version | tr -d '\n' ;                  \
09c1d0
    elif command -v git >/dev/null; then                    \
09c1d0
            if [ -d .git ] ; then                           \
09c1d0
                    git describe --tags HEAD | tr -d '\n';  \
09c1d0
            else                                            \
09c1d0
                    printf "unknown" ;                      \
09c1d0
            fi ;                                            \
09c1d0
    else                                                    \
09c1d0
            printf "unknown" ;                              \
09c1d0
    fi ;                                                    \
09c1d0
    printf '";\n'                                           \
09c1d0
    ) > version.tmp
09c1d0
    [root@intel-purley-03 mcelog]# cat version.tmp
09c1d0
    char version[] = "mcelog-144-3.94d853b2ea81.el7";
09c1d0
    [root@intel-purley-03 mcelog]# rm .os_version
09c1d0
    rm: remove regular file ‘.os_version’? y
09c1d0
    [root@intel-purley-03 mcelog]# make version.tmp
09c1d0
    ( printf "char version[] = \"" ;                        \
09c1d0
    if test -e .os_version; then                            \
09c1d0
            cat .os_version | tr -d '\n' ;                  \
09c1d0
    elif command -v git >/dev/null; then                    \
09c1d0
            if [ -d .git ] ; then                           \
09c1d0
                    git describe --tags HEAD | tr -d '\n';  \
09c1d0
            else                                            \
09c1d0
                    printf "unknown" ;                      \
09c1d0
            fi ;                                            \
09c1d0
    else                                                    \
09c1d0
            printf "unknown" ;                              \
09c1d0
    fi ;                                                    \
09c1d0
    printf '";\n'                                           \
09c1d0
    ) > version.tmp
09c1d0
    [root@intel-purley-03 mcelog]# cat version.tmp
09c1d0
    char version[] = "v149-7-g62e645e4c0e9";
09c1d0
    
09c1d0
    ----8<----
09c1d0
    
09c1d0
    OSes package mcelog (rpm, deb, etc.) and the package version may differ
09c1d0
    from the git version.
09c1d0
    
09c1d0
    Add the ability for the OS to define a version in a local .os_version
09c1d0
    file.  If the file exists, the version in the file is returned for
09c1d0
    'mcelog --version'.  If the file isn't specified the old method of using
09c1d0
    git and defaulting to 'unknown' are used.
09c1d0
    
09c1d0
    Signed-off-by: Prarit Bhargava <prarit@redhat.com>
09c1d0
    Signed-off-by: Andi Kleen <ak@linux.intel.com>
09c1d0
09c1d0
diff --git a/Makefile b/Makefile
09c1d0
index 864378eb72de315f07d424540509e844241fd932..57373afaf6c77f40d2188dc855c5bc2bd5a02657 100644
09c1d0
--- a/Makefile
09c1d0
+++ b/Makefile
09c1d0
@@ -81,16 +81,20 @@ depend: .depend
09c1d0
 	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(WARNINGS) $(ADD_DEFINES) -o $@ $<
09c1d0
 
09c1d0
 version.tmp: FORCE
09c1d0
-	( echo -n "char version[] = \"" ; 	\
09c1d0
-	if command -v git >/dev/null; then 	\
09c1d0
-	if [ -d .git ] ; then 			\
09c1d0
-		git describe --tags HEAD | tr -d '\n'; 	\
09c1d0
-	else 					\
09c1d0
-		echo -n "unknown" ; 		\
09c1d0
-	fi ;					\
09c1d0
-	else echo -n "unknown" ; fi ;		\
09c1d0
-	echo '";'				\
09c1d0
-	 ) > version.tmp
09c1d0
+	( printf "char version[] = \"" ; 			\
09c1d0
+	if test -e .os_version; then				\
09c1d0
+		cat .os_version	| tr -d '\n' ;			\
09c1d0
+	elif command -v git >/dev/null; then 			\
09c1d0
+		if [ -d .git ] ; then 				\
09c1d0
+			git describe --tags HEAD | tr -d '\n'; 	\
09c1d0
+		else 						\
09c1d0
+			printf "unknown" ; 			\
09c1d0
+		fi ;						\
09c1d0
+	else							\
09c1d0
+		printf "unknown" ;				\
09c1d0
+	fi ;							\
09c1d0
+	printf '";\n'						\
09c1d0
+	) > version.tmp
09c1d0
 
09c1d0
 version.c: version.tmp
09c1d0
 	cmp version.tmp version.c || mv version.tmp version.c