build-tool 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +5 -0
- data/lib/build-tool/vcs/archive.rb +76 -46
- data/lib/build-tool/version.rb +1 -1
- metadata +4 -4
data/History.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== Version 0.6.5
|
2
|
+
=== Enhancements
|
3
|
+
- Archive Buildsystem now supports bzip2 compressed archives.
|
4
|
+
- Archive Buildsystem is much more fault tolerant now.
|
5
|
+
|
1
6
|
== Version 0.6.4
|
2
7
|
=== Enhancements
|
3
8
|
- Check for xdg-open before using it and give error message if missing.
|
@@ -128,47 +128,75 @@ def fetch( verbose = false )
|
|
128
128
|
FileUtils.mkdir_p( File.dirname( local_path ) ) if !$noop
|
129
129
|
|
130
130
|
# Download the archive
|
131
|
-
logger.
|
131
|
+
logger.info"downloading #{archive_url}"
|
132
132
|
if !$noop
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
133
|
+
|
134
|
+
begin
|
135
|
+
|
136
|
+
# We first open the archive. Will throw an exception if the url is invalid.
|
137
|
+
open( archive_url ) do |file|
|
138
|
+
|
139
|
+
begin
|
140
|
+
|
141
|
+
# Create the local file
|
142
|
+
open( archive_local_path, "wb" ) do |target|
|
143
|
+
|
144
|
+
# Copy
|
145
|
+
while c = file.getc
|
146
|
+
target.putc( c )
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
rescue
|
152
|
+
|
153
|
+
# Clean up
|
154
|
+
File.unlink( archive_local_path ) if File.exist?( archive_local_path )
|
155
|
+
raise
|
156
|
+
|
157
|
+
end
|
158
|
+
|
137
159
|
end
|
138
|
-
|
139
|
-
|
160
|
+
|
161
|
+
rescue StandardError => e
|
162
|
+
|
163
|
+
msg = "Failed to download #{archive_url}: #{e.to_s}"
|
164
|
+
logger.error( msg )
|
165
|
+
raise StandardError, msg
|
166
|
+
|
167
|
+
end
|
168
|
+
|
140
169
|
end
|
141
170
|
return 0
|
142
171
|
end
|
143
172
|
|
144
173
|
def guess_top_level_directory
|
145
174
|
return "<topdir>" if $noop
|
146
|
-
|
175
|
+
|
176
|
+
# Find the command to list the archive content
|
147
177
|
if archive_name =~ /(\.tgz|\.tar\.gz)$/
|
148
|
-
|
149
|
-
rc = /^([^\/]*)\//.match( line )
|
150
|
-
if topdir and topdir != rc[1]
|
151
|
-
raise StandardError, "Unable to determine toplevel directory for archive #{archive_name}!"
|
152
|
-
end
|
153
|
-
topdir = rc[1]
|
154
|
-
} != 0
|
155
|
-
# No topdir
|
156
|
-
return nil
|
157
|
-
end
|
178
|
+
cmd = "gzip -dc #{archive_local_path} | tar tf -"
|
158
179
|
elsif archive_name =~ /(\.txz|\.tar\.xz)$/
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
180
|
+
cmd = "xz -dc #{archive_local_path} | tar tf -"
|
181
|
+
elsif archive_name =~ /(\.tar\.bz2)$/
|
182
|
+
cmd = "bzip2 -dc #{archive_local_path} | tar tf -"
|
183
|
+
else
|
184
|
+
raise NotImplementedError, "'#{archive_name}' has a unsupported format."
|
185
|
+
end
|
186
|
+
|
187
|
+
# Then check for a toplevel directory.
|
188
|
+
topdir = nil
|
189
|
+
self.class.execute( cmd ) do |line|
|
190
|
+
rc = /^([^\/]*)\/?/.match( line )
|
191
|
+
if topdir
|
192
|
+
if topdir != rc[1]
|
193
|
+
return false
|
163
194
|
end
|
195
|
+
else
|
164
196
|
topdir = rc[1]
|
165
|
-
} != 0
|
166
|
-
# No topdir
|
167
|
-
return nil
|
168
197
|
end
|
169
|
-
else
|
170
|
-
raise NotImplementedError, "No idea how to unpack the archive '#{archive_name}'."
|
171
198
|
end
|
199
|
+
|
172
200
|
return topdir
|
173
201
|
end
|
174
202
|
|
@@ -184,29 +212,31 @@ def rebase( verbose = false )
|
|
184
212
|
return 0
|
185
213
|
end
|
186
214
|
|
187
|
-
#
|
188
|
-
|
215
|
+
# Check if there is a common top level dir
|
216
|
+
# eg. my-package-0.4.7
|
217
|
+
if guess_top_level_directory()
|
218
|
+
strip_components = 1
|
219
|
+
else
|
220
|
+
strip_components = 0
|
221
|
+
end
|
189
222
|
|
223
|
+
# Get the command to unpack
|
190
224
|
if archive_name =~ /(\.tgz|\.tar\.gz)$/
|
191
|
-
|
192
|
-
cmd = "gunzip -c #{archive_local_path} | tar --strip-components=1 --extract --file=- --directory=#{local_path}"
|
193
|
-
else
|
194
|
-
cmd = "gunzip -c #{archive_local_path} | tar --strip-components=0 --extract --file=- --directory=#{local_path}"
|
195
|
-
end
|
196
|
-
if self.class.execute( cmd ) != 0
|
197
|
-
raise StandardError, "Failed to unpack the archive: $?"
|
198
|
-
end
|
225
|
+
cmd = "gunzip -dc #{archive_local_path} | tar --strip-components=#{strip_components} --extract --file=- --directory=#{local_path}"
|
199
226
|
elsif archive_name =~ /(\.txz|\.tar\.xz)$/
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
cmd = "xz -dc #{archive_local_path} | tar --strip-components=0 --extract --file=- --directory=#{local_path}"
|
204
|
-
end
|
205
|
-
if self.class.execute( cmd ) != 0
|
206
|
-
raise StandardError, "Failed to unpack the archive: $?"
|
207
|
-
end
|
227
|
+
cmd = "xz -dc #{archive_local_path} | tar --strip-components=#{strip_components} --extract --file=- --directory=#{local_path}"
|
228
|
+
elsif archive_name =~ /\.tar\.bz2$/
|
229
|
+
cmd = "bzip2 -dc #{archive_local_path} | tar --strip-components=#{strip_components} --extract --file=- --directory=#{local_path}"
|
208
230
|
else
|
209
|
-
raise NotImplementedError, "
|
231
|
+
raise NotImplementedError, "'#{archive_name}' has unsupported format."
|
232
|
+
end
|
233
|
+
|
234
|
+
# Create the directory we want to use to checkout
|
235
|
+
FileUtils.mkdir_p local_path if !$noop
|
236
|
+
|
237
|
+
# Unpack
|
238
|
+
if self.class.execute( cmd ) != 0
|
239
|
+
raise StandardError, "Failed to unpack the archive: $?"
|
210
240
|
end
|
211
241
|
|
212
242
|
0
|
data/lib/build-tool/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 5
|
10
|
+
version: 0.6.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Jansen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-03 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|