machines 0.5.3 → 0.5.4
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/CHANGELOG.md +7 -1
- data/EXAMPLES.md +3 -1
- data/lib/machines/file_operations.rb +1 -1
- data/lib/machines/installation.rb +23 -4
- data/lib/machines/version.rb +1 -1
- data/lib/packages/amazon_mp3.rb +1 -1
- data/spec/lib/machines/installation_spec.rb +29 -8
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
== 0.5.4
|
2
|
+
|
3
|
+
* Added support extracting for bz2 archives
|
4
|
+
* `install` can now download an archive and extract to /usr/local/lib and create a link in /usr/local/bin
|
5
|
+
|
6
|
+
|
1
7
|
== 0.5.3
|
2
8
|
|
3
9
|
* Implement `list` command to list available machines from machines.yml
|
4
10
|
* Display syntax when `build` called with no machine
|
5
|
-
* Support running multiple tasks - e.g. `machines build machine passenger passenger_nginx nginx`
|
11
|
+
* Support running multiple tasks - e.g. `machines build machine passenger passenger_nginx nginx webapps`
|
6
12
|
* modify git_clone to pull if the repo already exists
|
7
13
|
|
8
14
|
== 0.5.2
|
data/EXAMPLES.md
CHANGED
@@ -23,7 +23,7 @@ Now the drivers for my printer are installed.
|
|
23
23
|
Running individual tasks
|
24
24
|
=======================================
|
25
25
|
|
26
|
-
Here is an example of upgrading Ruby, passenger and Nginx. First we check what commands will be run with the `dryrun` command.
|
26
|
+
Here is an example of upgrading Ruby, passenger and Nginx. First we check what commands will be run with the `dryrun` command. This particular time I was upgrading to Ruby 1.9.3-p194 and the latest passenger (3.0.17) and Nginx (1.2.3).
|
27
27
|
|
28
28
|
machines dryrun phil rbenv passenger passenger_nginx nginx webapps
|
29
29
|
cat log/output.log
|
@@ -39,3 +39,5 @@ We can see that git and curl are installed as part of the rbenv install (althoug
|
|
39
39
|
All looks good so we'll run the build:
|
40
40
|
|
41
41
|
machines build phil rbenv passenger passenger_nginx nginx webapps
|
42
|
+
|
43
|
+
Everything gets reinstalled and reconfigured and we can carry on. `sudo restart nginx` may be required.
|
@@ -63,7 +63,7 @@ module Machines
|
|
63
63
|
|
64
64
|
# Rename a remote file or folder
|
65
65
|
# @param [String] oldname Existing filename
|
66
|
-
# @param [String] newname Rename to this
|
66
|
+
# @param [String] newname Rename to this
|
67
67
|
def rename oldname, newname
|
68
68
|
Command.new("mv -f #{oldname} #{newname}", check_file(newname))
|
69
69
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Machines
|
2
2
|
module Installation
|
3
|
+
include FileOperations
|
4
|
+
|
3
5
|
APTGET_QUIET = 'apt-get -q -y'
|
4
6
|
|
5
7
|
# Adds a PPA source and updates apt
|
@@ -45,13 +47,21 @@ module Machines
|
|
45
47
|
Command.new(command, check)
|
46
48
|
end
|
47
49
|
|
48
|
-
# Download, extract, and remove an archive. Currently supports `zip`
|
50
|
+
# Download, extract, and remove an archive. Currently supports `zip`, `tar.gz`, `tar.bz2`.
|
49
51
|
# @param [String] package Package name to extract
|
50
52
|
# @param [Hash] options
|
51
53
|
# @option options [Optional String] :to folder to clone or extract to (defaults to /usr/local/src)
|
52
54
|
def extract package, options = {}
|
53
55
|
name = File.basename(package)
|
54
|
-
|
56
|
+
if package[/.zip/]
|
57
|
+
cmd = 'unzip -qq'
|
58
|
+
elsif package[/.tar.gz/]
|
59
|
+
cmd = 'tar -zxf'
|
60
|
+
elsif package[/.tar.bz2/]
|
61
|
+
cmd = 'tar -jxf'
|
62
|
+
else
|
63
|
+
raise "extract: Unknown extension for #{package}"
|
64
|
+
end
|
55
65
|
dir = cmd =~ /unzip/ ? File.basename(name, '.zip') : File.basename(name).gsub(/\.tar.*/, '')
|
56
66
|
dest = options[:to] || '/usr/local/src'
|
57
67
|
Command.new("cd #{dest} && wget #{package} && #{cmd} #{name} && rm #{name} && cd -", check_dir("#{File.join(dest, dir)}"))
|
@@ -95,13 +105,17 @@ module Machines
|
|
95
105
|
# (See `extract` to just uncompress tar.gz or zip files)
|
96
106
|
# @param [Symbol, String, Array] packages can be:
|
97
107
|
# URL::
|
98
|
-
# Download from
|
108
|
+
# Download from URL and run `dpkg` (if `:as => :dpkg`)
|
109
|
+
# Download URL to `/usr/local/lib` and link `:bin` to `/usr/local/bin`
|
99
110
|
# Array or string (with no URL)::
|
100
111
|
# Run `apt` to install specified packages in the array or string
|
101
112
|
# Packages are installed separately to aid progress feedback
|
102
113
|
# Ensure this is the main package as dpkg get-selections is used to validate installation
|
103
114
|
# install %w(build-essential libssl-dev mysql-server) #=> Installs apt packages
|
104
115
|
# install 'http://example.com/my_package.deb', :cleanup => true #=> Installs a deb using dpkg then removes the deb
|
116
|
+
# @param [Hash] options
|
117
|
+
# @option options [Optional Symbol] :as Identify the package type so appropriate command can run. Currently supports `:dpkg` only
|
118
|
+
# @option options [Optional String] :bin Specify the bin file to link to (e.g. '/bin/executable' will create a link /usr/local/bin/executable that points to /usr/local/lib/bin/executable)
|
105
119
|
def install packages, options = {}
|
106
120
|
if packages.is_a?(String)
|
107
121
|
if packages =~ /^http:\/\//
|
@@ -109,10 +123,15 @@ module Machines
|
|
109
123
|
if packages =~ /\.deb$/i
|
110
124
|
name = File.basename(packages)
|
111
125
|
commands << Command.new("cd /tmp && wget #{packages} && dpkg -i --force-architecture #{name} && rm #{name} && cd -", nil)
|
112
|
-
|
126
|
+
elsif options[:as] == :dpkg
|
113
127
|
commands << extract(packages, :to => '/tmp')
|
114
128
|
name = File.basename(packages).gsub(/\.(tar|zip).*/, '')
|
115
129
|
commands << Command.new("cd /tmp/#{name} && dpkg -i --force-architecture *.deb && cd - && rm -rf /tmp/#{name}", nil)
|
130
|
+
elsif options[:bin]
|
131
|
+
commands << extract(packages, :to => '/tmp')
|
132
|
+
name = File.basename(packages).gsub(/\.(tar|zip).*/, '')
|
133
|
+
commands << rename("/tmp/#{name}", "/usr/local/lib")
|
134
|
+
commands << link("/usr/local/lib/#{name}/#{options[:bin]}", "/usr/local/bin/#{File.basename(options[:bin])}")
|
116
135
|
end
|
117
136
|
return commands
|
118
137
|
else
|
data/lib/machines/version.rb
CHANGED
data/lib/packages/amazon_mp3.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
task :amazon_mp3, 'Download and install MP3 downloader from Amazon' do
|
2
|
-
sudo install 'http://www.hilltopyodeler.com/packages/AmazonMP3-InstallerForUbuntuNewerThan-9.04.tar.gz'
|
2
|
+
sudo install 'http://www.hilltopyodeler.com/packages/AmazonMP3-InstallerForUbuntuNewerThan-9.04.tar.gz', :as => :dpkg
|
3
3
|
end
|
4
4
|
|
@@ -41,9 +41,21 @@ describe 'Installation' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'extract' do
|
44
|
+
it 'instaniates commands to download, extract and remove a tar.gz archive' do
|
45
|
+
subject = extract 'http://url/package.tar.gz'
|
46
|
+
subject.command.must_equal 'cd /usr/local/src && wget http://url/package.tar.gz && tar -zxf package.tar.gz && rm package.tar.gz && cd -'
|
47
|
+
subject.check.must_equal 'test -d /usr/local/src/package && echo CHECK PASSED || echo CHECK FAILED'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'instaniates commands to download, extract and remove a tar.bz2 archive' do
|
51
|
+
subject = extract 'http://url/package.tar.bz2'
|
52
|
+
subject.command.must_equal 'cd /usr/local/src && wget http://url/package.tar.bz2 && tar -jxf package.tar.bz2 && rm package.tar.bz2 && cd -'
|
53
|
+
subject.check.must_equal 'test -d /usr/local/src/package && echo CHECK PASSED || echo CHECK FAILED'
|
54
|
+
end
|
55
|
+
|
44
56
|
it 'instaniates commands to download, extract and remove a tar archive' do
|
45
|
-
subject = extract 'http://url/package.tar'
|
46
|
-
subject.command.must_equal 'cd /usr/local/src && wget http://url/package.tar && tar -zxf package.tar && rm package.tar && cd -'
|
57
|
+
subject = extract 'http://url/package.tar.gz'
|
58
|
+
subject.command.must_equal 'cd /usr/local/src && wget http://url/package.tar.gz && tar -zxf package.tar.gz && rm package.tar.gz && cd -'
|
47
59
|
subject.check.must_equal 'test -d /usr/local/src/package && echo CHECK PASSED || echo CHECK FAILED'
|
48
60
|
end
|
49
61
|
|
@@ -117,28 +129,37 @@ describe 'Installation' do
|
|
117
129
|
end
|
118
130
|
end
|
119
131
|
|
120
|
-
describe 'install' do
|
121
|
-
it '
|
132
|
+
describe 'install instaniates commands to' do
|
133
|
+
it 'download, extract and link to binary executable' do
|
134
|
+
subject = install 'http://some.url/package_name.tar.bz2', :bin => 'bin/package'
|
135
|
+
subject.map(&:command).must_equal [
|
136
|
+
'cd /tmp && wget http://some.url/package_name.tar.bz2 && tar -jxf package_name.tar.bz2 && rm package_name.tar.bz2 && cd -',
|
137
|
+
'mv -f /tmp/package_name /usr/local/lib',
|
138
|
+
'ln -sf /usr/local/lib/package_name/bin/package /usr/local/bin/package'
|
139
|
+
]
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'download, install and remove a DEB package ' do
|
122
143
|
subject = install "http://some.url/package_name.deb"
|
123
144
|
subject.map(&:command).must_equal [
|
124
145
|
'cd /tmp && wget http://some.url/package_name.deb && dpkg -i --force-architecture package_name.deb && rm package_name.deb && cd -'
|
125
146
|
]
|
126
147
|
end
|
127
148
|
|
128
|
-
it '
|
129
|
-
subject = install "http://some.url/package_name.tar.gz"
|
149
|
+
it 'download, extract, install and remove a group of DEB packages ' do
|
150
|
+
subject = install "http://some.url/package_name.tar.gz", :as => :dpkg
|
130
151
|
subject.map(&:command).must_equal [
|
131
152
|
'cd /tmp && wget http://some.url/package_name.tar.gz && tar -zxf package_name.tar.gz && rm package_name.tar.gz && cd -',
|
132
153
|
'cd /tmp/package_name && dpkg -i --force-architecture *.deb && cd - && rm -rf /tmp/package_name'
|
133
154
|
]
|
134
155
|
end
|
135
156
|
|
136
|
-
it '
|
157
|
+
it 'install a single apt package' do
|
137
158
|
subject = install 'package1'
|
138
159
|
subject.map(&:command).must_equal ['apt-get -q -y install package1']
|
139
160
|
end
|
140
161
|
|
141
|
-
it '
|
162
|
+
it 'install multiple apt packages' do
|
142
163
|
subject = install %w(package1 package2)
|
143
164
|
subject.map(&:command).must_equal [
|
144
165
|
'apt-get -q -y install package1',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: machines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -520,7 +520,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
520
520
|
version: '0'
|
521
521
|
segments:
|
522
522
|
- 0
|
523
|
-
hash:
|
523
|
+
hash: -3397019508806936970
|
524
524
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
525
525
|
none: false
|
526
526
|
requirements:
|