ngauthier-aptinstaller 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +43 -0
- data/TODO.markdown +4 -0
- data/VERSION.yml +1 -1
- data/bin/aptinstaller +3 -3
- data/lib/aptinstaller/aptinstaller.rb +37 -15
- metadata +3 -4
- data/History.txt +0 -4
- data/Manifest.txt +0 -8
- data/README.txt +0 -54
data/README.markdown
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Aptinstaller: automatically install apt package dependencies
|
2
|
+
|
3
|
+
## Description
|
4
|
+
This gem installs packages through apt-get in a similar manner as geminstaller installs gems.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
aptinstaller [/full/path/to/rails/project/root]
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
### Add a Config File
|
12
|
+
Put something like this in config/aptinstaller.yml:
|
13
|
+
|
14
|
+
---
|
15
|
+
packages:
|
16
|
+
- executable: firefox
|
17
|
+
- executable: MP4Box
|
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).
|
23
|
+
|
24
|
+
### Add to Preinitializer
|
25
|
+
|
26
|
+
Then in config/preinitializer.rb (create it if it doesn't exist, it's pulled automatically
|
27
|
+
from boot.rb):
|
28
|
+
|
29
|
+
require 'rubygems'
|
30
|
+
require 'aptinstaller'
|
31
|
+
AptInstaller.autopkg(:config => 'config/aptinstaller.yml')
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
### Latest Stable
|
36
|
+
sudo gem install ngauthier-aptinstaller
|
37
|
+
|
38
|
+
### Cutting Edge
|
39
|
+
rake gem
|
40
|
+
sudo gem install pkg/aptinstaller-x.y.z.gem
|
41
|
+
|
42
|
+
## Other Notes
|
43
|
+
This gem uses Jeweler. HighFive@technicalpickles!
|
data/TODO.markdown
ADDED
data/VERSION.yml
CHANGED
data/bin/aptinstaller
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'aptinstaller'
|
4
|
+
AptInstaller.autopkg_install(ARGV[0])
|
@@ -3,7 +3,34 @@ require 'yaml'
|
|
3
3
|
class AptInstaller
|
4
4
|
|
5
5
|
def self.autopkg(opts = {})
|
6
|
-
|
6
|
+
config_yaml = self.read_yaml_file(opts[:config])
|
7
|
+
packages = self.detect_packages_to_install(config_yaml['packages'])
|
8
|
+
if packages.size > 0
|
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['executable']
|
12
|
+
$stderr.write " (provided by package \"#{package['package']}\")" if package['package']
|
13
|
+
$stderr.write "\n"
|
14
|
+
end
|
15
|
+
$stderr.write "\nYou can install them by running \"aptinstaller\" in the root of your project\n\n"
|
16
|
+
exit(1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.autopkg_install(rails_root = '.')
|
21
|
+
rails_root ||= '.' # in case they pass in nil
|
22
|
+
config_yaml = self.read_yaml_file(File.join(rails_root, 'config', 'aptinstaller.yml'))
|
23
|
+
packages = self.detect_packages_to_install(config_yaml['packages'])
|
24
|
+
if packages.size > 0
|
25
|
+
exec("apt-get install #{packages.collect{|p| p['package'] || p['executable'] }.join(" ")}")
|
26
|
+
else
|
27
|
+
puts "All dependencies are installed"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.read_yaml_file(config_file)
|
7
34
|
raise "Error reading config file, no :config parameter specified" unless config_file
|
8
35
|
begin
|
9
36
|
begin
|
@@ -19,21 +46,16 @@ class AptInstaller
|
|
19
46
|
rescue => ex
|
20
47
|
raise "Error parsing YAML file: #{ex.to_s}"
|
21
48
|
end
|
22
|
-
|
23
|
-
|
49
|
+
config_yaml
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.detect_packages_to_install(packages)
|
53
|
+
not_installed = []
|
54
|
+
packages.each do |package|
|
24
55
|
exec = package['executable']
|
25
56
|
pkg = package['package']
|
26
|
-
|
27
|
-
end
|
28
|
-
if errors.size > 0
|
29
|
-
$stderr.write "\nThe following packages are required by this program but not installed:\n\n"
|
30
|
-
errors.each do |package|
|
31
|
-
$stderr.write "\t* "+package['executable']+"\n"
|
32
|
-
end
|
33
|
-
$stderr.write "\nYou can install them by running:\n"
|
34
|
-
$stderr.write "\tapt-get install "
|
35
|
-
$stderr.write errors.collect{|p| p['package'] || p['executable']}.join(" ")
|
36
|
-
$stderr.write "\n\nor by running \"aptinstaller\" in the root of your project\n\n"
|
37
|
-
exit(1)
|
57
|
+
not_installed.push(package) if `which #{exec}`.size == 0
|
38
58
|
end
|
59
|
+
not_installed
|
60
|
+
end
|
39
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ngauthier-aptinstaller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Gauthier
|
@@ -23,9 +23,8 @@ extra_rdoc_files: []
|
|
23
23
|
|
24
24
|
files:
|
25
25
|
- VERSION.yml
|
26
|
-
-
|
27
|
-
- README.
|
28
|
-
- Manifest.txt
|
26
|
+
- TODO.markdown
|
27
|
+
- README.markdown
|
29
28
|
- bin/aptinstaller
|
30
29
|
- lib/aptinstaller.rb
|
31
30
|
- lib/aptinstaller
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
data/README.txt
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
= aptinstaller
|
2
|
-
|
3
|
-
* http://github.com/ngauthier/aptinstaller/tree/master
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
This gem installs packages through apt-get in a similar manner as geminstaller installs gems.
|
7
|
-
|
8
|
-
== Usage:
|
9
|
-
aptinstaller [/full/path/to/rails/project/root]
|
10
|
-
|
11
|
-
Note: to run on a particular environment, invoke the executable as such:
|
12
|
-
|
13
|
-
$> RAILS_ENV=staging aptinstaller /full/path/to/rails/project/root
|
14
|
-
|
15
|
-
== INCOMPLETE ==
|
16
|
-
* Currently it doesn't do anything. I'm just trying to rake the gem.
|
17
|
-
|
18
|
-
== SYNOPSIS:
|
19
|
-
|
20
|
-
FIX (code sample of usage)
|
21
|
-
|
22
|
-
== REQUIREMENTS:
|
23
|
-
|
24
|
-
* a rails app that requires apt packages
|
25
|
-
|
26
|
-
== INSTALL:
|
27
|
-
|
28
|
-
rake gem
|
29
|
-
sudo gem install pkg/aptinstaller-0.1.0.gem
|
30
|
-
|
31
|
-
== LICENSE:
|
32
|
-
|
33
|
-
(The MIT License)
|
34
|
-
|
35
|
-
Copyright (c) 2008 FIX
|
36
|
-
|
37
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
38
|
-
a copy of this software and associated documentation files (the
|
39
|
-
'Software'), to deal in the Software without restriction, including
|
40
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
41
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
42
|
-
permit persons to whom the Software is furnished to do so, subject to
|
43
|
-
the following conditions:
|
44
|
-
|
45
|
-
The above copyright notice and this permission notice shall be
|
46
|
-
included in all copies or substantial portions of the Software.
|
47
|
-
|
48
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
49
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
50
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
51
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
52
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
53
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
54
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|