aptly 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ class String
2
+ def quote
3
+ return '' if self.nil?
4
+ "'" + self.gsub("'", '') + "'"
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Aptly
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "rootDir": "./.aptly"
3
+ }
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "Command Execution" do
5
+ it "should return an error on non-zero exit codes" do
6
+ expect { Aptly.runcmd 'exit 1' }.to raise_error
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "AptlyError" do
5
+ it "should contain output" do
6
+ e = AptlyError.new 'a', 'b'
7
+ e.message.should eq('a')
8
+ e.output.should eq('b')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "Hash extensions" do
5
+ it "should return kwargs properly when set" do
6
+ {:arg => 'val'}.arg(:arg, '').should eq('val')
7
+ end
8
+
9
+ it "should return defaults when arg is not set" do
10
+ {}.arg(:arg, 'val').should eq('val')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "Creating mirrors" do
5
+ # This mirror is created in spec_helper so that we only do it once for the
6
+ # entire test suite run.
7
+ it "should fail to create a mirror with a duplicate name" do
8
+ expect { Aptly.create_mirror(
9
+ 'aptly', 'http://repo.aptly.info', 'squeeze',
10
+ :components => ['main']
11
+ )}.to raise_error
12
+ end
13
+
14
+ it "should error if no component is provided" do
15
+ expect { Aptly.create_mirror(
16
+ 'no_component', 'http://repo.aptly.info', 'squeeze'
17
+ )}.to raise_error
18
+ end
19
+ end
20
+
21
+ describe "Updating Mirrors" do
22
+ it "should successfully update an existing mirror" do
23
+ mirror = Aptly::Mirror.new 'aptly'
24
+ mirror.update
25
+ end
26
+ end
27
+
28
+ describe "Loading Mirrors" do
29
+ it "should error trying to load a mirror that doesn't exist" do
30
+ expect { Aptly::Mirror.new 'nothing' }.to raise_error
31
+ end
32
+ end
33
+
34
+ describe "Updating Mirrors" do
35
+ it "should successfully update a mirror" do
36
+ mirror = Aptly::Mirror.new 'aptly'
37
+ mirror.update
38
+ # Need to check here for updated content
39
+ end
40
+ end
41
+
42
+ describe "List Packages" do
43
+ it "should return a list of packages in the mirror" do
44
+ mirror = Aptly::Mirror.new 'aptly'
45
+ mirror.list_packages.should include('aptly_0.5.1_amd64')
46
+ end
47
+ end
48
+
49
+ describe "Snapshot Mirrors" do
50
+ it "should create a new snaphot of a mirror" do
51
+ mirror = Aptly::Mirror.new 'aptly'
52
+ snap = mirror.snapshot 'snap_from_mirror'
53
+ snap.kind_of?(Aptly::Snapshot).should eq(true)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "Aptly mutex" do
5
+ it "should recognize when the mutex is locked" do
6
+ Mutex.lock
7
+ Mutex.locked?.should eq(true)
8
+ Mutex.unlock
9
+ Mutex.locked?.should eq(false)
10
+ end
11
+
12
+ it "should acquire a stale mutex" do
13
+ # Create a lock with a mangled PID
14
+ File.open(Mutex.mutex_path, 'w') {|f| f.write('99999')}
15
+ Mutex.locked?.should eq(true)
16
+ Mutex.running?.should eq(false)
17
+
18
+ # Attempt to acquire a lock
19
+ Mutex.lock
20
+ Mutex.locked?.should eq(true)
21
+ Mutex.running?.should eq(true)
22
+ Mutex.unlock
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,148 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "Creating Aptly Repos" do
5
+ it "should create repos successfully" do
6
+ Aptly.create_repo 'repo1'
7
+ Aptly.create_repo 'repo2'
8
+ end
9
+
10
+ it "should return a list of repositories" do
11
+ Aptly.list_repos.should eq(['repo1', 'repo2'])
12
+ end
13
+
14
+ it "should error if repo already exists" do
15
+ expect { Aptly.create_repo 'repo1' }.to raise_error
16
+ end
17
+ end
18
+
19
+ describe "Loading Aptly Repos" do
20
+ it "should successfully load existing repos" do
21
+ repo = Aptly::Repo.new 'repo1'
22
+ repo.kind_of?(Aptly::Repo).should eq(true)
23
+ end
24
+
25
+ it "should fail if the repo doesn't exist" do
26
+ expect { Aptly::Repo.new 'nothing' }.to raise_error
27
+ end
28
+ end
29
+
30
+ describe "Dropping Aptly Repos" do
31
+ it "should successfully drop a repo" do
32
+ repo = Aptly::Repo.new 'repo1'
33
+ repo.drop
34
+ end
35
+
36
+ it "should reflect the correct repos after dropping" do
37
+ repos = Aptly.list_repos
38
+ repos.should eq(['repo2'])
39
+ end
40
+ end
41
+
42
+ describe "Listing Repo Content" do
43
+ it "should find no packages in the new, empty repo" do
44
+ repo = Aptly::Repo.new 'repo2'
45
+ repo.list_packages.should eq([])
46
+ end
47
+ end
48
+
49
+ describe "Adding Packages" do
50
+ it "should successfully add a single file" do
51
+ repo = Aptly::Repo.new 'repo2'
52
+ repo.add 'spec/pkgs/pkg1_1.0.1-1_amd64.deb'
53
+ repo.list_packages.should eq(['pkg1_1.0.1-1_amd64'])
54
+ end
55
+
56
+ it "should successfully add a directory of packages" do
57
+ repo = Aptly::Repo.new 'repo2'
58
+ repo.add 'spec/pkgs'
59
+ repo.list_packages.should eq(['pkg1_1.0.1-1_amd64', 'pkg2_1.0.2-2_amd64'])
60
+ end
61
+ end
62
+
63
+ describe "Importing Packages" do
64
+ it "should import packages from a mirror" do
65
+ repo = Aptly.create_repo 'repo3'
66
+ repo.import 'aptly', 'aptly_0.5_amd64'
67
+ repo.list_packages.should eq(['aptly_0.5_amd64'])
68
+ end
69
+ end
70
+
71
+ describe "Copying Packages" do
72
+ it "should copy a package to another repo" do
73
+ repoA = Aptly.create_repo 'copyA'
74
+ repoB = Aptly.create_repo 'copyB'
75
+
76
+ # Copy to...
77
+ repoA.add 'spec/pkgs/pkg1_1.0.1-1_amd64.deb'
78
+ repoA.copy_to repoB.name, 'pkg1_1.0.1-1_amd64'
79
+ repoB.list_packages.should eq(['pkg1_1.0.1-1_amd64'])
80
+
81
+ # Copy from...
82
+ repoB.add 'spec/pkgs/pkg2_1.0.2-2_amd64.deb'
83
+ repoA.copy_from repoB.name, 'pkg2_1.0.2-2_amd64'
84
+ repoA.list_packages.should eq(['pkg1_1.0.1-1_amd64', 'pkg2_1.0.2-2_amd64'])
85
+ end
86
+ end
87
+
88
+ describe "Moving Packages" do
89
+ it "should move a package from one repo to another" do
90
+ repoA = Aptly.create_repo 'moveA'
91
+ repoB = Aptly.create_repo 'moveB'
92
+
93
+ # Move to...
94
+ repoA.add 'spec/pkgs/pkg1_1.0.1-1_amd64.deb'
95
+ repoA.move_to repoB.name, 'pkg1_1.0.1-1_amd64'
96
+ repoA.list_packages.should eq([])
97
+ repoB.list_packages.should eq(['pkg1_1.0.1-1_amd64'])
98
+
99
+ # Move from...
100
+ repoA.move_from repoB.name, 'pkg1_1.0.1-1_amd64'
101
+ repoA.list_packages.should eq(['pkg1_1.0.1-1_amd64'])
102
+ repoB.list_packages.should eq([])
103
+ end
104
+ end
105
+
106
+ describe "Removing Packages" do
107
+ it "should remove a package from a repo" do
108
+ repo = Aptly.create_repo 'remove'
109
+ repo.add 'spec/pkgs/pkg1_1.0.1-1_amd64.deb'
110
+ repo.list_packages.should eq(['pkg1_1.0.1-1_amd64'])
111
+
112
+ repo.remove 'pkg1_1.0.1-1_amd64'
113
+ repo.list_packages.should eq([])
114
+ end
115
+ end
116
+
117
+ describe "Snapshot Repos" do
118
+ it "should create a new snaphot of a repo" do
119
+ repo = Aptly.create_repo 'repo_to_snap'
120
+ repo.add 'spec/pkgs/pkg1_1.0.1-1_amd64.deb'
121
+ snap = repo.snapshot 'snap_from_repo'
122
+ snap.kind_of?(Aptly::Snapshot).should eq(true)
123
+ end
124
+ end
125
+
126
+ describe "Publish Repos" do
127
+ it "should publish an existing repo" do
128
+ repo = Aptly.create_repo 'repo_to_publish'
129
+ repo.add 'spec/pkgs/pkg1_1.0.1-1_amd64.deb'
130
+ repo.publish dist: 'repo_to_publish'
131
+ end
132
+ end
133
+
134
+ describe "Modify Repo" do
135
+ it "should modify the repo metadata" do
136
+ repoA = Aptly.create_repo 'modify'
137
+ repoA.dist = 'mydist'
138
+ repoA.comment = 'mycomment'
139
+ repoA.component = 'mycomponent'
140
+ repoA.save
141
+
142
+ repoB = Aptly::Repo.new 'modify'
143
+ repoB.dist.should eq('mydist')
144
+ repoB.comment.should eq('mycomment')
145
+ repoB.component.should eq('mycomponent')
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "Creating Snapshots" do
5
+ it "should error on invalid snapshot type" do
6
+ expect { Aptly.create_snapshot 'x', 'y', 'z' }.to raise_error
7
+ end
8
+
9
+ it "should successfully create a mirror snapshot" do
10
+ Aptly.create_mirror_snapshot 'aptly_snap', 'aptly'
11
+ end
12
+
13
+ it "should error on duplicate snapshot name" do
14
+ expect {
15
+ Aptly.create_mirror_snapshot 'aptly_snap', 'aptly'
16
+ }.to raise_error
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ module Aptly
4
+ describe "String extensions" do
5
+ it "should enclose strings in single quotes" do
6
+ "this is a test".quote.should eq("'this is a test'")
7
+ end
8
+
9
+ it "should strip the string of single quotes" do
10
+ "this' is' a' test".quote.should eq("'this is a test'")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ DIR="$(dirname ${BASH_SOURCE[0]})"
3
+ exec $DIR/real_aptly -config=$DIR/../aptly.conf ${@}
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+ URL="http://dl.bintray.com/smira/aptly/0.5/"
3
+ case "$(uname -s)" in
4
+ Darwin)
5
+ URL="${URL}/osx/aptly"
6
+ ;;
7
+ Linux)
8
+ URL="${URL}/debian-squeeze-x64/aptly"
9
+ ;;
10
+ *)
11
+ exit 1
12
+ esac
13
+
14
+ # Fetch aptly
15
+ if [ ! -x bin/real_aptly ]; then
16
+ (mkdir -p bin && curl -L -o bin/real_aptly $URL && chmod +x bin/real_aptly)
17
+ fi
18
+
19
+ # Add Aptly repo GPG keys
20
+ gpg --no-default-keyring --keyring trustedkeys.gpg --keyserver keys.gnupg.net \
21
+ --recv-keys 2A194991
@@ -0,0 +1,22 @@
1
+ require 'simplecov'
2
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
3
+ SimpleCov.start do
4
+ add_filter '/spec/'
5
+ end
6
+ require 'aptly'
7
+ Aptly::Mutex.mutex_path = "/tmp/aptly_#{Random.rand(1024)}.lock"
8
+ ENV['PATH'] = "#{Dir.getwd}/spec/bin:#{ENV['PATH']}"
9
+
10
+ # Create a mirror of the aptly repo for testing purposes
11
+ puts "==> Mirroring aptly..."
12
+ begin
13
+ mirror = Aptly.create_mirror(
14
+ 'aptly', 'http://repo.aptly.info/', 'squeeze',
15
+ components: ['main']
16
+ )
17
+ mirror.update
18
+ rescue AptlyError => e
19
+ puts "Failed: #{e.message}"
20
+ puts "==> output:\n#{e.output}\n"
21
+ end
22
+ puts "Done!"
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aptly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Uber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Wrapper for managing deb package repositories with aptly
70
+ email: ru@ryanuber.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/aptly/error.rb
76
+ - lib/aptly/hash.rb
77
+ - lib/aptly/mirror.rb
78
+ - lib/aptly/mutex.rb
79
+ - lib/aptly/publish.rb
80
+ - lib/aptly/repo.rb
81
+ - lib/aptly/snapshot.rb
82
+ - lib/aptly/string.rb
83
+ - lib/aptly/version.rb
84
+ - lib/aptly.rb
85
+ - spec/aptly/aptly_spec.rb
86
+ - spec/aptly/error_spec.rb
87
+ - spec/aptly/hash_spec.rb
88
+ - spec/aptly/mirror_spec.rb
89
+ - spec/aptly/mutex_spec.rb
90
+ - spec/aptly/repo_spec.rb
91
+ - spec/aptly/snapshot_spec.rb
92
+ - spec/aptly/string_spec.rb
93
+ - spec/aptly.conf
94
+ - spec/bin/aptly
95
+ - spec/pkgs/pkg1_1.0.1-1_amd64.deb
96
+ - spec/pkgs/pkg2_1.0.2-2_amd64.deb
97
+ - spec/setup.sh
98
+ - spec/spec_helper.rb
99
+ homepage: https://github.com/ryanuber/ruby-aptly
100
+ licenses:
101
+ - Apache 2.0
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: 1.8.7
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.0.14
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Interact with aptly
123
+ test_files:
124
+ - spec/aptly/aptly_spec.rb
125
+ - spec/aptly/error_spec.rb
126
+ - spec/aptly/hash_spec.rb
127
+ - spec/aptly/mirror_spec.rb
128
+ - spec/aptly/mutex_spec.rb
129
+ - spec/aptly/repo_spec.rb
130
+ - spec/aptly/snapshot_spec.rb
131
+ - spec/aptly/string_spec.rb
132
+ - spec/aptly.conf
133
+ - spec/bin/aptly
134
+ - spec/pkgs/pkg1_1.0.1-1_amd64.deb
135
+ - spec/pkgs/pkg2_1.0.2-2_amd64.deb
136
+ - spec/setup.sh
137
+ - spec/spec_helper.rb
138
+ has_rdoc: