[23606] users/jberry/mpwa/app

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 5 00:13:08 PDT 2007


Revision: 23606
          http://trac.macosforge.org/projects/macports/changeset/23606
Author:   jberry at macports.org
Date:     2007-04-05 00:13:07 -0700 (Thu, 05 Apr 2007)

Log Message:
-----------
Begin reorg of mpwa hierarchy to match revised design

Modified Paths:
--------------
    users/jberry/mpwa/app/controllers/application.rb
    users/jberry/mpwa/app/controllers/ports_controller.rb
    users/jberry/mpwa/app/views/ports/submit.rhtml

Modified: users/jberry/mpwa/app/controllers/application.rb
===================================================================
--- users/jberry/mpwa/app/controllers/application.rb	2007-04-05 04:32:02 UTC (rev 23605)
+++ users/jberry/mpwa/app/controllers/application.rb	2007-04-05 07:13:07 UTC (rev 23606)
@@ -3,7 +3,7 @@
 class ApplicationController < ActionController::Base
 
     attr_reader :svn, :tar, :mtree
-	attr_reader :repo_url, :repo_root, :repo_submissions, :repo_submissions_url
+	attr_reader :repo_url, :repo_root, :repo_port, :repo_port_url
 
 	def initialize
 		@svn = "/opt/local/bin/svn"
@@ -12,8 +12,8 @@
 		
 		@repo_url = "file:///Users/jberry/Projects/macports/users/jberry/mpwa/testrepo/repo"
 		@repo_root = "/Users/jberry/Projects/macports/users/jberry/mpwa/testrepo/root"
-		@repo_submissions = "#{@repo_root}/port/submissions"
-		@repo_submissions_url = "#{@repo_url}/port/submissions"
+		@repo_port = "#{@repo_root}/port"
+		@repo_port_url = "#{@repo_url}/port"
 	end
 	
 end
\ No newline at end of file

Modified: users/jberry/mpwa/app/controllers/ports_controller.rb
===================================================================
--- users/jberry/mpwa/app/controllers/ports_controller.rb	2007-04-05 04:32:02 UTC (rev 23605)
+++ users/jberry/mpwa/app/controllers/ports_controller.rb	2007-04-05 07:13:07 UTC (rev 23606)
@@ -7,158 +7,152 @@
         basename = "macports"
         n = 1
         begin
-    	    tmpname = File.join(tmpdir, sprintf('%s.%d.%d', basename, $$, n))
-    	    n += 1
-      	    next if File.exist?(tmpname)
-     	    begin
-     	        Dir.mkdir(tmpname)
-     	    rescue SystemCallError
-     	        next
-     	    end
+            tmpname = File.join(tmpdir, sprintf('%s.%d.%d', basename, $$, n))
+            n += 1
+            next if File.exist?(tmpname)
+            begin
+                Dir.mkdir(tmpname)
+            rescue SystemCallError
+                next
+            end
         end while !File.exist?(tmpname)
         return tmpname
     end
 
-	def subversionCommand(args)
-		`#{svn} #{args}`
-	end
+    def subversionCommand(args)
+        `#{svn} #{args}`
+    end
 
-	def ensurePort(category, portName)
-        # Make sure the base directory exists
-        assert { File.directory?(repo_submissions) }
+    def ensureRepositoryPath(root, path)
+        # Make sure the root director exists
+        assert { File.directory?(root) }
+        
+        # Step through path, building each component that doesn't exist
+        Pathname.new(path).descend do |p|
+            full = Pathname.new(root) + p
+            if !full.directory?
+                full.mkdir
+                subversionCommand("add #{full}")
+                subversionCommand("commit -m 'Make repository path segment' #{full}")
+             end
+        end
+    end
+    
+    def submit
+        # TODO:
+        # => Move some of this into the model
+        # => And/or break up into more methods
+        
+        # Get and validate parameters
+        @portName = params[:portname]
+        @portpkg = params[:portpkg]
+        
+        # Validate parameters (we're probably making this too hard)
+        raise "bad portName" if @portName.nil?
+        raise "bad package" if @portpkg.nil?
+        
+        tempDir = makeTempDir
+        portpkg = "#{tempDir}/portpkg.tgz"
+        pkgdir = "#{tempDir}/portpkg"
+        common = "#{tempDir}/common"
+        target = "#{tempDir}/target"
 
-		# Build the category directory as needed
- 		categoryDir = "#{repo_submissions}/#{category}"
-		if !File.directory?(categoryDir)
-			FileUtils.mkdir(categoryDir)
-			subversionCommand("add #{categoryDir}")
-			subversionCommand("commit -m 'Make category #{category}' #{categoryDir}")
-		end
-		
-		# Build the port directory as needed
-		portDir = "#{repo_submissions}/#{category}/#{portName}"
-		if !File.directory?(portDir)
-			FileUtils.mkdir(portDir)
-			subversionCommand("add #{portDir}")
-			subversionCommand("commit -m 'Make new port #{portName}' #{portDir}")
-		end
-		
-		# Build the port common directory as needed
-		commonDir = "#{repo_submissions}/#{category}/#{portName}/common"
-		if !File.directory?(commonDir)
-			FileUtils.mkdir(commonDir)
-			subversionCommand("add #{commonDir}")
-			subversionCommand("commit -m 'Make common directory for #{portName}' #{commonDir}")
-		end
-	end
-	
-	def submit
-	    # TODO:
-	    # => Move some of this into the model
-	    # => And/or break up into more methods
-	    
-		# Get and validate parameters
-		@category = params[:category]
-		@portName = params[:portname]
-		@submission = params[:submission]
-		
-		# Validate parameters (we're probably making this too hard)
-		raise "bad category" if @category.nil?
-		raise "bad portName" if @portName.nil?
-		raise "bad package" if @submission.nil?
-		
-		# Look for, and create if not found, a category/port
-		ensurePort(@category, @portName)
-		
-		# Unpack into temporary directory a directory called "submission"
-		tempDir = makeTempDir
-		package = "#{tempDir}/package"
-		submission = "#{tempDir}/submission"
-		common = "#{tempDir}/common"
-		target = "#{tempDir}/target"
-		submission_url = "#{repo_submissions_url}/#{@category}/#{@portName}"
-		
-		File.open(package, "w") { |f| f.write(@submission.read) }		
-		system("#{tar} -C #{tempDir} -zf #{package} -x submission")
-		
-		# Check out a private temporary copy of the submissions directory
-		# so that we don't get into concurrency issues by multi-modifying the directory
-		subversionCommand("co #{submission_url}/common #{common}")
-		
-		# Sync the submission into the common directory by parsing the results of mtree
-		changeCnt = 0
-		treeOut = `#{mtree} -c -k type,cksum -p #{submission} | #{mtree} -p #{common}`
-		treeOut.each_line do |line|
-		    puts "Line #{line}"
-		    
-		    case line
-	        when /^\w+/
-	            puts "Whitespace line #$1"
-	            
-	        when /^(.*) changed$/
-	            srcFile = File.join(submission, $1)
-	            dstFile = File.join(common, $1)
-	            puts "Changed file #{srcFile} != #{dstFile}"
-	            FileUtils.cp(srcFile, dstFile)
-	            changeCnt += 1
-	            
-	        when /^(.*) extra$/
-	            dstFile = File.join(common, $1)
-	            if /^\./ =~ File.basename(dstFile)
-	                puts "Skipping invisible extra entry #{dstFile}"
-	            else
- 	                puts "Extra entry #{dstFile}"
- 	                subversionCommand("rm #{dstFile}")
-    	            changeCnt += 1
+        # Form partial path to the common directory for the portname
+        firstChar = @portName[0,1].downcase
+        commonPartial = "common/#{firstChar}/#{@portName}"
+        
+        # Look for, and create if not found, the common directory for the port
+        ensureRepositoryPath(repo_port, commonPartial)
+        
+        # Unpack the submitted portdir into a temporary directory
+        File.open(portpkg, "w") { |f| f.write(@portpkg.read) }       
+        system("#{tar} -C #{tempDir} -zf #{portpkg} -x portpkg")
+        
+        # Check out a private temporary copy of the common directory
+        # so that we don't get into concurrency issues by multi-modifying the directory
+        subversionCommand("co #{repo_port_url}/#{commonPartial} #{common}")
+        
+        # Sync the submission into the common directory by parsing the results of mtree
+        changeCnt = 0
+        treeOut = `#{mtree} -c -k type,cksum -p #{pkgdir} | #{mtree} -p #{common}`
+        treeOut.each_line do |line|
+            puts "Line #{line}"
+            
+            case line
+            when /^\w+/
+                puts "Whitespace line #$1"
+                
+            when /^(.*) changed$/
+                srcFile = File.join(pkgdir, $1)
+                dstFile = File.join(common, $1)
+                puts "Changed file #{srcFile} != #{dstFile}"
+                FileUtils.cp(srcFile, dstFile)
+                changeCnt += 1
+                
+            when /^(.*) extra$/
+                dstFile = File.join(common, $1)
+                if /^\./ =~ File.basename(dstFile)
+                    puts "Skipping invisible extra entry #{dstFile}"
+                else
+                    puts "Extra entry #{dstFile}"
+                    subversionCommand("rm #{dstFile}")
+                    changeCnt += 1
                end
-	            
-	        when /^(.*) missing$/
-	            srcFile = File.join(submission, $1)
-	            dstFile = File.join(common, $1)
+                
+            when /^(.*) missing$/
+                srcFile = File.join(pkgdir, $1)
+                dstFile = File.join(common, $1)
 
- 	            if /^\./ =~ File.basename(dstFile)
-	                puts "Skipping invisible new entry #{dstFile}"
- 	            else
-       	            puts "New entry #{srcFile} ==> #{dstFile}"
+                if /^\./ =~ File.basename(dstFile)
+                    puts "Skipping invisible new entry #{dstFile}"
+                else
+                    puts "New entry #{srcFile} ==> #{dstFile}"
  
                     if File.directory?(srcFile)
                         subversionCommand("mkdir #{dstFile}")
                     else
-        	            FileUtils.cp(srcFile, dstFile)
+                        FileUtils.cp(srcFile, dstFile)
                         subversionCommand("add #{dstFile}")
                     end
                     
-    	            changeCnt += 1
+                    changeCnt += 1
                 end
 
-		    end
-		end
-		
-		if changeCnt == 0
-		    puts "No changes detected, so don't create a new submission"
-		else
-    		# Commit changes to the common directory
-    		commitOutput = subversionCommand("commit -m 'New submission of #{@portName}' #{common}")
-    		commitRevision = /^Committed revision (\d+)./.match(commitOutput)[1]
-    		puts "Creating new submission #{commitRevision} at #{submission_url}/#{commitRevision}"
-	
-    		# Make the target directory structure
-    		subversionCommand("mkdir -m 'Create new submission #{commitRevision} of port #{@portName}' #{submission_url}/#{commitRevision}")
-	
-    		# Check out the submission directory
-    		subversionCommand("co #{submission_url}/#{commitRevision} #{target}")
+            end
+        end
+        
+        if changeCnt == 0
+            puts "No changes detected, so don't create a new submission"
+        else
+            puts "Creating new submission from #{common}"
+
+            # Commit changes to the common directory
+            commitOutput = subversionCommand("commit -m 'New submission of #{@portName}' #{common}")
+            commitRevision = /^Committed revision (\d+)./.match(commitOutput)[1]
+            
+            # Form the portid from the committed revision number
+            portid = commitRevision
+            
+    return
+            puts "Creating new submission #{commitRevision} at #{repo_port}/#{commitRevision}"
     
+            # Make the target directory structure
+            subversionCommand("mkdir -m 'Create new submission #{commitRevision} of port #{@portName}' #{submission_url}/#{commitRevision}")
+    
+            # Check out the submission directory
+            subversionCommand("co #{submission_url}/#{commitRevision} #{target}")
+    
             # Add original package and meta directory
             FileUtils.cp(package, "#{target}/port.tgz")
             FileUtils.mkdir("#{target}/meta")
             subversionCommand("add #{target}/port.tgz #{target}/meta")
-	
-    		# Copy over the common directory into unpacked
-    		subversionCommand("cp #{common} #{target}/unpacked")
-	
-    		# Commit the submission directory
-    		subversionCommand("commit -m 'Complete submission #{commitRevision} of port #{@portName}' #{target}")
-	    end
- 	end
+    
+            # Copy over the common directory into unpacked
+            subversionCommand("cp #{common} #{target}/unpacked")
+    
+            # Commit the submission directory
+            subversionCommand("commit -m 'Complete submission #{commitRevision} of port #{@portName}' #{target}")
+        end
+    end
   
 end

Modified: users/jberry/mpwa/app/views/ports/submit.rhtml
===================================================================
--- users/jberry/mpwa/app/views/ports/submit.rhtml	2007-04-05 04:32:02 UTC (rev 23605)
+++ users/jberry/mpwa/app/views/ports/submit.rhtml	2007-04-05 07:13:07 UTC (rev 23606)
@@ -2,7 +2,7 @@
 <p>Find me in app/views/ports/submit.rhtml</p>
 
 <p>repo_root: <%= @controller.repo_root %></p>
-<p>repo_submissions: <%= @controller.repo_submissions %></p>
+<p>repo_port: <%= @controller.repo_port %></p>
 
 <p>category: <%= @category %></p>
 <p>portname: <%= @portname %></p>
\ No newline at end of file

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070405/439230aa/attachment.html


More information about the macports-changes mailing list