package_manager 0.0.4 → 0.0.5
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.
- data/lib/package_manager.rb +1 -1
- data/lib/package_manager/apt.rb +2 -2
- data/lib/package_manager/base.rb +18 -9
- metadata +31 -31
data/lib/package_manager.rb
CHANGED
data/lib/package_manager/apt.rb
CHANGED
data/lib/package_manager/base.rb
CHANGED
@@ -32,48 +32,57 @@ module PackageManager
|
|
32
32
|
|
33
33
|
# Returns an array of matches
|
34
34
|
def find_available( package_match )
|
35
|
-
run_command( find_available_command, package_match ).split("\n")
|
35
|
+
run_command( find_available_command, [ package_match ] ).split( "\n" )
|
36
36
|
end
|
37
37
|
|
38
38
|
# Returns an array of matches
|
39
39
|
def find_installed( package_match )
|
40
|
-
run_command( find_installed_command, package_match ).split("\n").uniq
|
40
|
+
run_command( find_installed_command, [ package_match ] ).split( "\n" ).uniq
|
41
41
|
end
|
42
42
|
|
43
43
|
# Returns an array of file names
|
44
44
|
def list_contents( package )
|
45
|
-
run_command( list_contents_command, package ).split("\n")
|
45
|
+
run_command( list_contents_command, [ package ] ).split( "\n" )
|
46
46
|
end
|
47
47
|
|
48
48
|
# Returns true if the package installed successfully
|
49
49
|
def install( package )
|
50
|
-
run_command( install_command, package )
|
50
|
+
run_command( 'sudo ' + install_command, [ package ], { :echo_output => true } )
|
51
51
|
$?.exitstatus == 0
|
52
52
|
end
|
53
53
|
|
54
54
|
# Returns true if the package installed successfully
|
55
55
|
def install_file( file )
|
56
56
|
raise "The file '#{ file }' does not exist" if ! File.exist?( file )
|
57
|
-
run_command( install_file_command, file )
|
57
|
+
run_command( 'sudo ' + install_file_command, [ file ], { :echo_output => true } )
|
58
58
|
$?.exitstatus == 0
|
59
59
|
end
|
60
60
|
|
61
61
|
# Returns true if the package uninstalled successfully
|
62
62
|
def uninstall( package )
|
63
|
-
run_command( uninstall_command, package )
|
63
|
+
run_command( 'sudo ' + uninstall_command, [ package ], { :echo_output => true } )
|
64
64
|
$?.exitstatus == 0
|
65
65
|
end
|
66
66
|
|
67
67
|
# Returns the package name if found, or an empty string
|
68
68
|
def provides( file )
|
69
69
|
raise "The file '#{ file }' does not exist" if ! File.exist?( file )
|
70
|
-
run_command( provides_command, file )
|
70
|
+
run_command( provides_command, [ file ] )
|
71
71
|
end
|
72
72
|
|
73
73
|
private
|
74
74
|
|
75
|
-
def run_command( command,
|
76
|
-
|
75
|
+
def run_command( command, args, options = {} )
|
76
|
+
full_command = "#{ command } #{ args.join( ' ' ) }"
|
77
|
+
out = ''
|
78
|
+
IO.popen( full_command ) do | pipe |
|
79
|
+
pipe.each_line do | s |
|
80
|
+
puts s if options[ :echo_output ]
|
81
|
+
out << s
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
out.chomp
|
77
86
|
end
|
78
87
|
|
79
88
|
def self.guess_package_manager
|
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
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-
|
18
|
+
date: 2010-09-19 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -37,53 +37,53 @@ dependencies:
|
|
37
37
|
description: Unifies the command interface for using yum and apt on Linux, Fink and MacPorts on OS X
|
38
38
|
email: joe.g.yates@gmail.com
|
39
39
|
executables:
|
40
|
-
- pkg-find-available
|
41
|
-
- pkg-find-installed
|
42
|
-
- pkg-install
|
43
|
-
- pkg-install-file
|
44
|
-
- pkg-list-contents
|
45
40
|
- pkg-provides
|
41
|
+
- pkg-list-contents
|
42
|
+
- pkg-install-file
|
46
43
|
- pkg-uninstall
|
44
|
+
- pkg-install
|
45
|
+
- pkg-find-available
|
46
|
+
- pkg-find-installed
|
47
47
|
extensions: []
|
48
48
|
|
49
49
|
extra_rdoc_files:
|
50
50
|
- README.rdoc
|
51
|
-
- bin/pkg-find-available
|
52
|
-
- bin/pkg-find-installed
|
53
|
-
- bin/pkg-install
|
54
|
-
- bin/pkg-install-file
|
55
|
-
- bin/pkg-list-contents
|
56
51
|
- bin/pkg-provides
|
52
|
+
- bin/pkg-list-contents
|
53
|
+
- bin/pkg-install-file
|
57
54
|
- bin/pkg-uninstall
|
58
|
-
-
|
55
|
+
- bin/pkg-install
|
56
|
+
- bin/pkg-find-available
|
57
|
+
- bin/pkg-find-installed
|
58
|
+
- lib/package_manager.rb
|
59
|
+
- lib/package_manager/yum.rb
|
59
60
|
- lib/package_manager/base.rb
|
60
|
-
- lib/package_manager/dpkg.rb
|
61
61
|
- lib/package_manager/fink.rb
|
62
62
|
- lib/package_manager/port.rb
|
63
|
+
- lib/package_manager/apt.rb
|
63
64
|
- lib/package_manager/rpm.rb
|
64
|
-
- lib/package_manager/
|
65
|
-
- lib/package_manager.rb
|
65
|
+
- lib/package_manager/dpkg.rb
|
66
66
|
files:
|
67
67
|
- Rakefile
|
68
68
|
- README.rdoc
|
69
|
-
- bin/pkg-find-available
|
70
|
-
- bin/pkg-find-installed
|
71
|
-
- bin/pkg-install
|
72
|
-
- bin/pkg-install-file
|
73
|
-
- bin/pkg-list-contents
|
74
69
|
- bin/pkg-provides
|
70
|
+
- bin/pkg-list-contents
|
71
|
+
- bin/pkg-install-file
|
75
72
|
- bin/pkg-uninstall
|
76
|
-
-
|
73
|
+
- bin/pkg-install
|
74
|
+
- bin/pkg-find-available
|
75
|
+
- bin/pkg-find-installed
|
76
|
+
- lib/package_manager.rb
|
77
|
+
- lib/package_manager/yum.rb
|
77
78
|
- lib/package_manager/base.rb
|
78
|
-
- lib/package_manager/dpkg.rb
|
79
79
|
- lib/package_manager/fink.rb
|
80
80
|
- lib/package_manager/port.rb
|
81
|
+
- lib/package_manager/apt.rb
|
81
82
|
- lib/package_manager/rpm.rb
|
82
|
-
- lib/package_manager/
|
83
|
-
- lib/package_manager.rb
|
84
|
-
- spec/platform_spec.rb
|
85
|
-
- spec/script_methods_spec.rb
|
83
|
+
- lib/package_manager/dpkg.rb
|
86
84
|
- spec/subclasses_spec.rb
|
85
|
+
- spec/script_methods_spec.rb
|
86
|
+
- spec/platform_spec.rb
|
87
87
|
- spec/version_spec.rb
|
88
88
|
has_rdoc: true
|
89
89
|
homepage: http://github.com/joeyates/package_manager
|
@@ -123,7 +123,7 @@ signing_key:
|
|
123
123
|
specification_version: 3
|
124
124
|
summary: A package manager abstraction
|
125
125
|
test_files:
|
126
|
-
- spec/platform_spec.rb
|
127
|
-
- spec/script_methods_spec.rb
|
128
126
|
- spec/subclasses_spec.rb
|
127
|
+
- spec/script_methods_spec.rb
|
128
|
+
- spec/platform_spec.rb
|
129
129
|
- spec/version_spec.rb
|