now handles *-tags.mk in build for adopting the new tag - probably needs some rework...
authorthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Thu, 7 Jun 2007 14:21:03 +0000 (14:21 +0000)
committerthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Thu, 7 Jun 2007 14:21:03 +0000 (14:21 +0000)
scripts/import-module.sh

index e506f67..298eb76 100755 (executable)
@@ -108,6 +108,12 @@ function svn_dir_needs_revert () {
    if [ -n "$output" ] ; then echo y ; else echo n ; fi
 }
 
+function svn_file_needs_commit () {
+   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 <module.spec> otherwise expects a single *.spec file
@@ -289,9 +295,6 @@ function tag_module () {
 
     echo 'Tagging' $module
 
-    run_prompt $(dir_needs_creation $tagwork) "Creating $tagwork" \
-        mkdir -p $tagwork
-
     run_prompt $(dir_needs_creation $tagtrunk) "Checking out $tagtrunk" \
         svn co $svn/$module/trunk $tagtrunk
 
@@ -348,9 +351,33 @@ function tag_module () {
     run_prompt y "Creating tag $newtag" \
        svn copy --message "$module-${version}.${newsubversion}" $svn/$module/trunk $newtag
 
-    echo "This command does not handle changes in onelab-tags.mk - yet"
-
-    
+    # make changes in build/*-tags.mk
+    tagbuild=$HOME/tags/build/trunk
+    oldname=$module-${version}.${subversion}
+    newname=$module-${version}.${newsubversion}
+
+    run_prompt $(dir_needs_creation $tagbuild) "Checking out $tagbuild" \
+        svn co $svn/$module/build $tagbuild
+
+    run_prompt y "Updating $tagbuild" \
+        svn up $tagbuild
+
+    run_prompt $(svn_dir_needs_revert $tagbuild) "Reverting $tagbuild for safety " \
+        svn revert -R $tagbuild
+
+    run "cd $tagbuild" \
+       cd $tagbuild
+
+    for tagsmk in *-tags.mk; do
+       echo "Managing $tagsmk"
+       sed -i -e "s,$oldname,$newname,g" $tagsmk
+       if [ $(svn_file_needs_commit $tagsmk) = "y" ] ; then
+          echo "Changes in $tagsmk"
+          svn diff $tagsmk
+          run_prompt y "Adopt $newname in $tagsmk " \
+              svn commit -m"Adopting-$newname" $tagsmk
+       fi
+    done    
 }
 
 case $0 in