Environment variables are configuration-defined.

It was previously inherited, but that behavior was error-prone. This
commit fixes that.
master
Luka Vandervelden 2019-08-29 14:51:50 +02:00
parent 3d78fa2074
commit e048ca9685
1 changed files with 15 additions and 1 deletions

View File

@ -74,6 +74,7 @@ class Package::Context
property architecture = "x86_64"
property prefixes = ["/usr", "/", "/usr/weirdos"]
property environment = {} of String => String
def initialize
@packaging_backends << Backend::Packaging.new "pkgutils" do |context, package|
@ -213,7 +214,7 @@ class Package::Context
end
def run(chdir, command, args)
Process.run command, args, chdir: chdir, output: Process::Redirect::Inherit, error: Process::Redirect::Inherit
Process.run command, args, chdir: chdir, output: Process::Redirect::Inherit, error: Process::Redirect::Inherit, env: @environment
end
def run(command, args)
@ -263,6 +264,19 @@ class Package::Context
@sources_directory = value.as_s
when "prefixes"
@prefixes = value.as_a_or_s
when "environment"
value.as_a_or_s.each do |entry|
match = entry.split(':').map(
&.gsub(/^[ \t]*/, "").gsub(/[ \t]*$/, ""))
if match.size != 2
STDERR.puts "WARNING: misformed environment definition: #{entry}"
next
end
key, value = match
@environment[key] = value
end
end
end
end