dr 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f081cd07df3b86b2a8818d16a0c2b76c3205514d
4
+ data.tar.gz: e873f13774d8f4bccf3d6b9ccec059150bfdd7ef
5
+ SHA512:
6
+ metadata.gz: af79fd771e8a4ab7693ff38c5dfd78b490c57bf19eb9fd461d6a65c6e3fdcadfc86050055e45e32ca2f07dcbf275e4f1175b1ad81aec0e02a48e41984a6bab49
7
+ data.tar.gz: 34932b9939ca7c0a433af6df9e6b83d1c009bbe74128bc5eebf7f43ca20ae453f0cf42649438fd0dea0490eae63d734db372c1134b60823a454a287abd8554b0
data/README.md CHANGED
@@ -1,29 +1,28 @@
1
- # Debian Repository Management Tool
1
+ # Kano Repository Manager
2
2
 
3
- TODO: Write a gem description
3
+ [![Gem Version](https://badge.fury.io/rb/dr.svg)](http://badge.fury.io/rb/dr)
4
4
 
5
- ## Installation
5
+ **dr** (stands for debian repository) is a Debian repository management tool.
6
+ It will help you set up and maintain your own small package repository for any
7
+ Debian-based distribution. You can keep your sources in **git** and use the
8
+ **dr** tool to manage builds, versions, and releases. It works particularly
9
+ well in case your development is very fast and you ship new versions of
10
+ your packages often (even several times a day).
6
11
 
7
- Add this line to your application's Gemfile:
12
+ The following diagram illustrates how `dr` works. It takes source packages
13
+ that are managed in git repositories, builds them and serves them in
14
+ different suites. For more information, please see this
15
+ [project's wiki](https://github.com/KanoComputing/kano-package-system/wiki).
8
16
 
9
- gem 'mkpkg'
17
+ <p align="center">
18
+ <img src="http://i.imgur.com/pe8A9kd.png"
19
+ alt="How dr operates">
20
+ </p>
10
21
 
11
- And then execute:
22
+ It is the tool we use to manage our software repository and the custom
23
+ packages for **Kano OS**. The application is written in **Ruby**, building
24
+ on top of many other tools (such as reprepro, debuild, debhelper, and others).
12
25
 
13
- $ bundle
26
+ Here is like it looks like in the terminal:
14
27
 
15
- Or install it yourself as:
16
-
17
- $ gem install mkpkg
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it ( http://github.com/<my-github-username>/mkpkg/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
28
+ ![Example of using dr](http://linuxwell.com/assets/images/posts/tco-example.png)
data/bin/dr CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # Copyright (C) 2014 Kano Computing Ltd.
4
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
5
+
3
6
  require "thor"
4
7
  require "fileutils"
5
8
  require "io/console"
@@ -7,6 +10,7 @@ require "io/console"
7
10
  require "dr/repo"
8
11
  require "dr/gitpackage"
9
12
  require "dr/debpackage"
13
+ require "dr/buildroot"
10
14
 
11
15
  require "dr/shellcmd"
12
16
  require "dr/logger"
@@ -162,6 +166,7 @@ class RepoCLI < ExtendedThor
162
166
  :arches => ["amd64"],
163
167
  :components => ["main"],
164
168
  :suites => ["stable", "testing", "unstable"],
169
+ :base => "Kano OS",
165
170
  :codenames => []
166
171
  }
167
172
 
@@ -171,6 +176,25 @@ class RepoCLI < ExtendedThor
171
176
  desc = ask " Description [#{repo_conf[:desc]}]:"
172
177
  repo_conf[:desc] = desc if desc.length > 0
173
178
 
179
+ base_map = {}
180
+ puts " Base OS [pick one]: "
181
+ Dr::BuildRoot.os_bases.each_with_index do |base, index|
182
+ base_name, base_params = base
183
+ base_map[index+1] = base_name
184
+
185
+ base_name = base_name.fg "yellow" if base_name == repo_conf[:base]
186
+ puts " [#{index+1}] #{base_name}"
187
+ end
188
+
189
+ base = ask " Your choice: "
190
+ until base.length == 0 || base_map.has_key?(base.to_i)
191
+ base = ask " Your choice: "
192
+ end
193
+ repo_conf[:base] = base_map[base.to_i] if base.length > 0
194
+
195
+ # guess default arch
196
+ repo_conf[:arches] = [Dr::BuildRoot.os_bases[repo_conf[:base]][:arches][0]]
197
+
174
198
  arches = ask " Architectures [#{repo_conf[:arches].join(" ").fg("yellow")}]:"
175
199
  repo_conf[:arches] = arches.split(/\s+/) if arches.length > 0
176
200
 
@@ -343,8 +367,19 @@ class RepoCLI < ExtendedThor
343
367
  repo = get_repo_handle
344
368
 
345
369
  log :info, "Releasing all packages from testing"
346
- repo.list_packages.each do |pkg|
347
- repo.push pkg.name, nil, "stable", (options["force"] == true)
370
+ repo.list_packages("testing").each do |pkg|
371
+ begin
372
+ repo.push pkg.name, nil, "stable", (options["force"] == true)
373
+ rescue Dr::AlreadyExists
374
+ ;
375
+ end
376
+ end
377
+
378
+ log :info, "Removing packages that are not in testing any more"
379
+ repo.list_packages("release").each do |pkg|
380
+ if ! repo.suite_has_package? "testing", pkg.name
381
+ repo.unpush pkg.name, "release"
382
+ end
348
383
  end
349
384
  end
350
385
 
@@ -374,6 +409,6 @@ end
374
409
 
375
410
  begin
376
411
  RepoCLI.start ARGV
377
- rescue Exception => e
412
+ rescue StandardError => e
378
413
  Dr::Logger.log :err, e.to_s
379
414
  end
data/lib/dr.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "dr/version"
2
5
  require "dr/repo"
3
6
 
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "tco"
2
5
 
3
6
  require "dr/logger"
@@ -7,46 +10,59 @@ module Dr
7
10
  class BuildRoot
8
11
  include Logger
9
12
 
10
- def initialize(arch, br_archive=nil)
11
- @location = br_archive
12
-
13
- @extra_pkgs = "sudo,vim,ca-certificates,fakeroot,build-essential,curl," +
14
- "devscripts,debhelper,git,bc,locales,equivs,pkg-config"
15
- @repos = {
16
- :raspbian => {
17
- :url => "http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/",
18
- :key => "http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian.public.key",
19
- :src => true,
20
- :codename => "wheezy",
21
- :components => "main contrib non-free rpi"
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
+ }
22
40
  },
41
+ :base => :raspbian,
42
+ :packages => []
43
+ }
44
+ }
45
+ def self.os_bases
46
+ @@os_bases
47
+ end
23
48
 
24
- :raspi_foundation => {
25
- :url => "http://archive.raspberrypi.org/debian/",
26
- :key => "http://archive.raspberrypi.org/debian/raspberrypi.gpg.key",
27
- :src => false,
28
- :codename => "wheezy",
29
- :components => "main"
30
- },
49
+ def initialize(base, arch, br_cache)
50
+ @location = "#{br_cache}/#{base.strip.downcase.gsub(" ", "_")}-#{arch}.tar.gz"
51
+ @base = base
52
+ @arch = arch
31
53
 
32
- :kano => {
33
- :url => "http://dev.kano.me/archive/",
34
- :key => "http://dev.kano.me/archive/repo.gpg.key",
35
- :src => false,
36
- :codename => "devel",
37
- :components => "main"
38
- }
39
- }
40
- @base_repo = :raspbian
54
+ @essential_pkgs = "sudo,vim,ca-certificates,fakeroot,build-essential," +
55
+ "curl,devscripts,debhelper,git,bc,locales,equivs," +
56
+ "pkg-config,libfile-fcntllock-perl"
41
57
 
42
- if br_archive == nil || !File.exists?(br_archive)
43
- setup arch
58
+ if !File.exists?(@location)
59
+ setup base, arch
44
60
  end
45
61
  end
46
62
 
47
63
  def open
48
64
  Dir.mktmpdir do |tmp|
49
- log :info, "Preparing the build root"
65
+ log :info, "Preparing #{@base.fg "blue"} #{@arch.fg "orange"} build root"
50
66
  ShellCmd.new "sudo tar xz -C #{tmp} -f #{@location}", :tag => "tar"
51
67
  begin
52
68
  log :info, "Mounting the /proc file system"
@@ -65,7 +81,19 @@ module Dr
65
81
  end
66
82
 
67
83
  private
68
- def setup(arch)
84
+ def setup(base, arch)
85
+ unless @@os_bases.include? base
86
+ raise "OS base #{base.fg "blue"} isn't supported by dr."
87
+ end
88
+
89
+ unless @@os_bases[base][:arches].include? arch
90
+ raise "Arch #{arch.fg "blue"} not supported by this base."
91
+ end
92
+
93
+ repos = @@os_bases[base][:repos]
94
+ base_repo = @@os_bases[base][:base].to_sym
95
+ additional_pkgs = @@os_bases[base][:packages].join ","
96
+
69
97
  Dir.mktmpdir do |tmp|
70
98
  broot = "#{tmp}/broot"
71
99
  FileUtils.mkdir_p "#{tmp}/broot"
@@ -73,11 +101,11 @@ module Dr
73
101
  log :info, "Setting up the buildroot"
74
102
 
75
103
  begin
76
- log :info, "Bootstrapping Raspian (first stage)"
104
+ log :info, "Bootstrapping #{base} (first stage)"
77
105
 
78
106
  cmd = "sudo debootstrap --foreign --variant=buildd --no-check-gpg " +
79
- "--include=#{@extra_pkgs} --arch=#{arch} wheezy #{broot} " +
80
- "#{@repos[@base_repo][:url]}"
107
+ "--include=#{@essential_pkgs},#{additional_pkgs} " +
108
+ "--arch=#{arch} wheezy #{broot} #{repos[base_repo][:url]}"
81
109
  debootsrap = ShellCmd.new cmd, {
82
110
  :tag => "debootstrap",
83
111
  :show_out => true
@@ -99,7 +127,7 @@ module Dr
99
127
 
100
128
  log :info, "Configuring the build root"
101
129
 
102
- repo_setup_sequences = @repos.map do |name, repo|
130
+ repo_setup_sequences = repos.map do |name, repo|
103
131
  seq = "echo 'deb #{repo[:url]} #{repo[:codename]} " +
104
132
  "#{repo[:components]}' >> /etc/apt/sources.list\n"
105
133
 
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "yaml"
2
5
 
3
6
  module Dr
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "dr/package"
2
5
 
3
6
  module Dr
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "dr/package"
2
5
  require "dr/pkgversion"
3
6
  require "dr/shellcmd"
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "dr/shellcmd"
2
5
  require "dr/logger"
3
6
 
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "tco"
2
5
 
3
6
  tco_conf = Tco::config
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "dr/logger"
2
5
  require "dr/shellcmd"
3
6
 
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  module Dr
2
5
  class PkgVersion
3
6
  attr_accessor :upstream, :debian, :date, :build
@@ -63,7 +66,13 @@ module Dr
63
66
  v << ".#{today}"
64
67
  end
65
68
 
66
- v << "build#{@build}" if @build > 0
69
+ if @build > 0
70
+ if @build < 10
71
+ v << "build0#{@build}"
72
+ else
73
+ v << "build#{@build}"
74
+ end
75
+ end
67
76
 
68
77
  v
69
78
  end
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "dr/gitpackage"
2
5
  require "dr/debpackage"
3
6
 
@@ -10,6 +13,8 @@ require "fileutils"
10
13
  require "yaml"
11
14
 
12
15
  module Dr
16
+ class AlreadyExists < StandardError; end
17
+
13
18
  class Repo
14
19
  include Logger
15
20
 
@@ -19,6 +24,9 @@ module Dr
19
24
  @location = File.expand_path loc
20
25
 
21
26
  @packages_dir = "#{@location}/packages"
27
+
28
+ meta = "#{@location}/metadata"
29
+ @metadata = File.exists?(meta) ? YAML.load_file(meta) : {}
22
30
  end
23
31
 
24
32
  def setup(conf)
@@ -65,9 +73,15 @@ module Dr
65
73
  end
66
74
 
67
75
  FileUtils.mkdir_p @packages_dir
76
+ FileUtils.mkdir_p "#{@location}/buildroots"
77
+
78
+ @metadata = {"base-os" => conf[:base]}
79
+ File.open("#{@location}/metadata", "w" ) do |out|
80
+ YAML.dump(@metadata)
81
+ end
68
82
 
69
83
  conf[:arches].each do |arch|
70
- BuildRoot.new arch, "#{@location}/build-root-#{arch}.tar.gz"
84
+ buildroot arch
71
85
  end
72
86
  end
73
87
 
@@ -93,7 +107,8 @@ module Dr
93
107
  end
94
108
 
95
109
  def buildroot(arch)
96
- BuildRoot.new arch, "#{@location}/build-root-#{arch}.tar.gz"
110
+ cache_dir = "#{@location}/buildroots/"
111
+ BuildRoot.new @metadata["base-os"], arch, cache_dir
97
112
  end
98
113
 
99
114
  def get_package(name)
@@ -150,6 +165,12 @@ module Dr
150
165
  v
151
166
  end
152
167
 
168
+ def suite_has_package?(suite, pkg_name)
169
+ pkg_versions = get_subpackage_versions(pkg_name)[codename_to_suite(suite)]
170
+
171
+ pkg_versions.length > 0
172
+ end
173
+
153
174
  def suite_has_higher_pkg_version?(suite, pkg, version)
154
175
  used_versions = get_subpackage_versions(pkg.name)[codename_to_suite(suite)]
155
176
 
@@ -228,10 +249,12 @@ module Dr
228
249
  reprepro = "reprepro -b #{@location}/archive " +
229
250
  "--gnupghome #{location}/gnupg-keyring/ removesrc " +
230
251
  "#{suite} #{pkg.name}"
231
- ShellCmd.new reprepro, :tag => "reprepro", :show_out => true
252
+ ShellCmd.new reprepro, :tag => "reprepro", :show_out => false
232
253
  else
233
- log :err, "The same package of a higher version is already in the repo."
234
- raise "Push failed"
254
+ log :warn, "The same package of a higher version is already in the " +
255
+ "#{suite} suite."
256
+
257
+ raise AlreadyExists.new "Push failed"
235
258
  end
236
259
  end
237
260
 
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  require "open3"
2
5
  require "tco"
3
6
 
@@ -1,3 +1,6 @@
1
+ # Copyright (C) 2014 Kano Computing Ltd.
2
+ # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
3
+
1
4
  module Dr
2
- VERSION = "0.1.13"
5
+ VERSION = "0.1.14"
3
6
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
5
- prerelease:
4
+ version: 0.1.14
6
5
  platform: ruby
7
6
  authors:
8
7
  - Radek Pazdera
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: tco
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,39 +55,37 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
- description: ! "dr works with distribution-level packaging\n tools
95
- and helps you make and distribute your own\n Debian packages
96
- through your own repository.\n This is a super early release,
97
- certainly NOT ready\n for production."
83
+ description: |-
84
+ dr works with distribution-level packaging
85
+ tools and helps you make and distribute your own
86
+ Debian packages through your own repository.
87
+ This is a super early release, certainly NOT ready
88
+ for production.
98
89
  email:
99
90
  - radek@kano.me
100
91
  executables:
@@ -125,27 +116,26 @@ files:
125
116
  homepage: http://github.com/KanoComputing/kano-package-system
126
117
  licenses:
127
118
  - GPLv2
119
+ metadata: {}
128
120
  post_install_message:
129
121
  rdoc_options: []
130
122
  require_paths:
131
123
  - lib
132
124
  required_ruby_version: !ruby/object:Gem::Requirement
133
- none: false
134
125
  requirements:
135
- - - ! '>='
126
+ - - '>='
136
127
  - !ruby/object:Gem::Version
137
128
  version: '0'
138
129
  required_rubygems_version: !ruby/object:Gem::Requirement
139
- none: false
140
130
  requirements:
141
- - - ! '>='
131
+ - - '>='
142
132
  - !ruby/object:Gem::Version
143
133
  version: '0'
144
134
  requirements: []
145
135
  rubyforge_project:
146
- rubygems_version: 1.8.23
136
+ rubygems_version: 2.0.14
147
137
  signing_key:
148
- specification_version: 3
138
+ specification_version: 4
149
139
  summary: dr stands for debian-repository. It is a packaging tool that helps you make,
150
140
  distribute and maintain you own disto packages and repositories. It's in a very
151
141
  early stage, NOT READY for production.