purplepkg 0.0.3 → 0.0.4

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.
@@ -0,0 +1,57 @@
1
+ DEBIAN_CONTROL_TEMPLATE = proc do |pkg| <<EOS
2
+ Source: #{pkg.name}
3
+ Section: unknown
4
+ Priority: optional
5
+ Maintainer:
6
+ Uploaders:
7
+ Build-Depends: debhelper (>> 3.0.0)
8
+
9
+ Package: #{pkg.name}
10
+ Architecture: #{`dpkg-architecture -qDEB_HOST_GNU_CPU`.strip}
11
+ Description: #{pkg.description}
12
+ #{pkg.description}
13
+ EOS
14
+ end
15
+
16
+ DEBIAN_CHANGELOG_TEMPLATE = proc do |pkg| <<EOS
17
+ #{pkg.name} (#{pkg.version}) local; urgency=low
18
+
19
+ * Created Purple Package for #{pkg.long_name}
20
+
21
+ -- mainname <mainemail> #{`822-date`}
22
+
23
+ EOS
24
+ end
25
+
26
+ module Purple
27
+ class PurpleCabinet
28
+ def make
29
+ packages.each do |pkg|
30
+
31
+ debian_dir = assert_dir File.join(pkg.srcdir, 'debian')
32
+
33
+ # Debian changelog file - creating dummy
34
+ File.open File.join(debian_dir, 'changelog'), 'w' do |f|
35
+ f.write DEBIAN_CHANGELOG_TEMPLATE.call(pkg)
36
+ end
37
+
38
+ # Debian control file
39
+ File.open File.join(debian_dir, 'control'), 'w' do |f|
40
+ f.write DEBIAN_CONTROL_TEMPLATE.call(pkg)
41
+ end
42
+
43
+ File.symlink pkg.stage_root, File.join(debian_dir, 'tmp') unless File.symlink? File.join(debian_dir, 'tmp')
44
+ assert_dir File.join(debian_dir, 'tmp', 'DEBIAN')
45
+
46
+ system "cd #{pkg.srcdir}; dpkg-gencontrol"
47
+ system "dpkg-deb -b #{pkg.stage_root} #{packagedir}"
48
+ end
49
+ end
50
+
51
+ def deploy
52
+ package_list = Dir.new(packagedir).to_a.reject{|s| s =~ /^\.{1,2}/}
53
+ puts "DEBUG PurpleCabinet#deploy(debian.rb): #{package_list.inspect}"
54
+ system "cd #{packagedir}; sudo dpkg -i #{package_list.collect{|s| '"'+s+'"'}.join(' ')}"
55
+ end
56
+ end
57
+ end
@@ -53,7 +53,7 @@ module Purple
53
53
  when /bz2$/; '-j'
54
54
  else ''
55
55
  end
56
- if not Purple.sys "tar x #{unpack} -C '#{cabinet.srcdir}' -f #{cabinet.filesdir}/#{f}"
56
+ if not cabinet.sys 'prepare', "tar xv #{unpack} -C '#{cabinet.srcdir}' -f #{cabinet.filesdir}/#{f}"
57
57
  throw :stop
58
58
  end
59
59
  end
@@ -61,11 +61,11 @@ module Purple
61
61
  end
62
62
 
63
63
  def default_config
64
- throw :stop unless system "cd #{srcdir}; ./configure --prefix=/usr"
64
+ throw :stop unless cabinet.sys 'config', "cd #{srcdir}; ./configure --prefix=/usr"
65
65
  end
66
66
 
67
67
  def default_build
68
- throw :stop unless system "make -C '#{srcdir}'"
68
+ throw :stop unless cabinet.sys 'build', "make -C '#{srcdir}'"
69
69
  end
70
70
 
71
71
  def default_stage
@@ -89,7 +89,7 @@ module Purple
89
89
  end
90
90
  end
91
91
 
92
- throw :stop if not system "make -C '#{srcdir}' #{make_args} install"
92
+ throw :stop if not cabinet.sys 'stage', "make -C '#{srcdir}' #{make_args} install"
93
93
  end
94
94
  end
95
95
  end
@@ -0,0 +1,33 @@
1
+
2
+ module Purple
3
+ module Run
4
+ class Child
5
+ def initialize name, dir, cmd, *args
6
+ @out = File.new File.join(dir, name + ".out"), 'w'
7
+ @err = File.new File.join(dir, name + ".err"), 'w'
8
+ @cmd, @args = cmd, args
9
+ @status = @exit_code = nil
10
+ end
11
+ attr_reader :status, :exit_code
12
+
13
+ def start
14
+ pid = fork do
15
+ STDOUT.reopen @out
16
+ STDERR.reopen @err
17
+ puts "> #{@cmd} #{@args.join ' '}"
18
+ exec @cmd, *@args
19
+ end
20
+ Thread.new do
21
+ begin
22
+ #puts "DEBUG Purple::Process::Child#start: HERE"
23
+ @exit_code = Process.waitpid2(pid)[1].exitstatus
24
+ #puts "DEBUG Purple::Process::Child#start: status=#{@exit_code}"
25
+ ensure
26
+ @status = :done
27
+ end
28
+ end
29
+ #pid
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+
2
+
3
+ module Purple
4
+ module Util
5
+ def self.filter filename
6
+ contents = File.open(filename) { |f| contents = yield f.read }
7
+ File.open(filename, 'w') { |f| f.write contents }
8
+ end
9
+ end
10
+ end
data/lib/purple.rb CHANGED
@@ -7,6 +7,8 @@ module Purple
7
7
  autoload :Script, 'purple/script'
8
8
  autoload :Matches, 'purple/matches'
9
9
  autoload :Platform, 'purple/platform'
10
+ autoload :Run, 'purple/process'
11
+ autoload :Util, 'purple/util'
10
12
  PURPLE_FOLDER = "#{ENV['HOME']}/purple"
11
13
 
12
14
 
@@ -36,6 +38,10 @@ module Purple
36
38
  assert_dir File.join(@cabinet_dir, 'Package')
37
39
  end
38
40
 
41
+ def logdir
42
+ assert_dir File.join(@cabinet_dir, 'Log')
43
+ end
44
+
39
45
  def fetch_all
40
46
  urls.each do |url|
41
47
  Getter.get url, filesdir
@@ -127,7 +133,23 @@ module Purple
127
133
  end
128
134
  (FileTest.directory? path) ? path : nil
129
135
  end
130
-
136
+
137
+ def sys name, cmd, *args
138
+ bars = [' -', ' \\', ' |', ' /']
139
+ child = Run::Child.new name, logdir, cmd, *args
140
+ $>.print " > #{name}\015"
141
+ $>.flush
142
+ child.start
143
+ while not child.status
144
+ $>.print bars[0] + "\015"
145
+ $>.flush
146
+ bars << bars.shift
147
+ sleep 1
148
+ end
149
+ puts "Done"
150
+ return(child.exit_code == 0)
151
+ end
152
+
131
153
  end
132
154
 
133
155
  class PackageInfo
@@ -202,14 +224,15 @@ module Purple
202
224
  EOS
203
225
  )
204
226
  cabinet.setup
205
- Purple::Script.write cabinet, File.join(cabinet.cabinet_dir, cabinet.name + '.purple')
206
- cabinet
207
- end
208
227
 
209
- def self.sys cmd
210
- system cmd
211
- end
228
+ purple_script_path = File.join(cabinet.cabinet_dir, cabinet.name + '.purple')
229
+ if FileTest.exist? purple_script_path
230
+ raise 'purple script already exists'
231
+ end
212
232
 
233
+ Purple::Script.write cabinet, purple_script_path
234
+ cabinet
235
+ end
213
236
  end
214
237
 
215
238
  module Kernel
metadata CHANGED
@@ -3,8 +3,8 @@ 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.3
7
- date: 2004-11-12
6
+ version: 0.0.4
7
+ date: 2004-11-19
8
8
  summary: A simple pre-packing tool with meta-package plugin support.
9
9
  require_paths:
10
10
  - lib
@@ -35,8 +35,11 @@ files:
35
35
  - lib/purple/pkg_actions.rb
36
36
  - lib/purple/script.rb
37
37
  - lib/purple/makefile.rb
38
+ - lib/purple/util.rb
38
39
  - lib/purple/getter.rb
39
40
  - lib/purple/platform.rb
41
+ - lib/purple/debian.rb
42
+ - lib/purple/process.rb
40
43
  - bin/purple
41
44
  - bin/install_ruby
42
45
  test_files: []