obs_deploy 0.2.3 → 0.3.2
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 +4 -4
- data/Dockerfile.dev +8 -0
- data/{Dockerfile → Dockerfile.rpm} +0 -0
- data/Gemfile.lock +7 -5
- data/Makefile +9 -0
- data/README.md +17 -1
- data/dist/Makefile +1 -1
- data/dist/_service +9 -1
- data/dist/rubygem-obs_deploy.spec +3 -6
- data/lib/obs_deploy.rb +1 -0
- data/lib/obs_deploy/apache_sysconfig.rb +43 -8
- data/lib/obs_deploy/check_diff.rb +22 -4
- data/lib/obs_deploy/cli/commands.rb +2 -0
- data/lib/obs_deploy/cli/commands/get_diff.rb +20 -0
- data/lib/obs_deploy/cli/commands/refresh_repositories.rb +1 -1
- data/lib/obs_deploy/version.rb +1 -1
- data/lib/obs_deploy/zypper.rb +23 -7
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5b16b77225b642cdcc26e723e6c9d6b97615dbf23c898e24ce6ddb35c728761
|
4
|
+
data.tar.gz: 37ec0c9e13a348103d0049c619da0f774d39ff73f1d7daa69b29148b3500a36a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36bcb33b807e433fdb19f8a5cfaf73dc5e9b98dd5b8152e4e2aa8de0dffd2d1e4ee4001b99c1b97b2155f79e1e3cad0f3af71c7a28915d7719a63e052a1044ff
|
7
|
+
data.tar.gz: 8a463bf31c90f57034bbcb7599a378c3494f33543f4273077b565a0250949ba342578dfbc597ff41224c59d59af1baa22456e035eb6da30ae104224b6109ef5b
|
data/Dockerfile.dev
ADDED
File without changes
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
obs_deploy (0.2
|
4
|
+
obs_deploy (0.3.2)
|
5
5
|
cheetah
|
6
6
|
dry-cli
|
7
7
|
nokogiri
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
cheetah (0.5.2)
|
17
17
|
abstract_method (~> 1.2)
|
18
18
|
coderay (1.1.2)
|
19
|
-
concurrent-ruby (1.1.
|
19
|
+
concurrent-ruby (1.1.7)
|
20
20
|
crack (0.4.3)
|
21
21
|
safe_yaml (~> 1.0.0)
|
22
22
|
diff-lcs (1.3)
|
@@ -25,9 +25,10 @@ GEM
|
|
25
25
|
hashdiff (1.0.1)
|
26
26
|
jaro_winkler (1.5.4)
|
27
27
|
method_source (1.0.0)
|
28
|
-
mini_portile2 (2.
|
29
|
-
nokogiri (1.
|
30
|
-
mini_portile2 (~> 2.
|
28
|
+
mini_portile2 (2.5.0)
|
29
|
+
nokogiri (1.11.0)
|
30
|
+
mini_portile2 (~> 2.5.0)
|
31
|
+
racc (~> 1.4)
|
31
32
|
parallel (1.19.1)
|
32
33
|
parser (2.7.0.5)
|
33
34
|
ast (~> 2.4.0)
|
@@ -35,6 +36,7 @@ GEM
|
|
35
36
|
coderay (~> 1.1)
|
36
37
|
method_source (~> 1.0)
|
37
38
|
public_suffix (4.0.3)
|
39
|
+
racc (1.5.2)
|
38
40
|
rainbow (3.0.0)
|
39
41
|
rake (13.0.1)
|
40
42
|
rexml (3.2.4)
|
data/Makefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
docker-dev:
|
2
|
+
docker build -f Dockerfile.dev -t $(USER)/obs_deploy_dev .
|
3
|
+
docker run --rm -it -v "$(HOME)/.ssh:/tmp/.ssh:ro" -v "$(PWD):/obs_deploy" $(USER)/obs_deploy_dev bash
|
4
|
+
|
5
|
+
docker-rpm:
|
6
|
+
docker build -f Dockerfile.rpm -t $(USER)/obs_deploy_dev .
|
7
|
+
docker run --rm -it -v "$(HOME)/.ssh:/tmp/.ssh:ro" -v "$(PWD):/obs_deploy" $(USER)/obs_deploy_dev bash
|
8
|
+
|
9
|
+
|
data/README.md
CHANGED
@@ -5,6 +5,9 @@ Simple tool to deploy OBS via zypper to our reference server
|
|
5
5
|
## Build Status
|
6
6
|
[](https://app.circleci.com/pipelines/github/vpereira/obs_deploy)
|
7
7
|
|
8
|
+
## Codebeat
|
9
|
+
[](https://codebeat.co/projects/github-com-vpereira-obs_deploy-master)
|
10
|
+
|
8
11
|
|
9
12
|
## Installation
|
10
13
|
|
@@ -61,6 +64,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
61
64
|
|
62
65
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
66
|
|
67
|
+
### Fixtures
|
68
|
+
|
69
|
+
To generate the fixtures (located under `spec/fixtures`), we are using `curl -si $URL > $FIXTURE`
|
70
|
+
|
64
71
|
### Run the `bin/obs_deploy` on development:
|
65
72
|
|
66
73
|
On the checked out source, run the following:
|
@@ -80,7 +87,7 @@ if you want to run it against the OBS appliance running on VirtualBox:
|
|
80
87
|
- then run the container as:
|
81
88
|
|
82
89
|
```
|
83
|
-
docker
|
90
|
+
make docker-dev
|
84
91
|
```
|
85
92
|
Now you are inside the container and should be able to ping the obs appliance.
|
86
93
|
|
@@ -97,6 +104,15 @@ If you want to add new command to the cli, please read the `dry-cli` documentati
|
|
97
104
|
|
98
105
|
The commands are being sent via ssh and ssh is being called via `cheetah` https://github.com/openSUSE/cheetah. Please Read the `ssh.rb` file, specially the `SSH#run` method
|
99
106
|
|
107
|
+
## RPM Building
|
108
|
+
|
109
|
+
Under dist/ we have the necessary files to use to build the gem as rpm. The
|
110
|
+
`_service` still not used. Mainly because we need either to build the rubygem
|
111
|
+
dependencies or use https://github.com/openSUSE/obs-service-bundle_gems
|
112
|
+
|
113
|
+
Today as it is, you have to push the gem to rubygems and then generate the spec
|
114
|
+
and push it to build service
|
115
|
+
|
100
116
|
## Contributing
|
101
117
|
|
102
118
|
Bug reports and pull requests are welcome on GitHub at https://github.com/vpereira/obs_deploy.
|
data/dist/Makefile
CHANGED
data/dist/_service
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
<services>
|
2
|
-
<service name="
|
2
|
+
<service name="tar_scm">
|
3
|
+
<param name="scm">git</param>
|
4
|
+
<param name="url">git://github.com/vpereira/obs_deploy.git</param>
|
5
|
+
<param name="revision">master</param>
|
6
|
+
<param name="version">0.2.0</param>
|
3
7
|
</service>
|
8
|
+
<service name="recompress">
|
9
|
+
<param name="file">*.tar</param>
|
10
|
+
<param name="compression">xz</param>
|
11
|
+
</service>
|
4
12
|
</services>
|
@@ -18,23 +18,21 @@
|
|
18
18
|
|
19
19
|
%define mod_name obs_deploy
|
20
20
|
%define mod_full_name %{mod_name}-%{version}
|
21
|
-
%define rb_suffix ruby2.6
|
22
21
|
Name: rubygem-obs_deploy
|
23
|
-
Version: 0.
|
22
|
+
Version: 0.3.0
|
24
23
|
Release: 0
|
25
24
|
Summary: OBS Deployment tool
|
26
|
-
License:
|
25
|
+
License:
|
27
26
|
Group: Development/Languages/Ruby
|
28
27
|
URL: https://openbuildservice.org
|
29
28
|
Source: https://rubygems.org/gems/%{mod_full_name}.gem
|
30
29
|
BuildRequires: %{rubygem gem2rpm}
|
31
30
|
BuildRequires: %{ruby}
|
32
31
|
BuildRequires: ruby-macros >= 5
|
33
|
-
BuildRequires:
|
32
|
+
BuildRequires: update-alternatives
|
34
33
|
# FIXME: use proper Requires(pre/post/preun/...)
|
35
34
|
PreReq: update-alternatives
|
36
35
|
|
37
|
-
|
38
36
|
%description
|
39
37
|
OBS Deployment tool.
|
40
38
|
|
@@ -43,7 +41,6 @@ OBS Deployment tool.
|
|
43
41
|
%build
|
44
42
|
|
45
43
|
%install
|
46
|
-
%rails_fix_ruby_shebang bin/
|
47
44
|
%gem_install \
|
48
45
|
--symlink-binaries \
|
49
46
|
--doc-files="README.md" \
|
data/lib/obs_deploy.rb
CHANGED
@@ -2,29 +2,64 @@
|
|
2
2
|
|
3
3
|
module ObsDeploy
|
4
4
|
class ApacheSysconfig
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :path
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@
|
8
|
+
@path = '/etc/sysconfig/apache2'
|
9
9
|
end
|
10
10
|
|
11
11
|
def enable_maintenance_mode
|
12
|
-
|
12
|
+
unless maintenance_mode?
|
13
|
+
content = File.read(path).gsub(/^#{server_flags}=\"STATUS\"$/,
|
14
|
+
apache_status_line(maintenance))
|
15
|
+
write_apache_sysconfig(content)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def disable_maintenance_mode
|
16
|
-
|
20
|
+
if maintenance_mode?
|
21
|
+
content = File.read(path).gsub(/^#{server_flags}=\"STATUS MAINTENANCE\"/,
|
22
|
+
apache_status_line(no_maintenance))
|
23
|
+
write_apache_sysconfig(content)
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
def maintenance_mode?
|
20
|
-
|
28
|
+
find_server_flags.all? { |r| r.include?('MAINTENANCE') }
|
21
29
|
end
|
22
30
|
|
23
31
|
private
|
24
32
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
33
|
+
def no_maintenance
|
34
|
+
'STATUS'
|
35
|
+
end
|
36
|
+
|
37
|
+
def maintenance
|
38
|
+
'STATUS MAINTENANCE'
|
39
|
+
end
|
40
|
+
|
41
|
+
def server_flags
|
42
|
+
'APACHE_SERVER_FLAGS'
|
43
|
+
end
|
44
|
+
|
45
|
+
def apache_status_line(status)
|
46
|
+
"#{server_flags}=\"#{status}\""
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_server_flags
|
50
|
+
File.readlines(path).grep(/^#{server_flags}=/)
|
51
|
+
end
|
52
|
+
|
53
|
+
def write_apache_sysconfig(content)
|
54
|
+
f = Tempfile.new
|
55
|
+
f.write(content)
|
56
|
+
begin
|
57
|
+
File.rename(f.path, path)
|
58
|
+
rescue SystemCallError => e
|
59
|
+
puts e.inspect
|
60
|
+
ensure
|
61
|
+
f.unlink
|
62
|
+
f.close
|
28
63
|
end
|
29
64
|
end
|
30
65
|
end
|
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
module ObsDeploy
|
4
4
|
class CheckDiff
|
5
|
-
def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4')
|
5
|
+
def initialize(server: 'https://api.opensuse.org', product: 'SLE_12_SP4', project: 'OBS:Server:Unstable', target_server: 'https://api.opensuse.org')
|
6
6
|
@server = server
|
7
7
|
@product = product
|
8
|
+
@project = project
|
9
|
+
@target_server = target_server
|
8
10
|
end
|
9
11
|
|
10
12
|
def package_version
|
@@ -25,10 +27,26 @@ module ObsDeploy
|
|
25
27
|
Net::HTTP.get(URI("https://github.com/openSUSE/open-build-service/compare/#{obs_running_commit}...#{package_commit}.diff"))
|
26
28
|
end
|
27
29
|
|
30
|
+
def new_version_available?
|
31
|
+
obs_running_commit != package_commit
|
32
|
+
end
|
33
|
+
|
28
34
|
def has_migration?
|
29
35
|
return true if github_diff.nil? || github_diff.empty?
|
30
36
|
|
31
|
-
|
37
|
+
github_diff.match?(%r{db/migrate})
|
38
|
+
end
|
39
|
+
|
40
|
+
def has_data_migration?
|
41
|
+
return true if github_diff.nil? || github_diff.empty?
|
42
|
+
|
43
|
+
github_diff.match(%r{db/data})
|
44
|
+
end
|
45
|
+
|
46
|
+
def data_migrations
|
47
|
+
return [] unless has_data_migration?
|
48
|
+
|
49
|
+
github_diff.match(%r{db/data/.*\.rb}).to_a
|
32
50
|
end
|
33
51
|
|
34
52
|
def migrations
|
@@ -38,11 +56,11 @@ module ObsDeploy
|
|
38
56
|
end
|
39
57
|
|
40
58
|
def package_url
|
41
|
-
URI("#{@server}/public/build
|
59
|
+
URI("#{@server}/public/build/#{@project}/#{@product}/x86_64/obs-server")
|
42
60
|
end
|
43
61
|
|
44
62
|
def about_url
|
45
|
-
URI("#{@
|
63
|
+
URI("#{@target_server}/about")
|
46
64
|
end
|
47
65
|
end
|
48
66
|
end
|
@@ -11,6 +11,7 @@ module ObsDeploy
|
|
11
11
|
autoload :GetDeployedVersion, File.join(__dir__, 'commands/get_deployed_version.rb')
|
12
12
|
autoload :Systemctl, File.join(__dir__, 'commands/systemctl.rb')
|
13
13
|
autoload :GetPendingMigration, File.join(__dir__, 'commands/get_pending_migration.rb')
|
14
|
+
autoload :GetDiff, File.join(__dir__, 'commands/get_diff.rb')
|
14
15
|
|
15
16
|
# register the commands and its command line
|
16
17
|
register 'available-package', GetPackageVersion
|
@@ -20,6 +21,7 @@ module ObsDeploy
|
|
20
21
|
register 'refresh-repositories', RefreshRepositories
|
21
22
|
register 'systemctl', Systemctl
|
22
23
|
register 'pending-migrations', GetPendingMigration
|
24
|
+
register 'check-diff', GetDiff
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ObsDeploy
|
4
|
+
module CLI
|
5
|
+
module Commands
|
6
|
+
class GetDiff < Dry::CLI::Command
|
7
|
+
desc 'Get diff between deployed package and available package'
|
8
|
+
option :url, type: :string, default: 'https://api.opensuse.org', desc: 'API url'
|
9
|
+
option :package, type: :string, default: 'obs-api', desc: 'Package name'
|
10
|
+
option :project, type: :string, default: 'OBS:Server:Unstable', desc: 'Project name'
|
11
|
+
option :product, type: :string, default: 'SLE_12_SP4', desc: 'Product name'
|
12
|
+
option :architecture, type: :string, default: 'x86_64', desc: 'Architecture'
|
13
|
+
|
14
|
+
def call(url:, product:, project:, **)
|
15
|
+
puts "diff : #{ObsDeploy::CheckDiff.new(server: url, project: project, product: product).github_diff}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -12,7 +12,7 @@ module ObsDeploy
|
|
12
12
|
|
13
13
|
def call(user:, dry_run:, host:, port:, **)
|
14
14
|
ssh_driver = ObsDeploy::SSH.new(user: user, server: host, port: port)
|
15
|
-
zypper = ObsDeploy::Zypper.new
|
15
|
+
zypper = ObsDeploy::Zypper.new(dry_run: dry_run)
|
16
16
|
ssh_driver.run(zypper.refresh)
|
17
17
|
end
|
18
18
|
end
|
data/lib/obs_deploy/version.rb
CHANGED
data/lib/obs_deploy/zypper.rb
CHANGED
@@ -6,17 +6,33 @@ module ObsDeploy
|
|
6
6
|
|
7
7
|
def initialize(dry_run: true, package_name: 'obs-api')
|
8
8
|
@dry_run = dry_run
|
9
|
+
@package_name = package_name
|
9
10
|
end
|
10
11
|
|
11
12
|
def update
|
12
|
-
run [
|
13
|
+
run %w[zypper] + update_string + package_name
|
13
14
|
end
|
14
15
|
|
15
16
|
def refresh
|
16
|
-
run [
|
17
|
+
run %w[zypper --non-interactive --gpg-auto-import-keys refresh]
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
# TODO
|
21
|
+
# check if we want to lock from specific repositories
|
22
|
+
def add_lock
|
23
|
+
run %w[zypper addlock] + package_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def remove_lock
|
27
|
+
run %w[zypper removelock] + package_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def locked?
|
31
|
+
# check the return value
|
32
|
+
run %w[zypper locks] + package_name
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
20
36
|
|
21
37
|
def run(params)
|
22
38
|
params
|
@@ -31,15 +47,15 @@ module ObsDeploy
|
|
31
47
|
end
|
32
48
|
|
33
49
|
def package_name
|
34
|
-
[
|
50
|
+
[@package_name]
|
35
51
|
end
|
36
52
|
|
37
53
|
def update_params
|
38
|
-
[
|
54
|
+
%w[--non-interactive update --best-effort --details]
|
39
55
|
end
|
40
56
|
|
41
57
|
def dry_run_params
|
42
|
-
[
|
58
|
+
%w[--dry-run --download-only]
|
43
59
|
end
|
44
|
-
|
60
|
+
end
|
45
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obs_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pereira
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email:
|
141
141
|
- vpereira@suse.de
|
142
142
|
executables:
|
@@ -151,9 +151,11 @@ files:
|
|
151
151
|
- ".rspec"
|
152
152
|
- ".rubocop.yml"
|
153
153
|
- ".travis.yml"
|
154
|
-
- Dockerfile
|
154
|
+
- Dockerfile.dev
|
155
|
+
- Dockerfile.rpm
|
155
156
|
- Gemfile
|
156
157
|
- Gemfile.lock
|
158
|
+
- Makefile
|
157
159
|
- README.md
|
158
160
|
- Rakefile
|
159
161
|
- bin/console
|
@@ -169,6 +171,7 @@ files:
|
|
169
171
|
- lib/obs_deploy/cli/commands.rb
|
170
172
|
- lib/obs_deploy/cli/commands/deploy.rb
|
171
173
|
- lib/obs_deploy/cli/commands/get_deployed_version.rb
|
174
|
+
- lib/obs_deploy/cli/commands/get_diff.rb
|
172
175
|
- lib/obs_deploy/cli/commands/get_package_version.rb
|
173
176
|
- lib/obs_deploy/cli/commands/get_pending_migration.rb
|
174
177
|
- lib/obs_deploy/cli/commands/refresh_repositories.rb
|
@@ -185,7 +188,7 @@ metadata:
|
|
185
188
|
allowed_push_host: https://rubygems.org
|
186
189
|
homepage_uri: https://openbuildservice.org
|
187
190
|
source_code_uri: https://github.com/vpereira/obs_deploy.git
|
188
|
-
post_install_message:
|
191
|
+
post_install_message:
|
189
192
|
rdoc_options: []
|
190
193
|
require_paths:
|
191
194
|
- lib
|
@@ -201,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
204
|
version: '0'
|
202
205
|
requirements: []
|
203
206
|
rubygems_version: 3.0.6
|
204
|
-
signing_key:
|
207
|
+
signing_key:
|
205
208
|
specification_version: 4
|
206
209
|
summary: OBS Deployment tool
|
207
210
|
test_files: []
|