Archived
3
0

Arrows implemented in sources.

This commit is contained in:
Luka Vandervelden 2019-08-22 19:57:51 +02:00
parent e6fb4d6c3d
commit 8322c78e30
2 changed files with 32 additions and 14 deletions

View File

@ -10,13 +10,6 @@ require "./instructions.cr"
require "./sources.cr"
require "./exception.cr"
# 🤔
class URI
def basename
File.basename path
end
end
module FileUtils
def self.find(directory, &block : Proc(String, Nil))
Dir.each_child directory do |child|
@ -187,8 +180,8 @@ class Package::Recipe
def download
sources.each do |url|
unless File.exists? url.basename
status = @context.run @context.sources_directory, "wget", [ url.to_s, "-O", url.basename ]
unless File.exists? url.filename
status = @context.run @context.sources_directory, "wget", [ url.to_s, "-O", url.filename ]
raise DownloadError.new self, url unless status.success?
end
@ -199,13 +192,13 @@ class Package::Recipe
Dir.mkdir_p building_directory
sources.each do |url|
basename = url.basename
basename = url.filename
status = @context.run(
building_directory,
"bsdtar", [
"xvf",
@context.sources_directory + "/" + url.basename
@context.sources_directory + "/" + url.filename
]
)

View File

@ -1,9 +1,34 @@
require "uri"
class Package::Sources < Array(URI)
def <<(url : String)
self << URI.parse url
class Source < URI
getter filename : String
def initialize(uri : URI)
@fragment = uri.fragment
@host = uri.host
@password = uri.host
@port = uri.port
@query = uri.query
@scheme = uri.scheme
@user = uri.user
@path = uri.path.gsub /\ *\->.*/, ""
@filename = File.basename(uri.path).gsub /.*-> */, ""
end
def scheme : String
@scheme || "file"
end
def self.parse(uri : String)
self.new URI.parse uri
end
end
class Package::Sources < Array(Source)
def <<(url : String)
self << Source.parse url
end
end