Updated the wrapfs-patch-release.sh script to give appropriate patch file.
authorrohit <rohit>
Sun, 6 May 2018 03:22:17 +0000 (03:22 +0000)
committerrohit <rohit>
Sun, 6 May 2018 03:22:17 +0000 (03:22 +0000)
wrapfs-patch-release.sh

index 9b043675201608cb75cba8ac003b3bc1a03f42b0..2c73d71d768dfa904f5416fbbdd07a0b21ac0ea8 100755 (executable)
@@ -1,4 +1,34 @@
 #! /bin/bash
+# We can use this script for the following:
+# 1.) Updating the kernel version to the korg latest linux version - 
+#       Run it without any arguments. No patchfile will be released. For e.g.:
+#
+#       ./wrapfs-patch-release.sh 
+#
+# 2.) Updating it to a known linux release version - 
+#       Use '-v' or '--version' and pass the respective linux version.
+#       No patch file will be released. For e.g.:
+#       
+#       ./wrapfs-patch-release.sh -v 2.6.32.21
+#
+#       ./wrapfs-patch-release.sh --version 2.6.32.21
+#
+# 3.) Releasing a patch file with specific kernel version
+#       Use '-r' or '--release-patch' option. For e.g. -
+#
+#       ./wrapfs-patch-release.sh --version 2.6.32.21 -r yes
+#
+#       ./wrapfs-patch-release.sh --version 2.6.32.21 --release-patch yes
+#
+# 4.) Releasing a patch file with current kernel version
+#       Does a git pull to the latest kernel released version on master branch. 
+#       Does a merge of master branch on wrapfs branch and then releases a
+#       respective patch. Use '-r' or '--release-patch' option. For e.g. -
+#
+#       ./wrapfs-patch-release.sh -r yes
+#
+#       ./wrapfs-patch-release.sh --release-patch yes
+#
 
 set -u -e
 
@@ -6,7 +36,8 @@ _=${LINUX_VERSION:=""}
 _=${LINUX_BRANCH:=""}
 _=${LOCATION:=$(pwd)}
 _=${PATCH_FILE:=""}
-_=${LINUX_PATCH_VERSION:=""}
+_=${RELEASE_PATCH:=""}
+_=${PATCH_VERSION:=""}
 
 # check if the script is running for a git repository or not 
 if [ ! -d .git ]; then
@@ -14,14 +45,13 @@ if [ ! -d .git ]; then
     exit
 fi
 
-TEMP=`getopt -o v:p: --long version:patch: -n 'parse-options' -- "$@"`
-
+TEMP=`getopt -o v:r: --long version: --long release-patch: -n 'parse-options' -- "$@"`
 eval set -- "$TEMP"
 
 while true; do
   case "$1" in
     -v | --version ) LINUX_VERSION=$2; shift 2;;
-    -p | --patch ) PATCH_FILE=$2; shift 2;;
+    -r | --release-patch ) RELEASE_PATCH=$2; shift 2;;
     -- ) shift;break;;
     * ) echo $1; break;;
   esac
@@ -43,7 +73,8 @@ patch() {
   local src="$1"
   local dest="wrapfs"
   local file="$2"
-  echo "runcmd git diff -u $src..$dest > $2"
+  runcmd git diff -u $src..$dest > $2
+  runcmd gzip $2
 }
 
 trim() {
@@ -57,6 +88,7 @@ trim() {
 
 get_linux_version() {
   local file=$1
+  local extra=$2
   local ret=""
   while IFS='' read -r line || [[ -n "$line" ]]; do
     key=$(trim ${line%%=*})
@@ -70,6 +102,9 @@ get_linux_version() {
     if [[ $key == "SUBLEVEL" ]]; then
       ret=${ret}.${value}
     fi
+    if [[ $key == "EXTRAVERSION"  && $extra == "true" ]]; then
+      ret=${ret}${value}
+    fi
     if [ -z "$key" ] || [ -z "$value" ]; then
       break;
     fi
@@ -93,7 +128,7 @@ if [ -z "${WRAPFS_REPO:+x}" ]; then
     exit 1
 fi
 
-WRAPFS_KERNEL_VERSION=$(get_linux_version $LOCATION/Makefile)
+WRAPFS_KERNEL_VERSION=$(get_linux_version $LOCATION/Makefile "false")
 
 case "$WRAPFS_REPO" in
     wrapfs-latest*)
@@ -132,14 +167,18 @@ runcmd git pull wrapfs wrapfs
 # Merge master on wrapfs
 runcmd git merge master
 
-if [ -n "${PATCH_FILE:+x}" ]; then
+if [ "${RELEASE_PATCH}" == "yes" ]; then
+  describe=`git describe`
+  PATCH_FILE="wrapfs-${describe}.diff"
+
   # Release patch with latest linux
   if [[ "$LINUX_VERSION" != "" ]]; then
-    LINUX_PATCH_VERSION="v$LINUX_VERSION"
-    patch $LINUX_PATCH_VERSION $PATCH_FILE
+    PATCH_VERSION="v${LINUX_VERSION}"
+    patch $PATCH_VERSION $PATCH_FILE
   else 
-    LINUX_PATCH_VERSION=`git describe`
-    patch $LINUX_PATCH_VERSION $PATCH_FILE
+    PATCH_VERSION=$(get_linux_version $LOCATION/Makefile "true")
+    PATCH_VERSION="v$PATCH_VERSION"
+    patch $PATCH_VERSION $PATCH_FILE
   fi
 fi