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,60 +0,0 @@
1
- #--
2
- #
3
- # enhancerepo is a rpm-md repository metadata tool.
4
- # Copyright (C) 2008, 2009 Novell Inc.
5
- # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
6
- #
7
- # This program is free software; you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation; either version 2 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program; if not, write to the Free Software
19
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
- # MA 02110-1301, USA. A copy of the GNU General Public License is
21
- # also available at http://www.gnu.org/copyleft/gpl.html.
22
- #
23
- #++
24
- #
25
- require File.join(File.dirname(__FILE__), 'test_helper')
26
- require 'tmpdir'
27
- require 'pathname'
28
- require 'rubygems'
29
- require 'enhance_repo'
30
- require 'stringio'
31
-
32
- class RpmMd_test < Test::Unit::TestCase
33
-
34
- def setup
35
- rpms = Pathname.new(File.join(File.dirname(__FILE__), 'data', 'rpms'))
36
- @rpms1 = rpms + 'update-test-11.1'
37
- @rpms3 = rpms + 'update-test-factory'
38
- end
39
-
40
- # def teardown
41
- # end
42
-
43
- def test_disk_info
44
- config = EnhanceRepo::ConfigOpts.new
45
- config.outputdir = Pathname.new(File.join(Dir.tmpdir, 'enhancerepo#{Time.now.to_i}'))
46
- config.dir = @rpms1
47
- @repo = EnhanceRepo::RpmMd::Repo.new(config)
48
- @repo.primary.read_packages
49
- out = StringIO.new
50
- @repo.primary.write(out)
51
- #puts out.string
52
-
53
- end
54
-
55
- def test_update_info
56
- #config.generate_update = packages
57
- end
58
-
59
-
60
- end
@@ -1,53 +0,0 @@
1
- #--
2
- #
3
- # enhancerepo is a rpm-md repository metadata tool.
4
- # Copyright (C) 2008, 2009 Novell Inc.
5
- # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
6
- #
7
- # This program is free software; you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation; either version 2 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program; if not, write to the Free Software
19
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
- # MA 02110-1301, USA. A copy of the GNU General Public License is
21
- # also available at http://www.gnu.org/copyleft/gpl.html.
22
- #
23
- #++
24
- #
25
- require File.join(File.dirname(__FILE__), 'test_helper')
26
- require 'tmpdir'
27
- require 'enhance_repo'
28
- require 'stringio'
29
- require 'zlib'
30
-
31
- class SuseData_test < Test::Unit::TestCase
32
-
33
- def setup
34
- end
35
-
36
- def test_xml_output
37
- susedata = EnhanceRepo::RpmMd::SuseData.new(test_data('rpms/repo-1'))
38
- susedata.add_disk_usage
39
- susedata.add_keywords
40
- susedata.add_eulas
41
-
42
- assert ! susedata.empty?
43
-
44
- assert_equal 3, susedata.size
45
-
46
- Zlib::GzipReader.open(test_data('rpms/repo-1/repodata/susedata.xml.gz')) do |expected_susedata|
47
-
48
- buffer = StringIO.new
49
- susedata.write(buffer)
50
- assert_xml_equal(expected_susedata.read, buffer.string)
51
- end
52
- end
53
- end
@@ -1,62 +0,0 @@
1
- # Author:: Yuichi Tateno <hotchpotch@gmail.com>
2
- # Copyright:: Copyright (c) 2008 Yuichi Tateno
3
- # License:: MIT
4
-
5
- require File.dirname(__FILE__) + '/test_helper.rb'
6
-
7
- require "test/unit"
8
- require "tempdir"
9
- require "tempdir/tempfile"
10
-
11
- class TempdirTest < Test::Unit::TestCase
12
- def test_open
13
- _dir = nil
14
- Tempdir.open do |dir|
15
- assert dir.directory?
16
- assert_equal dir.class, Pathname
17
- _dir = dir.clone
18
- end
19
- assert !_dir.directory?
20
- end
21
-
22
- def test_tempdir
23
- begin
24
- assert_equal Tempdir.tmpdir.to_s, Dir.tmpdir.to_s
25
- Tempdir.tmpdir = Dir.tmpdir + '/foobar'
26
- assert_equal Tempdir.tmpdir.to_s, Pathname.new(Dir.tmpdir + '/foobar').to_s
27
- ensure
28
- Tempdir.tmpdir = Dir.tmpdir
29
- end
30
- end
31
-
32
- def test_new
33
- tmpdir = Tempdir.new
34
- assert tmpdir.dir.directory?
35
- _dir = tmpdir.dir.clone
36
- tmpdir.close
37
- assert !_dir.directory?
38
- end
39
-
40
- def test_open_with_name
41
- _dir = nil
42
- Tempdir.open('adfklvucoiae89u893qakj') do |dir|
43
- assert dir.directory?
44
- _dir = dir.clone
45
- end
46
- assert !_dir.directory?
47
- end
48
-
49
- def test_new_with_name
50
- tmpdir = Tempdir.new('asdfkjvijoaeeeeeegvafkldj12839uy')
51
- assert tmpdir.dir.directory?
52
- _dir = tmpdir.dir.clone
53
- tmpdir.close
54
- assert !_dir.directory?
55
- end
56
-
57
- def test_tempfile
58
- Tempdir::Tempfile.open {|f|
59
- assert f
60
- }
61
- end
62
- end
@@ -1,53 +0,0 @@
1
- #--
2
- #
3
- # enhancerepo is a rpm-md repository metadata tool.
4
- # Copyright (C) 2008, 2009 Novell Inc.
5
- # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
6
- #
7
- # This program is free software; you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation; either version 2 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program; if not, write to the Free Software
19
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
- # MA 02110-1301, USA. A copy of the GNU General Public License is
21
- # also available at http://www.gnu.org/copyleft/gpl.html.
22
- #
23
- #++
24
- #
25
- require 'rubygems'
26
- require 'test/unit'
27
- require 'shoulda'
28
- require 'mocha'
29
-
30
- $: << File.join(File.dirname(__FILE__), "..", "lib")
31
- require 'enhance_repo'
32
- require 'enhance_repo/xml_comparer'
33
- require 'active_support'
34
-
35
- EnhanceRepo::enable_logger
36
-
37
- def test_data(name)
38
- File.join(File.dirname(__FILE__), "data", name)
39
- end
40
-
41
- # compare xml files
42
- module Test
43
- module Unit
44
- module Assertions
45
- def assert_xml_equal(expected, result)
46
- comparer = XmlComparer.new(:show_messages => true)
47
- assert comparer.compare(expected, result)
48
- end
49
- end
50
- end
51
- end
52
-
53
-
@@ -1,80 +0,0 @@
1
-
2
- #--
3
- #
4
- # enhancerepo is a rpm-md repository metadata tool.
5
- # Copyright (C) 2008, 2009 Novell Inc.
6
- # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
- # MA 02110-1301, USA. A copy of the GNU General Public License is
22
- # also available at http://www.gnu.org/copyleft/gpl.html.
23
- #
24
- #++
25
- #
26
- require File.join(File.dirname(__FILE__), 'test_helper')
27
- require 'enhance_repo'
28
- require 'enhance_repo/rpm_md/update'
29
-
30
- require 'tempdir'
31
- require 'stringio'
32
-
33
- class Update_test < Test::Unit::TestCase
34
-
35
- def setup
36
- end
37
-
38
- def test_smart_fill_blanks
39
- update = EnhanceRepo::RpmMd::Update.new
40
-
41
- update.description = "fix crash on exit"
42
- #assert_equal "recommended", update
43
-
44
- # simple test
45
- update.description = "bnc#1245 b.nc-4566 BNC 123 cve-3443-434 CVE-3333 bug 1234"
46
- refs = []
47
- update.each_reference_for(:keyword => 'bnc', :href => 'http://novell.com/:id', :title => 'novell bug #:id') do |r|
48
- refs << r
49
- end
50
- refs.each { |r| puts r.inspect }
51
- assert_equal 3, refs.size, "3 references should be detected"
52
-
53
- # test for FOO xxxx-yyyy
54
- refs = []
55
- update.each_reference_for(:keyword => 'cve', :href => 'http://cve.com/:id', :title => 'cve advisory #:id') do |r|
56
- refs << r
57
- end
58
- refs.each { |r| puts r.inspect }
59
- assert_equal 2, refs.size, "2 CVE references should be detected"
60
-
61
- # test for multiple keywords
62
- refs = []
63
- update.each_reference_for(:keywords => ['bug', 'bnc'], :href => 'http://novell.com/:id', :title => 'bug #:id') do |r|
64
- refs << r
65
- end
66
- refs.each { |r| puts r.inspect }
67
- assert_equal 4, refs.size, "4 bugs should be detected"
68
-
69
- # test the pre-configured reference detectors
70
- refs = []
71
- update.each_detected_reference do |r|
72
- refs << r
73
- end
74
- puts
75
- refs.each { |r| puts r.inspect }
76
- assert_equal 5, refs.size, "4 bugs should be detected"
77
-
78
- end
79
-
80
- end
@@ -1,59 +0,0 @@
1
-
2
- #--
3
- #
4
- # enhancerepo is a rpm-md repository metadata tool.
5
- # Copyright (C) 2008, 2009 Novell Inc.
6
- # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
- # MA 02110-1301, USA. A copy of the GNU General Public License is
22
- # also available at http://www.gnu.org/copyleft/gpl.html.
23
- #
24
- #++
25
- #
26
- require File.join(File.dirname(__FILE__), 'test_helper')
27
- require 'enhance_repo'
28
- require 'tempdir'
29
- require 'stringio'
30
-
31
- class UpdateInfo_test < Test::Unit::TestCase
32
-
33
- def setup
34
- end
35
-
36
- def test_xml_output
37
- config = EnhanceRepo::ConfigOpts.new
38
- config.dir = test_data('rpms/repo-1')
39
- updateinfo = EnhanceRepo::RpmMd::UpdateInfo.new(config)
40
-
41
- Tempdir.open do |dir|
42
- updateinfo.generate_update(['a', 'b'], File.join(dir, 'repoparts'))
43
- puts Dir[File.join(dir, '*')]
44
-
45
- updateinfo.read_repoparts(:repoparts_path => File.join(dir, 'repoparts'))
46
-
47
- assert ! updateinfo.empty?, "updateinfo can't be empty"
48
- assert_equal 1, updateinfo.size, "updateinfo contains 1 update"
49
-
50
- Zlib::GzipReader.open(test_data('rpms/repo-1/repodata/updateinfo.xml.gz')) do |expected_updateinfo|
51
- buffer = StringIO.new
52
- updateinfo.write(buffer)
53
- # assert_xml_equal(expected_updateinfo.read, buffer.string)
54
- end
55
-
56
- end
57
-
58
- end
59
- end