tentacle 0.1

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.
Files changed (6) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.md +52 -0
  3. data/Rakefile +38 -0
  4. data/bin/tentacle +95 -0
  5. data/lib/tentacle.rb +46 -0
  6. metadata +155 -0
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Sergio Rubio <rubiojr@frameos.org>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # tentacle
2
+
3
+ Description goes here.
4
+
5
+ # Installation
6
+
7
+ * Fedora/RHEL
8
+
9
+ yum install ruby-devel make gcc gcc-c++ rubygems libxml2-devel libxslt-devel git
10
+ gem install tentacle
11
+
12
+ # Usage
13
+
14
+ **Print help**
15
+
16
+ tentacle --help
17
+
18
+ **List available repos***
19
+
20
+ tentacle available-repos
21
+
22
+ **Basic search**
23
+
24
+ tentacle search ruby
25
+
26
+ Searches for package names matching ruby. Regexp may be used.
27
+
28
+ **Regexp search**
29
+
30
+ tentacle search ^ruby-1.8.7
31
+
32
+ Searches for package names matching ^ruby-1.8.7
33
+
34
+
35
+ **Distro class search**
36
+
37
+ tentacle search --distro-class rhel-5 ruby
38
+
39
+ Search for ruby packages in RHEL5 compatible repositories
40
+
41
+ **Repo search**
42
+
43
+ tentacle search --repo-id rbel5-x86_64 ruby
44
+
45
+ Search for ruby packages in RBEL 5 repository. The list of available repo-ids is displayed with 'tentacle available-repos'
46
+
47
+
48
+ # Copyright
49
+
50
+ Copyright (c) 2011 Sergio Rubio. See LICENSE.txt for
51
+ further details.
52
+
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'lib/tentacle'
4
+
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
8
+ gem.version = Tentacle::VERSION
9
+ gem.name = "tentacle"
10
+ gem.homepage = "http://github.com/rubiojr/tentacle"
11
+ gem.license = "MIT"
12
+ gem.summary = %Q{Digs YUM repositories to search for RPM packages}
13
+ gem.description = %Q{Digs yum repositories to search for RPM packages}
14
+ gem.email = "rubiojr@frameos.org"
15
+ gem.authors = ["Sergio Rubio"]
16
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
17
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
18
+ gem.add_runtime_dependency 'clamp'
19
+ gem.add_runtime_dependency 'git'
20
+ gem.add_runtime_dependency 'colorize'
21
+ gem.add_runtime_dependency 'rest-client'
22
+ gem.add_runtime_dependency 'pkg-wizard', '>= 0.1.28'
23
+ gem.add_runtime_dependency 'yumrepo', '>= 0.1'
24
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ task :default => :build
29
+
30
+ require 'rdoc/task'
31
+ Rake::RDocTask.new do |rdoc|
32
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
33
+
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "tentacle #{version}"
36
+ rdoc.rdoc_files.include('README*')
37
+ rdoc.rdoc_files.include('lib/**/*.rb')
38
+ end
data/bin/tentacle ADDED
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'rest-client'
4
+ require 'git'
5
+ require 'yumrepo'
6
+ require 'clamp'
7
+ require 'colorize'
8
+ require 'tentacle'
9
+
10
+ include Tentacle
11
+
12
+ TEMP_DIR = "/tmp/metarpm-#{Time.now.to_i}"
13
+ $stdout.sync = true
14
+ YumRepo::Settings.instance.cache_path = File.join(ENV['HOME'], ".tentacle/cache")
15
+ YumRepo::Settings.instance.log_level = :info
16
+
17
+ class ValidateFeedsCommand < Clamp::Command
18
+
19
+ def execute
20
+ Git.clone "git://gist.github.com/1139245.git", TEMP_DIR
21
+
22
+ urls = []
23
+ File.readlines(File.join(TEMP_DIR, "repo_feeds.txt")).each do |line|
24
+ next if (line.strip.chomp.empty? or line =~ /^\s*#/)
25
+ urls << line
26
+ end
27
+ urls.sort! { |a,b| a.split(',')[1] <=> b.split(',')[1] }
28
+
29
+ urls.each do |u|
30
+ f = RepoFeed.new(u)
31
+ print "Validating #{f.repo_id}... ".ljust(40)
32
+ if not validate_url(f.url)
33
+ puts "FAILED".red
34
+ else
35
+ puts "OK".green
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ class SearchCommand < Clamp::Command
43
+
44
+ option "--distro-class", "CLASS", "Filter by distro class"
45
+ option "--repo-id", "CLASS", "Filter by distro class"
46
+ parameter "PKG", "Search for packages matching PKG", :attribute_name => :pkg
47
+
48
+ def execute
49
+ $stdout.sync = true
50
+ puts "Searching packages matching #{pkg.dup.magenta}..."
51
+ FeedCollection.all.each do |fc|
52
+ if repo_id and fc.repo_id != repo_id
53
+ next
54
+ end
55
+ if distro_class and fc.distro_class != distro_class
56
+ next
57
+ end
58
+ pl = YumRepo::PackageList.new fc.url
59
+ pl.each do |p|
60
+ full_name = "#{p.name}-#{p.version}-#{p.release}"
61
+ puts " #{full_name} ".ljust(50) + "[#{fc.repo_id}]".yellow if "#{p.name}-#{p.version}-#{p.release}" =~ /#{pkg}/
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ class AvailableReposCommand < Clamp::Command
68
+
69
+ def execute
70
+ FeedCollection.all.each do |feed|
71
+ puts feed.repo_id
72
+ end
73
+ end
74
+
75
+ end
76
+
77
+ class VersionCommand < Clamp::Command
78
+
79
+ def execute
80
+ puts "Tentacle Version #{Tentacle::VERSION}"
81
+ end
82
+
83
+ end
84
+
85
+ class Driver < Clamp::Command
86
+ option "--debug", :flag, "Print debug messages" do
87
+ YumRepo::Settings.instance.log_level = :debug
88
+ end
89
+ subcommand "validate", "Validate repository URLs", ValidateFeedsCommand
90
+ subcommand "search", "Package search", SearchCommand
91
+ subcommand "available-repos", "List available repos", AvailableReposCommand
92
+ subcommand "version", "Print Tentacle version", VersionCommand
93
+ end
94
+
95
+ Driver.run
data/lib/tentacle.rb ADDED
@@ -0,0 +1,46 @@
1
+ module Tentacle
2
+
3
+ VERSION = '0.1'
4
+
5
+ def validate_url(url)
6
+ RestClient.get(url + '/repodata/repomd.xml') rescue return false
7
+ YumRepo::Repomd.new(url) rescue return false
8
+ true
9
+ end
10
+
11
+ class RepoFeed
12
+ attr_reader :url, :repo_id, :distro_class
13
+ def initialize(feed)
14
+ @url, @repo_id, @distro_class = feed.split(',').map { |f| f.strip.chomp }
15
+ end
16
+
17
+ def to_s
18
+ "URL: #{url.red} REPO_ID: #{repo_id} CLASS: #{distro_class}"
19
+ end
20
+ end
21
+
22
+ class FeedCollection
23
+
24
+ def self.all(validate = false)
25
+ Git.clone "git://gist.github.com/1139245.git", TEMP_DIR
26
+ feeds = []
27
+ urls = []
28
+ File.readlines(File.join(TEMP_DIR, "repo_feeds.txt")).each do |line|
29
+ next if (line.strip.chomp.empty? or line =~ /^\s*#/)
30
+ urls << line
31
+ end
32
+ urls.sort! { |a,b| a.split(',')[1] <=> b.split(',')[1] }
33
+
34
+ urls.each do |u|
35
+ f = RepoFeed.new(u)
36
+ if validate and validate_url(f.url)
37
+ feeds << f
38
+ else
39
+ feeds << f
40
+ end
41
+ end
42
+ feeds
43
+ end
44
+
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tentacle
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Sergio Rubio
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-08-11 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: clamp
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: git
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: colorize
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ type: :runtime
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: rest-client
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ type: :runtime
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: pkg-wizard
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 35
84
+ segments:
85
+ - 0
86
+ - 1
87
+ - 28
88
+ version: 0.1.28
89
+ type: :runtime
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: yumrepo
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 9
100
+ segments:
101
+ - 0
102
+ - 1
103
+ version: "0.1"
104
+ type: :runtime
105
+ version_requirements: *id006
106
+ description: Digs yum repositories to search for RPM packages
107
+ email: rubiojr@frameos.org
108
+ executables:
109
+ - tentacle
110
+ extensions: []
111
+
112
+ extra_rdoc_files:
113
+ - LICENSE.txt
114
+ - README.md
115
+ files:
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - bin/tentacle
120
+ - lib/tentacle.rb
121
+ homepage: http://github.com/rubiojr/tentacle
122
+ licenses:
123
+ - MIT
124
+ post_install_message:
125
+ rdoc_options: []
126
+
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ hash: 3
144
+ segments:
145
+ - 0
146
+ version: "0"
147
+ requirements: []
148
+
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.5
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Digs YUM repositories to search for RPM packages
154
+ test_files: []
155
+