package_manager 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,3 +2,18 @@
2
2
 
3
3
  Unifies the command interface for using yum and apt on Linux, Fink and MacPorts on OS X
4
4
 
5
+ = Commands
6
+
7
+ The following commands are provided:
8
+ * pkg-find-available
9
+ * pkg-find-installed
10
+ * pkg-install
11
+ * pkg-install-file
12
+ * pkg-list-contents
13
+
14
+ = Package Management Systems[http://en.wikipedia.org/wiki/Package_management_system]
15
+
16
+ * Fink
17
+ * Mac Ports
18
+ * YUM
19
+ * http://github.com/mxcl/homebrew
data/Rakefile CHANGED
@@ -8,11 +8,14 @@ require 'package_manager'
8
8
 
9
9
  TITLE = 'A package manager abstraction'
10
10
  ADMIN_FILES = FileList[ 'Rakefile', 'README.rdoc' ]
11
- SOURCE_FILES = FileList[ 'bin/*', 'lib/**/*.rb' ]
11
+ EXECUTABLES = FileList[ 'bin/*' ]
12
+ SOURCE_FILES = FileList[ 'lib/**/*.rb' ]
12
13
  SPEC_FILES = FileList[ 'spec/**/*' ]
13
- RDOC_FILES = FileList[ 'README.rdoc' ] + SOURCE_FILES
14
+ RDOC_FILES = FileList[ 'README.rdoc' ] + EXECUTABLES + SOURCE_FILES
14
15
  RDOC_OPTS = [ '--quiet', '--main', 'README.rdoc', '--inline-source' ]
15
16
 
17
+ EXECUTABLE_FILENAMES = EXECUTABLES.collect { | file | file.gsub( %r(^bin/), '' ) }
18
+
16
19
  spec = Gem::Specification.new do |s|
17
20
  s.name = 'package_manager'
18
21
  s.summary = TITLE
@@ -24,8 +27,9 @@ spec = Gem::Specification.new do |s|
24
27
  s.email = 'joe.g.yates@gmail.com'
25
28
 
26
29
  s.files = ADMIN_FILES +
30
+ EXECUTABLES +
27
31
  SOURCE_FILES
28
- s.executables += [ 'pkg-find-available' ]
32
+ s.executables += EXECUTABLE_FILENAMES
29
33
  s.require_paths = [ 'lib' ]
30
34
  s.add_dependency( 'rake', '>= 0.8.7' )
31
35
 
@@ -1,19 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'optparse'
4
- require 'rubygems' if RUBY_VERSION < '1.9'
5
-
6
- ROOT_PATH = File.dirname( File.dirname( File.expand_path( __FILE__ ) ) )
7
- LIB_PATH = File.join( ROOT_PATH, 'lib' )
3
+ ROOT_PATH = File.dirname( File.dirname( File.expand_path( __FILE__ ) ) )
4
+ LIB_PATH = File.join( ROOT_PATH, 'lib' )
8
5
  $:.unshift( LIB_PATH )
9
6
  require 'package_manager'
10
7
 
11
- OptionParser.new do | opts |
12
- opts.banner = <<EOT
13
- #{ $0 }: Find available packages matching a string
8
+ usage = <<EOT
9
+ pkg-find-available: Find available packages matching a string
14
10
  Usage: #{ $0 } [options]
15
11
  EOT
16
- end.parse!
12
+
13
+ if ARGV.size < 1
14
+ $stderr.puts 'No search pattern supplied'
15
+ $stderr.puts usage
16
+ exit 1
17
+ end
17
18
 
18
19
  pkg = PackageManager::Base.load
19
20
  puts pkg.find_available( ARGV )
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ROOT_PATH = File.dirname( File.dirname( File.expand_path( __FILE__ ) ) )
4
+ LIB_PATH = File.join( ROOT_PATH, 'lib' )
5
+ $:.unshift( LIB_PATH )
6
+ require 'package_manager'
7
+
8
+ usage = <<EOT
9
+ pkg-find-installed: Find installed packages matching a string
10
+ Usage: #{ $0 } [options]
11
+ EOT
12
+
13
+ if ARGV.size < 1
14
+ $stderr.puts 'No search pattern supplied'
15
+ $stderr.puts usage
16
+ exit 1
17
+ end
18
+
19
+ pkg = PackageManager::Base.load
20
+ puts pkg.find_installed( ARGV )
data/bin/pkg-install ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ROOT_PATH = File.dirname( File.dirname( File.expand_path( __FILE__ ) ) )
4
+ LIB_PATH = File.join( ROOT_PATH, 'lib' )
5
+ $:.unshift( LIB_PATH )
6
+ require 'package_manager'
7
+
8
+ usage = <<EOT
9
+ pkg-install: Install a package from a repository
10
+ Usage: #{ $0 } [options]
11
+ EOT
12
+
13
+ if ARGV.size < 1
14
+ $stderr.puts 'No package name supplied'
15
+ $stderr.puts usage
16
+ exit 1
17
+ end
18
+
19
+ pkg = PackageManager::Base.load
20
+ puts pkg.install( ARGV )
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ROOT_PATH = File.dirname( File.dirname( File.expand_path( __FILE__ ) ) )
4
+ LIB_PATH = File.join( ROOT_PATH, 'lib' )
5
+ $:.unshift( LIB_PATH )
6
+ require 'package_manager'
7
+
8
+ usage = <<EOT
9
+ pkg-install-file: Install a package from a file
10
+ Usage: #{ $0 } [options]
11
+ EOT
12
+
13
+ pkg = PackageManager::Base.load
14
+ puts pkg.install_file( ARGV )
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ROOT_PATH = File.dirname( File.dirname( File.expand_path( __FILE__ ) ) )
4
+ LIB_PATH = File.join( ROOT_PATH, 'lib' )
5
+ $:.unshift( LIB_PATH )
6
+ require 'package_manager'
7
+
8
+ usage = <<EOT
9
+ pkg-list-contents: List the files installed by a package
10
+ Usage: #{ $0 } [options]
11
+ EOT
12
+
13
+ if ARGV.size < 1
14
+ $stderr.puts 'No package name supplied'
15
+ $stderr.puts usage
16
+ exit 1
17
+ end
18
+
19
+ pkg = PackageManager::Base.load
20
+ puts pkg.list_contents( ARGV )
@@ -0,0 +1,25 @@
1
+ module PackageManager
2
+
3
+ class Apt < Dpkg
4
+
5
+ def initialize
6
+ @name = 'apt'
7
+ end
8
+
9
+ private
10
+
11
+ def find_available_command
12
+ 'apt-cache search'
13
+ end
14
+
15
+ def find_installed_command
16
+ 'apt-cache search --installed --names-only'
17
+ end
18
+
19
+ def install_command
20
+ 'apt-get install'
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -14,6 +14,32 @@ module PackageManager
14
14
  run_command( command, argv[ 0 ] )
15
15
  end
16
16
 
17
+ def find_installed( argv )
18
+ raise "You should supply a search pattern" if argv.size < 1
19
+ command = find_installed_command
20
+ run_command( command, argv[ 0 ] )
21
+ end
22
+
23
+ def list_contents( argv )
24
+ raise "You should supply a package name" if argv.size < 1
25
+ command = list_contents_command
26
+ run_command( command, argv[ 0 ] )
27
+ end
28
+
29
+ def install( argv )
30
+ raise "You should supply a package name" if argv.size < 1
31
+ command = install_command
32
+ run_command( command, argv[ 0 ] )
33
+ end
34
+
35
+ def install_file( argv )
36
+ raise "You should supply a package name" if argv.size < 1
37
+ raise "The file '#{ ARGV[ 0 ] }' does not exist" if ! File.exist?( argv[ 0 ] )
38
+ run_command( install_file_command, argv[ 0 ] )
39
+ end
40
+
41
+ private
42
+
17
43
  def run_command( command, *args )
18
44
  `#{ command } #{ args.join( ' ' ) }`
19
45
  end
@@ -0,0 +1,21 @@
1
+ module PackageManager
2
+
3
+ class Dpkg < Base
4
+
5
+ def initialize
6
+ @name = 'dpkg'
7
+ end
8
+
9
+ private
10
+
11
+ def list_contents_command
12
+ 'dpkg -L'
13
+ end
14
+
15
+ def install_file_command
16
+ 'dpkg -i'
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,11 @@
1
+ module PackageManager
2
+
3
+ class Fink < Apt
4
+
5
+ def initialize
6
+ @name = 'fink'
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -12,6 +12,11 @@ module PackageManager
12
12
  'port search'
13
13
  end
14
14
 
15
+ def find_installed_command
16
+ # list all | grab first word | grep
17
+ "port installed | sed -E -e 's/ +([^ ]+).*/\\1/' | grep "
18
+ end
19
+
15
20
  end
16
21
 
17
22
  end
@@ -0,0 +1,25 @@
1
+ module PackageManager
2
+
3
+ class Rpm < Base
4
+
5
+ def initialize
6
+ @name = 'rpm'
7
+ end
8
+
9
+ private
10
+
11
+ def find_installed_command
12
+ 'rpm -qa | grep'
13
+ end
14
+
15
+ def list_contents_command
16
+ 'rpm -q --filesbypkg'
17
+ end
18
+
19
+ def install_file_command
20
+ 'rpm -ihv'
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,17 @@
1
+ module PackageManager
2
+
3
+ class Yum < Rpm
4
+
5
+ def initialize
6
+ @name = 'yum'
7
+ end
8
+
9
+ private
10
+
11
+ def install_command
12
+ 'yum install'
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -7,7 +7,7 @@ module PackageManager
7
7
  module VERSION #:nodoc:
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
- TINY = 1
10
+ TINY = 2
11
11
 
12
12
  STRING = [ MAJOR, MINOR, TINY ].join('.')
13
13
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: package_manager
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joe Yates
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-06 00:00:00 +01:00
18
+ date: 2010-09-08 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -38,20 +38,42 @@ description: Unifies the command interface for using yum and apt on Linux, Fink
38
38
  email: joe.g.yates@gmail.com
39
39
  executables:
40
40
  - pkg-find-available
41
+ - pkg-find-installed
42
+ - pkg-install
43
+ - pkg-install-file
44
+ - pkg-list-contents
41
45
  extensions: []
42
46
 
43
47
  extra_rdoc_files:
44
48
  - README.rdoc
45
49
  - bin/pkg-find-available
50
+ - bin/pkg-find-installed
51
+ - bin/pkg-install
52
+ - bin/pkg-install-file
53
+ - bin/pkg-list-contents
54
+ - lib/package_manager/apt.rb
46
55
  - lib/package_manager/base.rb
56
+ - lib/package_manager/dpkg.rb
57
+ - lib/package_manager/fink.rb
47
58
  - lib/package_manager/port.rb
59
+ - lib/package_manager/rpm.rb
60
+ - lib/package_manager/yum.rb
48
61
  - lib/package_manager.rb
49
62
  files:
50
63
  - Rakefile
51
64
  - README.rdoc
52
65
  - bin/pkg-find-available
66
+ - bin/pkg-find-installed
67
+ - bin/pkg-install
68
+ - bin/pkg-install-file
69
+ - bin/pkg-list-contents
70
+ - lib/package_manager/apt.rb
53
71
  - lib/package_manager/base.rb
72
+ - lib/package_manager/dpkg.rb
73
+ - lib/package_manager/fink.rb
54
74
  - lib/package_manager/port.rb
75
+ - lib/package_manager/rpm.rb
76
+ - lib/package_manager/yum.rb
55
77
  - lib/package_manager.rb
56
78
  has_rdoc: true
57
79
  homepage: http://github.com/joeyates/package_manager