pkgman 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9e6ce1cbde5c8d865813f230ddcd56f04ce63237f4b65ee2da952aa32076bb9
4
- data.tar.gz: 51efe06c5f706d52c3b964f581af11e97db97ca63703b67b46dbe690e2cad608
3
+ metadata.gz: 62abee3f859bc2fdcce758da90d1f924d0e2031c863fe974d8447e25794a0888
4
+ data.tar.gz: 20b154321c88415de880cf4a2ae38a2ca73d8af486e01106abe04ad9c7970f9f
5
5
  SHA512:
6
- metadata.gz: b4eee1a0a208a4757c232cd17710d32918de9c418faac80c44deb415af93fd44c65a830d730742ff1df98383a6edd4d195a755d50f529e042b5b54925787bc7e
7
- data.tar.gz: 0eb09fa8a52d7117e70ee42b2a09d1657f0f3c9d9f00e9a8a6414f2d7d9a0dcb26756f6a8143bf0c704e6bc02e2866b9fa29e4c6fd88a70410472c7fbc2c8310
6
+ metadata.gz: 722fe843745aa79c64604417728d1b2383c1c19eb39c1bce97d5743e61892774313966ae99af1cac0bde2870f565452001aa2a3afc9e1432aa546385b0fe59ff
7
+ data.tar.gz: 508d58e7299a59421d5d43b696305be545c07681df28252abe72e0172303b5f3d8407e8a86711feced299e893ba073b727da7b4db78833ee14a9cc852f029507
data/Gemfile CHANGED
@@ -2,5 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- # Specify your gem's dependencies in pkgman.gemspec
6
5
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pkgman (0.1.0)
4
+ pkgman (0.1.1)
5
5
  docker-api (~> 1.34)
6
6
  faraday (~> 0.14)
7
7
  liquid (~> 4.0)
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- docker-api (1.34.0)
13
+ docker-api (1.34.1)
14
14
  excon (>= 0.47.0)
15
15
  multi_json
16
16
  excon (0.60.0)
@@ -1,5 +1,4 @@
1
1
  require "pkgman/version"
2
2
 
3
3
  module Pkgman
4
- # Your code goes here...
5
4
  end
@@ -15,14 +15,16 @@ module Pkgman
15
15
 
16
16
  command = ['/bin/bash', '-c', command]
17
17
 
18
- stdout, stderr, status = @container.exec(command, options) do |stream, chunk|
18
+ result = @container.exec(command, options) do |stream, chunk|
19
19
  puts "#{stream}: #{chunk}"
20
20
  end
21
21
 
22
- if status > 0
22
+ if result[2] > 0
23
23
  self.destroy
24
24
  raise Exception.new('Execution failed')
25
25
  end
26
+
27
+ result
26
28
  end
27
29
 
28
30
  def download(what, dst)
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'pkgman/builds/source'
3
3
  require 'pkgman/packages/rpm'
4
+ require 'pkgman/repositories/cloud_smith'
4
5
  require 'pkgman/repositories/local'
5
6
  require 'pkgman/repositories/package_cloud'
6
7
  require 'pkgman/runtime'
@@ -40,12 +41,17 @@ module Pkgman
40
41
  when 'packagecloud'
41
42
  repo = Pkgman::Repositories::PackageCloud.new(target, repository, pkg)
42
43
  repo.execute
44
+ when 'cloudsmith'
45
+ repo = Pkgman::Repositories::CloudSmith.new(target, repository, pkg)
46
+ repo.execute
43
47
  end
44
48
  end
45
49
  else
46
50
  puts "Unknown package strategy #{package['type']}"
47
51
  end
48
52
  end
53
+
54
+ target.destroy
49
55
  end
50
56
 
51
57
  end
@@ -0,0 +1,52 @@
1
+ require 'json'
2
+
3
+ module Pkgman
4
+ module Repositories
5
+
6
+ class CloudSmith
7
+
8
+ def initialize(target, repository, package)
9
+ @target = target
10
+ @repository = repository
11
+ @package = package
12
+ end
13
+
14
+ def execute
15
+ token = @repository['token']
16
+ user = @repository['user']
17
+ repo = @repository['repository']
18
+
19
+ filename = File.basename(@package.path)
20
+
21
+ hash, _, _ = @target.execute("md5sum #{@package.path} | cut -d ' ' -f 1")
22
+ hash = hash.map { |it| it.to_s }.join("")
23
+
24
+ cmd = "curl -q -X POST -H \"Authorization: token #{token}\" "
25
+ cmd += "-d \"md5_checksum=#{hash}&filename=#{filename}\" "
26
+ cmd +="https://api.cloudsmith.io/v1/files/#{user}/#{repo}/"
27
+
28
+ file, _, _ = @target.execute(cmd)
29
+ file = file.map { |it| it.to_s }.join("")
30
+
31
+ file = JSON.load(file)
32
+
33
+ cmd = "curl -vvv -X POST "
34
+ file['upload_fields'].each_key do |key|
35
+ cmd += "-F \"#{key}=#{file['upload_fields'][key]}\" "
36
+ end
37
+ cmd += "-F file=@#{@package.path} "
38
+ cmd += file['upload_url']
39
+
40
+ @target.execute(cmd)
41
+
42
+ cmd = "curl -X POST -H \"Authorization: token #{token}\" "
43
+ cmd += "-d \"distribution=el/7&package_file=#{file['identifier']}\" "
44
+ cmd += "https://api.cloudsmith.io/v1/packages/#{user}/#{repo}/upload/rpm/"
45
+
46
+ @target.execute(cmd)
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -8,8 +8,8 @@ module Pkgman
8
8
  def initialize(runtime, target)
9
9
  @target = target
10
10
  case @target['image']
11
- when 'centos'
12
- @driver = Targets::Centos.new(runtime, target)
11
+ when 'centos'
12
+ @driver = Targets::Centos.new(runtime, target)
13
13
  end
14
14
  end
15
15
 
@@ -21,5 +21,9 @@ module Pkgman
21
21
  @driver.container.download(*args, &block)
22
22
  end
23
23
 
24
+ def destroy
25
+ @driver.container.destroy
26
+ end
27
+
24
28
  end
25
29
  end
@@ -17,9 +17,9 @@ module Pkgman
17
17
 
18
18
  self.install(*target['requires'])
19
19
 
20
- @container.execute('mkdir /tmp/compiled')
21
- @container.execute('mkdir /tmp/src')
22
- @container.execute('mkdir /tmp/product')
20
+ @container.execute('mkdir -p /tmp/compiled')
21
+ @container.execute('mkdir -p /tmp/src')
22
+ @container.execute('mkdir -p /tmp/product')
23
23
  end
24
24
 
25
25
  def update
@@ -1,3 +1,3 @@
1
1
  module Pkgman
2
- VERSION = '0.1.0' unless const_defined?(:VERSION)
2
+ VERSION = '0.1.1' unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkgman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Jelen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -132,6 +132,7 @@ files:
132
132
  - lib/pkgman/descriptor.rb
133
133
  - lib/pkgman/executor.rb
134
134
  - lib/pkgman/packages/rpm.rb
135
+ - lib/pkgman/repositories/cloud_smith.rb
135
136
  - lib/pkgman/repositories/local.rb
136
137
  - lib/pkgman/repositories/package_cloud.rb
137
138
  - lib/pkgman/runtime.rb