choreograph 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/choreograph +4 -0
- data/choreograph.gemspec +32 -0
- data/lib/choreograph.rb +168 -0
- data/lib/choreograph/version.rb +3 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13c534969fb8dee5bbfa1c772387265ebdfa692d
|
4
|
+
data.tar.gz: 6b6e178f299d5eccfed4fea58c79fcb216e3d650
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 712a067c3f18a845a3ff81f5931efd2a52014aafdd07705b05f150e1d2c22909d38f6d3410576731a7004a86500e2f52e6e49ee9d46f68e46018aa2fdd6e131f
|
7
|
+
data.tar.gz: a6a436131319dca2180c3a7591bf4abdf6d938667c3b908e7c3cf6ab3969a226b57852cee401795795ee5cf49b175c2523ed1bbad6d83e27bbbdaf7dd7fa1c09
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Landis Forsloff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Choreograph
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'choreograph'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install choreograph
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/choreograph/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/choreograph
ADDED
data/choreograph.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'choreograph/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
|
8
|
+
spec.name = "choreograph"
|
9
|
+
spec.version = Choreograph::VERSION
|
10
|
+
spec.authors = ["Landis Forsloff"]
|
11
|
+
spec.email = ["landis@forsloff.com"]
|
12
|
+
spec.summary = %q{A Macintosh package manager}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = ["choreograph"]
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "thor", "~> 0.18.1"
|
26
|
+
spec.add_runtime_dependency "httparty", "~> 0.13.3"
|
27
|
+
spec.add_runtime_dependency "recursive-open-struct", "~> 0.5.0"
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
end
|
data/lib/choreograph.rb
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
#
|
2
|
+
# ________ __
|
3
|
+
# / ____/ /_ ____ ________ ____ ____ __________ _____ / /_
|
4
|
+
# / / / __ \/ __ \/ ___/ _ \/ __ \/ __ `/ ___/ __ `/ __ \/ __ \
|
5
|
+
# / /___/ / / / /_/ / / / __/ /_/ / /_/ / / / /_/ / /_/ / / / /
|
6
|
+
# \____/_/ /_/\____/_/ \___/\____/\__, /_/ \__,_/ .___/_/ /_/
|
7
|
+
# /____/ /_/
|
8
|
+
#
|
9
|
+
# Author: Landis Forsloff
|
10
|
+
# Email: landis@forsloff.com
|
11
|
+
#
|
12
|
+
#
|
13
|
+
#
|
14
|
+
|
15
|
+
require 'choreograph/version'
|
16
|
+
|
17
|
+
require 'thor'
|
18
|
+
require 'httparty'
|
19
|
+
require 'yaml'
|
20
|
+
require 'open3'
|
21
|
+
require 'recursive-open-struct'
|
22
|
+
|
23
|
+
|
24
|
+
module Choreograph
|
25
|
+
|
26
|
+
class CLI < Thor
|
27
|
+
|
28
|
+
desc "setup", "Setup Choreograph"
|
29
|
+
method_option :force, type: :boolean, aliases: '-f'
|
30
|
+
def setup
|
31
|
+
if File.exists?('/etc/com.forsloff.choreograph.conf') && !options[:force]
|
32
|
+
puts "Choreograph has already been setup. please run `choreograph setup -f`"
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
settings = { :cache => false, :sources => ['https://raw.githubusercontent.com/forsloff/conductor-repository/master/packages/{{package}}.yaml'] }
|
36
|
+
`echo "#{settings.to_yaml}" | sudo tee /etc/com.forsloff.choreograph.conf`
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
desc "cache", "Enable or disable caching, using the specified caching server."
|
41
|
+
method_option :enable, type: :string, aliases: '-e'
|
42
|
+
method_option :disable, type: :boolean, aliases: '-d'
|
43
|
+
method_option :force, type: :boolean, aliases: '-f'
|
44
|
+
def cache
|
45
|
+
|
46
|
+
if options[:enable] && options[:disable]
|
47
|
+
puts "Use only one, --enable(-e) or --disable(-d)"
|
48
|
+
exit(0)
|
49
|
+
end
|
50
|
+
|
51
|
+
config = YAML.load_file( '/etc/com.forsloff.choreograph.conf' )
|
52
|
+
|
53
|
+
#TODO: Validate the format of the caching server url
|
54
|
+
if options[:enable]
|
55
|
+
if config[:cache] && !options[:force]
|
56
|
+
puts "Caching is currently configured. Using #{options[:cache]},"
|
57
|
+
puts "to overwrite the current caching sever use --force(-f)"
|
58
|
+
exit(0)
|
59
|
+
end
|
60
|
+
config[:cache] = options[:enable]
|
61
|
+
elsif options[:disable]
|
62
|
+
config[:cache] = false
|
63
|
+
end
|
64
|
+
|
65
|
+
`echo "#{config.to_yaml}" | sudo tee /etc/com.forsloff.choreograph.conf`
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "source URL", "Add or Remove a source from the source list"
|
70
|
+
method_option :add, type: :boolean, aliases: '-a'
|
71
|
+
method_option :remove, type: :boolean, aliases: '-r'
|
72
|
+
def source(url)
|
73
|
+
|
74
|
+
if options[:add] && options[:remove]
|
75
|
+
puts "Use only one, --add(-a) or --remove(-r)"
|
76
|
+
exit(0)
|
77
|
+
end
|
78
|
+
|
79
|
+
config = YAML.load_file( '/etc/com.forsloff.choreograph.conf' )
|
80
|
+
|
81
|
+
if options[:add]
|
82
|
+
if config[:sources].include?(url)
|
83
|
+
puts "This source has already been added"
|
84
|
+
exit(0)
|
85
|
+
end
|
86
|
+
config[:sources] << url
|
87
|
+
elsif options[:remove]
|
88
|
+
config[:sources].delete(url)
|
89
|
+
end
|
90
|
+
|
91
|
+
`echo "#{config.to_yaml}" | sudo tee /etc/com.forsloff.Choreograph.conf`
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "install [APPLICATION]", "Install an Application"
|
96
|
+
method_option :version, type: :string, aliases: '-v', default: 'current'
|
97
|
+
def install(application)
|
98
|
+
|
99
|
+
# Check all of the avaible package sources for the requested package.
|
100
|
+
|
101
|
+
#package_sources = ['https://raw.githubusercontent.com/forsloff/conductor-repository/master/packages/{{package}}.yaml']
|
102
|
+
config = YAML::load_file('/etc/com.forsloff.choreograph.conf')
|
103
|
+
config[:sources].each do |source|
|
104
|
+
@manifest = HTTParty.get( source.gsub!('{{package}}', application) )
|
105
|
+
next if @manifest.code == 404
|
106
|
+
end
|
107
|
+
if @manifest.code == 404
|
108
|
+
puts 'The requested application could not be found.'
|
109
|
+
else
|
110
|
+
manifest = RecursiveOpenStruct.new( YAML.load(@manifest.body), :recurse_over_arrays => true )
|
111
|
+
end
|
112
|
+
|
113
|
+
# If there is a request for a spacific version return the corasponding url, else return the current version url
|
114
|
+
resource = options[:version] == 'current' ? manifest.current : manifest.versions.send(options[:version])
|
115
|
+
|
116
|
+
# Create a temp download directory in /tmp/
|
117
|
+
destination = `mktemp -d /tmp/com.forsloff.choreograph.XXXXXXXXXXXX`.gsub("\n", "")
|
118
|
+
|
119
|
+
# Try to download using aira2c, failing that use curl. If the download fails delete our temp directory and exit
|
120
|
+
# TODO: add support for using muliplue download url in aira2c
|
121
|
+
status = syscall('aria2c', resource.url, '-d', destination, '--file-allocation', 'none')
|
122
|
+
if status.nil?
|
123
|
+
syscall "cd #{destination} && { curl -O #{resource.url} -silent ; cd -; }"
|
124
|
+
elsif status == false
|
125
|
+
puts 'An error occured while downloading... Exiting'
|
126
|
+
syscall 'rm', '-r', destination
|
127
|
+
exit
|
128
|
+
end
|
129
|
+
|
130
|
+
if resource.dmg
|
131
|
+
source = File.join(destination, resource.dmg)
|
132
|
+
mountpoint = Digest::MD5.hexdigest(source).prepend('/Volumes/')
|
133
|
+
syscall 'hdiutil', 'attach', source, '-mountpoint', mountpoint, '-nobrowse', '-quiet'
|
134
|
+
elsif resource.zip
|
135
|
+
source = File.join(destination, resource.zip)
|
136
|
+
mountpoint = destination
|
137
|
+
syscall 'ditto', '-xk', source, mountpoint
|
138
|
+
end
|
139
|
+
|
140
|
+
if resource.pkg
|
141
|
+
package = File.join(mountpoint, resource.pkg)
|
142
|
+
syscall 'sudo', 'installer', '-pkg', package, '-target', '/'
|
143
|
+
end
|
144
|
+
|
145
|
+
if resource.app
|
146
|
+
application = File.join(mountpoint, resource.app)
|
147
|
+
syscall 'cp', '-a', application, '/Applications/'
|
148
|
+
end
|
149
|
+
|
150
|
+
syscall('hdiutil', 'detach', mountpoint, '-quiet') if resource.dmg
|
151
|
+
|
152
|
+
syscall 'rm', '-r', destination
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def syscall(*cmd)
|
159
|
+
begin
|
160
|
+
stdout, stderr, status = Open3.capture3(*cmd)
|
161
|
+
status.success? && stdout.slice!(0..-(1 + $/.size)) # strip trailing eol
|
162
|
+
rescue
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: choreograph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Landis Forsloff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.18.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.18.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.13.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.13.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: recursive-open-struct
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.5.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.5.0
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- landis@forsloff.com
|
86
|
+
executables:
|
87
|
+
- choreograph
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/choreograph
|
97
|
+
- choreograph.gemspec
|
98
|
+
- lib/choreograph.rb
|
99
|
+
- lib/choreograph/version.rb
|
100
|
+
homepage: ''
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.1.9
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: A Macintosh package manager
|
124
|
+
test_files: []
|