diff options
Diffstat (limited to 'relink_symlinks')
-rw-r--r-- | relink_symlinks | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/relink_symlinks b/relink_symlinks new file mode 100644 index 0000000..5ad5234 --- /dev/null +++ b/relink_symlinks @@ -0,0 +1,25 @@ +#!/usr/bin/perl +# relativize absolute symlinks + +use strict; +use File::Find; + +sub relativize { + return unless -l $_; + + my $link = readlink($_); + return unless $link =~ m{^/}; + + $link =~ s{^/}{}; + my $dirname = $File::Find::dir; + $dirname =~ s/^$ENV{RPM_BUILD_ROOT}//; + $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}); |