aboutsummaryrefslogtreecommitdiffstats
path: root/relink_symlinks
diff options
context:
space:
mode:
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);