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

# 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
class Package::Instructions < Array(String)
getter phase : String
def initialize(@phase)
super()
end
def run(directory : String) : BuildStatus
if size == 0
Baguette::Log.error "Empty instructions for phase #{@phase}"
return BuildStatus::Pass
end
each do |command|
child = Do.run directory, "sh", ["-x", "-c", command]
if child.exit_status != 0
return BuildStatus::Failed
end
end
BuildStatus::Success
end
end