deb-s3-lock-fix 0.11.8.fix0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,66 @@
1
+ Package: <%= name %>
2
+ Version: <%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>
3
+ License: <%= license %>
4
+ Vendor: <%= vendor %>
5
+ Architecture: <%= architecture %>
6
+ Maintainer: <%= maintainer %>
7
+ Installed-Size: <%= attributes[:deb_installed_size] %>
8
+ <% if !dependencies.empty? and !attributes[:no_depends?] -%>
9
+ Depends: <%= dependencies.collect { |d| fix_dependency(d) }.flatten.join(", ") %>
10
+ <% end -%>
11
+ <% if attributes[:deb_conflicts] -%>
12
+ Conflicts: <%= attributes[:deb_conflicts] %>
13
+ <% end -%>
14
+ <% if attributes[:deb_breaks] -%>
15
+ Breaks: <%= attributes[:deb_breaks] %>
16
+ <% end -%>
17
+ <% if attributes[:deb_pre_depends] -%>
18
+ Pre-Depends: <%= attributes[:deb_pre_depends] %>
19
+ <% end -%>
20
+ <% if attributes[:deb_provides] -%>
21
+ <%# Turn each provides from 'foo = 123' to simply 'foo' because Debian :\ -%>
22
+ <%# http://www.debian.org/doc/debian-policy/ch-relationships.html -%>
23
+ Provides: <%= attributes[:deb_provides] %>
24
+ <% end -%>
25
+ <% if attributes[:deb_replaces] -%>
26
+ Replaces: <%= attributes[:deb_replaces] %>
27
+ <% end -%>
28
+ <% if attributes[:deb_recommends] -%>
29
+ Recommends: <%= attributes[:deb_recommends] %>
30
+ <% end -%>
31
+ <% if attributes[:deb_suggests] -%>
32
+ Suggests: <%= attributes[:deb_suggests] %>
33
+ <% end -%>
34
+ <% if attributes[:deb_enhances] -%>
35
+ Enhances: <%= attributes[:deb_enhances] %>
36
+ <% end -%>
37
+ Section: <%= category %>
38
+ <% if attributes[:deb_origin] -%>
39
+ Origin: <%= attributes[:deb_origin] %>
40
+ <% end -%>
41
+ Priority: <%= attributes[:deb_priority] %>
42
+ Homepage: <%= url or "http://nourlgiven.example.com/" %>
43
+ Filename: <%= url_filename(codename) %>
44
+ <% if size -%>
45
+ Size: <%= size %>
46
+ <% end -%>
47
+ <% if sha1 -%>
48
+ SHA1: <%= sha1 %>
49
+ <% end -%>
50
+ <% if sha256 -%>
51
+ SHA256: <%= sha256 %>
52
+ <% end -%>
53
+ <% if md5 -%>
54
+ MD5sum: <%= md5 %>
55
+ <% end -%>
56
+ <% lines = (description or "no description given").split("\n") -%>
57
+ <% firstline, *remainder = lines -%>
58
+ Description: <%= firstline %>
59
+ <% if remainder.any? -%>
60
+ <%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
61
+ <% end -%>
62
+ <% if attributes[:deb_field] -%>
63
+ <% attributes[:deb_field].each do |field, value| -%>
64
+ <%= field %>: <%= value %>
65
+ <% end -%>
66
+ <% end -%>
@@ -0,0 +1,20 @@
1
+ <% if origin -%>
2
+ Origin: <%= origin %>
3
+ <% end -%>
4
+ Codename: <%= codename %>
5
+ Date: <%= Time.now.utc.strftime("%a, %d %b %Y %T %Z") %>
6
+ Architectures: <%= architectures.join(" ") %>
7
+ Components: <%= components.join(" ") %>
8
+ Suite: <%= suite %>
9
+ MD5Sum:
10
+ <% files.sort.each do |f,p| -%>
11
+ <%= p[:md5] %> <%= p[:size].to_s.rjust(16) %> <%= f %>
12
+ <% end -%>
13
+ SHA1:
14
+ <% files.sort.each do |f,p| -%>
15
+ <%= p[:sha1] %> <%= p[:size].to_s.rjust(16) %> <%= f %>
16
+ <% end -%>
17
+ SHA256:
18
+ <% files.sort.each do |f,p| -%>
19
+ <%= p[:sha256] %> <%= p[:size].to_s.rjust(16) %> <%= f %>
20
+ <% end -%>
@@ -0,0 +1,115 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require "digest/md5"
3
+ require "erb"
4
+
5
+ module Deb::S3::Utils
6
+ module_function
7
+ def s3; @s3 end
8
+ def s3= v; @s3 = v end
9
+ def bucket; @bucket end
10
+ def bucket= v; @bucket = v end
11
+ def access_policy; @access_policy end
12
+ def access_policy= v; @access_policy = v end
13
+ def signing_key; @signing_key end
14
+ def signing_key= v; @signing_key = v end
15
+ def gpg_options; @gpg_options end
16
+ def gpg_options= v; @gpg_options = v end
17
+ def prefix; @prefix end
18
+ def prefix= v; @prefix = v end
19
+ def encryption; @encryption end
20
+ def encryption= v; @encryption = v end
21
+
22
+ class SafeSystemError < RuntimeError; end
23
+ class AlreadyExistsError < RuntimeError; end
24
+
25
+ def safesystem(*args)
26
+ success = system(*args)
27
+ if !success
28
+ raise SafeSystemError, "'system(#{args.inspect})' failed with error code: #{$?.exitstatus}"
29
+ end
30
+ return success
31
+ end
32
+
33
+ def debianize_op(op)
34
+ # Operators in debian packaging are <<, <=, =, >= and >>
35
+ # So any operator like < or > must be replaced
36
+ {:< => "<<", :> => ">>"}[op.to_sym] or op
37
+ end
38
+
39
+ def template(path)
40
+ template_file = File.join(File.dirname(__FILE__), "templates", path)
41
+ template_code = File.read(template_file)
42
+ ERB.new(template_code, trim_mode: "-")
43
+ end
44
+
45
+ def s3_path(path)
46
+ File.join(*[Deb::S3::Utils.prefix, path].compact)
47
+ end
48
+
49
+ # from fog, Fog::AWS.escape
50
+ def s3_escape(string)
51
+ string.gsub(/([^a-zA-Z0-9_.\-~+]+)/) {
52
+ "%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
53
+ }
54
+ end
55
+
56
+ def s3_exists?(path)
57
+ Deb::S3::Utils.s3.head_object(
58
+ :bucket => Deb::S3::Utils.bucket,
59
+ :key => s3_path(path),
60
+ )
61
+ rescue Aws::S3::Errors::NotFound
62
+ false
63
+ end
64
+
65
+ def s3_read(path)
66
+ Deb::S3::Utils.s3.get_object(
67
+ :bucket => Deb::S3::Utils.bucket,
68
+ :key => s3_path(path),
69
+ )[:body].read
70
+ rescue Aws::S3::Errors::NoSuchKey
71
+ nil
72
+ end
73
+
74
+ def s3_store(path, filename=nil, content_type='application/octet-stream; charset=binary', cache_control=nil, fail_if_exists=false)
75
+ filename = File.basename(path) unless filename
76
+ obj = s3_exists?(filename)
77
+
78
+ file_md5 = Digest::MD5.file(path)
79
+
80
+ # check if the object already exists
81
+ if obj != false
82
+ return if (file_md5.to_s == obj[:etag].gsub('"', '') or file_md5.to_s == obj[:metadata]['md5'])
83
+ raise AlreadyExistsError, "file #{filename} already exists with different contents" if fail_if_exists
84
+ end
85
+
86
+ options = {
87
+ :bucket => Deb::S3::Utils.bucket,
88
+ :key => s3_path(filename),
89
+ :acl => Deb::S3::Utils.access_policy,
90
+ :content_type => content_type,
91
+ :metadata => { "md5" => file_md5.to_s },
92
+ }
93
+ if !cache_control.nil?
94
+ options[:cache_control] = cache_control
95
+ end
96
+
97
+ # specify if encryption is required
98
+ options[:server_side_encryption] = "AES256" if Deb::S3::Utils.encryption
99
+
100
+ # upload the file
101
+ File.open(path) do |f|
102
+ options[:body] = f
103
+ Deb::S3::Utils.s3.put_object(options)
104
+ end
105
+ end
106
+
107
+ def s3_remove(path)
108
+ if s3_exists?(path)
109
+ Deb::S3::Utils.s3.delete_object(
110
+ :bucket =>Deb::S3::Utils.bucket,
111
+ :key => s3_path(path),
112
+ )
113
+ end
114
+ end
115
+ end
data/lib/deb/s3.rb ADDED
@@ -0,0 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Deb
3
+ module S3
4
+ VERSION = "0.11.8"
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deb-s3-lock-fix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.8.fix0.1
5
+ platform: ruby
6
+ authors:
7
+ - Braeden Wolf & Ken Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-s3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk-dynamodb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '11'
83
+ description: Fork of deb-s3 with a specific fix for locking. Original work by Ken
84
+ Robertson.
85
+ email: braedenwolf@outlook.com & ken@invalidlogic.com
86
+ executables:
87
+ - deb-s3
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - README.md
92
+ - bin/deb-s3
93
+ - lib/deb/s3.rb
94
+ - lib/deb/s3/cli.rb
95
+ - lib/deb/s3/lock.rb
96
+ - lib/deb/s3/manifest.rb
97
+ - lib/deb/s3/package.rb
98
+ - lib/deb/s3/release.rb
99
+ - lib/deb/s3/templates/package.erb
100
+ - lib/deb/s3/templates/release.erb
101
+ - lib/deb/s3/utils.rb
102
+ homepage: https://github.com/braedenwolf/deb-s3-lock-fix
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 2.7.0
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">"
118
+ - !ruby/object:Gem::Version
119
+ version: 1.3.1
120
+ requirements: []
121
+ rubygems_version: 3.1.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Easily create and manage an APT repository on S3 (with specific lock fix).
125
+ test_files: []