Class: Autoproj::CLI::Bootstrap

Inherits:
Object
  • Object
show all
Includes:
Ops::Tools
Defined in:
lib/autoproj/cli/bootstrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ops::Tools

#common_options, #create_autobuild_package, #load_autoprojrc, #load_main_initrb

Constructor Details

#initialize(root_dir = Dir.pwd) ⇒ Bootstrap

Returns a new instance of Bootstrap.



13
14
15
16
17
18
19
# File 'lib/autoproj/cli/bootstrap.rb', line 13

def initialize(root_dir = Dir.pwd)
    if File.exist?(File.join(root_dir, "autoproj", "manifest"))
        raise CLIException, "this installation is already bootstrapped. Remove the autoproj directory if it is not the case"
    end

    @root_dir = root_dir
end

Instance Attribute Details

#root_dirObject (readonly)

Returns the value of attribute root_dir.



11
12
13
# File 'lib/autoproj/cli/bootstrap.rb', line 11

def root_dir
  @root_dir
end

Instance Method Details

#notify_env_sh_updatedObject



89
90
# File 'lib/autoproj/cli/bootstrap.rb', line 89

def notify_env_sh_updated
end

#run(buildconf_info, interactive: nil, **options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/autoproj/cli/bootstrap.rb', line 36

def run(buildconf_info, interactive: nil, **options)
    ws = Workspace.new(root_dir)
    ws.config.interactive = interactive unless interactive.nil?
    ws.setup

    seed_config = options.delete(:seed_config)

    switcher = Ops::MainConfigSwitcher.new(ws)
    check_root_dir_empty =
        ws.config.interactive? && switcher.check_root_dir_empty?

    begin
        switcher.bootstrap(buildconf_info,
                           check_root_dir_empty: check_root_dir_empty,
                           **options)
        if seed_config
            FileUtils.cp seed_config, File.join(ws.config_dir, "config.yml")
        end

        STDOUT.puts <<-EOTEXT


#{Autoproj.color('autoproj bootstrap successfully finished', :green, :bold)}

#{Autoproj.color('To further use autoproj and the installed software', :bold)}, you
must add the following line at the bottom of your .bashrc:
source #{root_dir}/#{Autoproj::ENV_FILENAME}

WARNING: autoproj will not work until your restart all
your consoles, or run the following in them:
$ source #{root_dir}/#{Autoproj::ENV_FILENAME}

#{Autoproj.color('To import and build the packages', :bold)}, you can now run
aup
amake

The resulting software is installed in
#{ws.prefix_dir}

        EOTEXT
    rescue RuntimeError
        STDERR.puts <<-EOTEXT
#{Autoproj.color('autoproj bootstrap failed', :red, :bold)}
To retry, first source the #{Autoproj::ENV_FILENAME} script with
source #{root_dir}/#{Autoproj::ENV_FILENAME}
and then re-run autoproj bootstrap
autoproj bootstrap '#{ARGV.join("'")}'
        EOTEXT

        raise
    end
end

#validate_options(args, options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/autoproj/cli/bootstrap.rb', line 21

def validate_options(args, options)
    args, options = Base.validate_options(args, options)
    if (path = options[:reuse])
        path = ENV["AUTOPROJ_CURRENT_ROOT"] if path == "reuse"

        path = File.expand_path(path)
        if !File.directory?(path) || !File.directory?(File.join(path, "autoproj"))
            raise CLIInvalidArguments, "#{path} does not look like an autoproj installation"
        end

        options[:reuse] = [path]
    end
    [args, options]
end