ngauthier-aptinstaller 0.3.1 → 0.3.2
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/README.markdown +2 -7
- data/TODO.markdown +1 -0
- data/VERSION.yml +1 -1
- data/lib/aptinstaller/aptinstaller.rb +38 -13
- metadata +1 -1
data/README.markdown
CHANGED
@@ -13,13 +13,8 @@ Put something like this in config/aptinstaller.yml:
|
|
13
13
|
|
14
14
|
---
|
15
15
|
packages:
|
16
|
-
-
|
17
|
-
-
|
18
|
-
package: gpac
|
19
|
-
|
20
|
-
The executable field is the name of the executable (i.e. $ MP4Box). If the package's name in the
|
21
|
-
repositories is different from the executable, specify the package name with the "package"
|
22
|
-
field (i.e. "gpac" which provides the MP4Box executable).
|
16
|
+
- name: firefox
|
17
|
+
- name: gpac
|
23
18
|
|
24
19
|
### Add to Preinitializer
|
25
20
|
|
data/TODO.markdown
CHANGED
data/VERSION.yml
CHANGED
@@ -5,14 +5,19 @@ class AptInstaller
|
|
5
5
|
def self.autopkg(opts = {})
|
6
6
|
config_yaml = self.read_yaml_file(opts[:config])
|
7
7
|
packages = self.detect_packages_to_install(config_yaml['packages'])
|
8
|
-
if packages.size > 0
|
8
|
+
if packages[:not_installed].size > 0
|
9
9
|
$stderr.write "\nThe following packages are required by this program but not installed:\n\n"
|
10
|
-
packages.each do |package|
|
11
|
-
$stderr.write "\t* "+package['
|
12
|
-
$stderr.write " (provided by package \"#{package['package']}\")" if package['package']
|
13
|
-
$stderr.write "\n"
|
10
|
+
packages[:not_installed].each do |package|
|
11
|
+
$stderr.write "\t* "+package['name']+"\n"
|
14
12
|
end
|
15
|
-
|
13
|
+
end
|
14
|
+
if packages[:out_of_date].size > 0
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
if packages[:not_installed].size + packages[:out_of_date].size > 0
|
19
|
+
$stderr.write "\nYou can install and upgrade automatically by "
|
20
|
+
$stderr.write "running \"aptinstaller\" in the root of your project\n\n"
|
16
21
|
exit(1)
|
17
22
|
end
|
18
23
|
end
|
@@ -27,9 +32,14 @@ class AptInstaller
|
|
27
32
|
$stderr.flush
|
28
33
|
exit(1)
|
29
34
|
end
|
30
|
-
if packages.size > 0
|
31
|
-
|
32
|
-
|
35
|
+
if packages[:not_installed].size > 0
|
36
|
+
pkg_str = packages[:not_installed].collect{|p| p['name']}.join(" ")
|
37
|
+
system "apt-get install #{pkg_str}"
|
38
|
+
end
|
39
|
+
if packages[:out_of_date].size > 0
|
40
|
+
|
41
|
+
end
|
42
|
+
if packages[:not_installed].size + packages[:out_of_date].size == 0
|
33
43
|
puts "All dependencies are installed"
|
34
44
|
end
|
35
45
|
end
|
@@ -57,11 +67,26 @@ class AptInstaller
|
|
57
67
|
|
58
68
|
def self.detect_packages_to_install(packages)
|
59
69
|
not_installed = []
|
70
|
+
out_of_date = []
|
60
71
|
packages.each do |package|
|
61
|
-
|
62
|
-
|
63
|
-
not_installed.push(package) if `which #{exec}`.size == 0
|
72
|
+
not_installed.push(package) unless self.detect_package(package)
|
73
|
+
out_of_date.push(package) unless self.verify_version(package)
|
64
74
|
end
|
65
|
-
not_installed
|
75
|
+
{:not_installed => not_installed, :out_of_date => out_of_date}
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.detect_package(package)
|
79
|
+
info = `aptitude show #{package['name']}`.split("\n")
|
80
|
+
meta = {}
|
81
|
+
info.each{|i|
|
82
|
+
i = i.split(": ")
|
83
|
+
meta[i[0]] = i[1]
|
84
|
+
}
|
85
|
+
return meta['State'] == 'installed'
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.verify_version(package)
|
89
|
+
pkg_name = package['name']
|
90
|
+
return true if package['version'] == nil
|
66
91
|
end
|
67
92
|
end
|