autobuild 1.4.7 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/Changes.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == Version 1.4.8
2
+ * make the archive importer nicer to use:
3
+ - the archive_dir is unneeded for tarballs from now on
4
+ - filename detection works better (and therefore the :filename option will be
5
+ less needed)
6
+
1
7
  == Version 1.4.7
2
8
  * have the git importer update the autobuild remote on update.
3
9
 
data/lib/autobuild.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.4.7" unless defined? Autobuild::VERSION
2
+ VERSION = "1.4.8" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
  require 'autobuild/config'
@@ -34,11 +34,15 @@ module Autobuild
34
34
  end
35
35
  end
36
36
 
37
+ def update_cached_file?; @options[:update_cached_file] end
38
+
37
39
  # Updates the downloaded file in cache only if it is needed
38
40
  def update_cache(package)
39
- do_update = true
41
+ do_update = false
40
42
 
41
- if File.file?(cachefile)
43
+ if !File.file?(cachefile)
44
+ do_update = true
45
+ elsif self.update_cached_file?
42
46
  cached_size = File.lstat(cachefile).size
43
47
  cached_mtime = File.lstat(cachefile).mtime
44
48
 
@@ -57,6 +61,7 @@ module Autobuild
57
61
  do_update = (size != cached_size)
58
62
  else
59
63
  $stderr.puts "WARNING: neither size nor modification time available for #{@url}, will always update"
64
+ do_update = true
60
65
  end
61
66
  end
62
67
 
@@ -93,6 +98,9 @@ module Autobuild
93
98
  # subdirectory.
94
99
  def initialize(url, options)
95
100
  @options = options.dup
101
+ if !@options.has_key?(:update_cached_file)
102
+ @options[:update_cached_file] = true
103
+ end
96
104
  @options[:cachedir] ||= "#{Autobuild.prefix}/cache"
97
105
 
98
106
  @url = URI.parse(url)
@@ -102,7 +110,7 @@ module Autobuild
102
110
  if @url.scheme == 'file'
103
111
  @cachefile = @url.path
104
112
  else
105
- @cachefile = File.join(cachedir, @options[:filename] || File.basename(url))
113
+ @cachefile = File.join(cachedir, @options[:filename] || File.basename(url).gsub(/\?.*/, ''))
106
114
  end
107
115
  end
108
116
 
@@ -116,24 +124,26 @@ module Autobuild
116
124
  update_cache(package)
117
125
 
118
126
  base_dir = File.dirname(package.srcdir)
119
- FileUtils.mkdir_p base_dir
120
-
121
- main_dir = if @options[:no_subdirectory] then package.srcdir
122
- else base_dir
123
- end
124
127
 
125
128
  if mode == Zip
129
+ main_dir = if @options[:no_subdirectory] then package.srcdir
130
+ else base_dir
131
+ end
132
+
126
133
  cmd = [ 'unzip', '-o', '-f', cachefile, '-d', main_dir ]
134
+ if archive_dir
135
+ FileUtils.rm_rf File.join(package.srcdir)
136
+ FileUtils.mv File.join(base_dir, archive_dir), package.srcdir
137
+ elsif !File.directory?(package.srcdir)
138
+ raise Autobuild::Exception, "#{cachefile} does not contain directory called #{File.basename(package.srcdir)}. Did you forget to use the :archive_dir option ?"
139
+ end
127
140
  else
128
- cmd = [ 'tar', "x#{TAR_OPTION[mode]}f", cachefile, '-C', main_dir ]
129
- end
130
-
131
- Subprocess.run(package, :import, *cmd)
132
- if archive_dir
133
- FileUtils.mv File.join(base_dir, archive_dir), package.srcdir
134
- end
135
- if !File.directory?(package.srcdir)
136
- raise Autobuild::Exception, "#{cachefile} does not contain directory called #{File.basename(package.srcdir)}. Did you forget to use the :archive_dir option ?"
141
+ FileUtils.mkdir_p package.srcdir
142
+ cmd = ["x#{TAR_OPTION[mode]}f", cachefile, '-C', package.srcdir]
143
+ if !@options[:no_subdirectory]
144
+ cmd << '--strip-components=1'
145
+ end
146
+ Subprocess.run(package, :import, Autobuild.tool('tar'), *cmd)
137
147
  end
138
148
 
139
149
  rescue OpenURI::HTTPError
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Joyeux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-08 00:00:00 +01:00
12
+ date: 2010-01-14 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency