dr 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/dr/buildroot.rb +54 -5
  2. data/lib/dr/version.rb +1 -1
  3. metadata +2 -2
@@ -10,9 +10,34 @@ module Dr
10
10
  def initialize(arch, br_archive=nil)
11
11
  @location = br_archive
12
12
 
13
- @extra_pkgs = "sudo,vim,ca-certificates,fakeroot,build-essential," +
13
+ @extra_pkgs = "sudo,vim,ca-certificates,fakeroot,build-essential,curl," +
14
14
  "devscripts,debhelper,git,bc,locales,equivs,pkg-config"
15
- @repo = "http://mirrordirector.raspbian.org/raspbian/"
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"
22
+ },
23
+
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
+ },
31
+
32
+ :kano => {
33
+ :url => "http://dev.kano.me/archive/",
34
+ :key => "http://dev.kano.me/archive/repo.gpg.key",
35
+ :src => false,
36
+ :codename => "release",
37
+ :components => "main"
38
+ }
39
+ }
40
+ @base_repo = :raspbian
16
41
 
17
42
  if br_archive == nil || !File.exists?(br_archive)
18
43
  setup arch
@@ -24,8 +49,15 @@ module Dr
24
49
  log :info, "Preparing the build root"
25
50
  ShellCmd.new "sudo tar xz -C #{tmp} -f #{@location}", :tag => "tar"
26
51
  begin
52
+ log :info, "Mounting the /proc file system"
53
+ mnt_cmd = "sudo chroot #{tmp} mount -t proc none /proc"
54
+ ShellCmd.new mnt_cmd, :tag => "mount"
27
55
  yield tmp
28
56
  ensure
57
+ log :info, "Unmounting the /proc file system"
58
+ umnt_cmd = "sudo chroot #{tmp} umount -f /proc"
59
+ ShellCmd.new umnt_cmd, :tag => "umount"
60
+
29
61
  log :info, "Cleaning up the buildroot"
30
62
  ShellCmd.new "sudo rm -rf #{tmp}/*", :tag => "rm"
31
63
  end
@@ -44,7 +76,8 @@ module Dr
44
76
  log :info, "Bootstrapping Raspian (first stage)"
45
77
 
46
78
  cmd = "sudo debootstrap --foreign --variant=buildd --no-check-gpg " +
47
- "--include=#{@extra_pkgs} --arch=#{arch} wheezy #{broot} #{@repo}"
79
+ "--include=#{@extra_pkgs} --arch=#{arch} wheezy #{broot} " +
80
+ "#{@repos[@base_repo][:url]}"
48
81
  debootsrap = ShellCmd.new cmd, {
49
82
  :tag => "debootstrap",
50
83
  :show_out => true
@@ -65,9 +98,25 @@ module Dr
65
98
  }
66
99
 
67
100
  log :info, "Configuring the build root"
101
+
102
+ repo_setup_sequences = @repos.map do |name, repo|
103
+ seq = "echo 'deb #{repo[:url]} #{repo[:codename]} " +
104
+ "#{repo[:components]}' >> /etc/apt/sources.list\n"
105
+
106
+ if repo.has_key?(:src) && repo[:src]
107
+ seq += "echo 'deb-src #{repo[:url]} #{repo[:codename]} " +
108
+ "#{repo[:components]}' >> /etc/apt/sources.list\n"
109
+ end
110
+
111
+ if repo.has_key?(:key) && repo[:key]
112
+ seq += "curl --retry 5 '#{repo[:key]}' | apt-key add -\n"
113
+ end
114
+
115
+ seq
116
+ end
117
+
68
118
  cmd = "sudo chroot #{broot} <<EOF
69
- echo 'deb #{@repo} wheezy main contrib non-free rpi' >> /etc/apt/sources.list
70
- echo 'deb-src #{@repo} wheezy main contrib non-free rpi' >> /etc/apt/sources.list
119
+ #{repo_setup_sequences.join "\n\n"}
71
120
 
72
121
  echo 'en_US.UTF-8 UTF-8' >/etc/locale.gen
73
122
  locale-gen en_US.UTF-8
@@ -1,3 +1,3 @@
1
1
  module Dr
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-12 00:00:00.000000000 Z
12
+ date: 2014-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor