linecook-gem 0.5.6 → 0.5.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee54645b2e182e0aa4f8c40d7dda5685d743972d
4
- data.tar.gz: 602ff0898efb7b578c4f7fdb3398094b205a7d0f
3
+ metadata.gz: cce2615879f794147894aa74975081c3d398563c
4
+ data.tar.gz: 7fcc50dbe5e86411bae22b27d97fac338dad972b
5
5
  SHA512:
6
- metadata.gz: 701617fea4cfe33880db86b3c17a0dcdd15402f25a050da4469f4734f85bd9da80cdaccdbe2cf704e58f020b3ea35e4653e79e1d8cfc918e1b7c34d32fe322e1
7
- data.tar.gz: 6bb3c78a373ae13c17d6bf71ec692a688c5cac026d110e00ef3829e7de88b6b7531ac8b3501a9b26f731d68adbfa6ca3944af7529dc63a90a2ac3f7b96e6cb79
6
+ metadata.gz: d820b2680bc55310f63828501c612766c4d98f59a9ca18696bf44fdde16ce44f81b766797d77fae52198598a1b5fe8b81305cccffe4ddd8d27089b9a40d431bd
7
+ data.tar.gz: c0582af148803041adcbaee5396706868c883b9f66bf9ffa11180cb417e9272fa005b90e6c5ad427b2cb6015d2c65afc75e47c1fb3b4863fbcc469087e8a2861
@@ -160,13 +160,15 @@ module Linecook
160
160
 
161
161
  def unmount(clean: false)
162
162
  @socket_dirs.each { |sock| execute("umount #{sock}") }
163
- source = capture("mount | grep #{@lower_dir} | awk '{print $1}'") if clean
163
+ source = capture("mount | grep #{@lower_dir} | grep squashfs | awk '{print $1}'") if clean
164
164
  execute("umount #{@root}")
165
165
  execute("umount #{@upper_base}")
166
166
  execute("umount #{@lower_dir}")
167
167
  execute("rmdir #{@lower_dir}")
168
168
  execute("rmdir #{@upper_base}")
169
- FileUtils.rm_f(source) if clean
169
+
170
+ # Clean up the source image, but only if it's not mounted elsewhre
171
+ FileUtils.rm_f(source) if clean && capture("mount | grep #{source} || true").strip.empty?
170
172
  end
171
173
 
172
174
  def bridge_network
@@ -198,9 +200,13 @@ eos
198
200
  def setup_image
199
201
  @source_path = Linecook::ImageManager.fetch(@source_image, profile: :public)
200
202
  if @remote
201
- dest = "#{File.basename(@source_path)}"
203
+ name = File.basename(@source_path)
204
+ dest = "/u/linecook/images/#{name}"
202
205
  unless test("[ -f #{dest} ]") && capture("shasum #{dest}").split.first == `shasum #{@source_path}`.split.first
203
- @remote.upload(@source_path, dest)
206
+ tmp = "/tmp/#{name}-#{SecureRandom.hex(4)}"
207
+ @remote.run("sudo mkdir -p #{File.dirname(dest)}")
208
+ @remote.upload(@source_path, tmp)
209
+ @remote.run("sudo mv #{tmp} #{dest}")
204
210
  end
205
211
  @image_path = dest
206
212
  else
@@ -1,3 +1,3 @@
1
1
  module Linecook
2
- VERSION = '0.5.6'
2
+ VERSION = '0.5.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linecook-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Hamel