Difference between revisions of "User:Kr/Concurrent Checkout"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Fixed typo.)
m (The Code: Some code hightlightning ... though "awk" was not available as a language ;-))
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
This script has been pointed to by an [http://blogs.sun.com/GullFOSS/ GullFOSS] [http://blogs.sun.com/GullFOSS/entry/aawax_or_how_to_check entry].
 
This script has been pointed to by an [http://blogs.sun.com/GullFOSS/ GullFOSS] [http://blogs.sun.com/GullFOSS/entry/aawax_or_how_to_check entry].
  
The following script may be invoked as:
+
==Parameters==
  ./conco -v modules=smoketestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v async=f -v tag=SRC680_m203
+
* CWS - the name of a CWS
 
+
* Milestone - the name of a milestone, this is mutual exclusive wrt CWS
The handling of concurrent check outs is far from optimal, there is much room for improvement :-)
+
* Master - the master
 +
* CVS - the CVS server, defaults to "anoncvs@anoncvs.services.openoffice.org"
 +
* modules - the modules, defaults to "smoketestoo_native"
  
 +
==Examples==
 
<pre>
 
<pre>
#!/usr/bin/awk -f
+
# Check out a particular CWS
 +
conco.awk -v Master=SRC680 -v CWS=bunoexttm
  
function co(modules,amodules,i,j) {
+
# Check out a particular MWS
  shell="/bin/sh"
+
conco.awk -v Master=SRC680 -v Milestone=m215
  
  cvscmd = "cvs '-d:pserver:%s:/cvs' co -r%s %s > /dev/null "
+
# More complex CWS check out
  if (async == "t")
+
conco.awk -v modules=smoketestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v Master=SRC680 -v CWS=bunoexttm
    cvscmd = cvscmd "&"
+
 
 +
# More complex master check out
 +
conco.awk -v modules=smoketestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v Master=SRC680 -v Milestone=m203
 +
</pre>
 +
 
 +
==Comments==
 +
The handling of concurrent check outs is far from optimal, there is much room for improvement :-)
 +
 
 +
==The Code==
 +
<source lang="bash">
 +
#!/usr/bin/awk -f
  
   cvscmd = cvscmd "\n"
+
function coModules(modules,dirname,tag,module,amodules,i,j) {
 +
   cvscmd = "cvs '-d:pserver:%s:/cvs' co %s %s > /dev/null &\n"
  
 
   split(modules,amodules)
 
   split(modules,amodules)
 
   j = 0 # Maximum number of concurrent jobs.
 
   j = 0 # Maximum number of concurrent jobs.
 
   for (i in amodules) {
 
   for (i in amodules) {
     if (j == 0) {
+
     if (j <= 0) {
       j = 30 # Maximum number of concurrent jobs.
+
       j = jobs # Maximum number of concurrent jobs.
       printf("wait\n") | shell
+
       printf("wait\n") | Shell
 
     }
 
     }
     printf(cvscmd,CVS,tag,amodules[i]) | shell
+
 
 +
    module = amodules[i]
 +
 
 +
    if (split(module,temp,"@") == 2) {
 +
      dirname = temp[1]
 +
      tag    = "-r"temp[2]
 +
    }
 +
    else
 +
      dirname = module
 +
 
 +
     printf(cvscmd,CVS,tag,dirname) | Shell
 
     j --
 
     j --
 
   }
 
   }
 
   
 
   
   printf("wait\n") | shell
+
   printf("wait\n") | Shell
   close(shell)
+
   close(Shell)
 
}
 
}
  
BEGIN {
+
function queryMilestone(cws,milestone) {
   print "modules: " modules
+
   print "export SOLARENV=./solenv"                               |& Shell
   print "CVS: "     CVS
+
   print "$SOLARENV/bin/cwsquery -m " Master " -c " cws " current" |& Shell
  print "tag:"     tag
+
   Shell |& getline milestone
   print "async: "   async
+
   close(Shell)
  
   # smodules: The module status array.
+
   return milestone
  walkDependencies(modules)
+
}
  
  # Unfortunately, there are some modules, which somehow are not reachable by
+
function queryModules(modules) {
   # the dependencies.
+
   print "export WORK_STAMP=" Master            |& Shell
   bmodules="config_office dmake default_images external_images lingucomponent"
+
   print "export CWS_WORK_STAMP=" CWS            |& Shell
   asorti(smodules,dest)
+
   print "export SOLARENV=./solenv"              |& Shell
  for (i in dest) {
+
  print "echo `$SOLARENV/bin/cwsquery modules`" |& Shell
    if (smodules[dest[i]] == 2) {
+
  Shell |& getline modules
      bmodules=bmodules " " dest[i]
+
   close(Shell)
    }
+
   }
+
  
   print "checking out needed modules: " bmodules " ..."
+
   return modules
  co(bmodules)
+
 
}
 
}
  
function walkDependencies(modules,cnt,recs,line,nf,i,j,module) {
+
 
 +
function walkDependencies(modules,tags,smodules,amodules,cnt,recs,line,nf,i,j,module) {
 
   if (length(modules) <= 0)
 
   if (length(modules) <= 0)
 
     return
 
     return
Line 63: Line 86:
  
 
   # CO "build.lst" of wanted modules.
 
   # CO "build.lst" of wanted modules.
   bmodules=""
+
   modules=""
 
   for (i in amodules) {
 
   for (i in amodules) {
     if (!(amodules[i] in smodules) || smodules[amodules[i]] == 0) {
+
     module = amodules[i]
       smodules[amodules[i]] = 1 # mark this module as tested
+
 
       bmodules=bmodules " " amodules[i]"/prj/build.lst"
+
    if (!(module in smodules) || smodules[module] == 0) {
 +
       smodules[module] = 1 # mark this module as tested
 +
 
 +
       if (!(module in tags)) # no tagged yet?
 +
        tags[module] = Master Milestone
 +
 
 +
      modules=modules " " module"/prj/build.lst@" tags[module]
 
     }
 
     }
 
   }
 
   }
  
   print "getting build.lst for " bmodules " ..."
+
   print "getting build.lst for " modules " ..."
   co(bmodules)
+
   coModules(modules)
 +
 
  
 
   modules=""
 
   modules=""
Line 79: Line 109:
 
     # Check if the module is there now, otherwise ignore it.
 
     # Check if the module is there now, otherwise ignore it.
 
     if (getline < (amodules[i]"/prj/build.lst") >= 0) {
 
     if (getline < (amodules[i]"/prj/build.lst") >= 0) {
      smodules[amodules[i]] = 2 # Mark this module as valid.
 
 
       close(amodules[i]"/prj/build.lst")
 
       close(amodules[i]"/prj/build.lst")
 +
 +
      smodules[amodules[i]] = 2 # Mark this module as valid.
  
 
       # Get dependencies.
 
       # Get dependencies.
Line 93: Line 124:
 
         j = 4
 
         j = 4
 
         while(j < nf) {
 
         while(j < nf) {
           tmp=index(recs[j],":")
+
           if (split(recs[j],temp,":") == 2)
          if (tmp == 0)
+
             module = temp[2]
             tmp=1
+
           else  
           else
+
             module = temp[1]
             tmp=tmp+1
+
  
          module=substr(recs[j],tmp)
 
 
           if (!(module in smodules)) {
 
           if (!(module in smodules)) {
 
             modules = modules " " module
 
             modules = modules " " module
Line 113: Line 142:
 
   }
 
   }
  
   walkDependencies(modules)
+
   walkDependencies(modules,tags,smodules)
 
}
 
}
</pre>
+
 
 +
function findDependencies(modules,tags,smodules,temp) {
 +
  walkDependencies(modules,tags,smodules)
 +
 
 +
  modules=""
 +
  asorti(smodules,temp)
 +
  for (i in temp) {
 +
    if (smodules[temp[i]] == 2) {
 +
      modules=modules " " temp[i]
 +
 
 +
      if (temp[i] in tags) # need to tag
 +
        modules = modules "@" tags[temp[i]]
 +
      else
 +
        modules = modules "@" Master Milestone
 +
    }
 +
  }
 +
 
 +
  return modules
 +
}
 +
 
 +
BEGIN {
 +
  Shell      ="/bin/sh"
 +
  DefModules = "smoketestoo_native"
 +
  DefCVS    = "anoncvs@anoncvs.services.openoffice.org"
 +
 
 +
  # Fall back for modules.
 +
  if (modules == "") {
 +
    print "No modules given (-v modules=<name>*)"
 +
    print "falling back to " DefModules
 +
    print
 +
 
 +
    modules = DefModules
 +
  }
 +
     
 +
  # Fall back for CVS server.
 +
  if (CVS == "") {
 +
    print "No CVS server given (-v CVS=<server>)"
 +
    print "falling back to " DefCVS
 +
    print
 +
 
 +
    CVS = DefCVS
 +
  }
 +
     
 +
  if (jobs == "") {
 +
    if (CVS == "anoncvs@anoncvs.services.openoffice.org")
 +
      jobs = 3
 +
    else
 +
      jobs = 35
 +
  }
 +
 
 +
  if (CWS != "") {
 +
    coModules("solenv@" Master)
 +
    Milestone = queryMilestone(CWS)
 +
    cwsModules = queryModules()
 +
    print "rm -r solenv" | Shell
 +
    close(Shell)
 +
 
 +
    split(cwsModules,temp)
 +
    for (i in temp) {
 +
      tags[temp[i]] = "cws_" tolower(Master) "_" tolower(CWS)
 +
    }
 +
  }
 +
 
 +
  print "modules: "  modules
 +
  print "CVS: "      CVS
 +
  print "Master:"    Master
 +
  print "cws:"      CWS
 +
  print "jobs: "    jobs
 +
  print "milestone:" Milestone
 +
 
 +
  Milestone = "_" Milestone
 +
 
 +
 
 +
  # Unfortunately, there are some modules, which somehow are not reachable by
 +
  # the dependencies.
 +
  smodules["config_office"  ]=2
 +
  smodules["dmake"          ]=2
 +
  smodules["default_images" ]=2
 +
  smodules["external_images"]=2
 +
  smodules["lingucomponent" ]=2
 +
  modules=findDependencies(modules,tags,smodules)
 +
 
 +
  print "checking out needed modules: " modules " ..."
 +
  coModules(modules, Master)
 +
}
 +
</source>

Latest revision as of 14:32, 3 December 2008

This script has been pointed to by an GullFOSS entry.

Parameters

  • CWS - the name of a CWS
  • Milestone - the name of a milestone, this is mutual exclusive wrt CWS
  • Master - the master
  • CVS - the CVS server, defaults to "anoncvs@anoncvs.services.openoffice.org"
  • modules - the modules, defaults to "smoketestoo_native"

Examples

# Check out a particular CWS
conco.awk -v Master=SRC680 -v CWS=bunoexttm

# Check out a particular MWS
conco.awk -v Master=SRC680 -v Milestone=m215

# More complex CWS check out
conco.awk -v modules=smoketestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v Master=SRC680 -v CWS=bunoexttm

# More complex master check out
conco.awk -v modules=smoketestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v Master=SRC680 -v Milestone=m203

Comments

The handling of concurrent check outs is far from optimal, there is much room for improvement :-)

The Code

#!/usr/bin/awk -f
 
function coModules(modules,dirname,tag,module,amodules,i,j) {
  cvscmd = "cvs '-d:pserver:%s:/cvs' co %s %s > /dev/null &\n"
 
  split(modules,amodules)
  j = 0 # Maximum number of concurrent jobs.
  for (i in amodules) {
    if (j <= 0) {
      j = jobs # Maximum number of concurrent jobs.
      printf("wait\n") | Shell
    }
 
    module = amodules[i]
 
    if (split(module,temp,"@") == 2) {
      dirname = temp[1]
      tag     = "-r"temp[2]
    }
    else 
      dirname = module
 
    printf(cvscmd,CVS,tag,dirname) | Shell
    j --
  }
 
  printf("wait\n") | Shell
  close(Shell)
}
 
function queryMilestone(cws,milestone) {
  print "export SOLARENV=./solenv"                                |& Shell
  print "$SOLARENV/bin/cwsquery -m " Master " -c " cws " current" |& Shell
  Shell |& getline milestone
  close(Shell)
 
  return milestone
}
 
function queryModules(modules) {
  print "export WORK_STAMP=" Master             |& Shell
  print "export CWS_WORK_STAMP=" CWS            |& Shell
  print "export SOLARENV=./solenv"              |& Shell
  print "echo `$SOLARENV/bin/cwsquery modules`" |& Shell
  Shell |& getline modules
  close(Shell)
 
  return modules
}
 
 
function walkDependencies(modules,tags,smodules,amodules,cnt,recs,line,nf,i,j,module) {
  if (length(modules) <= 0)
    return
 
  split(modules,amodules)
 
  # CO "build.lst" of wanted modules.
  modules=""
  for (i in amodules) {
    module = amodules[i]
 
    if (!(module in smodules) || smodules[module] == 0) {
      smodules[module] = 1 # mark this module as tested
 
      if (!(module in tags)) # no tagged yet?
        tags[module] = Master Milestone
 
      modules=modules " " module"/prj/build.lst@" tags[module]
    }
  }
 
  print "getting build.lst for " modules " ..."
  coModules(modules)
 
 
  modules=""
  # Walk the dependencies.
  for (i in amodules) {
    # Check if the module is there now, otherwise ignore it.
    if (getline < (amodules[i]"/prj/build.lst") >= 0) {
      close(amodules[i]"/prj/build.lst")
 
      smodules[amodules[i]] = 2 # Mark this module as valid.
 
      # Get dependencies.
      do { 
        cnt = getline line < (amodules[i]"/prj/build.lst")
      }
      while(cnt >= 0 && line ~ /^#.*/)
      close(amodules[i]"/prj/build.lst")
 
      if (cnt >= 0) {
        nf = split(line, recs)
        j = 4
        while(j < nf) {
          if (split(recs[j],temp,":") == 2)
            module = temp[2]
          else 
            module = temp[1]
 
          if (!(module in smodules)) {
            modules = modules " " module
            smodules[module] = 0
          }
 
          j=j + 1
        }
      }
    }
    else
      smodules[amodules[i]] = 1 # Mark this module as invalid.
  }
 
  walkDependencies(modules,tags,smodules)
}
 
function findDependencies(modules,tags,smodules,temp) {
  walkDependencies(modules,tags,smodules)
 
  modules=""
  asorti(smodules,temp)
  for (i in temp) {
    if (smodules[temp[i]] == 2) {
      modules=modules " " temp[i]
 
      if (temp[i] in tags) # need to tag
        modules = modules "@" tags[temp[i]]
      else
        modules = modules "@" Master Milestone
    }
  }
 
  return modules
}
 
BEGIN {
  Shell      ="/bin/sh"
  DefModules = "smoketestoo_native"
  DefCVS     = "anoncvs@anoncvs.services.openoffice.org"
 
  # Fall back for modules.
  if (modules == "") {
    print "No modules given (-v modules=<name>*)"
    print "falling back to " DefModules
    print
 
    modules = DefModules
  }
 
  # Fall back for CVS server.
  if (CVS == "") {
    print "No CVS server given (-v CVS=<server>)"
    print "falling back to " DefCVS
    print
 
    CVS = DefCVS
  }
 
  if (jobs == "") {
    if (CVS == "anoncvs@anoncvs.services.openoffice.org")
      jobs = 3
    else
      jobs = 35
  }
 
  if (CWS != "") {
    coModules("solenv@" Master)
    Milestone = queryMilestone(CWS)
    cwsModules = queryModules()
    print "rm -r solenv" | Shell
    close(Shell)
 
    split(cwsModules,temp)
    for (i in temp) {
      tags[temp[i]] = "cws_" tolower(Master) "_" tolower(CWS)
    }
  }
 
  print "modules: "  modules
  print "CVS: "      CVS
  print "Master:"    Master
  print "cws:"       CWS
  print "jobs: "     jobs
  print "milestone:" Milestone
 
  Milestone = "_" Milestone
 
 
  # Unfortunately, there are some modules, which somehow are not reachable by
  # the dependencies.
  smodules["config_office"  ]=2
  smodules["dmake"          ]=2
  smodules["default_images" ]=2
  smodules["external_images"]=2
  smodules["lingucomponent" ]=2
  modules=findDependencies(modules,tags,smodules)
 
  print "checking out needed modules: " modules " ..."
  coModules(modules, Master) 
}
Personal tools