conjur-debify 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/features/debify.feature +8 -2
- data/lib/conjur/debify.rb +93 -1
- data/lib/conjur/debify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7a88bd846714166dd0d608553936e84045ce0af
|
4
|
+
data.tar.gz: 4dc3afd7a054006c55b33ed0de011c17b8d2626b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fb023e1ed3f7edbe8f5428cedee4c2caf8f8a110031ba5d339268f9deb2100e411c9e28df8e59067c23c207acd515b26f5eab738d1c737e625af597f5f16f19
|
7
|
+
data.tar.gz: 2eff9c0a810e029252d419b9461a76442cf18e623f28d6e58fe6460b031f98d8948b638839728d782330acad62df50707a6edccabf893a7cdade80fcbeab0e88
|
data/CHANGELOG.md
CHANGED
data/features/debify.feature
CHANGED
@@ -6,10 +6,16 @@ Feature: Packaging
|
|
6
6
|
Then the exit status should be 0
|
7
7
|
And the stdout should contain exactly "conjur-example_0.0.1_amd64.deb"
|
8
8
|
|
9
|
+
@announce-output
|
10
|
+
Scenario: 'clean' command will delete non-Git-managed files
|
11
|
+
Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1 example -- --post-install /distrib/postinstall.sh`
|
12
|
+
And I successfully run `env DEBUG=true GLI_DEBUG=true debify clean -d ../../example --force`
|
13
|
+
And I successfully run `find ../../example`
|
14
|
+
Then the stdout from "find ../../example" should not contain "conjur-example_0.0.1_amd64.deb"
|
15
|
+
|
9
16
|
@announce-output
|
10
17
|
Scenario: 'example' project can be tested successfully
|
11
|
-
Given I run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1 example -- --post-install /distrib/postinstall.sh`
|
12
|
-
And the exit status should be 0
|
18
|
+
Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1 example -- --post-install /distrib/postinstall.sh`
|
13
19
|
When I run `env DEBUG=true GLI_DEBUG=true debify test -t 4.6-stable -d ../../example --no-pull example test.sh`
|
14
20
|
Then the exit status should be 0
|
15
21
|
And the stderr should contain "Test succeeded"
|
data/lib/conjur/debify.rb
CHANGED
@@ -58,6 +58,98 @@ def detect_version
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
def git_files
|
62
|
+
(`git ls-files -z`.split("\x0") + ['Gemfile.lock']).uniq
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Clean current working directory of non-Git-managed files"
|
66
|
+
long_desc <<DESC
|
67
|
+
Reliable builds depend on having a clean working directory.
|
68
|
+
|
69
|
+
Because debify runs some commands in volume-mounted Docker containers,
|
70
|
+
it is capable of creating root-owned files.
|
71
|
+
|
72
|
+
This command will delete all files in the working directory that are not
|
73
|
+
git-managed. The command is designed to run in Jenkins. Therefore, it will
|
74
|
+
only perform file deletion if:
|
75
|
+
|
76
|
+
* The current user, as provided by Etc.getlogin, is 'jenkins'
|
77
|
+
* The BUILD_NUMBER environment variable is set
|
78
|
+
|
79
|
+
File deletion can be compelled using the "force" option.
|
80
|
+
DESC
|
81
|
+
arg_name "project-name -- <fpm-arguments>"
|
82
|
+
command "clean" do |c|
|
83
|
+
c.desc "Set the current working directory"
|
84
|
+
c.flag [ :d, "dir" ]
|
85
|
+
|
86
|
+
c.desc "Ignore (don't delete) a file or directory"
|
87
|
+
c.flag [ :i, :ignore ]
|
88
|
+
|
89
|
+
c.desc "Force file deletion even if if this doesn't look like a Jenkins environment"
|
90
|
+
c.switch [ :force ]
|
91
|
+
|
92
|
+
c.action do |global_options,cmd_options,args|
|
93
|
+
def looks_like_jenkins?
|
94
|
+
require 'etc'
|
95
|
+
Etc.getlogin == 'jenkins' && ENV['BUILD_NUMBER']
|
96
|
+
end
|
97
|
+
|
98
|
+
require 'set'
|
99
|
+
perform_deletion = cmd_options[:force] || looks_like_jenkins?
|
100
|
+
if !perform_deletion
|
101
|
+
$stderr.puts "No --force, and this doesn't look like Jenkins. I won't actually delete anything"
|
102
|
+
end
|
103
|
+
@ignore_list = Array(cmd_options[:ignore]) + [ '.', '..', '.git' ]
|
104
|
+
|
105
|
+
def ignore_file? f
|
106
|
+
@ignore_list.find{|ignore| f.index(ignore) == 0}
|
107
|
+
end
|
108
|
+
|
109
|
+
dir = cmd_options[:dir] || '.'
|
110
|
+
dir = File.expand_path(dir)
|
111
|
+
Dir.chdir dir do
|
112
|
+
require 'find'
|
113
|
+
find_files = []
|
114
|
+
Find.find('.').each do |p|
|
115
|
+
find_files.push p[2..-1]
|
116
|
+
end
|
117
|
+
find_files.compact!
|
118
|
+
delete_files = (find_files - git_files)
|
119
|
+
delete_files.delete_if{|file|
|
120
|
+
File.directory?(file) || ignore_file?(file)
|
121
|
+
}
|
122
|
+
image = Docker::Image.create 'fromImage' => "alpine:3.3"
|
123
|
+
options = {
|
124
|
+
'Cmd' => [ "sh", "-c", "while true; do sleep 1; done" ],
|
125
|
+
'Image' => image.id,
|
126
|
+
'Binds' => [
|
127
|
+
[ dir, "/src" ].join(':'),
|
128
|
+
]
|
129
|
+
}
|
130
|
+
container = Docker::Container.create options
|
131
|
+
begin
|
132
|
+
container.start
|
133
|
+
delete_files.each do |file|
|
134
|
+
$stderr.puts file
|
135
|
+
|
136
|
+
file = "/src/#{file}"
|
137
|
+
cmd = if perform_deletion
|
138
|
+
[ "rm", "-f", file ]
|
139
|
+
else
|
140
|
+
[ "echo", file ]
|
141
|
+
end
|
142
|
+
|
143
|
+
stdout, stderr, status = container.exec cmd, &DebugMixin::DOCKER
|
144
|
+
$stderr.puts "Failed to delete #{file}" unless status == 0
|
145
|
+
end
|
146
|
+
ensure
|
147
|
+
container.delete force: true
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
61
153
|
desc "Build a debian package for a project"
|
62
154
|
long_desc <<DESC
|
63
155
|
The package is built using fpm (https://github.com/jordansissel/fpm).
|
@@ -115,7 +207,7 @@ command "package" do |c|
|
|
115
207
|
|
116
208
|
output = StringIO.new
|
117
209
|
Gem::Package::TarWriter.new(output) do |tar|
|
118
|
-
|
210
|
+
git_files.each do |fname|
|
119
211
|
stat = File.stat(fname)
|
120
212
|
tar.add_file(fname, stat.mode) { |tar_file| tar_file.write(File.read(fname)) }
|
121
213
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-debify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|