* Add support for rpm scripts that use RPM_INSTALL_PREFIX, by setting

RPM_INSTALL_PREFIX as part of the converted script. Closes: #400863
This commit is contained in:
joey
2006-12-15 18:34:39 +00:00
parent 7382aaf75f
commit c1a3316e71
2 changed files with 17 additions and 2 deletions

View File

@@ -448,6 +448,10 @@ are typically shell scripts, but often lack the leading #!/bin/sh
This can confuse dpkg, so add the #!/bin/sh if it looks like there
is no shebang magic already in place.
Also, if the rpm is relocatable, the script could refer to
RPM_INSTALL_PREFIX, which is set by rpm at run time. Deal with this by
adding code to the script to set RPM_INSTALL_PREFIX.
=cut
# This helper function deals with all the scripts.
@@ -457,9 +461,18 @@ sub _script_helper {
# set
if (@_) {
my $prefixcode="";
if (defined $this->prefixes) {
$prefixcode="RPM_INSTALL_PREFIX=".$this->prefixes."\n";
$prefixcode.="export RPM_INSTALL_PREFIX\n";
}
my $value=shift;
if (length $value and $value !~ m/^#!\s*\//) {
$value="#!/bin/sh\n$value";
$value="#!/bin/sh\n$prefixcode$value";
}
else {
$value=~s/\n/\n$prefixcode/s;
}
$this->{$script} = $value;
}