]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Support for relative paths in the config file.
authorTobias Brunner <tobias@strongswan.org>
Fri, 12 Jun 2009 15:56:58 +0000 (17:56 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 15 Sep 2009 12:15:17 +0000 (14:15 +0200)
testing/lib/config.rb
testing/lib/guest_config.rb
testing/lib/kernel_config.rb
testing/lib/strongswan_config.rb
testing/lib/testing.rb

index 534d1ded21f0ae7b3784ff6f0b64aab9ae81579b..2dc48bea13a0998810747e136f7f9514d99a19aa 100644 (file)
@@ -108,8 +108,10 @@ module Dumm
                  else
                    @kernels[c.kernel]
                  end
+      c.masterfs = File.expand_path(c.masterfs) if c.masterfs
       h.masterfs = c.masterfs if c.masterfs && (Testing.tarball?(c.masterfs) || File.directory?(c.masterfs))
-      h.templates = c.templates if c.templates && (c.templates.empty? || File.directory?(c.templates))
+      c.templates = File.expand_path(c.templates) if c.templates
+      h.templates = c.templates if c.templates && File.directory?(c.templates)
       h.mem = c.mem.to_i if c.mem
       h.consoles = c.consoles.select { |c| c =~ /^(xterm|pts)$/ } if c.consoles
       h.marshal_dump
index 21ec2e5a5d0238a720d5e83160bbed987fccc27c..6e2be97d26ffe8064e1ffad476b180ed9335ee8f 100644 (file)
@@ -45,9 +45,13 @@ module Dumm
         args << " con#{i.next}=#{con}"
       end
       # TODO if the masterfs is a tarball, extract that first
-      #Dir.chdir(Testing.root) do
-      #  Guest.new @name, @kernel.path || "/home/tbrunner/tbrunner/testing/umlbuild/linux-uml-2.6.21.1", @masterfs, args
-      #end
+      
+      # Creating the guests using Guest.new does not work because the union
+      # filesystem doesn't like us copying lots of files to the union directly
+      # when it's mounted. So we have to create the guests manually.
+      # Dir.chdir(Testing.root) do
+      #   Guest.new @name, @kernel.path, @masterfs, args
+      # end
       Dir.chdir(Testing.guests_dir) do
         Dir.mkdir(name, 0775)
         Dir.chdir(name) do
@@ -59,10 +63,15 @@ module Dumm
         end
       end
       @root = File.join(Testing.guests_dir, name, 'diff')
-      tmpl = File.join(@templates, name)
-      if File.directory?(tmpl)
-        FileUtils.cp_r(tmpl + '/.', @root) # '/.' is required to copy the contents of tmpl and not tmpl itself
+
+      if @templates
+        tmpl = File.join(@templates, name)
+        if File.directory?(tmpl)
+          # '/.' is required to copy the contents of tmpl and not tmpl itself
+          FileUtils.cp_r(tmpl + '/.', @root)
+        end
       end
+
       @needs_build = false
     end
 
index 183c785d5ee90fdc8b4683536d18cebb18ffbdd3..deb609655fe62c43c9e10507d417b404a10de5d3 100644 (file)
@@ -25,9 +25,12 @@ module Dumm
       @name = name
       @needs_build = true
       @source = (config.source || "none").to_sym
+      config.path = File.expand_path(config.path) if config.path
+      config.config = File.expand_path(config.config) if config.config
       @config = config.config if File.file?(config.config || "")
       config.patches ||= []
-      @patches = config.patches.select { |p| File.exists?(p) && p =~ /\.patch(\.(bz2|gz))?$/ }
+      @patches = config.patches.map { |p| File.expand_path(p) }.select{ |p|
+                   File.exists?(p) && p =~ /\.patch(\.(bz2|gz))?$/ }
       case @source
       when :git, :dir
         unless File.directory?(config.path)
index 44058cec5490741157bd63aaf9a76f218216674c..4eeda1ada4fbe2ad348e418a9dea5b1aa58d7e70 100644 (file)
@@ -23,9 +23,10 @@ module Dumm
       @needs_build = true
       @options = config.options
       @source = (config.source || "none").to_sym
+      config.path = File.expand_path(config.path) if config.path
       case @source
       when :git, :dir
-        unless File.directory?(config.path)
+        unless config.path && File.directory?(config.path)
           raise "Path '#{config.path}' not found!"
         end
         @source_path = config.path
@@ -34,7 +35,7 @@ module Dumm
           @checkout = config.checkout if Testing.git_tree?(@source_path, config.checkout)
         end
       when :tar
-        raise "Tarball '#{config.path}' not found!" unless Testing.tarball?(config.path)
+        raise "Tarball '#{config.path}' not found!" unless config.path && Testing.tarball?(config.path)
         @source_path = config.path
       else
         raise "Specify the source type of strongSwan config '#{name}'"
index 7444cd4bc8fc6eabca9bebc2f79402c735ecc815..009cd1ce64eca1a06c79d52a4a0a30aea9485f01 100644 (file)
@@ -113,10 +113,9 @@ module Dumm
       # Sets root to TESTING_ROOT and canonalizes it. Also sets the build
       # and guest dir based on the root.
       def set_directories!
-        require 'pathname'
         raise 'TESTING_ROOT is not set' unless defined?(::TESTING_ROOT)
         raise 'TESTING_ROOT is not a directory' unless File.directory?(::TESTING_ROOT)
-        @root = Pathname.new(::TESTING_ROOT).realpath.to_s
+        @root = File.expand_path(::TESTING_ROOT)
         ::TESTING_ROOT.replace @root
         @build_dir = File.join(@root, 'build')
         @guests_dir = File.join(@root, 'guests')