Skip to content
Snippets Groups Projects
Commit c5c1a964 authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab)
Browse files

Refuse to run if the GDK root was moved

This is a cause of problems for users. Although we already made fixing
it easy (gdk reconfigure) it was still hard for users to detect /
understand what was wrong.
parent ba5baa0c
No related branches found
No related tags found
1 merge request!209Refuse to run if the GDK root was moved
Loading
Loading
@@ -46,3 +46,4 @@
/.gitlab-bundle
/gem/*.gem
/gitlab-runner-config.toml
/.gdk-install-root
Loading
Loading
@@ -242,4 +242,4 @@ clean-config:
gitlab-shell/.gitlab_shell_secret \
redis/redis.conf \
.ruby-version \
Procfile
Procfile \
v0.2.3
- Remember installation directory during 'gdk init'
v0.2.2
- Add 'gdk version' command
 
Loading
Loading
Loading
Loading
@@ -13,6 +13,7 @@ require 'gitlab-development-kit'
module GDK
DOTFILE = File.expand_path('~/.gdk.yml')
TRUSTED_KEY = 'trusted_directories'
ROOT_CHECK_FILE = '.gdk-install-root'
 
def self.launcher_main
case ARGV.first
Loading
Loading
@@ -26,7 +27,7 @@ module GDK
end
directory = ARGV.count == 2 ? ARGV[1] : 'gitlab-development-kit'
cmd = %W(git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git #{directory})
system(*cmd) && trust!(directory)
system(*cmd) && trust!(directory) && remember!(directory)
when 'trust'
if ARGV.count != 2
puts "Usage: gdk trust DIR"
Loading
Loading
@@ -88,6 +89,16 @@ module GDK
def self.load_dotfile
File.open(DOTFILE, File::RDONLY | File::CREAT) { |f| YAML.load(f) } || {}
end
def self.remember!(directory)
open("#{directory}/#{ROOT_CHECK_FILE}", 'w') do |f|
f.puts File.realpath(directory)
end
true
rescue => ex
warn ex
false
end
end
 
exit(GDK::launcher_main)
module GDK
GEM_VERSION = '0.2.2'
GEM_VERSION = '0.2.3'
end
Loading
Loading
@@ -10,6 +10,15 @@ module GDK
# This function is called from bin/gdk. It must return true/false or
# an exit code.
def self.main
if !install_root_ok? && ARGV.first != 'reconfigure'
puts <<-EOS.gsub(/^\s+\|/, '')
|According to #{ROOT_CHECK_FILE} this gitlab-development-kit
|installation was moved. Run 'gdk reconfigure' to update hard-coded
|paths.
EOS
return false
end
case ARGV.shift
when 'run'
exec('./run', *ARGV, chdir: $gdk_root)
Loading
Loading
@@ -18,6 +27,7 @@ module GDK
when 'update'
exec(MAKE, 'update', chdir: $gdk_root)
when 'reconfigure'
remember!($gdk_root)
exec(MAKE, 'clean-config', 'all', chdir: $gdk_root)
when 'help'
puts File.read(File.join($gdk_root, 'HELP'))
Loading
Loading
@@ -27,4 +37,12 @@ module GDK
false
end
end
def self.install_root_ok?
expected_root = File.read(File.join($gdk_root, ROOT_CHECK_FILE)).chomp
File.realpath(expected_root) == File.realpath($gdk_root)
rescue => ex
warn ex
false
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment