cangallo 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f28a4e56d37526b9211c6c841b8557d2dad1577
4
- data.tar.gz: a1ed9b9e4f6bc3bb415b60dd0581dbc0774e29fe
3
+ metadata.gz: f7ebf3b1d9dbe3d482de15aab76fc565dac5e081
4
+ data.tar.gz: 70cf9236aab61ce22ebe46e12b9929344d008d3a
5
5
  SHA512:
6
- metadata.gz: 19682de08a165a693215ce92a4df771aecd778cfcb84caddbdc35a285ac5c951d9cea29eef68e630e21be13d61c3bb27db33af184494687eb222cb2710b27e08
7
- data.tar.gz: 845149b932fb7dee71080ea2c3232959ab539b728f869ac2a58209d747d55defbaddde76b0fb2f8e985d1dcfcd57f100b86fe25b5ccc7abdc9af80b70d58fd9f
6
+ metadata.gz: f242b310221dd1631fa24c5d62f142034629db318d20c7e016bd0729ccd94c51f38ea22e2ed10961d46a524df04dd5a945ccaee07a1e2a4c7d7251326e764ea8
7
+ data.tar.gz: f25a3baeab6f19f4921e1647479ed619aec8ee6d0a5c9ea1363e025d50d90c95073b14aec3514093a387baf5ff28ac5ab02df37497ed7a212eae56d8c1ef0c6e
@@ -0,0 +1,148 @@
1
+
2
+ # vim:tabstop=2:sw=2:et:
3
+
4
+ # Copyright 2016, Javier Fontán Muiños <jfontan@gmail.com>
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+ # not use this file except in compliance with the License. You may obtain
8
+ # a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require 'rubygems'
19
+
20
+ class Cangallo
21
+ class Check
22
+ def initialize
23
+ end
24
+
25
+ def check
26
+ problem = false
27
+
28
+ problem ||= !check_kernel
29
+ problem ||= !check_qemu_img
30
+ problem ||= !check_libguestfs
31
+
32
+ if problem
33
+ text = <<-EOT
34
+ There is at least one problem in your system. You can go this page to
35
+ get more information on how to fix it:
36
+
37
+ https://canga.io/install/
38
+
39
+ EOT
40
+
41
+ STDERR.puts text
42
+ end
43
+
44
+ STDERR.puts <<-EOT
45
+ It's also a good idea to execute libguestfs test tool:
46
+
47
+ $ libguestfs-test-tool
48
+
49
+ EOT
50
+
51
+ problem
52
+ end
53
+
54
+ def check_kernel
55
+ Dir['/boot/vmlinuz*'].each do |file|
56
+ if File.readable?(file)
57
+ return true
58
+ end
59
+ end
60
+
61
+ help_kernel
62
+ false
63
+ end
64
+
65
+ def help_kernel
66
+ text = <<-EOT
67
+ libguestfs needs a kernel to boot it's qemu appliance. There is no kernel
68
+ in your /boot directory readable by your kernel. Change the permissions of
69
+ at least one kernel in that directory to be readable by the current user.
70
+
71
+ EOT
72
+
73
+ STDERR.puts text
74
+ end
75
+
76
+ def check_qemu_img
77
+ version = Cangallo::Qcow2.qemu_img_version
78
+
79
+ if !version
80
+ text = "Could not get qemu-img version. Is it installed in your system?"
81
+
82
+ STDERR.puts text
83
+ STDERR.puts
84
+ exit(-1)
85
+ end
86
+
87
+ good = Gem::Version.new('2.4.0')
88
+ current = Gem::Version.new(version)
89
+
90
+ if current >= good
91
+ true
92
+ else
93
+ help_qemu_img
94
+ false
95
+ end
96
+ end
97
+
98
+ def help_qemu_img
99
+ text = <<-EOT
100
+ Cangallo needs a qemu-img version equal or greater than 2.4.0. Yours appears
101
+ to be older. This will make impossible to compress delta images. You can
102
+ download this qemu-img binary and add it to the path. Make sure the path
103
+ possition is before #{%x(which qemu-img).strip}.
104
+
105
+ https://canga.io/downloads/qemu-img.bz2
106
+
107
+ EOT
108
+
109
+ STDERR.puts text
110
+ end
111
+
112
+ def check_libguestfs
113
+ version = Cangallo::LibGuestfs.version
114
+
115
+ if !version
116
+ text = "Could not get virt-customize version. Is libguestfs installed?"
117
+
118
+ STDERR.puts text
119
+ STDERR.puts
120
+ exit(-1)
121
+ end
122
+
123
+ current = Gem::Version.new(version)
124
+ good = Gem::Version.new("1.30.0")
125
+ enough = Gem::Version.new("1.28.0")
126
+
127
+ if current < enough
128
+ help_libguestfs
129
+ return false
130
+ elsif current < good
131
+ STDERR.puts "libguestfs >= 1.30.0 recomended"
132
+ STDERR.puts
133
+ end
134
+
135
+ true
136
+ end
137
+
138
+ def help_libguestfs
139
+ text = <<-EOT
140
+ libguestfs version 1.28.0 is needed although 1.30.0 or newer is recomended.
141
+
142
+ EOT
143
+
144
+ STDERR.puts text
145
+ end
146
+ end
147
+ end
148
+
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  class Cangallo
19
- VERSION = '0.0.4'
19
+ VERSION = '0.0.5'
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cangallo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Fontan
@@ -48,6 +48,7 @@ files:
48
48
  - bin/canga
49
49
  - lib/cangallo.rb
50
50
  - lib/cangallo/cangafile.rb
51
+ - lib/cangallo/check.rb
51
52
  - lib/cangallo/config.rb
52
53
  - lib/cangallo/keybase.rb
53
54
  - lib/cangallo/libguestfs.rb