This repository has been archived on 2022-01-17. You can view files and clone it, but cannot push or open issues/pull-requests.
packaging/src/instructions.cr

33 lines
684 B
Crystal
Raw Permalink Normal View History

2019-07-02 03:50:50 +02:00
# User instructions for:
# source-split, [pre-](configure|build|install) and post-install
# Simple array of strings with a name.
#
# Methods:
# - run(directory) : BuildStatus
# execute each instruction in a shell in a sub process
2019-07-02 08:47:11 +02:00
class Package::Instructions < Array(String)
getter phase : String
def initialize(@phase)
super()
end
2019-07-02 19:45:33 +02:00
def run(directory : String) : BuildStatus
if size == 0
Baguette::Log.error "Empty instructions for phase #{@phase}"
return BuildStatus::Pass
end
2019-07-02 08:47:11 +02:00
each do |command|
child = Do.run directory, "sh", ["-x", "-c", command]
2019-07-02 08:47:11 +02:00
if child.exit_status != 0
return BuildStatus::Failed
2019-07-02 08:47:11 +02:00
end
end
2019-07-02 03:50:50 +02:00
BuildStatus::Success
2019-07-02 03:50:50 +02:00
end
end