tpkg 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Rakefile +1 -1
  2. data/bin/gem2tpkg +3 -2
  3. data/bin/tpkg +1 -1
  4. data/lib/tpkg.rb +33 -17
  5. data/lib/tpkg/metadata.rb +14 -1
  6. metadata +42 -17
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ spec = Gem::Specification.new do |s|
5
5
  s.add_dependency('facter')
6
6
  s.add_dependency('net-ssh')
7
7
  s.add_dependency('ddao-kwalify')
8
- s.version = '2.2.0'
8
+ s.version = '2.2.1'
9
9
  s.authors = ['Darren Dao', 'Jason Heiss']
10
10
  s.email = 'tpkg-users@lists.sourceforge.net'
11
11
  s.homepage = 'http://tpkg.sourceforge.net'
data/bin/gem2tpkg CHANGED
@@ -14,8 +14,9 @@ require 'facter'
14
14
  # default, as that may not be a tpkg gem. I.e. /usr/bin/gem on Mac OS X.
15
15
  DEFAULT_GEM_COMMAND = "#{Tpkg::DEFAULT_BASE}/ruby-1.8/bin/gem"
16
16
 
17
- # Haven't found a Ruby method for creating temporary directories,
18
- # so create a temporary file and replace it with a directory.
17
+ # Ruby 1.8.7 and later have Dir.mktmpdir, but we support ruby 1.8.5 for
18
+ # RHEL/CentOS 5. So this is a basic substitute.
19
+ # FIXME: consider "backport" for Dir.mktmpdir like we use in the test suite
19
20
  def tempdir(basename, tmpdir=Dir::tmpdir)
20
21
  tmpfile = Tempfile.new(basename, tmpdir)
21
22
  tmpdir = tmpfile.path
data/bin/tpkg CHANGED
@@ -483,7 +483,7 @@ when :verify
483
483
  # Verify an installed pkg
484
484
  else
485
485
  tpkg = instantiate_tpkg(@tpkg_options)
486
- results = tpkg.verify_file_metadata(@action_value)
486
+ results = tpkg.verify_file_metadata([@action_value])
487
487
  if results.length == 0
488
488
  puts "No package found"
489
489
  end
data/lib/tpkg.rb CHANGED
@@ -56,7 +56,7 @@ require 'kwalify' # for validating yaml
56
56
 
57
57
  class Tpkg
58
58
 
59
- VERSION = '2.2.0'
59
+ VERSION = '2.2.1'
60
60
 
61
61
  GENERIC_ERR = 1
62
62
  POSTINSTALL_ERR = 2
@@ -452,15 +452,28 @@ class Tpkg
452
452
  end
453
453
  toplevel
454
454
  end
455
-
455
+
456
+ # Takes the path to the 'tpkg' directory of an unpacked package and returns
457
+ # an array of the top level directories that exist for package files within
458
+ # that directory. Currently that is one or both of 'reloc' for relocatable
459
+ # files and 'root' for non-relocatable files.
460
+ def self.get_package_toplevels(tpkgdir)
461
+ toplevels = []
462
+ ['reloc', 'root'].each do |toplevel|
463
+ if File.directory?(File.join(tpkgdir, toplevel))
464
+ toplevels << File.join(tpkgdir, toplevel)
465
+ end
466
+ end
467
+ toplevels
468
+ end
469
+
456
470
  def self.get_filemetadata_from_directory(tpkgdir)
457
471
  filemetadata = {}
458
472
  root_dir = File.join(tpkgdir, "root")
459
473
  reloc_dir = File.join(tpkgdir, "reloc")
460
474
  files = []
461
475
 
462
- Find.find(root_dir, reloc_dir) do |f|
463
- next if !File.exist?(f)
476
+ Find.find(*get_package_toplevels(tpkgdir)) do |f|
464
477
  relocatable = false
465
478
 
466
479
  # Append file separator at the end for directory
@@ -625,8 +638,9 @@ class Tpkg
625
638
  File.rename(metadata_tmpfile.path, File.join(dest, 'metadata.yml'))
626
639
  end
627
640
 
628
- # Haven't found a Ruby method for creating temporary directories,
629
- # so create a temporary file and replace it with a directory.
641
+ # Ruby 1.8.7 and later have Dir.mktmpdir, but we support ruby 1.8.5 for
642
+ # RHEL/CentOS 5. So this is a basic substitute.
643
+ # FIXME: consider "backport" for Dir.mktmpdir like we use in the test suite
630
644
  def self.tempdir(basename, tmpdir=Dir::tmpdir)
631
645
  tmpfile = Tempfile.new(basename, tmpdir)
632
646
  tmpdir = tmpfile.path
@@ -1303,6 +1317,8 @@ class Tpkg
1303
1317
  elsif File.directory?(File.join(@configdir, 'tpkg', 'ca'))
1304
1318
  http.ca_path = File.join(@configdir, 'tpkg', 'ca')
1305
1319
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
1320
+ else
1321
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
1306
1322
  end
1307
1323
  end
1308
1324
  http.start
@@ -2559,12 +2575,7 @@ class Tpkg
2559
2575
 
2560
2576
  root_dir = File.join(workdir, 'tpkg', 'root')
2561
2577
  reloc_dir = File.join(workdir, 'tpkg', 'reloc')
2562
- Find.find(root_dir, reloc_dir) do |f|
2563
- # If the package doesn't contain either of the top level
2564
- # directories we need to skip them, find will pass them to us
2565
- # even if they don't exist.
2566
- next if !File.exist?(f)
2567
-
2578
+ Find.find(*Tpkg::get_package_toplevels(File.join(workdir, 'tpkg'))) do |f|
2568
2579
  begin
2569
2580
  if File.directory?(f)
2570
2581
  File.chown(default_dir_uid, default_dir_gid, f)
@@ -2669,11 +2680,7 @@ class Tpkg
2669
2680
 
2670
2681
  # We should get the perms, gid, uid stuff here since all the files
2671
2682
  # have been set up correctly
2672
- Find.find(root_dir, reloc_dir) do |f|
2673
- # If the package doesn't contain either of the top level
2674
- # directory we need to skip them, find will pass them to us
2675
- # even if they don't exist.
2676
- next if !File.exist?(f)
2683
+ Find.find(*Tpkg::get_package_toplevels(File.join(workdir, 'tpkg'))) do |f|
2677
2684
  next if File.symlink?(f)
2678
2685
 
2679
2686
  # check if it's from root dir or reloc dir
@@ -3078,6 +3085,15 @@ class Tpkg
3078
3085
  # datafile again in the future.
3079
3086
  external.delete(:datafile)
3080
3087
  elsif external[:datascript]
3088
+ # Warn the user about non-executable files, popen will visibly
3089
+ # complain but in the midst of a complex install of multiple
3090
+ # packages it won't be clear to the user in what context the
3091
+ # program was executed nor which package has the problem. Our
3092
+ # warning specifies that it was a datascript and includes the
3093
+ # package name.
3094
+ if !File.executable?(external[:datascript])
3095
+ warn "Warning: datascript for package #{File.basename(metadata[:filename])} is not executable, execution will likely fail"
3096
+ end
3081
3097
  # Run the script
3082
3098
  IO.popen(external[:datascript]) do |pipe|
3083
3099
  external[:data] = pipe.read
data/lib/tpkg/metadata.rb CHANGED
@@ -560,7 +560,20 @@ class Metadata
560
560
  external = {}
561
561
  external[:name] = extxml.elements['name'].text
562
562
  if extxml.elements['data']
563
- external[:data] = extxml.elements['data'].children.to_s
563
+ # The data element requires special handling. We want to capture its
564
+ # raw contents, which may be XML. The "text" method we use for other
565
+ # fields only returns text outside of child XML elements. That fine
566
+ # for other fields which we don't expect to contain any child
567
+ # elements. But here there may well be child elements and we need to
568
+ # capture the raw data.
569
+ # I.e. if we have:
570
+ # <data>
571
+ # <one>Some text</one>
572
+ # <two>Other text</two>
573
+ # </data>
574
+ # We want to capture:
575
+ # "\n <one>Some text</one>\n <two>Other text</two>\n"
576
+ external[:data] = extxml.elements['data'].children.join('')
564
577
  elsif extxml.elements['datafile']
565
578
  # We don't have access to the package contents here, so we just save
566
579
  # the name of the file and leave it up to others to read the file
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tpkg
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ hash: 5
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 2
9
+ - 1
10
+ version: 2.2.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Darren Dao
@@ -10,39 +16,51 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2011-01-10 00:00:00 -08:00
19
+ date: 2011-02-04 00:00:00 -08:00
14
20
  default_executable:
15
21
  dependencies:
16
22
  - !ruby/object:Gem::Dependency
17
23
  name: facter
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
21
27
  requirements:
22
28
  - - ">="
23
29
  - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
24
33
  version: "0"
25
- version:
34
+ type: :runtime
35
+ version_requirements: *id001
26
36
  - !ruby/object:Gem::Dependency
27
37
  name: net-ssh
28
- type: :runtime
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
31
41
  requirements:
32
42
  - - ">="
33
43
  - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
34
47
  version: "0"
35
- version:
48
+ type: :runtime
49
+ version_requirements: *id002
36
50
  - !ruby/object:Gem::Dependency
37
51
  name: ddao-kwalify
38
- type: :runtime
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
41
55
  requirements:
42
56
  - - ">="
43
57
  - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
44
61
  version: "0"
45
- version:
62
+ type: :runtime
63
+ version_requirements: *id003
46
64
  description:
47
65
  email: tpkg-users@lists.sourceforge.net
48
66
  executables:
@@ -93,21 +111,28 @@ rdoc_options: []
93
111
  require_paths:
94
112
  - lib
95
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
96
115
  requirements:
97
116
  - - ">="
98
117
  - !ruby/object:Gem::Version
118
+ hash: 31
119
+ segments:
120
+ - 1
121
+ - 8
99
122
  version: "1.8"
100
- version:
101
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
102
125
  requirements:
103
126
  - - ">="
104
127
  - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
105
131
  version: "0"
106
- version:
107
132
  requirements: []
108
133
 
109
134
  rubyforge_project: tpkg
110
- rubygems_version: 1.3.5
135
+ rubygems_version: 1.3.7
111
136
  signing_key:
112
137
  specification_version: 3
113
138
  summary: tpkg Application Packaging & Deployment