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

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m
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].
 +
 
The following script may be invoked as:
 
The following script may be invoked as:
 
   ./conco -v modules=smokretestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v async=f -v tag=SRC680_m203
 
   ./conco -v modules=smokretestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v async=f -v tag=SRC680_m203

Revision as of 16:59, 6 March 2007

This script has been pointed to by an GullFOSS entry.

The following script may be invoked as:

 ./conco -v modules=smokretestoo_native -v CVS="anoncvs@anoncvs.services.openoffice.org" -v async=f -v tag=SRC680_m203

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

#!/usr/bin/awk -f

function co(modules,amodules,i,j) {
  shell="/bin/sh"

  cvscmd = "cvs '-d:pserver:%s:/cvs' co -r%s %s > /dev/null "
  if (async == "t")
    cvscmd = cvscmd "&"

  cvscmd = cvscmd "\n"

  split(modules,amodules)
  j = 0 # Maximum number of concurrent jobs.
  for (i in amodules) {
    if (j == 0) {
      j = 30 # Maximum number of concurrent jobs.
      printf("wait\n") | shell
    }
    printf(cvscmd,CVS,tag,amodules[i]) | shell
    j --
  }
 
  printf("wait\n") | shell
  close(shell)
}

BEGIN {
  print "modules: " modules
  print "CVS: "     CVS
  print "tag:"      tag
  print "async: "   async

  # smodules: The module status array.
  walkDependencies(modules)

  # Unfortunately, there are some modules, which somehow are not reachable by
  # the dependencies.
  bmodules="config_office dmake default_images external_images lingucomponent"
  asorti(smodules,dest)
  for (i in dest) {
    if (smodules[dest[i]] == 2) {
      bmodules=bmodules " " dest[i]
    }
  }

  print "checking out needed modules: " bmodules " ..."
  co(bmodules) 
}

function walkDependencies(modules,cnt,recs,line,nf,i,j,module) {
  if (length(modules) <= 0)
    return

  split(modules,amodules)

  # CO "build.lst" of wanted modules.
  bmodules=""
  for (i in amodules) {
    if (!(amodules[i] in smodules) || smodules[amodules[i]] == 0) {
      smodules[amodules[i]] = 1 # mark this module as tested
      bmodules=bmodules " " amodules[i]"/prj/build.lst"
    }
  }

  print "getting build.lst for " bmodules " ..."
  co(bmodules)

  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) {
      smodules[amodules[i]] = 2 # Mark this module as valid.
      close(amodules[i]"/prj/build.lst")

      # 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) {
          tmp=index(recs[j],":")
          if (tmp == 0)
            tmp=1
          else
            tmp=tmp+1

          module=substr(recs[j],tmp)
          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)
}
Personal tools