Class: Bosh::Gen::Generators::PackageSourceGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bosh/gen/generators/package_source_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_filenames_to_specObject



24
25
26
27
28
29
30
31
# File 'lib/bosh/gen/generators/package_source_generator.rb', line 24

def add_filenames_to_spec
  current_spec = YAML.load_file(package_dir("spec"))
  current_spec["files"] ||= []
  file_paths.each do |path|
    current_spec["files"] << File.join(package_name, File.basename(path))
  end
  create_file package_dir("spec"), YAML.dump(current_spec), :force => true
end

#check_packageObject

Raises:

  • (Thor::Error)


19
20
21
22
# File 'lib/bosh/gen/generators/package_source_generator.rb', line 19

def check_package
  raise Thor::Error.new("'#{package_name}' package does not yet exist; either create or fix spelling") unless File.exist?(package_dir(""))
  raise Thor::Error.new("'packages/#{package_name}/spec' is missing") unless File.exist?(package_dir("spec"))
end

#check_root_is_releaseObject



13
14
15
16
17
# File 'lib/bosh/gen/generators/package_source_generator.rb', line 13

def check_root_is_release
  unless File.exist?("jobs") && File.exist?("packages")
    raise Thor::Error.new("run inside a BOSH release project")
  end
end

#copy_filesObject



33
34
35
36
37
38
# File 'lib/bosh/gen/generators/package_source_generator.rb', line 33

def copy_files
  source_paths << File.dirname(file_paths.first) # file_paths all in same folder
  file_paths.each do |path|
    copy_file path, source_dir(File.basename(path))
  end
end

#packagingObject

Add a guess about the packaging/compilation of the file



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bosh/gen/generators/package_source_generator.rb', line 41

def packaging
  packaging_for_files = ""
  file_paths.each do |path|
    filename = File.basename(path)
    if filename =~ /^(.*)(\.tar\.gz|\.tgz)$/
      package_dir = $1
      # assume its a standard installable source package
      packaging_for_files += <<-BASH.gsub(/^\s{12}/, '')
      tar xfz #{package_name}/#{filename}
      (
        cd #{package_dir}
        ./configure --prefix=$BOSH_INSTALL_TARGET
        make -j${CPUS} && make install
      )
      
      BASH
    end
  end
  append_file "packages/#{package_name}/packaging", packaging_for_files
end

#readmeObject



62
63
64
65
66
# File 'lib/bosh/gen/generators/package_source_generator.rb', line 62

def readme
  if flags[:blob]
    say_status "readme", "Upload blobs with 'bosh upload-blobs'"
  end
end