parse archive param

This commit is contained in:
Artur Gurgul 2025-08-04 19:41:41 +02:00
parent 0fb2502e53
commit 68e1bac4b3
2 changed files with 59 additions and 9 deletions

View file

@ -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