Ignore:
Timestamp:
Apr 7, 2007, 12:14:45 AM (13 years ago)
Author:
jberry@…
Message:

A bit of cleanup to once again sync up the mpwa submit with the design doc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • users/jberry/mpwa/app/controllers/ports_controller.rb

    r23606 r23696  
    2121
    2222    def subversionCommand(args)
     23        puts "subversion: #{svn} #{args}"
    2324        `#{svn} #{args}`
    2425    end
     
    3940    end
    4041   
     42    def buildPortPkgDirPrefixPath(pkgId)
     43        # Two Level Cache
     44        # First level is low 6 bits of pkgId
     45        # Second level is next 6 bits of pkgId
     46 
     47        lev1 = pkgId & 0x3f
     48        lev2 = pkgId >> 6 & 0x3f
     49        path = format('%02x/%02x', lev1, lev2)
     50    end
     51
     52    def buildPortPkgDirPath(pkgId)
     53        prefix = buildPortPkgDirPrefixPath(pkgId)
     54        path = format('%s/%016x', prefix, pkgId)
     55    end
     56
    4157    def submit
    4258        # TODO:
     
    5369       
    5470        tempDir = makeTempDir
    55         portpkg = "#{tempDir}/portpkg.tgz"
     71        portpkg = "#{tempDir}/portpkg.xar"
    5672        pkgdir = "#{tempDir}/portpkg"
    5773        common = "#{tempDir}/common"
     
    6379       
    6480        # Look for, and create if not found, the common directory for the port
    65         ensureRepositoryPath(repo_port, commonPartial)
     81        ensureRepositoryPath(repo_portpkgs, commonPartial)
    6682       
    6783        # Unpack the submitted portdir into a temporary directory
    68         File.open(portpkg, "w") { |f| f.write(@portpkg.read) }       
    69         system("#{tar} -C #{tempDir} -zf #{portpkg} -x portpkg")
     84        File.open(portpkg, "w") { |f| f.write(@portpkg.read) }
     85       
     86        # Note: a bug in xar presently prevents us from limiting the extraction to the portpkg directory,
     87        # => which we'd like to do for the sake of cleanliness. Hopefully this will become fixed soon.
     88        system("cd #{tempDir}; #{xar} -xf #{portpkg}")
    7089       
    7190        # Check out a private temporary copy of the common directory
    7291        # so that we don't get into concurrency issues by multi-modifying the directory
    73         subversionCommand("co #{repo_port_url}/#{commonPartial} #{common}")
     92        subversionCommand("co #{repo_portpkgs_url}/#{commonPartial} #{common}")
    7493       
    7594        # Sync the submission into the common directory by parsing the results of mtree
     
    128147
    129148            # Commit changes to the common directory
    130             commitOutput = subversionCommand("commit -m 'New submission of #{@portName}' #{common}")
     149            commitOutput = subversionCommand("commit -m 'New portpkg of #{@portName}' #{common}")
    131150            commitRevision = /^Committed revision (\d+)./.match(commitOutput)[1]
    132151           
    133152            # Form the portid from the committed revision number
    134             portid = commitRevision
     153            pkgId = commitRevision.to_i
     154            portPkgDirPrefix = buildPortPkgDirPrefixPath(pkgId)
     155            portPkgDir = buildPortPkgDirPath(pkgId);
    135156           
    136     return
    137             puts "Creating new submission #{commitRevision} at #{repo_port}/#{commitRevision}"
     157            puts "Creating new portpkg #{pkgId} at #{repo_portpkgs}/#{portPkgDir}"
    138158   
    139             # Make the target directory structure
    140             subversionCommand("mkdir -m 'Create new submission #{commitRevision} of port #{@portName}' #{submission_url}/#{commitRevision}")
     159            # Make sure there's a path to the repository location for the portPkg
     160            ensureRepositoryPath(repo_portpkgs, portPkgDirPrefix)
     161           
     162            # Make the portPkg directory
     163            FileUtils.mkdir("#{repo_portpkgs}/#{portPkgDir}")
     164            subversionCommand("add #{repo_portpkgs}/#{portPkgDir}")
     165     
     166            # Add original package and meta directory
     167            FileUtils.cp(portpkg, "#{repo_portpkgs}/#{portPkgDir}/portpkg.xar")
     168            FileUtils.mkdir("#{repo_portpkgs}/#{portPkgDir}/meta")
     169            subversionCommand("add #{repo_portpkgs}/#{portPkgDir}/portpkg.xar #{repo_portpkgs}/#{portPkgDir}/meta")
    141170   
    142             # Check out the submission directory
    143             subversionCommand("co #{submission_url}/#{commitRevision} #{target}")
     171            # Copy the common directory into unpacked
     172            subversionCommand("cp #{common} #{repo_portpkgs}/#{portPkgDir}/unpacked")
    144173   
    145             # Add original package and meta directory
    146             FileUtils.cp(package, "#{target}/port.tgz")
    147             FileUtils.mkdir("#{target}/meta")
    148             subversionCommand("add #{target}/port.tgz #{target}/meta")
    149    
    150             # Copy over the common directory into unpacked
    151             subversionCommand("cp #{common} #{target}/unpacked")
    152    
    153             # Commit the submission directory
    154             subversionCommand("commit -m 'Complete submission #{commitRevision} of port #{@portName}' #{target}")
     174            # Commit the portpkg directory
     175            subversionCommand("commit -m 'Complete portpkg #{pkgId} of port #{@portName}' #{repo_portpkgs}/#{portPkgDir}")
    155176        end
    156177    end
Note: See TracChangeset for help on using the changeset viewer.