#! /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
_=${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
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
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() {
get_linux_version() {
local file=$1
+ local extra=$2
local ret=""
while IFS='' read -r line || [[ -n "$line" ]]; do
key=$(trim ${line%%=*})
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
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*)
# 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