Fixed wrapfs-patch-release.sh script to update master to current korg kernel version...
authorrohit <rohit>
Sun, 6 May 2018 00:14:58 +0000 (00:14 +0000)
committerrohit <rohit>
Sun, 6 May 2018 00:14:58 +0000 (00:14 +0000)
wrapfs-fix-branch.sh
wrapfs-patch-release.sh

index a77189412577ca5d74dffcdafce135c8ed92ef1c..ec6cc2d7a774ba4765c74eb703abe7948ae4c62d 100755 (executable)
@@ -5,8 +5,7 @@ set -u -e
 _=${LINUX_REPO:=""}
 _=${LINUX_BRANCH:=""}
 _=${LOG_FILE:="/tmp/wrapfs-fix-branch.log"}
-_=${SCRIPT:=$(readlink -f $0)}
-_=${LOCATION:=$(dirname $SCRIPT)}
+_=${LOCATION:=$(pwd)}
 
 # check if the script is running for a git repository or not 
 if [ ! -d .git ]; then
@@ -48,14 +47,49 @@ runcmd() {
     fi
 }
 
+trim() {
+    local var="$*"
+    # remove leading whitespace characters
+    var="${var#"${var%%[![:space:]]*}"}"
+    # remove trailing whitespace characters
+    var="${var%"${var##*[![:space:]]}"}"   
+    echo -n "$var"
+}
+
+get_linux_version() {
+  local file=$1
+  local ret=""
+  while IFS='' read -r line || [[ -n "$line" ]]; do
+    key=$(trim ${line%%=*})
+    value=$(trim ${line#*=})
+    if [[ $key == "VERSION" ]]; then
+      ret=${ret}${value}
+    fi
+    if [[ $key == "PATCHLEVEL" ]]; then
+      ret=${ret}.${value}
+    fi
+    if [[ $key == "SUBLEVEL" ]]; then
+      ret=${ret}.${value}
+    fi
+    if [[ $key == "EXTRAVERSION" ]]; then
+      ret=${ret}${value}
+    fi
+    if [ -z "$key" ] || [ -z "$value" ]; then
+      break;
+    fi
+  done < $file
+  echo -n $ret
+}
+
 case "$WRAPFS_REPO" in
     wrapfs-latest*)
        LINUX_REPO="torvalds/linux.git"
-        LINUX_BRANCH="master"
+        LINUX_BRANCH="korg/master"
        ;;
     wrapfs-2.* | wrapfs-3.* | wrapfs-4.* ) 
        LINUX_REPO="stable/linux-stable.git"
-        LINUX_BRANCH=$(echo $WRAPFS_REPO | sed s/wrapfs/linux/g | sed s/\.git//g)
+        LINUX_BRANCH=$(get_linux_version $LOCATION/Makefile)
+        LINUX_BRANCH="v$LINUX_BRANCH"
        ;;
     * )
         echo "$WRAPFS_REPO: Unidentified repository. Script support only for wrapfs repository."
@@ -91,7 +125,7 @@ fi
 
 # Fetch correct tags for respective linux version
 runcmd git fetch korg --tags $LINUX_BRANCH
-runcmd git reset --hard korg/$LINUX_BRANCH
+runcmd git reset --hard $LINUX_BRANCH
 
 # Reset master to linux code base
 runcmd git push -f origin master
@@ -105,3 +139,4 @@ if [ -z "${wrapfs_remote_branch:+x}" ]; then
 else
     runcmd git branch -r
 fi
+
index 14bee9bdb6ae9ad3ecebac6804355ad6a2644331..9b043675201608cb75cba8ac003b3bc1a03f42b0 100755 (executable)
@@ -6,6 +6,7 @@ _=${LINUX_VERSION:=""}
 _=${LINUX_BRANCH:=""}
 _=${LOCATION:=$(pwd)}
 _=${PATCH_FILE:=""}
+_=${LINUX_PATCH_VERSION:=""}
 
 # check if the script is running for a git repository or not 
 if [ ! -d .git ]; then
@@ -26,11 +27,6 @@ while true; do
   esac
 done
 
-if [ -z "${PATCH_FILE:+x}" ]; then
-  echo "Please give a path file name using -patch or -p option."
-  exit 1
-fi
-
 # function to execute commands 
 runcmd() {
     echo "----------------------------------------------------------------------"
@@ -44,10 +40,10 @@ runcmd() {
 }
 
 patch() {
-  local src="v$1"
+  local src="$1"
   local dest="wrapfs"
   local file="$2"
-  runcmd git diff -u $src..$dest > $2
+  echo "runcmd git diff -u $src..$dest > $2"
 }
 
 trim() {
@@ -74,9 +70,6 @@ get_linux_version() {
     if [[ $key == "SUBLEVEL" ]]; then
       ret=${ret}.${value}
     fi
-    if [[ $key == "EXTRAVERSION" ]]; then
-      ret=${ret}${value}
-    fi
     if [ -z "$key" ] || [ -z "$value" ]; then
       break;
     fi
@@ -123,7 +116,8 @@ runcmd git fetch korg --tags $LINUX_BRANCH
 if [[ "$LINUX_VERSION" != "" ]]; then
   runcmd git reset --hard "v$LINUX_VERSION"
 else 
-  runcmd git reset --hard "v$WRAPFS_KERNEL_VERSION"
+  #echo "runcmd git reset --hard "v$WRAPFS_KERNEL_VERSION""
+  runcmd git pull korg "linux-${WRAPFS_KERNEL_VERSION}.y"
 fi
 
 # Push the latest chnages from korg to origin
@@ -138,10 +132,14 @@ runcmd git pull wrapfs wrapfs
 # Merge master on wrapfs
 runcmd git merge master
 
-# Release patch with latest linux
-if [[ "$LINUX_VERSION" != "" ]]; then
-  patch $LINUX_VERSION $PATCH_FILE
-else 
-  patch $WRAPFS_KERNEL_VERSION $PATCH_FILE
+if [ -n "${PATCH_FILE:+x}" ]; then
+  # Release patch with latest linux
+  if [[ "$LINUX_VERSION" != "" ]]; then
+    LINUX_PATCH_VERSION="v$LINUX_VERSION"
+    patch $LINUX_PATCH_VERSION $PATCH_FILE
+  else 
+    LINUX_PATCH_VERSION=`git describe`
+    patch $LINUX_PATCH_VERSION $PATCH_FILE
+  fi
 fi