From: thierry Date: Thu, 24 May 2007 15:56:07 +0000 (+0000) Subject: first draft for also supporting an easier tagging process - automatically handles... X-Git-Tag: foo~480 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=b62065fb307ce7fa5bc4d976b5e0cbeebeccd9e9;p=infrastructure.git first draft for also supporting an easier tagging process - automatically handles subversion in the spec file and performs tagging - probably a bit rough but a good start --- diff --git a/scripts/import-module.sh b/scripts/import-module.sh index 6151508..e506f67 100755 --- a/scripts/import-module.sh +++ b/scripts/import-module.sh @@ -16,7 +16,6 @@ svn="svn+ssh://thierry@svn.one-lab.org/svn" cvs=":pserver:anon@cvs.planet-lab.org:/cvs" import=$HOME/import-$module-$date - function message () { echo -n '-------------------- ' echo $@ @@ -103,11 +102,60 @@ function dir_needs_creation () { if [ -d "$dir" ] ; then echo n ; else echo y ; fi } +function svn_dir_needs_revert () { + dir=$1; shift + output=$(svn status $dir 2>&1) + if [ -n "$output" ] ; then echo y ; else echo n ; fi +} + +############################## +# guess spec files and extract from there +# search for otherwise expects a single *.spec file +function figure_module_spec () { + src=$1; shift + module=$1; shift + if [ -f $src/$module.spec ] ; then + echo $src/$module.spec + else + nbspecs=$(ls $src/*.spec | wc -l) + if [ $nbspecs = 1 ] ; then + echo $(ls $src/*.spec) + else + echo "$0: could not guess spec file in $src" + exit 1 + fi + fi +} + +function extract_from_spec () { + specfile=$1; shift + varname=$1; shift + if [ ! -f $specfile ] ; then + echo "Could not locate $specfile -- exiting" + exit 1 + fi + line=$(grep "^%define[ \t][ \t]*$varname" $specfile) + value=$(echo $line | sed -e "s,%define[ \t][ \t]*$varname[ \t][ \t]*,,") + echo $value +} + +function patch_in_spec () { + specfile=$1; shift + varname=$1; shift + value=$1; shift + + ### sed -i unsupported on MACOS + sed -e "s,^%define[ \t][ \t]*$varname[ \t].*$,%define $varname $value," $specfile > ${specfile}.new + mv ${specfile}.new $specfile +} + ############################## ############################## ############################## -cat <