Skip to content
Permalink
Browse files

Scripts improvements provided by Jeroen: OS check, parameter input fo…

…rmat validation and reset version script

git-svn-id: https://geonetwork.svn.sourceforge.net/svnroot/geonetwork/trunk@7147 ff403467-3f20-0410-99e5-ff581e626a08
  • Loading branch information
josegar74
josegar74 committed Jan 13, 2011
1 parent 15ee9e8 commit 7c2124d919627127362a3b712ca90182bb862926
Showing with 148 additions and 23 deletions.
  1. +73 −0 resetReleaseVersions.sh
  2. +43 −12 updateBranchVersions.sh
  3. +32 −11 updateReleaseVersions.sh
@@ -0,0 +1,73 @@
#!/bin/bash

# Usage to reset a version number from e.g. 2.7.1 to 2.7.0
# In root folder of branch code: ./resetReleaseVersions.sh 2.7.1 2.7.0

version="$1"
new_version="$2"

function showUsage
{
echo -e "\nThis script is used to reset a version number from e.g. 2.7.1 to 2.7.0"
echo
echo -e "Usage: ./`basename $0 $1` actual_version next_version"
echo
echo -e "Example to update file versions from 2.7.0 to 2.7.1:"
echo -e "\t./`basename $0 $1` 2.7.0 2.7.1"
echo
}

if [ "$1" = "-h" ]
then
showUsage
exit
fi

if [ $# -ne 2 ]
then
showUsage
exit
fi


if [[ $1 != [0-9].[0-9].[0-9] ]]; then
echo
echo 'Update failed due to incorrect versionnumber format: ' $1
echo 'The format should be three numbers separated by dots. e.g.: 2.7.0'
echo
echo "Usage: ./`basename $0 $1` 2.7.1 2.7.0"
echo
exit
fi

if [[ $2 != [0-9].[0-9].[0-9] ]]; then
echo
echo 'Update failed due to incorrect new versionnumber format (' $2 ')'
echo 'The format should be three numbers separated by dots. e.g.: 2.7.1'
echo
echo "Usage: ./`basename $0 $1` 2.7.1 2.7.0"
echo
exit
fi

# Note: In MacOS (darwin10.0) sed requires -i .bak as option to work properly
if [[ $OSTYPE == 'darwin10.0' ]]; then
sedopt='-i .bak'
else
sedopt='-i'
fi

echo
echo 'Your Operating System is' $OSTYPE
echo 'sed will use the following option: ' $sedopt
echo

# Update version in sphinx doc files
sed $sedopt "s/${version}/${new_version}/g" docs/eng/users/source/conf.py
sed $sedopt "s/${version}/${new_version}/g" docs/eng/developer/source/conf.py

# Update installer
sed $sedopt "s/\<property name=\"version\" value=\"${version}\" \/\>/\<property name=\"version\" value=\"${new_version}\" \/\>/g" installer/build.xml

# Update version pom files
find . -name pom.xml -exec sed $sedopt "s/${version}/${new_version}/g" {} \;
@@ -3,16 +3,15 @@
# Usage to update branch from a release 2.6.2 version to 2.6.3-SNAPSHOT version
# In root folder of branch code: ./updateBranchVersion.sh 2.6.2 2.6.3

# Note: In MacOs change seed -i to seed -i .bak to work properly

function showUsage
{
echo -e "\nThis script is used to update branch from a release version to next SNAPSHOT version. Should be used in branch after creating a new release (tag)."
echo -e "\nUsage:"
echo -e "\t`basename $0 $1` {actual_version} {next_version}"
echo -e "\nExample to update file versions from 2.6.2 to 2.6.3-SNAPSHOT:"
echo -e "\t`basename $0 $1` 2.6.2 2.6.3"
echo -e "\n"
echo
echo -e "Usage: ./`basename $0 $1` actual_version next_version"
echo
echo -e "Example to update file versions from 2.7.0 to 2.7.1-SNAPSHOT:"
echo -e "\t./`basename $0 $1` 2.7.0 2.7.1"
echo
}

if [ "$1" = "-h" ]
@@ -27,16 +26,48 @@ then
exit
fi

if [[ $1 != [0-9].[0-9].[0-9] ]]; then
echo
echo 'Update failed due to incorrect versionnumber format (' $1 ')'
echo 'The format should be three numbers separated by dots. e.g.: 2.7.0'
echo
echo "Usage: ./`basename $0 $1` 2.7.0 2.7.1"
echo
exit
fi

if [[ $2 != [0-9].[0-9].[0-9] ]]; then
echo
echo 'Update failed due to incorrect new versionnumber format (' $2 ')'
echo 'The format should be three numbers separated by dots. e.g.: 2.7.1'
echo
echo "Usage: ./`basename $0 $1` 2.7.0 2.7.1"
echo
exit
fi

# Note: In MacOS (darwin10.0) sed requires -i .bak as option to work properly
if [[ $OSTYPE == 'darwin10.0' ]]; then
sedopt='-i .bak'
else
sedopt='-i'
fi

echo
echo 'Your Operating System is' $OSTYPE
echo 'sed will use the following option: ' $sedopt
echo

version="$1"
new_version="$2"

# Update version in sphinx doc files
sed -i "s/${version}/${new_version}-SNAPSHOT/g" docs/eng/users/source/conf.py
sed -i "s/${version}/${new_version}-SNAPSHOT/g" docs/eng/developer/source/conf.py
sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" docs/eng/users/source/conf.py
sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" docs/eng/developer/source/conf.py

# Update installer
sed -i "s/\<property name=\"version\" value=\"${version}\" \/\>/\<property name=\"version\" value=\"${new_version}\" \/\>/g" installer/build.xml
sed -i "s/\<property name=\"subVersion\" value=\"0\" \/\>/\<property name=\"subVersion\" value=\"SNAPSHOT\" \/\>/g" installer/build.xml
sed $sedopt "s/\<property name=\"version\" value=\"${version}\" \/\>/\<property name=\"version\" value=\"${new_version}\" \/\>/g" installer/build.xml
sed $sedopt "s/\<property name=\"subVersion\" value=\"0\" \/\>/\<property name=\"subVersion\" value=\"SNAPSHOT\" \/\>/g" installer/build.xml

# Update version pom files
find . -name pom.xml -exec sed -i "s/${version}/${new_version}-SNAPSHOT/g" {} \;
find . -name pom.xml -exec sed $sedopt "s/${version}/${new_version}-SNAPSHOT/g" {} \;
@@ -3,16 +3,15 @@
# Usage to create 2.6.2 release version from 2.6.2-SNAPSHOT
# In root folder of branch code: ./updateReleaseVersion.sh 2.6.2

# Note: In MacOs change seed -i to seed -i .bak to work properly

function showUsage
{
echo -e "\nThis script is used to update branch from a SNAPSHOT version to a release version. Should be used in branch before creating a new release (tag)."
echo -e "\nUsage:"
echo -e "\t`basename $0 $1` {version}"
echo -e "\nExample to update file versions from 2.6.2-SNAPSHOT to 2.6.2:"
echo -e "\t`basename $0 $1` 2.6.2"
echo -e "\n"
echo
echo -e "Usage: `basename $0 $1` version"
echo
echo -e "Example to update file versions from 2.7.0-SNAPSHOT to 2.7.0:"
echo -e "\t`basename $0 $1` 2.7.0"
echo
}

if [ "$1" = "-h" ]
@@ -27,14 +26,36 @@ then
exit
fi

if [[ $1 != [0-9].[0-9].[0-9] ]]; then
echo
echo 'Update failed due to incorrect versionnumber format: ' $1
echo 'The format should be three numbers separated by dots. e.g.: 2.7.0'
echo
echo "Usage: ./`basename $0 $1` 2.7.0"
echo
exit
fi

# Note: In MacOS (darwin10.0) sed requires -i .bak as option to work properly
if [[ $OSTYPE == 'darwin10.0' ]]; then
sedopt='-i .bak'
else
sedopt='-i'
fi

echo
echo 'Your Operating System is' $OSTYPE
echo 'sed will use the following option: ' $sedopt
echo

version="$1"

# Update version in sphinx doc files
sed -i "s/${version}-SNAPSHOT/${version}/g" docs/eng/users/source/conf.py
sed -i "s/${version}-SNAPSHOT/${version}/g" docs/eng/developer/source/conf.py
sed $sedopt "s/${version}-SNAPSHOT/${version}/g" docs/eng/users/source/conf.py
sed $sedopt "s/${version}-SNAPSHOT/${version}/g" docs/eng/developer/source/conf.py

# Update installer
sed -i "s/\<property name=\"subVersion\" value=\"SNAPSHOT\" \/\>/\<property name=\"subVersion\" value=\"0\" \/\>/g" installer/build.xml
sed $sedopt "s/\<property name=\"subVersion\" value=\"SNAPSHOT\" \/\>/\<property name=\"subVersion\" value=\"0\" \/\>/g" installer/build.xml

# Update version pom files
find . -name pom.xml -exec sed -i "s/${version}-SNAPSHOT/${version}/g" {} \;
find . -name pom.xml -exec sed $sedopt "s/${version}-SNAPSHOT/${version}/g" {} \;

0 comments on commit 7c2124d

Please sign in to comment.
You can’t perform that action at this time.