aboutsummaryrefslogtreecommitdiffstats
path: root/relink_symlinks
diff options
context:
space:
mode:
authorGuillaume Rousse <guillomovitch@mandriva.org>2008-01-29 21:34:54 +0000
committerGuillaume Rousse <guillomovitch@mandriva.org>2008-01-29 21:34:54 +0000
commit02e14506ac57f50b8fe77c79ae72be0403d52b2c (patch)
tree10ba2860acf8f4b7f38af9d22838f43ad358c0ec /relink_symlinks
parent7d1cb2c537e76a8408355a62f38016ed3a8c2085 (diff)
downloadspec-helper-02e14506ac57f50b8fe77c79ae72be0403d52b2c.tar
spec-helper-02e14506ac57f50b8fe77c79ae72be0403d52b2c.tar.gz
spec-helper-02e14506ac57f50b8fe77c79ae72be0403d52b2c.tar.bz2
spec-helper-02e14506ac57f50b8fe77c79ae72be0403d52b2c.tar.xz
spec-helper-02e14506ac57f50b8fe77c79ae72be0403d52b2c.zip
sanitize usage and test of buildroot env var
Diffstat (limited to 'relink_symlinks')
-rwxr-xr-xrelink_symlinks13
1 files changed, 8 insertions, 5 deletions
diff --git a/relink_symlinks b/relink_symlinks
index 4f8dad4..0150899 100755
--- a/relink_symlinks
+++ b/relink_symlinks
@@ -5,6 +5,12 @@ use strict;
use warnings;
use File::Find;
+my $buildroot = $ENV{RPM_BUILD_ROOT};
+die "No build root defined" unless $buildroot;
+die "Invalid build root" unless -d $buildroot;
+# normalize build root
+$buildroot =~ s|/$||;
+
sub relativize {
return unless -l $_;
@@ -13,14 +19,11 @@ sub relativize {
$link =~ s{^/}{};
my $dirname = $File::Find::dir;
- $dirname =~ s/^\Q$ENV{RPM_BUILD_ROOT}\E//;
+ $dirname =~ s/^\Q$buildroot\E//;
$dirname =~ s{/[^/]+}{../}g;
unlink $_;
symlink $dirname . $link, $_;
}
-die "No build root defined\n" unless $ENV{RPM_BUILD_ROOT};
-
-$ENV{RPM_BUILD_ROOT} =~ s{/$}{};
-find(\&relativize, $ENV{RPM_BUILD_ROOT});
+find(\&relativize, $buildroot);