Merge branch 'main' of ssh://gurgul.pro/artur/environment
This commit is contained in:
commit
8d6eb57fe0
3 changed files with 62 additions and 10 deletions
34
lib/make.rb
34
lib/make.rb
|
@ -28,7 +28,7 @@ module Make
|
|||
|
||||
class Context
|
||||
attr_accessor :name, :use_cache, :environment, :steps, :packages, :repository
|
||||
attr_accessor :target
|
||||
attr_accessor :target, :archive, :source_type
|
||||
|
||||
def initialize(options: OpenStruct.new)
|
||||
@target = options.target || :user
|
||||
|
@ -52,7 +52,21 @@ module Make
|
|||
# puts makefile
|
||||
|
||||
@packages = makefile["packages"] || []
|
||||
|
||||
project_sources = {
|
||||
repository: makefile["repository"] != nil,
|
||||
archive: makefile["archive"] != nil
|
||||
}.select { |_, v| v }
|
||||
|
||||
if project_sources.size == 1
|
||||
@source_type = project_sources.keys.first
|
||||
else
|
||||
raise "Exactly one type of source: 'repository' or 'archive'"
|
||||
end
|
||||
puts @source_type
|
||||
|
||||
@repository = Make.rostruct(makefile["repository"] || OpenStruct.new)
|
||||
@archive = Make.rostruct(makefile["archive"] || OpenStruct.new)
|
||||
@steps = makefile["steps"] || []
|
||||
|
||||
@environment = ENV.to_h.merge(
|
||||
|
@ -147,7 +161,14 @@ module Make
|
|||
install
|
||||
@context.rpd do | path |
|
||||
@cwd = path
|
||||
checkout
|
||||
|
||||
case @context.source_type
|
||||
when :repository
|
||||
checkout
|
||||
when :archive
|
||||
download_and_extract
|
||||
end
|
||||
|
||||
puts "path: #{path}"
|
||||
Dir.chdir(path)
|
||||
|
||||
|
@ -160,6 +181,13 @@ module Make
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def download_and_extract
|
||||
archive = @context.archive
|
||||
|
||||
puts archive
|
||||
exit -1
|
||||
end
|
||||
|
||||
def checkout
|
||||
repo_path = @context.local_repo
|
||||
|
@ -195,4 +223,4 @@ module Make
|
|||
builder = Builder.new(context)
|
||||
builder.build
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue