apt-dists-merge 1.0.1 → 1.0.3
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/NEWS.md +12 -0
- data/lib/apt-dists-merge/merger.rb +75 -36
- data/lib/apt-dists-merge/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 885ee75308e725f2c6ad7c16fa0b868a111d983551ed3fd2620c9f5851b3994f
|
|
4
|
+
data.tar.gz: c70f39bff07b7bf31d234598447497e20366bfa02d49cceb7887d2a3b1ceab88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 016a26b4725c3ab94e994a24c5d31a523b405a753228068aeb5eed0d8572b2d3187d8ad594c876402ef0cc8b6da291fd38b0a93100e8f7cc2c7b71c18e248c1f
|
|
7
|
+
data.tar.gz: '0083d7b62a49f4259ca70ed9aab1f45d6d10775afde2d3987c5e49163ef1c732807f93ab78ace217470c230b269b5ba0a418b3c3cc33ad6288426a082bd27225'
|
data/NEWS.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# NEWS
|
|
2
2
|
|
|
3
|
+
## 1.0.3 - 2026-11-02
|
|
4
|
+
|
|
5
|
+
### Improvements
|
|
6
|
+
|
|
7
|
+
* Added support for empty base and incoming.
|
|
8
|
+
|
|
9
|
+
## 1.0.2 - 2021-10-02
|
|
10
|
+
|
|
11
|
+
### Improvements
|
|
12
|
+
|
|
13
|
+
* Added support for removing duplicated packages.
|
|
14
|
+
|
|
3
15
|
## 1.0.1 - 2021-09-28
|
|
4
16
|
|
|
5
17
|
### Improvements
|
|
@@ -2,6 +2,8 @@ require "fileutils"
|
|
|
2
2
|
|
|
3
3
|
module APTDistsMerge
|
|
4
4
|
class Merger
|
|
5
|
+
EXTENSIONS = ["", ".gz", ".xz"]
|
|
6
|
+
|
|
5
7
|
def initialize(base_dir, incoming_dir, merged_dir)
|
|
6
8
|
@base_dir = base_dir
|
|
7
9
|
@incoming_dir = incoming_dir
|
|
@@ -27,26 +29,40 @@ module APTDistsMerge
|
|
|
27
29
|
|
|
28
30
|
private
|
|
29
31
|
def detect_extensions(base_path)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
EXTENSIONS.select do |extension|
|
|
33
|
+
File.exist?("#{base_path}#{extension}")
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
36
|
|
|
37
|
+
def data_exist?(path)
|
|
38
|
+
not detect_extensions(path).empty?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def detect_unsupported_paths(base_path)
|
|
42
|
+
paths = Dir.glob("#{base_path}*").select do |path|
|
|
43
|
+
File.file?(path)
|
|
44
|
+
end
|
|
45
|
+
supported_paths = detect_extensions(base_path).collect do |extension|
|
|
46
|
+
"#{base_path}#{extension}"
|
|
47
|
+
end
|
|
48
|
+
paths - supported_paths
|
|
49
|
+
end
|
|
50
|
+
|
|
35
51
|
def read_data(path)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
extension = detect_extensions(path).first
|
|
53
|
+
return nil if extension.nil?
|
|
54
|
+
real_path = "#{path}#{extension}"
|
|
55
|
+
case extension
|
|
56
|
+
when ".gz"
|
|
40
57
|
Zlib::GzipReader.open(real_path) do |input|
|
|
41
58
|
input.read
|
|
42
59
|
end
|
|
43
|
-
|
|
44
|
-
real_path = "#{path}.xz"
|
|
60
|
+
when ".xz"
|
|
45
61
|
IO.popen(["xz", "--decompress", "--stdout", real_path]) do |input|
|
|
46
62
|
input.read
|
|
47
63
|
end
|
|
48
64
|
else
|
|
49
|
-
|
|
65
|
+
File.read(real_path)
|
|
50
66
|
end
|
|
51
67
|
end
|
|
52
68
|
|
|
@@ -81,6 +97,36 @@ module APTDistsMerge
|
|
|
81
97
|
end
|
|
82
98
|
end
|
|
83
99
|
|
|
100
|
+
def copy_data(path, merged_path)
|
|
101
|
+
FileUtils.mkdir_p(File.dirname(merged_path))
|
|
102
|
+
detect_extensions(path).each do |extension|
|
|
103
|
+
FileUtils.cp("#{path}#{extension}", "#{merged_path}#{extension}")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def merge_data(base_path, incoming_path, merged_path)
|
|
108
|
+
[base_path, incoming_path].each do |path|
|
|
109
|
+
next if data_exist?(path)
|
|
110
|
+
unsupported_paths = detect_unsupported_paths(path)
|
|
111
|
+
next if unsupported_paths.empty?
|
|
112
|
+
$stderr.puts("Unsupported format: #{unsupported_paths.join(", ")}")
|
|
113
|
+
return false
|
|
114
|
+
end
|
|
115
|
+
if not data_exist?(base_path)
|
|
116
|
+
copy_data(incoming_path, merged_path)
|
|
117
|
+
elsif not data_exist?(incoming_path)
|
|
118
|
+
copy_data(base_path, merged_path)
|
|
119
|
+
else
|
|
120
|
+
base = read_data(base_path)
|
|
121
|
+
incoming = read_data(incoming_path)
|
|
122
|
+
write_data(yield(base, incoming),
|
|
123
|
+
merged_path,
|
|
124
|
+
detect_extensions(base_path) |
|
|
125
|
+
detect_extensions(incoming_path))
|
|
126
|
+
end
|
|
127
|
+
true
|
|
128
|
+
end
|
|
129
|
+
|
|
84
130
|
def release_path(dir)
|
|
85
131
|
"#{dir}/Release"
|
|
86
132
|
end
|
|
@@ -153,15 +199,11 @@ module APTDistsMerge
|
|
|
153
199
|
def merge_contents(component, arch)
|
|
154
200
|
base_path = contents_path(@base_dir, component, arch)
|
|
155
201
|
incoming_path = contents_path(@incoming_dir, component, arch)
|
|
156
|
-
base = read_data(base_path)
|
|
157
|
-
incoming = read_data(incoming_path)
|
|
158
|
-
merged = (base.lines | incoming.lines).sort
|
|
159
202
|
merged_path = contents_path(@merged_dir, component, arch)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
true
|
|
203
|
+
merge_data(base_path, incoming_path, merged_path) do |base, incoming|
|
|
204
|
+
merged = (base.lines | incoming.lines).sort
|
|
205
|
+
merged.join
|
|
206
|
+
end
|
|
165
207
|
end
|
|
166
208
|
|
|
167
209
|
def parse_deb822(content)
|
|
@@ -179,8 +221,8 @@ module APTDistsMerge
|
|
|
179
221
|
data
|
|
180
222
|
end
|
|
181
223
|
|
|
182
|
-
def
|
|
183
|
-
|
|
224
|
+
def parse_packages(data)
|
|
225
|
+
data.split("\n\n").collect do |content|
|
|
184
226
|
[parse_deb822(content), content]
|
|
185
227
|
end
|
|
186
228
|
end
|
|
@@ -196,7 +238,10 @@ module APTDistsMerge
|
|
|
196
238
|
end
|
|
197
239
|
|
|
198
240
|
def merge_packages_data(base, incoming)
|
|
199
|
-
(base + incoming).
|
|
241
|
+
packages = (base + incoming).uniq do |metadata,|
|
|
242
|
+
[metadata["Package"], metadata["Version"]]
|
|
243
|
+
end
|
|
244
|
+
packages.sort do |a, b|
|
|
200
245
|
a_metadata = a[0]
|
|
201
246
|
b_metadata = b[0]
|
|
202
247
|
a_package = a_metadata["Package"]
|
|
@@ -217,15 +262,12 @@ module APTDistsMerge
|
|
|
217
262
|
def merge_packages(component, arch)
|
|
218
263
|
base_path = packages_path(@base_dir, component, arch)
|
|
219
264
|
incoming_path = packages_path(@incoming_dir, component, arch)
|
|
220
|
-
base = read_packages(base_path)
|
|
221
|
-
incoming = read_packages(incoming_path)
|
|
222
|
-
merged = merge_packages_data(base, incoming)
|
|
223
265
|
merged_path = packages_path(@merged_dir, component, arch)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
266
|
+
merge_data(base_path, incoming_path, merged_path) do |base, incoming|
|
|
267
|
+
merged = merge_packages_data(parse_packages(base),
|
|
268
|
+
parse_packages(incoming))
|
|
269
|
+
merged.collect {|_, content| "#{content}\n\n"}.join
|
|
270
|
+
end
|
|
229
271
|
end
|
|
230
272
|
|
|
231
273
|
def merge_binary_release(component, arch)
|
|
@@ -251,15 +293,12 @@ module APTDistsMerge
|
|
|
251
293
|
def merge_sources(component)
|
|
252
294
|
base_path = sources_path(@base_dir, component)
|
|
253
295
|
incoming_path = sources_path(@incoming_dir, component)
|
|
254
|
-
base = read_packages(base_path)
|
|
255
|
-
incoming = read_packages(incoming_path)
|
|
256
|
-
merged = merge_packages_data(base, incoming)
|
|
257
296
|
merged_path = sources_path(@merged_dir, component)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
297
|
+
merge_data(base_path, incoming_path, merged_path) do |base, incoming|
|
|
298
|
+
merged = merge_packages_data(parse_packages(base),
|
|
299
|
+
parse_packages(incoming))
|
|
300
|
+
merged.collect {|_, content| "#{content}\n\n"}.join
|
|
301
|
+
end
|
|
263
302
|
end
|
|
264
303
|
|
|
265
304
|
def merge_source_release(component)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apt-dists-merge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sutou Kouhei
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Generally, you should use more general APT repository management tool
|
|
14
13
|
such as [aptly](https://www.aptly.info/) and [reprepro](https://salsa.debian.org/brlink/reprepro).
|
|
@@ -31,7 +30,6 @@ homepage: https://github.com/red-data-tools/apt-dists-merge
|
|
|
31
30
|
licenses:
|
|
32
31
|
- MIT
|
|
33
32
|
metadata: {}
|
|
34
|
-
post_install_message:
|
|
35
33
|
rdoc_options: []
|
|
36
34
|
require_paths:
|
|
37
35
|
- lib
|
|
@@ -46,8 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
46
44
|
- !ruby/object:Gem::Version
|
|
47
45
|
version: '0'
|
|
48
46
|
requirements: []
|
|
49
|
-
rubygems_version:
|
|
50
|
-
signing_key:
|
|
47
|
+
rubygems_version: 4.0.20
|
|
51
48
|
specification_version: 4
|
|
52
49
|
summary: APT dists merge provides a tool and a library to merge `dists/` contents
|
|
53
50
|
for APT repository.
|