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

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m
Line 1: Line 1:
 +
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 :-)
 +
 
<pre>
 
<pre>
 
#!/usr/bin/awk -f
 
#!/usr/bin/awk -f
  
#39
+
function co(modules,amodules,i,j) {
 
+
function co(modules,amodules) {
+
 
   shell="/bin/sh"
 
   shell="/bin/sh"
   CVSserver="anoncvs@anoncvs.services.openoffice.org"
+
 
#  CVSserver="kr@mytunnel"
+
   cvscmd = "cvs '-d:pserver:%s:/cvs' co -r%s %s > /dev/null "
 +
  if (async == "t")
 +
    cvscmd = cvscmd "&"
 +
 
 +
  cvscmd = cvscmd "\n"
  
 
   split(modules,amodules)
 
   split(modules,amodules)
 +
  j = 0 # Maximum number of concurrent jobs.
 
   for (i in amodules) {
 
   for (i in amodules) {
     printf("cvs '-d:pserver:%s:/cvs' co -rSRC680_m203 %s \n",CVSserver,amodules[i]) | shell
+
     if (j == 0) {
#    printf("cvs '-d:pserver:%s:/cvs' co -rSRC680_m203 %s > /dev/null &\n",CVSserver,amodules[i]) | shell
+
      j = 30 # Maximum number of concurrent jobs.
 +
      printf("wait\n") | shell
 +
    }
 +
    printf(cvscmd,CVS,tag,amodules[i]) | shell
 +
    j --
 
   }
 
   }
 
   
 
   
Line 20: Line 32:
  
 
BEGIN {
 
BEGIN {
   # smodules: module status array
+
   print "modules: " modules
   ana("instsetoo_native")
+
   print "CVS: "     CVS
#  ana("instsetoo_native")
+
  print "tag:"     tag
 +
  print "async: "  async
  
   bmodules="config_office dmake"
+
  # smodules: The module status array.
   n = asorti(smodules,dest)
+
  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) {
 
   for (i in dest) {
 
     if (smodules[dest[i]] == 2) {
 
     if (smodules[dest[i]] == 2) {
Line 36: Line 54:
 
}
 
}
  
function ana(modules,cnt,recs,line,nf,i,j,module) {
+
function walkDependencies(modules,cnt,recs,line,nf,i,j,module) {
 +
  if (length(modules) <= 0)
 +
    return
 +
 
 
   split(modules,amodules)
 
   split(modules,amodules)
  
   # create list of needed modules
+
   # CO "build.lst" of wanted modules.
 
   bmodules=""
 
   bmodules=""
 
   for (i in amodules) {
 
   for (i in amodules) {
Line 52: Line 73:
  
 
   modules=""
 
   modules=""
   # walk the dependencies
+
   # Walk the dependencies.
 
   for (i in amodules) {
 
   for (i in amodules) {
     # check if the module is there now, other just continue
+
     # 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
+
       smodules[amodules[i]] = 2 # Mark this module as valid.
 
       close(amodules[i]"/prj/build.lst")
 
       close(amodules[i]"/prj/build.lst")
  
       # get dependencies
+
       # Get dependencies.
 
       do {  
 
       do {  
 
         cnt = getline line < (amodules[i]"/prj/build.lst")
 
         cnt = getline line < (amodules[i]"/prj/build.lst")
Line 87: Line 108:
 
     }
 
     }
 
     else
 
     else
       smodules[amodules[i]] = 1 # mark this module as invalid
+
       smodules[amodules[i]] = 1 # Mark this module as invalid.
 
+
 
   }
 
   }
  
   if (length(modules) > 0)
+
   walkDependencies(modules)
    ana(modules)
+
 
}
 
}
 
</pre>
 
</pre>

Revision as of 16:40, 6 March 2007

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