diff options
author | Christopher Baines <mail@cbaines.net> | 2019-05-24 16:03:40 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-05-24 16:03:40 +0100 |
commit | 2b784c267f8688111ed3f745454e349500f426bc (patch) | |
tree | 71da95b6d23a4c62e6e12953d8f9af8a45f7481a /app/services/govuk_guix/update_gcroots_directory.rb | |
parent | f8fabe092138d4513a139b9f9a0f4aaccacd81b0 (diff) | |
download | govuk-mini-environment-admin-ami-backend.tar govuk-mini-environment-admin-ami-backend.tar.gz |
WIPami-backend
Diffstat (limited to 'app/services/govuk_guix/update_gcroots_directory.rb')
-rw-r--r-- | app/services/govuk_guix/update_gcroots_directory.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/services/govuk_guix/update_gcroots_directory.rb b/app/services/govuk_guix/update_gcroots_directory.rb index 97fe703..dec4679 100644 --- a/app/services/govuk_guix/update_gcroots_directory.rb +++ b/app/services/govuk_guix/update_gcroots_directory.rb @@ -24,6 +24,11 @@ module GovukGuix::UpdateGcrootsDirectory DIRECTORY = '/var/guix/gcroots/govuk-mini-environment-admin' def self.set_in_use_store_paths(store_paths, options = {}) + store_paths.each do |store_path| + raise "Invalid store path #{store_path}" \ + unless Guix.valid_store_path?(store_path) + end + current_store_paths = list_store_paths(options) (current_store_paths - store_paths).each do |store_path| @@ -36,15 +41,21 @@ module GovukGuix::UpdateGcrootsDirectory end def self.add_store_path(store_path, options = {}) + raise "Invalid store path #{store_path}" \ + unless Guix.valid_store_path?(store_path) + run_command( - 'ln', '-s', - store_path, + 'ln', '-f', '-s', + '-T', store_path, File.join(DIRECTORY, store_path['/gnu/store/'.length..-1]), run_remotely_on_host: options[:run_remotely_on_host] ) end def self.remove_store_path(store_path, options = {}) + raise "Invalid store path #{store_path}" \ + unless Guix.valid_store_path?(store_path) + run_command( 'rm', File.join(DIRECTORY, store_path['/gnu/store/'.length..-1]), run_remotely_on_host: options[:run_remotely_on_host] |