enhancerepo 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +27 -0
  3. data/bin/enhancerepo +2 -3
  4. data/lib/enhance_repo.rb +8 -13
  5. data/lib/enhance_repo/array_arg.rb +85 -0
  6. data/lib/enhance_repo/cli.rb +23 -78
  7. data/lib/enhance_repo/config_opts.rb +207 -13
  8. data/lib/enhance_repo/logger.rb +14 -10
  9. data/lib/enhance_repo/other.rb +11 -12
  10. data/lib/enhance_repo/package_id.rb +21 -12
  11. data/lib/enhance_repo/pattern.rb +50 -0
  12. data/lib/enhance_repo/product_id.rb +3 -1
  13. data/lib/enhance_repo/rpm_md.rb +3 -1
  14. data/lib/enhance_repo/rpm_md/data.rb +6 -7
  15. data/lib/enhance_repo/rpm_md/delta_info.rb +58 -67
  16. data/lib/enhance_repo/rpm_md/extra_primary_data.rb +4 -4
  17. data/lib/enhance_repo/rpm_md/file_lists.rb +12 -13
  18. data/lib/enhance_repo/rpm_md/index.rb +32 -27
  19. data/lib/enhance_repo/rpm_md/other.rb +7 -8
  20. data/lib/enhance_repo/rpm_md/pattern_writer.rb +131 -0
  21. data/lib/enhance_repo/rpm_md/patterns.rb +158 -0
  22. data/lib/enhance_repo/rpm_md/primary.rb +32 -33
  23. data/lib/enhance_repo/rpm_md/products.rb +19 -24
  24. data/lib/enhance_repo/rpm_md/repo.rb +33 -36
  25. data/lib/enhance_repo/rpm_md/resource.rb +6 -6
  26. data/lib/enhance_repo/rpm_md/suse_data.rb +41 -50
  27. data/lib/enhance_repo/rpm_md/suse_info.rb +12 -15
  28. data/lib/enhance_repo/rpm_md/update.rb +65 -36
  29. data/lib/enhance_repo/rpm_md/update_info.rb +38 -42
  30. data/lib/enhance_repo/rpm_md/update_smart_fields.rb +24 -24
  31. data/lib/enhance_repo/susetags/pattern_reader.rb +142 -0
  32. data/lib/enhance_repo/version.rb +5 -0
  33. data/lib/enhance_repo/xml_comparer.rb +28 -24
  34. metadata +190 -221
  35. data/CHANGELOG.rdoc +0 -18
  36. data/Manifest.txt +0 -85
  37. data/README +0 -10
  38. data/README.rdoc +0 -15
  39. data/Rakefile +0 -48
  40. data/TODO.rdoc +0 -4
  41. data/lib/tempdir.rb +0 -62
  42. data/lib/tempdir/tempfile.rb +0 -21
  43. data/test/all_tests.rb +0 -27
  44. data/test/data/packages/a-1.0.spec +0 -19
  45. data/test/data/packages/a-2.0.spec +0 -24
  46. data/test/data/repodata/update-test-11.1/filelists.xml.gz +0 -0
  47. data/test/data/repodata/update-test-11.1/other.xml.gz +0 -0
  48. data/test/data/repodata/update-test-11.1/primary.xml.gz +0 -0
  49. data/test/data/repodata/update-test-11.1/repomd.xml +0 -21
  50. data/test/data/repomd.xml +0 -21
  51. data/test/data/rpms/repo-1/a-1.0-0.x86_64.rpm +0 -0
  52. data/test/data/rpms/repo-1/a-1.0_2.0-0_0.x86_64.delta.rpm +0 -0
  53. data/test/data/rpms/repo-1/a-2.0-0.x86_64.rpm +0 -0
  54. data/test/data/rpms/repo-1/repodata/deltainfo.xml.gz +0 -0
  55. data/test/data/rpms/repo-1/repodata/deltainfo.xml.gz.gz +0 -0
  56. data/test/data/rpms/repo-1/repodata/filelists.xml.gz +0 -0
  57. data/test/data/rpms/repo-1/repodata/other.xml.gz +0 -0
  58. data/test/data/rpms/repo-1/repodata/primary.xml.gz +0 -0
  59. data/test/data/rpms/repo-1/repodata/repomd.xml +0 -45
  60. data/test/data/rpms/repo-1/repodata/susedata.xml.gz +0 -0
  61. data/test/data/rpms/repo-1/repodata/updateinfo.xml.gz +0 -0
  62. data/test/data/rpms/repo-1/repoparts/update-a-1.xml +0 -22
  63. data/test/data/rpms/repo-with-product/a-1.0-0.x86_64.rpm +0 -0
  64. data/test/data/rpms/repo-with-product/openSUSE-release-11.2-1.6.i586.rpm +0 -0
  65. data/test/data/rpms/repo-with-product/openSUSE-release-dvd-11.2-1.6.i586.rpm +0 -0
  66. data/test/data/rpms/repo-with-product/repodata/filelists.xml.gz +0 -0
  67. data/test/data/rpms/repo-with-product/repodata/other.xml.gz +0 -0
  68. data/test/data/rpms/repo-with-product/repodata/primary.xml.gz +0 -0
  69. data/test/data/rpms/repo-with-product/repodata/products.xml.gz +0 -0
  70. data/test/data/rpms/repo-with-product/repodata/repomd.xml +0 -27
  71. data/test/data/rpms/update-test-11.1/update-test-affects-package-manager.rpm +0 -0
  72. data/test/data/rpms/update-test-11.1/update-test-interactive.rpm +0 -0
  73. data/test/data/rpms/update-test-11.1/update-test-optional.rpm +0 -0
  74. data/test/data/rpms/update-test-11.1/update-test-reboot-needed.rpm +0 -0
  75. data/test/data/rpms/update-test-11.1/update-test-security.rpm +0 -0
  76. data/test/data/rpms/update-test-11.1/update-test-trival.rpm +0 -0
  77. data/test/data/rpms/update-test-factory/update-test-affects-package-manager-0-9999.1.2.noarch.rpm +0 -0
  78. data/test/data/rpms/update-test-factory/update-test-interactive-0-9999.1.2.noarch.rpm +0 -0
  79. data/test/data/rpms/update-test-factory/update-test-optional-0-9999.1.2.noarch.rpm +0 -0
  80. data/test/data/rpms/update-test-factory/update-test-reboot-needed-0-9999.1.2.noarch.rpm +0 -0
  81. data/test/data/rpms/update-test-factory/update-test-relogin-suggested-0-9999.1.2.noarch.rpm +0 -0
  82. data/test/data/rpms/update-test-factory/update-test-security-0-9999.1.2.noarch.rpm +0 -0
  83. data/test/deltainfo_test.rb +0 -50
  84. data/test/extensions_test.rb +0 -31
  85. data/test/index_test.rb +0 -51
  86. data/test/primary_test.rb +0 -51
  87. data/test/products_test.rb +0 -51
  88. data/test/repo_test.rb +0 -72
  89. data/test/repomdindex_test.rb +0 -58
  90. data/test/rpmmd_test.rb +0 -60
  91. data/test/susedata_test.rb +0 -53
  92. data/test/tempdir_test.rb +0 -62
  93. data/test/test_helper.rb +0 -53
  94. data/test/update_test.rb +0 -80
  95. data/test/updateinfo_test.rb +0 -59
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -24,15 +26,14 @@
24
26
  #
25
27
 
26
28
  module EnhanceRepo
27
-
28
29
  def self.enable_logger
29
30
  # support both log4r and ruby logger
30
31
  begin
31
32
  require 'log4r'
32
33
  include Log4r
33
34
  @logger = Log4r::Logger.new 'enhancerepo'
34
- console_format = Log4r::PatternFormatter.new(:pattern => "%l:\t %m")
35
- @logger.add Log4r::StdoutOutputter.new('console', :formatter=>console_format)
35
+ console_format = Log4r::PatternFormatter.new(pattern: "%l:\t %m")
36
+ @logger.add Log4r::StdoutOutputter.new('console', formatter: console_format)
36
37
  rescue LoadError
37
38
  require 'logger'
38
39
  @logger = ::Logger.new(STDERR)
@@ -41,21 +42,25 @@ module EnhanceRepo
41
42
  end
42
43
 
43
44
  def self.using_log4r?
44
- (! (Object.const_get(:Log4r) rescue nil).nil?)
45
+ !(begin
46
+ Object.const_get(:Log4r)
47
+ rescue
48
+ nil
49
+ end).nil?
45
50
  end
46
-
51
+
47
52
  def self.enable_debug
48
53
  EnhanceRepo.logger.level = using_log4r? ? Log4r::DEBUG : ::Logger::DEBUG
49
54
  end
50
-
55
+
51
56
  def self.logger
52
57
  @logger
53
58
  end
54
59
 
55
60
  def self.logger=(logger)
56
- @logger = logger
61
+ @logger = logger
57
62
  end
58
-
63
+
59
64
  # provide easy access to classes to the
60
65
  # global logger
61
66
  module Logger
@@ -63,5 +68,4 @@ module EnhanceRepo
63
68
  EnhanceRepo.logger
64
69
  end
65
70
  end
66
-
67
71
  end
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -30,7 +32,6 @@ module EnhanceRepo
30
32
  # http://en.opensuse.org/Standards/Rpm_Metadata
31
33
  #
32
34
  class Other
33
-
34
35
  def initialize(dir)
35
36
  @dir = dir
36
37
  @rpmfiles = []
@@ -39,7 +40,7 @@ module EnhanceRepo
39
40
  def read
40
41
  Dir["#{@dir}/**/*.rpm"].each do |rpmfile|
41
42
  @rpmfiles << rpmfile
42
- end
43
+ end
43
44
  end
44
45
 
45
46
  def empty?
@@ -47,34 +48,32 @@ module EnhanceRepo
47
48
  end
48
49
 
49
50
  def write_package(file, rpmfile)
50
- b = Builder::XmlMarkup.new(:target=>file, :indent=>2, :initial=>2)
51
+ b = Builder::XmlMarkup.new(target: file, indent: 2, initial: 2)
51
52
  pkgid = PackageId.new(rpmfile)
52
53
  puts pkgid.rpm.methods.sort
53
54
  pkgid[RPM::TAG_CHANGELOGTEXT].each do |ch|
54
55
  puts ch
55
56
  end
56
57
  exit
57
- b.package('pkgid'=>pkgid.checksum, 'name' => pkgid.name, 'arch'=>pkgid.arch ) do | b |
58
+ b.package('pkgid' => pkgid.checksum, 'name' => pkgid.name, 'arch' => pkgid.arch) do |b|
58
59
  b.version('epoch' => pkgid.version.e, 'ver' => pkgid.version.v, 'rel' => pkgid.version.r)
59
60
  pkgid.files.each do |f|
60
61
  b.file f
61
62
  end
62
63
  end
63
64
  end
64
-
65
+
65
66
  # write filelists.xml
66
67
  def write(file)
67
- #builder = Builder::XmlMarkup.new(:target=>file, :indent=>2)
68
- #builder.instruct!
69
- #xml = builder.tag!("otherdata", 'xmlns' => 'xmlns="http://linux.duke.edu/metadata/other"', 'packages'=> @rpmfiles.size ) do |b|
68
+ # builder = Builder::XmlMarkup.new(:target=>file, :indent=>2)
69
+ # builder.instruct!
70
+ # xml = builder.tag!("otherdata", 'xmlns' => 'xmlns="http://linux.duke.edu/metadata/other"', 'packages'=> @rpmfiles.size ) do |b|
70
71
  @rpmfiles.each do |rpmfile|
71
72
  # done package tag
72
73
  write_package(file, rpmfile)
73
74
  end
74
75
  # next package
75
- #end
76
+ # end
76
77
  end
77
-
78
78
  end
79
-
80
79
  end
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -23,28 +25,28 @@
23
25
  #++
24
26
  #
25
27
 
26
- require 'digest/sha1'
27
28
  require 'rpm'
28
29
 
29
30
  module EnhanceRepo
30
-
31
31
  # thin wrapper over rpm package
32
32
  class PackageId
33
33
  attr_accessor :checksum
34
34
  attr_accessor :path
35
35
  attr_accessor :rpm
36
-
36
+
37
+ include Logger
38
+
37
39
  def initialize(rpmfile)
38
40
  @path = rpmfile
39
- @rpm = RPM::Package.open(rpmfile)
40
- @checksum = Digest::SHA1.hexdigest(File.new(rpmfile).read)
41
+ @rpm = RPM::Package.open(rpmfile)
42
+ @checksum = EnhanceRepo::ConfigOpts.instance.digest_class.hexdigest(File.new(rpmfile).read)
41
43
  end
42
44
 
43
45
  # Forward other methods
44
46
  def method_missing(sym, *args)
45
47
  @rpm.send(sym, *args)
46
48
  end
47
-
49
+
48
50
  def hash
49
51
  @checksum.hash
50
52
  end
@@ -52,7 +54,16 @@ module EnhanceRepo
52
54
  def eql?(other)
53
55
  @checksum == other.checksum
54
56
  end
55
-
57
+
58
+ def arch
59
+ s = self[RPM::TAG_SOURCERPM]
60
+ if s.nil?
61
+ return 'src'
62
+ else
63
+ return @rpm.arch
64
+ end
65
+ end
66
+
56
67
  # match function at name and nvr level
57
68
  def matches(ident)
58
69
  # if the name matches, then it is sufficient
@@ -65,7 +76,7 @@ module EnhanceRepo
65
76
  return true if ident == "#{@rpm.name}-#{@rpm.version.v}-#{@rpm.version.r}"
66
77
  # and finally arch
67
78
  return true if ident == "#{@rpm.name}-#{@rpm.version.v}-#{@rpm.version.r}.#{@rpm.arch}"
68
- return false
79
+ false
69
80
  end
70
81
 
71
82
  def to_s
@@ -73,9 +84,7 @@ module EnhanceRepo
73
84
  end
74
85
 
75
86
  def ident
76
- "#{@rpm.to_s}.#{@rpm.arch}"
87
+ "#{@rpm}.#{@rpm.arch}"
77
88
  end
78
-
79
89
  end
80
-
81
90
  end
@@ -0,0 +1,50 @@
1
+ # Encoding: utf-8
2
+
3
+ require 'enhance_repo/rpm_md/pattern_writer'
4
+
5
+ module EnhanceRepo
6
+ class Pattern
7
+ # include serialization
8
+ include RpmMd::PatternWriter
9
+
10
+ attr_accessor :name
11
+ attr_accessor :version
12
+ attr_accessor :release
13
+ attr_accessor :architecture
14
+ attr_accessor :summary
15
+ attr_accessor :description
16
+ attr_accessor :icon
17
+ attr_accessor :order
18
+ attr_accessor :visible
19
+ attr_accessor :category
20
+ attr_accessor :supplements
21
+ attr_accessor :conflicts
22
+ attr_accessor :provides
23
+ attr_accessor :requires
24
+ attr_accessor :recommends
25
+ attr_accessor :suggests
26
+ attr_accessor :extends
27
+ attr_accessor :includes
28
+
29
+ def initialize
30
+ @name = ''
31
+ @version = ''
32
+ @release = ''
33
+ @architecture = 'noarch'
34
+ @summary = {}
35
+ @description = {}
36
+ @icon = nil
37
+ @order = 0
38
+ @visible = true
39
+ @category = {}
40
+ @supplements = {}
41
+ @conflicts = {}
42
+ @provides = {}
43
+ @requires = {}
44
+ @recommends = {}
45
+ @suggests = {}
46
+ @extends = {}
47
+ @includes = {}
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -25,11 +27,10 @@
25
27
 
26
28
  module EnhanceRepo
27
29
  module RpmMd
28
-
29
30
  # represents a metadata unit
30
31
  class Data
31
32
  include Logger
32
-
33
+
33
34
  # initialize the extra data with a name
34
35
  # or use the class name as default
35
36
  def initialize(name)
@@ -37,9 +38,9 @@ module EnhanceRepo
37
38
  end
38
39
 
39
40
  def name
40
- defined?(@name) ? @name : self.class.to_s.split("::").last.downcase
41
+ defined?(@name) ? @name : self.class.to_s.split('::').last.downcase
41
42
  end
42
-
43
+
43
44
  def metadata_filename
44
45
  "repodata/#{name}.xml#{should_compress? ? '.gz' : ''}"
45
46
  end
@@ -48,8 +49,6 @@ module EnhanceRepo
48
49
  def should_compress?
49
50
  true
50
51
  end
51
-
52
52
  end
53
-
54
53
  end
55
54
  end
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  #--
2
- #
4
+ #
3
5
  # enhancerepo is a rpm-md repository metadata tool.
4
6
  # Copyright (C) 2008, 2009 Novell Inc.
5
7
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
@@ -32,19 +34,18 @@ require 'pathname'
32
34
 
33
35
  module EnhanceRepo
34
36
  module RpmMd
35
-
36
37
  include REXML
37
38
 
38
39
  class DeltaRpm < PackageId
39
40
  attr_accessor :sequence, :sourcerpm
40
-
41
+
41
42
  def initialize(filename)
42
43
  super(filename)
43
44
  `applydeltarpm -i '#{filename}'`.each_line do |line|
44
45
  key, value = line.chop.split(':')
45
- value.gsub!(/ /, '')
46
- @sequence = value if key == "sequence"
47
- @sourcerpm = value if key == "source rpm"
46
+ value.delete!(' ')
47
+ @sequence = value if key == 'sequence'
48
+ @sourcerpm = value if key == 'source rpm'
48
49
  end
49
50
  end
50
51
 
@@ -55,26 +56,24 @@ module EnhanceRepo
55
56
  def eql?(other)
56
57
  ident == other.ident
57
58
  end
58
-
59
59
  end
60
60
 
61
61
  class DeltaInfo < Data
62
-
63
62
  def initialize(dir)
64
63
  @dir = dir
65
64
  # here we store known deltas
66
65
  # we index by new package
67
66
  # and in every slot we store an
68
67
  # array with such deltas
69
- @deltas = Hash.new
68
+ @deltas = {}
70
69
  end
71
70
 
72
71
  def delta_count
73
72
  @deltas.size
74
73
  end
75
-
74
+
76
75
  def empty?
77
- return @deltas.empty?
76
+ @deltas.empty?
78
77
  end
79
78
 
80
79
  # Create delta rpms for the last
@@ -94,78 +93,73 @@ module EnhanceRepo
94
93
  # options are :n => number of deltas (default 1)
95
94
  # and :outputdir => defaulting to the same
96
95
  # input directory
97
- def create_deltas(opts={})
96
+ def create_deltas(opts = {})
98
97
  outputdir = opts[:outputdir] || @dir
99
98
  n = opts[:n] || 1
100
99
 
101
100
  log.info "Scanning rpms for delta generation (#{n} levels)"
102
- #log.info "Creating deltarpms : level #{n}"
101
+ # log.info "Creating deltarpms : level #{n}"
103
102
  # make a hash name -> array of packages
104
- pkgs = Hash.new
105
-
103
+ pkgs = {}
104
+
106
105
  Dir["#{@dir}/**/*.rpm"].each do |rpmfile|
107
- #puts "Delta: #{rpmfile}"
106
+ # puts "Delta: #{rpmfile}"
108
107
  rpm = PackageId.new(rpmfile)
109
-
110
- pkgs[rpm.name] = Array.new if not pkgs.has_key?(rpm.name)
108
+
109
+ pkgs[rpm.name] = [] unless pkgs.key?(rpm.name)
111
110
  pkgs[rpm.name] << rpm
112
111
  end
113
112
 
114
113
  # now that we have al packages, sort them by version
115
- pkgs.each do |pkgname, pkglist|
116
-
117
- pkglist.sort! { |a,b| a.version <=> b.version }
114
+ pkgs.each do |_pkgname, pkglist|
115
+ pkglist.sort! { |a, b| a.version <=> b.version }
118
116
  pkglist.reverse!
119
117
  # now that the list is sorted, the new rpm is the first
120
118
  newpkg = pkglist.shift
121
- c = 0
122
- if not pkglist.empty?
123
- for pkg in pkglist
124
- break if c == n
125
- # do not create a delta for the same package
126
- next if newpkg.version == pkg.version
127
- # do not create a delta for different archs
128
- next if newpkg.arch != pkg.arch
129
- oldpkg = pkg
130
- # use the same dir as the new rpm
131
- log.info "`-> creating delta - #{oldpkg.to_s} -> #{newpkg.to_s} (#{c+1}/#{n})"
132
- # calculate directory where to save the delta. Use the newpkg
133
- # relative to the origin directory,
134
- # this only works because we know the rpm is inside @dir
135
- subdir = Pathname.new(newpkg.path).relative_path_from(Pathname.new(@dir)).dirname
136
- # calculate the deltarpm name
137
- deltafile = File.join(outputdir, subdir, delta_package_name(oldpkg,newpkg))
138
- FileUtils.mkdir_p File.dirname(deltafile)
139
- #puts "makedeltarpm #{oldpkg.path} #{newpkg.path} #{deltafile}"
140
- `makedeltarpm '#{oldpkg.path}' '#{newpkg.path}' '#{deltafile}'`
141
- c += 1
142
- end
119
+ c = 0
120
+ next if pkglist.empty?
121
+ for pkg in pkglist
122
+ break if c == n
123
+ # do not create a delta for the same package
124
+ next if newpkg.version == pkg.version
125
+ # do not create a delta for different archs
126
+ next if newpkg.arch != pkg.arch
127
+ oldpkg = pkg
128
+ # use the same dir as the new rpm
129
+ log.info "`-> creating delta - #{oldpkg} -> #{newpkg} (#{c + 1}/#{n})"
130
+ # calculate directory where to save the delta. Use the newpkg
131
+ # relative to the origin directory,
132
+ # this only works because we know the rpm is inside @dir
133
+ subdir = Pathname.new(newpkg.path).relative_path_from(Pathname.new(@dir)).dirname
134
+ # calculate the deltarpm name
135
+ deltafile = File.join(outputdir, subdir, delta_package_name(oldpkg, newpkg))
136
+ FileUtils.mkdir_p File.dirname(deltafile)
137
+ # puts "makedeltarpm #{oldpkg.path} #{newpkg.path} #{deltafile}"
138
+ `makedeltarpm '#{oldpkg.path}' '#{newpkg.path}' '#{deltafile}'`
139
+ c += 1
143
140
  end
144
-
145
141
  end
146
-
147
142
  end
148
143
 
149
144
  # figure out the name of a delta rpm
150
145
  def delta_package_name(oldpkg, newpkg)
151
- deltarpm = ""
152
- if ( oldpkg.version.v == newpkg.version.v )
153
- # if the version is the same, then it is specified only once, and the range
154
- # is used for the releases
155
- deltarpm = "#{oldpkg.name}-#{oldpkg.version.v}-#{oldpkg.version.r}_#{newpkg.version.r}.#{oldpkg.arch}.delta.rpm"
156
- else
157
- deltarpm = "#{oldpkg.name}-#{oldpkg.version.v}_#{newpkg.version.v}-#{oldpkg.version.r}_#{newpkg.version.r}.#{oldpkg.arch}.delta.rpm"
158
- end
146
+ deltarpm = ''
147
+ deltarpm = if oldpkg.version.v == newpkg.version.v
148
+ # if the version is the same, then it is specified only once, and the range
149
+ # is used for the releases
150
+ "#{oldpkg.name}-#{oldpkg.version.v}-#{oldpkg.version.r}_#{newpkg.version.r}.#{oldpkg.arch}.delta.rpm"
151
+ else
152
+ "#{oldpkg.name}-#{oldpkg.version.v}_#{newpkg.version.v}-#{oldpkg.version.r}_#{newpkg.version.r}.#{oldpkg.arch}.delta.rpm"
153
+ end
159
154
  end
160
-
155
+
161
156
  def add_deltas
162
157
  Dir["#{@dir}/**/*.delta.rpm"].each do |deltafile|
163
158
  delta = DeltaRpm.new(deltafile)
164
- #puts "Delta: #{deltafile} for '#{delta.ident}'"
165
- @deltas[delta] = Array.new if @deltas[delta].nil?
159
+ # puts "Delta: #{deltafile} for '#{delta.ident}'"
160
+ @deltas[delta] = [] if @deltas[delta].nil?
166
161
  @deltas[delta] << delta
167
162
  end
168
-
169
163
  end
170
164
 
171
165
  # write a update out
@@ -173,13 +167,13 @@ module EnhanceRepo
173
167
  builder = Nokogiri::XML::Builder.new do |b|
174
168
  b.deltainfo do
175
169
  @deltas.each do |ident, deltas|
176
- b.newpackage( 'name' => ident.name, 'arch' => ident.arch,
177
- 'version' => ident.version.v,
178
- 'release' => ident.version.r ) do |b|
170
+ b.newpackage('name' => ident.name, 'arch' => ident.arch,
171
+ 'version' => ident.version.v,
172
+ 'release' => ident.version.r) do
179
173
  deltas.each do |delta|
180
174
  # get the edition by getting the name out
181
175
  version = RPM::Version.new(delta.sourcerpm.gsub(/#{Regexp.escape(delta.name)}-/, ''))
182
- b.delta('oldepoch'=>0, 'oldversion'=>version.v, 'oldrelease'=>version.r) do |b|
176
+ b.delta('oldepoch' => 0, 'oldversion' => version.v, 'oldrelease' => version.r) do
183
177
  # remove the base dir, make it relative
184
178
  delta_abs_path = Pathname.new(delta.path).realpath
185
179
  base_dir_abs_path = Pathname.new(@dir).realpath
@@ -187,19 +181,16 @@ module EnhanceRepo
187
181
  b.filename relative_path
188
182
  b.sequence(delta.sequence)
189
183
  b.size(File.size(delta.path))
190
- b.checksum(delta.checksum, 'type'=>'sha')
184
+ b.checksum(delta.checksum, 'type' => EnhanceRepo::ConfigOpts.instance.digest_name)
191
185
  end # </delta>
192
186
  end
193
187
  end # </newpackage>
194
188
  end # each delta
195
- end #</deltainfo>
189
+ end # </deltainfo>
196
190
  end
197
191
  # ready builder
198
- file.write(builder.doc.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML))
192
+ file.write(builder.doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML))
199
193
  end
200
-
201
194
  end
202
-
203
-
204
195
  end
205
196
  end