santa 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +7 -0
- data/README.md +14 -0
- data/Rakefile +8 -0
- data/bin/santa +5 -0
- data/lib/santa.rb +47 -0
- data/santa.gemspec +31 -0
- data/test/test_all.rb +26 -0
- metadata +64 -0
data/CHANGELOG
ADDED
data/Manifest
ADDED
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
### Santa: brings you your packages
|
3
|
+
|
4
|
+
Ever wished you could specify which Debian/Ubuntu packages your app needs in a format similar to bundler's Gemfile?
|
5
|
+
|
6
|
+
You can with santa.
|
7
|
+
|
8
|
+
|
9
|
+
$ gem install santa
|
10
|
+
|
11
|
+
$ echo deb "ruby1.9.1-dev" > Debfile
|
12
|
+
|
13
|
+
$ santa
|
14
|
+
|
data/Rakefile
ADDED
data/bin/santa
ADDED
data/lib/santa.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
class Santa
|
3
|
+
attr_reader :commands_to_run
|
4
|
+
|
5
|
+
def initialize(*str, &bl)
|
6
|
+
@repos = []
|
7
|
+
@commands_to_run = [['apt-get', 'update']]
|
8
|
+
|
9
|
+
@lsb = {}
|
10
|
+
File.read('/etc/lsb-release').lines.each {|line| @lsb.merge!(Hash[*line.chomp.split(/=/)]) }
|
11
|
+
|
12
|
+
instance_eval(*str, &bl) if str.length > 0 || bl
|
13
|
+
end
|
14
|
+
|
15
|
+
def deb(debname, opts={})
|
16
|
+
append_cmd 'apt-get', 'install', debname.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def cmd(*cmds)
|
20
|
+
cmds.unshift 'sudo' unless ENV['USER'] == 'root'
|
21
|
+
puts "--> #{cmds.join(' ')}"
|
22
|
+
raise "command failed: exit status #{$?}" unless system(*cmds)
|
23
|
+
end
|
24
|
+
|
25
|
+
def executable?(cmd)
|
26
|
+
ENV['PATH'].split(':').any? {|f| File.executable?("#{f}/#{cmd}")}
|
27
|
+
end
|
28
|
+
|
29
|
+
def go!
|
30
|
+
@commands_to_run.each {|c| cmd(*c) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def prepend_cmd(*cmds)
|
34
|
+
@commands_to_run.unshift cmds unless @commands_to_run.include? cmds
|
35
|
+
end
|
36
|
+
|
37
|
+
def append_cmd(*cmds)
|
38
|
+
@commands_to_run.push cmds unless @commands_to_run.include? cmds
|
39
|
+
end
|
40
|
+
|
41
|
+
def repo(*repos, &bl)
|
42
|
+
repos.each {|r| prepend_cmd 'add-apt-repository', '-y', r.to_s }
|
43
|
+
prepend_cmd 'apt-get', 'install', 'python-software-properties' unless executable? 'add-apt-repository'
|
44
|
+
|
45
|
+
instance_eval &bl if bl
|
46
|
+
end
|
47
|
+
end
|
data/santa.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "santa"
|
5
|
+
s.version = "0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Andrew Snow"]
|
9
|
+
s.date = "2012-12-28"
|
10
|
+
s.description = "Bundler for .debs"
|
11
|
+
s.email = "andrew@modulus.org"
|
12
|
+
s.executables = ["santa"]
|
13
|
+
s.extra_rdoc_files = ["CHANGELOG", "README.md", "bin/santa", "lib/santa.rb"]
|
14
|
+
s.files = ["CHANGELOG", "README.md", "Rakefile", "bin/santa", "lib/santa.rb", "test/test_all.rb", "Manifest", "santa.gemspec"]
|
15
|
+
s.homepage = "https://github.com/andys/santa"
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Santa", "--main", "README.md"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = "santa"
|
19
|
+
s.rubygems_version = "1.8.24"
|
20
|
+
s.summary = "Bundler for .debs"
|
21
|
+
s.test_files = ["test/test_all.rb"]
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
s.specification_version = 3
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
+
else
|
28
|
+
end
|
29
|
+
else
|
30
|
+
end
|
31
|
+
end
|
data/test/test_all.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../lib/santa"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestSanta < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@santa = Santa.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_command
|
11
|
+
@santa.deb 'xyz'
|
12
|
+
assert_equal [["apt-get", "update"], ["apt-get", "install", "xyz"]], @santa.commands_to_run
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_add_repo
|
16
|
+
@santa.instance_eval do
|
17
|
+
repo 'rrr' do
|
18
|
+
deb 'xyz'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
assert_equal [["add-apt-repository", "-y", "rrr"],["apt-get", "update"], ["apt-get", "install", "xyz"]], @santa.commands_to_run
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: santa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: '0.1'
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Snow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Bundler for .debs
|
15
|
+
email: andrew@modulus.org
|
16
|
+
executables:
|
17
|
+
- santa
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- CHANGELOG
|
21
|
+
- README.md
|
22
|
+
- bin/santa
|
23
|
+
- lib/santa.rb
|
24
|
+
files:
|
25
|
+
- CHANGELOG
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/santa
|
29
|
+
- lib/santa.rb
|
30
|
+
- test/test_all.rb
|
31
|
+
- Manifest
|
32
|
+
- santa.gemspec
|
33
|
+
homepage: https://github.com/andys/santa
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options:
|
37
|
+
- --line-numbers
|
38
|
+
- --inline-source
|
39
|
+
- --title
|
40
|
+
- Santa
|
41
|
+
- --main
|
42
|
+
- README.md
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
none: false
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.2'
|
56
|
+
none: false
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project: santa
|
59
|
+
rubygems_version: 1.8.24
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Bundler for .debs
|
63
|
+
test_files:
|
64
|
+
- test/test_all.rb
|