purplepkg 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/purple +20 -18
- data/lib/purple.rb +14 -7
- data/lib/purple/getter.rb +12 -1
- data/lib/purple/getter_curl.rb +55 -0
- data/lib/purple/osx.rb +13 -4
- data/lib/purple/pkg_actions.rb +32 -10
- data/lib/purple/script.rb +6 -5
- metadata +5 -4
data/bin/purple
CHANGED
@@ -8,8 +8,8 @@ require 'purple'
|
|
8
8
|
|
9
9
|
def usage
|
10
10
|
puts <<-EOS
|
11
|
-
Purple Packager, Copyright (c) 2004, Simon Conrad-Armes <curne@curnomatic.dk>
|
12
|
-
Rights granted, under GNU GPL (version 2 or later), see file
|
11
|
+
Purple Packager, Copyright (c) 2004-2005, Simon Conrad-Armes <curne@curnomatic.dk>
|
12
|
+
Rights granted, under GNU GPL (version 2 or later), see file COPYING
|
13
13
|
|
14
14
|
Usage: #{File.basename $0} [options] <package>
|
15
15
|
|
@@ -45,6 +45,8 @@ def filetype url
|
|
45
45
|
return case filename
|
46
46
|
when /\.tar\.(gz|bz2)|\.tgz$/
|
47
47
|
:tarball
|
48
|
+
when /\.zip$/
|
49
|
+
:zipfile
|
48
50
|
when /\.purple$/
|
49
51
|
:script
|
50
52
|
end
|
@@ -67,11 +69,10 @@ opts.set_options(
|
|
67
69
|
|
68
70
|
OPTIONS = Hash.new
|
69
71
|
opts.each_option { |name,arg| OPTIONS[name.gsub(/^--/, '')] = arg }
|
70
|
-
p OPTIONS
|
71
72
|
|
72
73
|
usage if OPTIONS.has_key? 'help'
|
73
74
|
|
74
|
-
steps = [:prepare, :config, :build, :stage]
|
75
|
+
steps = [:prepare, :setup, :config, :build, :stage]
|
75
76
|
|
76
77
|
if OPTIONS.has_key? 'make' or 'deps' == OPTIONS['stop-at']
|
77
78
|
steps << :deps
|
@@ -106,33 +107,34 @@ end
|
|
106
107
|
arg_ref = arg_uri.to_s
|
107
108
|
|
108
109
|
# Decide what to do with the argument
|
109
|
-
puts "DEBUG main: #{filetype(arg_ref).inspect}"
|
110
110
|
case filetype(arg_ref)
|
111
|
-
when :tarball
|
111
|
+
when :tarball, :zipfile
|
112
112
|
@cabinet = Purple.cabinet_from_url arg_ref
|
113
113
|
when :script
|
114
114
|
@cabinet = Purple::Script.open URI.parse(arg_ref).path
|
115
115
|
else
|
116
116
|
raise "Unknown file type of argument '#{arg_ref}'"
|
117
117
|
end
|
118
|
-
p @cabinet
|
119
118
|
|
120
119
|
error = catch :stop do
|
121
|
-
|
120
|
+
begin
|
121
|
+
@cabinet.setup
|
122
122
|
|
123
|
-
|
123
|
+
@cabinet.run_steps steps
|
124
124
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
if OPTIONS.has_key? 'make' or OPTIONS.has_key? 'deploy'
|
126
|
+
Purple::Platform.detect
|
127
|
+
@cabinet.make
|
128
|
+
end
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
130
|
+
if OPTIONS.has_key? 'deploy'
|
131
|
+
@cabinet.deploy
|
132
|
+
end
|
134
133
|
|
135
|
-
|
134
|
+
:normal_complete
|
135
|
+
rescue StandardError => e
|
136
|
+
throw e.to_s
|
137
|
+
end
|
136
138
|
end
|
137
139
|
|
138
140
|
if :normal_complete != error
|
data/lib/purple.rb
CHANGED
@@ -77,38 +77,45 @@ module Purple
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
80
|
+
def prepare_step
|
81
81
|
@packages.each do |p|
|
82
82
|
p.files.each { |f| fetch f }
|
83
83
|
p.prepare
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
87
|
+
def setup_step
|
88
|
+
@packages.each do |p|
|
89
|
+
p.files.each { |f| fetch f }
|
90
|
+
p.setup
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def config_step
|
88
95
|
@packages.each { |p|
|
89
96
|
return false if not p.config
|
90
97
|
}
|
91
98
|
end
|
92
99
|
|
93
|
-
def
|
100
|
+
def build_step
|
94
101
|
@packages.each { |p|
|
95
102
|
return false if not p.build
|
96
103
|
}
|
97
104
|
end
|
98
105
|
|
99
|
-
def
|
106
|
+
def stage_step
|
100
107
|
@packages.each { |p|
|
101
108
|
return false if not p.stage
|
102
109
|
}
|
103
110
|
end
|
104
111
|
|
105
|
-
def
|
112
|
+
def deps_step
|
106
113
|
true
|
107
114
|
end
|
108
115
|
|
109
|
-
def run_steps steps=[:prepare, :build, :deps, :make]
|
116
|
+
def run_steps steps=[:prepare, :setup, :build, :deps, :make]
|
110
117
|
steps.each do |step|
|
111
|
-
self.method(step).call
|
118
|
+
self.method("#{step}_step").call
|
112
119
|
end
|
113
120
|
end
|
114
121
|
|
data/lib/purple/getter.rb
CHANGED
@@ -7,7 +7,18 @@ module Purple
|
|
7
7
|
@uri = URI.parse url
|
8
8
|
plugin = case @uri.scheme
|
9
9
|
when /http|ftp/
|
10
|
-
|
10
|
+
getter = nil
|
11
|
+
ENV['PATH'].split(':').each { |p|
|
12
|
+
case true
|
13
|
+
when FileTest.executable?(File.join(p, 'wget'))
|
14
|
+
getter = 'wget'
|
15
|
+
break
|
16
|
+
when FileTest.executable?(File.join(p, 'wget'))
|
17
|
+
getter = 'wget'
|
18
|
+
break
|
19
|
+
end
|
20
|
+
}
|
21
|
+
getter
|
11
22
|
when 'file'
|
12
23
|
'cp'
|
13
24
|
else
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Purple
|
4
|
+
module Getter
|
5
|
+
class Getter_curl < Generic
|
6
|
+
def initialize *args
|
7
|
+
super
|
8
|
+
@done = "0"
|
9
|
+
end
|
10
|
+
|
11
|
+
def get
|
12
|
+
@thread = Thread.new do
|
13
|
+
filename = File.basename uri.path
|
14
|
+
Open3.popen3 "curl -o '#{@destdir}/#{filename}' #{@uri.to_s}" do
|
15
|
+
|pw, pr, pe|
|
16
|
+
parse_input pw, pr, pe
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_status
|
22
|
+
[@status, @done]
|
23
|
+
end
|
24
|
+
|
25
|
+
# curl specific methods
|
26
|
+
|
27
|
+
def parse_input pw, pr, pe
|
28
|
+
puts "DEBUG Getter_curl#parse_input: Start" if $DEBUG
|
29
|
+
|
30
|
+
# Start line
|
31
|
+
2.times { pe.gets }
|
32
|
+
|
33
|
+
# Data incoming
|
34
|
+
while line = pe.read(79)
|
35
|
+
puts "->#{line.inspect}" if $DEBUG
|
36
|
+
break if line.size < 79
|
37
|
+
|
38
|
+
# % Total % Received % Xferd AverageDload SpeedUpload
|
39
|
+
# TimeTotal Current Left Speed Current
|
40
|
+
md = /
|
41
|
+
if md
|
42
|
+
@done = md[1]
|
43
|
+
@rate = md[7]
|
44
|
+
end
|
45
|
+
|
46
|
+
if "100" == @done
|
47
|
+
@status = "Done"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
pe.read
|
51
|
+
puts "DEBUG Getter_curl#parse_input: Done" if $DEBUG
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/purple/osx.rb
CHANGED
@@ -86,10 +86,19 @@ end
|
|
86
86
|
end
|
87
87
|
|
88
88
|
Dir.mkdir "#{osx_stage}/Resources"
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
|
90
|
+
info = ['README', 'NOTICE'].find { |f|
|
91
|
+
FileTest.exists? File.join(pkg.srcdir, f)
|
92
|
+
}
|
93
|
+
if info
|
94
|
+
FileUtils.cp File.join(pkg.srcdir, info), File.join(osx_stage, 'Resources/', 'ReadMe.txt')
|
95
|
+
end
|
96
|
+
|
97
|
+
license = ['COPYING', 'LICENSE'].find { |f|
|
98
|
+
FileTest.exists? "#{pkg.srcdir}/#{f}"
|
99
|
+
}
|
100
|
+
if license
|
101
|
+
FileUtils.cp "#{pkg.srcdir}/#{license}", "#{osx_stage}/Resources/License.txt"
|
93
102
|
end
|
94
103
|
|
95
104
|
File.open "#{osx_stage}/Info.plist", "w" do |f|
|
data/lib/purple/pkg_actions.rb
CHANGED
@@ -15,10 +15,21 @@ module Purple
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
def #{name}= prc
|
18
|
-
|
18
|
+
case prc
|
19
|
+
when Proc
|
20
|
+
@method_#{name}_package = prc
|
21
|
+
when String
|
22
|
+
@method_#{name}_package = proc { |pkg|
|
23
|
+
prc = eval("%(\#{prc})") if prc =~ /\\\#\\\{/
|
24
|
+
puts "DEBUG: prc==\#{prc}" if $DEBUG
|
25
|
+
pkg.cabinet.sys #{name.to_s.inspect}, prc
|
26
|
+
}
|
27
|
+
when Array
|
28
|
+
self.#{name} = prc.join '; '
|
29
|
+
end
|
19
30
|
end
|
20
31
|
EOS
|
21
|
-
|
32
|
+
puts "DEBUG PackageActions##package_method: prg=\n#{prg}" if $DEBUG
|
22
33
|
module_eval prg
|
23
34
|
end
|
24
35
|
|
@@ -26,10 +37,11 @@ module Purple
|
|
26
37
|
return @srcdir if defined? @srcdir
|
27
38
|
dirs = Dir.new(cabinet.srcdir).reject { |s| s =~ /^\.{1,2}$/ }
|
28
39
|
if 1 == dirs.size
|
29
|
-
|
40
|
+
s = dirs[0]
|
30
41
|
else
|
31
|
-
|
42
|
+
s = Dir.new(cabinet.srcdir).find { |s| s =~ Regexp.new('^' + Regexp.escape(name)) }
|
32
43
|
end
|
44
|
+
@srcdir = File.join(cabinet.srcdir, s)
|
33
45
|
throw :stop, "Unable to determine source directory for package #{name}" if not @srcdir
|
34
46
|
puts "Choosing #{@srcdir} as source code folder"
|
35
47
|
@srcdir
|
@@ -40,22 +52,32 @@ module Purple
|
|
40
52
|
end
|
41
53
|
|
42
54
|
package_method :prepare
|
55
|
+
package_method :setup
|
43
56
|
package_method :config
|
44
57
|
package_method :build
|
45
58
|
package_method :stage
|
46
59
|
package_method :make
|
47
60
|
|
61
|
+
def default_setup
|
62
|
+
end
|
63
|
+
|
48
64
|
def default_prepare
|
49
65
|
puts "DEBUG PackageActions#default_prepare" if $DEBUG
|
50
66
|
files.each do |f|
|
51
67
|
unpack = case f
|
52
|
-
when /gz
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
68
|
+
when /(gz|bz2)$/
|
69
|
+
compress_arg = case $1
|
70
|
+
when 'gz'; '-z'
|
71
|
+
when 'bz2'; '-j'
|
72
|
+
else ''
|
73
|
+
end
|
74
|
+
proc { |filename| "tar xv #{compress_arg} -C '#{cabinet.srcdir}' -f #{cabinet.filesdir}/#{filename}" }
|
75
|
+
when /zip$/
|
76
|
+
proc { |filename| "cd '#{cabinet.srcdir}'; unzip -o '#{cabinet.filesdir}/#{filename}'" }
|
77
|
+
else
|
78
|
+
throw :stop
|
58
79
|
end
|
80
|
+
throw :stop unless cabinet.sys 'prepare', unpack.call(f)
|
59
81
|
end
|
60
82
|
|
61
83
|
end
|
data/lib/purple/script.rb
CHANGED
@@ -24,12 +24,12 @@ package(#{pkg.name.inspect}) { |p|
|
|
24
24
|
p.long_name #{pkg.long_name.inspect}
|
25
25
|
p.identifier #{pkg.identifier.inspect}
|
26
26
|
p.version #{pkg.version.inspect}
|
27
|
-
p.major #{pkg.major}
|
28
|
-
p.minor #{pkg.minor}
|
27
|
+
p.major #{pkg.major.inspect}
|
28
|
+
p.minor #{pkg.minor.inspect}
|
29
29
|
|
30
30
|
# Uncomment and modify for special configuration
|
31
31
|
#p.config proc { |pkg|
|
32
|
-
# throw :stop unless
|
32
|
+
# throw :stop unless pkg.cabinet.sys "cd \#{pkg.srcdir}; ./configure --prefix=/usr"
|
33
33
|
#}
|
34
34
|
|
35
35
|
}
|
@@ -44,6 +44,7 @@ module Purple
|
|
44
44
|
|
45
45
|
def self.parse string
|
46
46
|
script = self.new
|
47
|
+
puts "DEBUG Purple::Script##parse: script_string=#{string}" if $DEBUG
|
47
48
|
script.instance_eval string
|
48
49
|
puts "DEBUG Purple::Script##parse: cabinet=#{script.cabinet}" if $DEBUG
|
49
50
|
script.cabinet
|
@@ -68,7 +69,7 @@ module Purple
|
|
68
69
|
end
|
69
70
|
|
70
71
|
def package name=nil
|
71
|
-
puts "> #package(#{name.inspect})"
|
72
|
+
puts "> #package(#{name.inspect})" if $DEBUG
|
72
73
|
package = PackageScript.new @cabinet
|
73
74
|
@package_scripts << package
|
74
75
|
package.name name
|
@@ -119,7 +120,7 @@ module Purple
|
|
119
120
|
end
|
120
121
|
|
121
122
|
callthrough :long_name, :name, :identifier, :version, :major, :minor
|
122
|
-
callthrough :prepare, :config, :build, :stage, :make
|
123
|
+
callthrough :prepare, :setup, :config, :build, :stage, :make
|
123
124
|
|
124
125
|
def pkg
|
125
126
|
@package
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.8.1
|
|
3
3
|
specification_version: 1
|
4
4
|
name: purplepkg
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date:
|
8
|
-
summary: A simple pre-
|
6
|
+
version: 0.0.6
|
7
|
+
date: 2005-03-08
|
8
|
+
summary: A simple pre-packaging tool with meta-package plugin support.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
author: Simon Conrad-Armes
|
12
12
|
email: curne@curnomatic.dk
|
13
13
|
homepage: purplepkg.rubyforge.org
|
14
|
-
rubyforge_project:
|
14
|
+
rubyforge_project: purplepkg
|
15
15
|
description:
|
16
16
|
autorequire:
|
17
17
|
default_executable:
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/purple/platform.rb
|
41
41
|
- lib/purple/debian.rb
|
42
42
|
- lib/purple/process.rb
|
43
|
+
- lib/purple/getter_curl.rb
|
43
44
|
- bin/purple
|
44
45
|
- bin/install_ruby
|
45
46
|
test_files: []
|