gitian 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.
- data/lib/commands/abstract_gitian_command.rb +7 -0
- data/lib/commands/gitian.rb +60 -0
- data/lib/rubygems_plugin.rb +9 -0
- data/spec/commands/gitian_spec.rb +69 -0
- data/spec/spec_helper.rb +4 -0
- metadata +76 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
class Gem::Commands::GitianCommand < Gem::AbstractGitianCommand
|
2
|
+
def description
|
3
|
+
'Use a Gitian distribution as the primary gem source and enable gem security'
|
4
|
+
end
|
5
|
+
|
6
|
+
def arguments
|
7
|
+
"[URL] URL of Gitian distribution, (default #{URL})"
|
8
|
+
end
|
9
|
+
|
10
|
+
def usage
|
11
|
+
"#{program_name} [URL]"
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super 'gitian', description
|
16
|
+
|
17
|
+
defaults.merge!(:insecure => false, :release => 'latest')
|
18
|
+
|
19
|
+
add_option('-r', '--release REL', 'Specify a release (default is "latest")') do |value, options|
|
20
|
+
options[:release] = value
|
21
|
+
end
|
22
|
+
|
23
|
+
add_option('', '--insecure', 'Do not require signatures on gems (defeats the design goal of Gitian!)') do |value, options|
|
24
|
+
options[:insecure] = true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute
|
29
|
+
say "Thanks for using Gitian!"
|
30
|
+
gitian(options[:insecure], options[:release])
|
31
|
+
show_status
|
32
|
+
end
|
33
|
+
|
34
|
+
def gitian(insecure, release)
|
35
|
+
gem_opts = Gem.configuration["gem"] || ""
|
36
|
+
gem_opts.gsub!(/\s*--trust-policy[ =]\S+/, "")
|
37
|
+
policy = "HighSecurity"
|
38
|
+
policy = "MediumSecurity" if insecure
|
39
|
+
gem_opts = gem_opts + " --trust-policy #{policy}"
|
40
|
+
Gem.configuration["gem"] = gem_opts.strip
|
41
|
+
oldurl = Gem.configuration["gitian_source"]
|
42
|
+
|
43
|
+
url = get_one_optional_argument || URL
|
44
|
+
url = url + release
|
45
|
+
url += "/" if url[-1,1] != "/"
|
46
|
+
|
47
|
+
sources = Gem.sources
|
48
|
+
sources.reject! { |s| s == url || s == oldurl }
|
49
|
+
sources.unshift url
|
50
|
+
Gem.sources = sources
|
51
|
+
|
52
|
+
Gem.configuration["gitian_source"] = url
|
53
|
+
|
54
|
+
Gem.configuration.write
|
55
|
+
say "High security enabled. You will get an 'unsigned gem' error if you try to install a gem from a normal, non-signing gem repository."
|
56
|
+
end
|
57
|
+
|
58
|
+
def show_status
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
2
|
+
|
3
|
+
require 'rubygems/command_manager'
|
4
|
+
require 'commands/abstract_gitian_command'
|
5
|
+
|
6
|
+
%w[gitian].each do |command|
|
7
|
+
require "commands/#{command}"
|
8
|
+
Gem::CommandManager.instance.register_command command.to_sym
|
9
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Gem::Commands::GitianCommand do
|
4
|
+
before :each do
|
5
|
+
@command = Gem::Commands::GitianCommand.new
|
6
|
+
@command.stub!(:say)
|
7
|
+
@url = "http://original/asdf"
|
8
|
+
@new_url = "http://new/asdf/"
|
9
|
+
@gitian_url = Gem::AbstractGitianCommand::URL
|
10
|
+
@command.options[:release] = 'latest'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set sources if url supplied" do
|
14
|
+
@command.should_receive(:get_one_optional_argument).and_return(@new_url)
|
15
|
+
Gem.configuration.should_receive(:[]).with("gitian_source").and_return(nil)
|
16
|
+
Gem.configuration.should_receive(:[]=).with("gitian_source", @new_url + "latest")
|
17
|
+
Gem.configuration.should_receive(:[]).with("gem").and_return("--no-ri")
|
18
|
+
Gem.configuration.should_receive(:[]=).with("gem", "--no-ri --trust-policy HighSecurity")
|
19
|
+
Gem.configuration.should_receive(:write)
|
20
|
+
Gem.should_receive(:sources).and_return([@url])
|
21
|
+
Gem.should_receive(:sources=).with([@new_url + "latest", @url])
|
22
|
+
@command.execute
|
23
|
+
end
|
24
|
+
|
25
|
+
def normal_expects
|
26
|
+
@command.should_receive(:get_one_optional_argument).and_return(nil)
|
27
|
+
Gem.configuration.should_receive(:write)
|
28
|
+
Gem.configuration.should_receive(:[]).with("gitian_source").and_return(nil)
|
29
|
+
Gem.configuration.should_receive(:[]=).with("gitian_source", @gitian_url + "latest")
|
30
|
+
Gem.should_receive(:sources).and_return([@url])
|
31
|
+
Gem.should_receive(:sources=).with([@gitian_url + "latest", @url])
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should set sources if url not supplied" do
|
35
|
+
normal_expects
|
36
|
+
Gem.configuration.should_receive(:[]).with("gem").and_return("--no-ri")
|
37
|
+
Gem.configuration.should_receive(:[]=).with("gem", "--no-ri --trust-policy HighSecurity")
|
38
|
+
@command.execute
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set gem command line if there wasn't one before" do
|
42
|
+
normal_expects
|
43
|
+
Gem.configuration.should_receive(:[]).with("gem").and_return(nil)
|
44
|
+
Gem.configuration.should_receive(:[]=).with("gem", "--trust-policy HighSecurity")
|
45
|
+
@command.execute
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should override trust policy" do
|
49
|
+
normal_expects
|
50
|
+
Gem.configuration.should_receive(:[]).with("gem").and_return("--trust-policy NoSecurity")
|
51
|
+
Gem.configuration.should_receive(:[]=).with("gem", "--trust-policy HighSecurity")
|
52
|
+
@command.execute
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should override trust policy anywhere on command line" do
|
56
|
+
normal_expects
|
57
|
+
Gem.configuration.should_receive(:[]).with("gem").and_return("--a --trust-policy=NoSecurity --b")
|
58
|
+
Gem.configuration.should_receive(:[]=).with("gem", "--a --b --trust-policy HighSecurity")
|
59
|
+
@command.execute
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should allow insecurity" do
|
63
|
+
normal_expects
|
64
|
+
Gem.configuration.should_receive(:[]).with("gem").and_return(nil)
|
65
|
+
Gem.configuration.should_receive(:[]=).with("gem", "--trust-policy MediumSecurity")
|
66
|
+
@command.gitian(true, 'latest')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitian
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Miron Cuperman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-05 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.0
|
24
|
+
version:
|
25
|
+
description: Add gitian sub-commands to the gem command
|
26
|
+
email: info.deb@nginz.org
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- lib/commands/abstract_gitian_command.rb
|
35
|
+
- lib/commands/gitian.rb
|
36
|
+
- lib/rubygems_plugin.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/devrandom/gitian
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message: |+
|
42
|
+
|
43
|
+
========================================================================
|
44
|
+
|
45
|
+
Thanks for installing Gitian! You can now run:
|
46
|
+
|
47
|
+
gem gitian use Gitian.org or another distribution as your main gem source
|
48
|
+
|
49
|
+
========================================================================
|
50
|
+
|
51
|
+
rdoc_options:
|
52
|
+
- --charset=UTF-8
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.3.5
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.3.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Use Gitian repository as gem source
|
74
|
+
test_files:
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
- spec/commands/gitian_spec.rb
|