dpkg-s3 0.1.0 → 0.2.0

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: 8085118424eabe4c62a7016b26f53033f27719496830531aa12dadde91887553
4
- data.tar.gz: 8894ff4df72564465523ba841ea680f0e370970ce2fe5922c478d13236c69da1
3
+ metadata.gz: 543c4501eca1fde367aec9d6f5c06c5ebfcdd8c1a8f24917e664133375061ad3
4
+ data.tar.gz: b84c89139bec19e5e0f3489a3272c76138e26d6bf2ac12ac7273c5d38312c92f
5
5
  SHA512:
6
- metadata.gz: 66a81617d7e57fd104e9ec3a03b682e607f2dcdd454148e4fd6a25b778d393ee349cf62a9336f9100cfa51e1e6c7c5b53ed533708f92b4d85452c4eb558b1db0
7
- data.tar.gz: 712883d85bc9704a0a009be8674c672911b51351ab74101130c981698b24156f53d3066833d9a1c95cd97610165b39efd211009eb0f21af4e9cab0a18d43bfb8
6
+ metadata.gz: 523d6e5aa5731035fe940a0ee826877d237fd19c1f055a025094bf4489957546281238411273185cf6bff3a2496a24264cc430adbb291332f12441c7123f1600
7
+ data.tar.gz: e99e6632a28bc3f556ac43412dab1eacb6f7fff3eaa68119368a1eff247599921d476bf9d407680dec637991acc6d888c7e7eb76a18e5065d4d767d0c3a511bc
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # dpkg-s3
2
2
 
3
- [![Build Status](https://travis-ci.org/gamunu/dpkg-s3.svg?branch=master)](https://travis-ci.org/gamunu/dpkg-s3)
3
+ <p align="left">
4
+ <a href="https://github.com/gamunu/dpkg-s3/actions"><img alt="test status" src="https://github.com/gamunu/dpkg-s3/workflows/build-test/badge.svg"></a>
5
+ </p>
4
6
 
5
7
  `dpkg-s3` is a simple utility to make creating and managing APT repositories on
6
8
  S3.
@@ -6,5 +6,8 @@ $:.unshift File.join(Pathname.new(__FILE__).realpath,'../../lib')
6
6
  require 'rubygems'
7
7
  require 'dpkg/s3/cli'
8
8
 
9
- Dpkg::S3::CLI.start
10
-
9
+ begin
10
+ Dpkg::S3::CLI.start
11
+ rescue
12
+ $stderr.puts "\n\tError during processing: #{$!.message}\n\n"
13
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Dpkg
3
3
  module S3
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
@@ -1,10 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
- require "aws-sdk"
2
+ require "aws-sdk-s3"
3
3
  require "thor"
4
-
5
- # Hack: aws requires this!
6
- require "json"
7
-
8
4
  require "dpkg/s3"
9
5
  require "dpkg/s3/utils"
10
6
  require "dpkg/s3/manifest"
@@ -147,6 +143,10 @@ class Dpkg::S3::CLI < Thor
147
143
  :desc => "Whether to skip all package uploads." +
148
144
  "This is useful when hosting .deb files outside of the bucket."
149
145
 
146
+ def self.exit_on_failure?
147
+ true
148
+ end
149
+
150
150
  def upload(*files)
151
151
  if files.nil? || files.empty?
152
152
  error("You must specify at least one file to upload")
@@ -638,4 +638,4 @@ class Dpkg::S3::CLI < Thor
638
638
  error("Invalid visibility setting given. Can be public, private, authenticated, or bucket_owner.")
639
639
  end
640
640
  end
641
- end
641
+ end
@@ -2,6 +2,7 @@
2
2
  require "tempfile"
3
3
  require "socket"
4
4
  require "etc"
5
+ require "securerandom"
5
6
 
6
7
  class Dpkg::S3::Lock
7
8
  attr_accessor :user
@@ -28,13 +29,17 @@ class Dpkg::S3::Lock
28
29
 
29
30
  def lock(codename, component = nil, architecture = nil, cache_control = nil)
30
31
  lockfile = Tempfile.new("lockfile")
31
- lockfile.write("#{Etc.getlogin}@#{Socket.gethostname}")
32
+ lock_content = generate_lock_content
33
+ lockfile.write lock_content
32
34
  lockfile.close
33
35
 
34
36
  Dpkg::S3::Utils.s3_store(lockfile.path,
35
37
  lock_path(codename, component, architecture, cache_control),
36
38
  "text/plain",
37
39
  cache_control)
40
+
41
+ return if lock_content == Dpkg::S3::Utils.s3_read(lock_path(codename, component, architecture, cache_control))
42
+ throw "Failed to acquire lock, was overwritten by another deb-s3 process"
38
43
  end
39
44
 
40
45
  def unlock(codename, component = nil, architecture = nil, cache_control = nil)
@@ -43,7 +48,7 @@ class Dpkg::S3::Lock
43
48
 
44
49
  def current(codename, component = nil, architecture = nil, cache_control = nil)
45
50
  lock_content = Dpkg::S3::Utils.s3_read(lock_path(codename, component, architecture, cache_control))
46
- lock_content = lock_content.split('@')
51
+ lock_content = lock_content.split.first.split('@')
47
52
  lock = Dpkg::S3::Lock.new
48
53
  lock.user = lock_content[0]
49
54
  lock.host = lock_content[1] if lock_content.size > 1
@@ -54,5 +59,9 @@ class Dpkg::S3::Lock
54
59
  def lock_path(codename, component = nil, architecture = nil, cache_control = nil)
55
60
  "dists/#{codename}/#{component}/binary-#{architecture}/lockfile"
56
61
  end
62
+
63
+ def generate_lock_content
64
+ "#{Etc.getlogin}@#{Socket.gethostname}\n#{SecureRandom.hex}"
65
+ end
57
66
  end
58
67
  end
@@ -106,7 +106,7 @@ class Dpkg::S3::Manifest
106
106
  # store any packages that need to be stored
107
107
  @packages_to_be_upload.each do |pkg|
108
108
  yield pkg.url_filename(@codename) if block_given?
109
- s3_store(pkg.filename, pkg.url_filename(@codename), 'application/octet-stream; charset=binary', self.cache_control, self.fail_if_exists)
109
+ s3_store(pkg.filename, pkg.url_filename(@codename), 'application/x-debian-package', self.cache_control, self.fail_if_exists)
110
110
  end
111
111
  end
112
112
 
@@ -126,7 +126,7 @@ class Dpkg::S3::Manifest
126
126
  Zlib::GzipWriter.open(gztemp.path) { |gz| gz.write manifest }
127
127
  f = "dists/#{@codename}/#{@component}/binary-#{@architecture}/Packages.gz"
128
128
  yield f if block_given?
129
- s3_store(gztemp.path, f, 'application/x-gzip; charset=binary', self.cache_control)
129
+ s3_store(gztemp.path, f, 'application/x-gzip', self.cache_control)
130
130
  @files["#{@component}/binary-#{@architecture}/Packages.gz"] = hashfile(gztemp.path)
131
131
  gztemp.unlink
132
132
 
@@ -4,7 +4,7 @@ require "digest/sha2"
4
4
  require "digest/md5"
5
5
  require "socket"
6
6
  require "tmpdir"
7
- require "uri"
7
+ require "cgi"
8
8
 
9
9
  require 'dpkg/s3/utils'
10
10
 
@@ -84,7 +84,7 @@ class Dpkg::S3::Package
84
84
 
85
85
  Dir.mktmpdir do |path|
86
86
  safesystem("#{extract_control_tarball_cmd} | tar -#{compression}xf - -C #{path}")
87
- File.read(File.join(path, "control"))
87
+ File.read(File.join(path, "control"), :encoding => "UTF-8")
88
88
  end
89
89
  end
90
90
  end
@@ -146,7 +146,7 @@ class Dpkg::S3::Package
146
146
  @url_filename || "pool/#{codename}/#{self.name[0]}/#{self.name[0..1]}/#{s3_escape(File.basename(self.filename))}"
147
147
  end
148
148
 
149
- def generate(codename)
149
+ def generate(codename = nil)
150
150
  template("package.erb").result(binding)
151
151
  end
152
152
 
@@ -253,7 +253,7 @@ class Dpkg::S3::Package
253
253
 
254
254
  # Packages manifest fields
255
255
  filename = fields.delete('Filename')
256
- self.url_filename = filename && URI.unescape(filename)
256
+ self.url_filename = filename && CGI.unescape(filename)
257
257
  self.sha1 = fields.delete('SHA1')
258
258
  self.sha256 = fields.delete('SHA256')
259
259
  self.md5 = fields.delete('MD5sum')
@@ -309,4 +309,4 @@ class Dpkg::S3::Package
309
309
  fields[field] = value if field
310
310
  end
311
311
  end
312
- end
312
+ end
@@ -73,7 +73,7 @@ module Dpkg::S3::Utils
73
73
  false
74
74
  end
75
75
 
76
- def s3_store(path, filename=nil, content_type='application/octet-stream; charset=binary', cache_control=nil, fail_if_exists=false)
76
+ def s3_store(path, filename=nil, content_type='application/x-debian-package', cache_control=nil, fail_if_exists=false)
77
77
  filename = File.basename(path) unless filename
78
78
  obj = s3_exists?(filename)
79
79
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpkg-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gamunu Balagalla
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.19.0
19
+ version: 1.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.19.0
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: aws-sdk
28
+ name: aws-sdk-s3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2'
33
+ version: '1.64'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2'
40
+ version: '1.64'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5'
47
+ version: '5.8'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5'
54
+ version: '5.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '11'
61
+ version: '13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '11'
68
+ version: '13'
69
69
  description: Easily create and manage an APT repository on S3.
70
70
  email: gamunu.balagalla@outlook.com
71
71
  executables:
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.3
106
+ rubygems_version: 3.1.2
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Easily create and manage an APT repository on S3.