dr 0.1.14 → 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 +4 -4
- data/bin/dr +83 -26
- data/lib/dr.rb +13 -1
- data/lib/dr/buildroot.rb +7 -42
- data/lib/dr/config.rb +16 -0
- data/lib/dr/gitpackage.rb +56 -6
- data/lib/dr/repo.rb +7 -4
- data/lib/dr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242402de0362275310fd746e3c9ba832a963fd0d
|
4
|
+
data.tar.gz: 5a0a15e68b0863c37c19dc556d9a3aff43a61989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 540afeb391762426284f47ff8defc361b1d7aad061c39af8ebe7ca494175d3b5357c9eb3af6141179d325f9250619c0a7460879a7a178b29daacc55f0dfdbf43
|
7
|
+
data.tar.gz: cabec28d4f33d8a1a0ee1cc5d6a9a59b27b004c86c96bf2d135b51514cb8fd70367e8c0351a6915159fbbf31fe714a208af4860f787a4635b8e0ce5b8c478e18
|
data/bin/dr
CHANGED
@@ -7,6 +7,7 @@ require "thor"
|
|
7
7
|
require "fileutils"
|
8
8
|
require "io/console"
|
9
9
|
|
10
|
+
require "dr"
|
10
11
|
require "dr/repo"
|
11
12
|
require "dr/gitpackage"
|
12
13
|
require "dr/debpackage"
|
@@ -21,15 +22,11 @@ class ExtendedThor < Thor
|
|
21
22
|
include Dr::Logger
|
22
23
|
|
23
24
|
def get_repo_handle
|
24
|
-
unless @conf
|
25
|
-
@conf = Dr::Config.new ["/etc/dr.conf", "~/.dr.conf"]
|
26
|
-
end
|
27
|
-
|
28
25
|
if options.has_key? "repo"
|
29
26
|
Dr::Repo.new options["repo"]
|
30
27
|
else
|
31
|
-
if
|
32
|
-
Dr::Repo.new
|
28
|
+
if Dr.config.default_repo != nil
|
29
|
+
Dr::Repo.new Dr.config.repositories[Dr.config.default_repo][:location]
|
33
30
|
else
|
34
31
|
log :warn, "No repo was specified, using '#{Dir.pwd}'."
|
35
32
|
Dr::Repo.new Dir.pwd
|
@@ -166,7 +163,7 @@ class RepoCLI < ExtendedThor
|
|
166
163
|
:arches => ["amd64"],
|
167
164
|
:components => ["main"],
|
168
165
|
:suites => ["stable", "testing", "unstable"],
|
169
|
-
:
|
166
|
+
:distro => "Kano OS",
|
170
167
|
:codenames => []
|
171
168
|
}
|
172
169
|
|
@@ -176,27 +173,46 @@ class RepoCLI < ExtendedThor
|
|
176
173
|
desc = ask " Description [#{repo_conf[:desc]}]:"
|
177
174
|
repo_conf[:desc] = desc if desc.length > 0
|
178
175
|
|
179
|
-
|
180
|
-
puts "
|
181
|
-
Dr::
|
182
|
-
|
183
|
-
|
176
|
+
distro_map = {}
|
177
|
+
puts " Distribution [pick one]: "
|
178
|
+
Dr::config.distros.each_with_index do |distro, index|
|
179
|
+
distro_name, distro_params = distro
|
180
|
+
distro_map[index+1] = distro_name
|
184
181
|
|
185
|
-
|
186
|
-
puts " [#{index+1}] #{
|
182
|
+
distro_name = distro_name.fg "yellow" if distro_name == repo_conf[:distro]
|
183
|
+
puts " [#{index+1}] #{distro_name}"
|
187
184
|
end
|
188
185
|
|
189
|
-
|
190
|
-
until
|
191
|
-
|
186
|
+
distro = ask " Your choice: "
|
187
|
+
until distro.length == 0 || distro_map.has_key?(distro.to_i)
|
188
|
+
distro = ask " Your choice: "
|
192
189
|
end
|
193
|
-
repo_conf[:
|
190
|
+
repo_conf[:distro] = distro_map[distro.to_i] if distro.length > 0
|
194
191
|
|
192
|
+
require 'pp'
|
195
193
|
# guess default arch
|
196
|
-
|
194
|
+
pp Dr::config.distros
|
195
|
+
pp Dr::config.distros[repo_conf[:distro]]
|
196
|
+
repo_conf[:arches] = [Dr::config.distros[repo_conf[:distro]][:arches][0]]
|
197
|
+
|
198
|
+
while true
|
199
|
+
str = ask " Architectures [#{repo_conf[:arches].join(" ").fg("yellow")}]:"
|
200
|
+
break if str.length == 0
|
201
|
+
|
202
|
+
arches = str.split(/\s+/)
|
203
|
+
arches_valid = arches.reduce(true) do |acc, arch|
|
204
|
+
supported = Dr::config.distros[repo_conf[:distro]][:arches].include?(arch)
|
205
|
+
if !supported
|
206
|
+
puts " " + "#{arch.fg "yellow"}" + " not supported by the distro"
|
207
|
+
end
|
197
208
|
|
198
|
-
|
199
|
-
|
209
|
+
supported
|
210
|
+
end
|
211
|
+
next if !arches_valid
|
212
|
+
|
213
|
+
repo_conf[:arches] = arches
|
214
|
+
break
|
215
|
+
end
|
200
216
|
|
201
217
|
components = ask " Components [#{repo_conf[:components].join(" ").fg("yellow")}]:"
|
202
218
|
repo_conf[:components] = components.split /\s+/ if components.length > 0
|
@@ -360,6 +376,40 @@ class RepoCLI < ExtendedThor
|
|
360
376
|
log :info, "Updated #{updated.to_s.fg "blue"} packages in #{suite.fg "blue"}"
|
361
377
|
end
|
362
378
|
|
379
|
+
desc "git-tag-release", "Mark relased packages' repositories"
|
380
|
+
method_option :force, :aliases => "-f", :type => :boolean,
|
381
|
+
:desc => "Force override existing tags"
|
382
|
+
method_option :package, :aliases => "-p", :type => :string,
|
383
|
+
:desc => "Only tag a single package"
|
384
|
+
method_option :summary, :aliases => "-s", :type => :string,
|
385
|
+
:desc => "A summary for the release (Github only)"
|
386
|
+
method_option :title, :aliases => "-t", :type => :string,
|
387
|
+
:desc => "A title for the release (Github only)"
|
388
|
+
def git_tag_release(tag)
|
389
|
+
repo = get_repo_handle
|
390
|
+
|
391
|
+
packages = if options["package"] == nil
|
392
|
+
repo.list_packages "stable"
|
393
|
+
else
|
394
|
+
if repo.get_subpackage_versions(options["package"])["stable"].empty?
|
395
|
+
log :warn, "This package isn't in the #{"stable".fg "green"} branch, skipping."
|
396
|
+
end
|
397
|
+
|
398
|
+
[repo.get_package(options["package"])]
|
399
|
+
end
|
400
|
+
|
401
|
+
packages.each do |pkg|
|
402
|
+
if pkg.is_a? Dr::GitPackage
|
403
|
+
version = repo.get_subpackage_versions(pkg.name)["stable"].values.max
|
404
|
+
bm = repo.get_build_metadata pkg.name, version
|
405
|
+
|
406
|
+
pkg.tag_release tag, bm["revision"], options
|
407
|
+
else
|
408
|
+
log :info, "#{pkg.name.style "pkg-name"} is not associated with a git repo, skipping"
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
363
413
|
desc "release", "Push all the packages from testing to release"
|
364
414
|
method_option :force, :aliases => "-f", :type => :boolean,
|
365
415
|
:desc => "Force-push all released packages"
|
@@ -368,8 +418,9 @@ class RepoCLI < ExtendedThor
|
|
368
418
|
|
369
419
|
log :info, "Releasing all packages from testing"
|
370
420
|
repo.list_packages("testing").each do |pkg|
|
421
|
+
v = repo.get_subpackage_versions(pkg.name)["testing"].values
|
371
422
|
begin
|
372
|
-
repo.push pkg.name,
|
423
|
+
repo.push pkg.name, v.max, "stable", (options["force"] == true)
|
373
424
|
rescue Dr::AlreadyExists
|
374
425
|
;
|
375
426
|
end
|
@@ -407,8 +458,14 @@ class RepoCLI < ExtendedThor
|
|
407
458
|
end
|
408
459
|
end
|
409
460
|
|
410
|
-
begin
|
411
|
-
|
412
|
-
|
461
|
+
#begin
|
462
|
+
Dr::check_dependencies [
|
463
|
+
"git", "reprepro", "gzip", "debuild", "debootstrap", "qemu-*-static",
|
464
|
+
"chroot", "curl", "gpg", "tar", "dpkg", "dpkg-deb", "dpkg-sig", "rm",
|
465
|
+
"sudo"
|
466
|
+
]
|
467
|
+
|
468
|
+
RepoCLI.start ARGV
|
469
|
+
#rescue StandardError => e
|
413
470
|
Dr::Logger.log :err, e.to_s
|
414
|
-
end
|
471
|
+
#end
|
data/lib/dr.rb
CHANGED
@@ -3,7 +3,19 @@
|
|
3
3
|
|
4
4
|
require "dr/version"
|
5
5
|
require "dr/repo"
|
6
|
+
require "dr/logger"
|
6
7
|
|
7
8
|
module Dr
|
8
|
-
|
9
|
+
def self.check_dependencies(deps=[])
|
10
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path_dir|
|
11
|
+
deps.delete_if do |dep_name|
|
12
|
+
Dir[File.join(path_dir, dep_name)].length > 0
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if deps.length > 0
|
17
|
+
Logger.log :warn, "Missing some dependencies:"
|
18
|
+
deps.each { |dep| Logger.log :warn, " #{dep.fg "red"}" }
|
19
|
+
end
|
20
|
+
end
|
9
21
|
end
|
data/lib/dr/buildroot.rb
CHANGED
@@ -5,47 +5,12 @@ require "tco"
|
|
5
5
|
|
6
6
|
require "dr/logger"
|
7
7
|
require "dr/shellcmd"
|
8
|
+
require "dr/config"
|
8
9
|
|
9
10
|
module Dr
|
10
11
|
class BuildRoot
|
11
12
|
include Logger
|
12
13
|
|
13
|
-
@@os_bases = {
|
14
|
-
"Kano OS" => {
|
15
|
-
:arches => ["armhf", "armel"],
|
16
|
-
:repos => {
|
17
|
-
:raspbian => {
|
18
|
-
:url => "http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/",
|
19
|
-
:key => "http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian.public.key",
|
20
|
-
:src => true,
|
21
|
-
:codename => "wheezy",
|
22
|
-
:components => "main contrib non-free rpi"
|
23
|
-
},
|
24
|
-
|
25
|
-
:raspi_foundation => {
|
26
|
-
:url => "http://archive.raspberrypi.org/debian/",
|
27
|
-
:key => "http://archive.raspberrypi.org/debian/raspberrypi.gpg.key",
|
28
|
-
:src => false,
|
29
|
-
:codename => "wheezy",
|
30
|
-
:components => "main"
|
31
|
-
},
|
32
|
-
|
33
|
-
:kano => {
|
34
|
-
:url => "http://dev.kano.me/archive/",
|
35
|
-
:key => "http://dev.kano.me/archive/repo.gpg.key",
|
36
|
-
:src => false,
|
37
|
-
:codename => "devel",
|
38
|
-
:components => "main"
|
39
|
-
}
|
40
|
-
},
|
41
|
-
:base => :raspbian,
|
42
|
-
:packages => []
|
43
|
-
}
|
44
|
-
}
|
45
|
-
def self.os_bases
|
46
|
-
@@os_bases
|
47
|
-
end
|
48
|
-
|
49
14
|
def initialize(base, arch, br_cache)
|
50
15
|
@location = "#{br_cache}/#{base.strip.downcase.gsub(" ", "_")}-#{arch}.tar.gz"
|
51
16
|
@base = base
|
@@ -82,17 +47,17 @@ module Dr
|
|
82
47
|
|
83
48
|
private
|
84
49
|
def setup(base, arch)
|
85
|
-
unless
|
86
|
-
raise "OS base #{base.fg "blue"} isn't supported by dr."
|
50
|
+
unless Dr.config.distros.include? base
|
51
|
+
raise "Sorry, OS base #{base.fg "blue"} isn't supported by dr."
|
87
52
|
end
|
88
53
|
|
89
|
-
unless
|
54
|
+
unless Dr.config.distros[base][:arches].include? arch
|
90
55
|
raise "Arch #{arch.fg "blue"} not supported by this base."
|
91
56
|
end
|
92
57
|
|
93
|
-
repos =
|
94
|
-
base_repo =
|
95
|
-
additional_pkgs =
|
58
|
+
repos = Dr.config.distros[base][:repos]
|
59
|
+
base_repo = Dr.config.distros[base][:base_repo].to_sym
|
60
|
+
additional_pkgs = Dr.config.distros[base][:packages].join ","
|
96
61
|
|
97
62
|
Dir.mktmpdir do |tmp|
|
98
63
|
broot = "#{tmp}/broot"
|
data/lib/dr/config.rb
CHANGED
@@ -3,10 +3,14 @@
|
|
3
3
|
|
4
4
|
require "yaml"
|
5
5
|
|
6
|
+
require "dr/distros"
|
7
|
+
|
6
8
|
module Dr
|
7
9
|
class Config
|
8
10
|
attr_reader :default_repo, :repositories
|
9
11
|
|
12
|
+
include Distros
|
13
|
+
|
10
14
|
def initialize(locations)
|
11
15
|
@default_repo = nil
|
12
16
|
@repositories = {}
|
@@ -42,6 +46,18 @@ module Dr
|
|
42
46
|
raise "Default repo #{@default_repo} doesn't exist"
|
43
47
|
end
|
44
48
|
end
|
49
|
+
|
50
|
+
if conf_file.has_key? "distros"
|
51
|
+
conf_file["distros"].each do |name, distro|
|
52
|
+
distro_sym_keys = distro.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
53
|
+
add_distro(name, distro_sym_keys)
|
54
|
+
end
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
58
|
+
|
59
|
+
@config = Config.new ["/etc/dr.conf", "~/.dr.conf"]
|
60
|
+
def self.config
|
61
|
+
@config
|
62
|
+
end
|
47
63
|
end
|
data/lib/dr/gitpackage.rb
CHANGED
@@ -6,6 +6,7 @@ require "dr/pkgversion"
|
|
6
6
|
require "dr/shellcmd"
|
7
7
|
|
8
8
|
require "yaml"
|
9
|
+
require "octokit"
|
9
10
|
|
10
11
|
module Dr
|
11
12
|
class GitPackage < Package
|
@@ -250,6 +251,55 @@ EOS
|
|
250
251
|
version
|
251
252
|
end
|
252
253
|
|
254
|
+
def tag_release(tag_name, revision, options={})
|
255
|
+
url = get_repo_url
|
256
|
+
|
257
|
+
log :info, "Tagging #{@name.style "pkg-name"} package for " +
|
258
|
+
"#{tag_name.fg "yellow"} release"
|
259
|
+
|
260
|
+
gh_repo = case url
|
261
|
+
when /git\@github.com\:/i then url.split(":")[1].gsub(/\.git$/, "").strip
|
262
|
+
when /github.com\//i then url.split("/")[-2..-1].join("/").gsub(/\.git$/, "").strip
|
263
|
+
else nil
|
264
|
+
end
|
265
|
+
|
266
|
+
if gh_repo == nil
|
267
|
+
git_cmd = "git --git-dir #{@git_dir} tag #{tag}"
|
268
|
+
git = ShellCmd.new git_cmd,
|
269
|
+
:tag => "git",
|
270
|
+
:show_out => false,
|
271
|
+
:raise_on_error => false
|
272
|
+
|
273
|
+
if git.status == 128
|
274
|
+
log :warn, "Tag #{tag_name.fg "yellow"} already exists."
|
275
|
+
return
|
276
|
+
end
|
277
|
+
|
278
|
+
git_cmd = "git --git-dir #{@git_dir} push origin --tags"
|
279
|
+
git = ShellCmd.new git_cmd, :show_out => false
|
280
|
+
|
281
|
+
return
|
282
|
+
end
|
283
|
+
|
284
|
+
title = options["title"] || "Kano OS #{tag_name}"
|
285
|
+
summary = options["summary"] || "https://github.com/KanoComputing/peldins/wiki/Changelog-#{tag_name}"
|
286
|
+
|
287
|
+
token = ENV["GITHUB_API_TOKEN"]
|
288
|
+
client = Octokit::Client.new :access_token => token
|
289
|
+
|
290
|
+
releases = client.releases gh_repo
|
291
|
+
ri = releases.index { |r| r[:tag_name] == tag_name }
|
292
|
+
|
293
|
+
if ri == nil
|
294
|
+
client.create_release gh_repo, tag_name,
|
295
|
+
:target_commitish => revision,
|
296
|
+
:name => title,
|
297
|
+
:body => summary
|
298
|
+
else
|
299
|
+
log :warn, "The #{tag_name.fg "yellow"} release exists already for #{@name.style "pkg-name"}."
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
253
303
|
private
|
254
304
|
def update_from_origin(branch)
|
255
305
|
log :info, "Pulling changes from origin"
|
@@ -269,6 +319,12 @@ EOS
|
|
269
319
|
[original_rev, current_rev]
|
270
320
|
end
|
271
321
|
|
322
|
+
def get_repo_url
|
323
|
+
git_cmd = "git --git-dir #{@git_dir} config --get remote.origin.url"
|
324
|
+
git = ShellCmd.new git_cmd, :tag => "git"
|
325
|
+
git.out
|
326
|
+
end
|
327
|
+
|
272
328
|
def get_version(changelog_file)
|
273
329
|
File.open changelog_file, "r" do |f|
|
274
330
|
f.each_line do |l|
|
@@ -305,12 +361,6 @@ EOS
|
|
305
361
|
arches.uniq
|
306
362
|
end
|
307
363
|
|
308
|
-
def get_repo_url
|
309
|
-
git_cmd = "git --git-dir #{@git_dir} --bare remote show origin -n"
|
310
|
-
git = ShellCmd.new git_cmd, :tag => "git"
|
311
|
-
git.out.lines.grep(/Fetch URL/)[0].chomp[13..-1]
|
312
|
-
end
|
313
|
-
|
314
364
|
def get_current_branch
|
315
365
|
git_cmd = ShellCmd.new "git --git-dir #{@git_dir} --bare branch", {
|
316
366
|
:tag => "git"
|
data/lib/dr/repo.rb
CHANGED
@@ -26,12 +26,15 @@ module Dr
|
|
26
26
|
@packages_dir = "#{@location}/packages"
|
27
27
|
|
28
28
|
meta = "#{@location}/metadata"
|
29
|
-
|
29
|
+
begin
|
30
|
+
@metadata = YAML.load_file(meta)
|
31
|
+
rescue
|
32
|
+
@metadata = {}
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
def setup(conf)
|
33
37
|
log :info, "Creating the archive directory"
|
34
|
-
|
35
38
|
begin
|
36
39
|
FileUtils.mkdir_p location
|
37
40
|
rescue Exception => e
|
@@ -75,7 +78,7 @@ module Dr
|
|
75
78
|
FileUtils.mkdir_p @packages_dir
|
76
79
|
FileUtils.mkdir_p "#{@location}/buildroots"
|
77
80
|
|
78
|
-
@metadata = {"
|
81
|
+
@metadata = {"distro" => conf[:distro]}
|
79
82
|
File.open("#{@location}/metadata", "w" ) do |out|
|
80
83
|
YAML.dump(@metadata)
|
81
84
|
end
|
@@ -108,7 +111,7 @@ module Dr
|
|
108
111
|
|
109
112
|
def buildroot(arch)
|
110
113
|
cache_dir = "#{@location}/buildroots/"
|
111
|
-
BuildRoot.new @metadata["
|
114
|
+
BuildRoot.new @metadata["distro"], arch, cache_dir
|
112
115
|
end
|
113
116
|
|
114
117
|
def get_package(name)
|
data/lib/dr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radek Pazdera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|