diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> | 2006-06-07 13:06:03 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> | 2006-06-07 13:06:03 +0000 |
commit | 0a74190d1ee254f9d40cd875e65263305fd1c739 (patch) | |
tree | f5a144e51f53ea2b756646deaa420fff93bd9ab3 /relink_symlinks | |
parent | 1a3752d130dd9f7dd766ea57efbad65ce949ed75 (diff) | |
download | spec-helper-0a74190d1ee254f9d40cd875e65263305fd1c739.tar spec-helper-0a74190d1ee254f9d40cd875e65263305fd1c739.tar.gz spec-helper-0a74190d1ee254f9d40cd875e65263305fd1c739.tar.bz2 spec-helper-0a74190d1ee254f9d40cd875e65263305fd1c739.tar.xz spec-helper-0a74190d1ee254f9d40cd875e65263305fd1c739.zip |
Replace relative_me_babe by relink_symlinks, by Guillaume Rousse (bug #22983)
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}); |