Arrows implemented in sources.
This commit is contained in:
parent
e6fb4d6c3d
commit
8322c78e30
@ -10,13 +10,6 @@ require "./instructions.cr"
|
|||||||
require "./sources.cr"
|
require "./sources.cr"
|
||||||
require "./exception.cr"
|
require "./exception.cr"
|
||||||
|
|
||||||
# 🤔
|
|
||||||
class URI
|
|
||||||
def basename
|
|
||||||
File.basename path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module FileUtils
|
module FileUtils
|
||||||
def self.find(directory, &block : Proc(String, Nil))
|
def self.find(directory, &block : Proc(String, Nil))
|
||||||
Dir.each_child directory do |child|
|
Dir.each_child directory do |child|
|
||||||
@ -187,8 +180,8 @@ class Package::Recipe
|
|||||||
|
|
||||||
def download
|
def download
|
||||||
sources.each do |url|
|
sources.each do |url|
|
||||||
unless File.exists? url.basename
|
unless File.exists? url.filename
|
||||||
status = @context.run @context.sources_directory, "wget", [ url.to_s, "-O", url.basename ]
|
status = @context.run @context.sources_directory, "wget", [ url.to_s, "-O", url.filename ]
|
||||||
|
|
||||||
raise DownloadError.new self, url unless status.success?
|
raise DownloadError.new self, url unless status.success?
|
||||||
end
|
end
|
||||||
@ -199,13 +192,13 @@ class Package::Recipe
|
|||||||
Dir.mkdir_p building_directory
|
Dir.mkdir_p building_directory
|
||||||
|
|
||||||
sources.each do |url|
|
sources.each do |url|
|
||||||
basename = url.basename
|
basename = url.filename
|
||||||
|
|
||||||
status = @context.run(
|
status = @context.run(
|
||||||
building_directory,
|
building_directory,
|
||||||
"bsdtar", [
|
"bsdtar", [
|
||||||
"xvf",
|
"xvf",
|
||||||
@context.sources_directory + "/" + url.basename
|
@context.sources_directory + "/" + url.filename
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,9 +1,34 @@
|
|||||||
|
|
||||||
require "uri"
|
require "uri"
|
||||||
|
|
||||||
class Package::Sources < Array(URI)
|
class Source < URI
|
||||||
def <<(url : String)
|
getter filename : String
|
||||||
self << URI.parse url
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user