aboutsummaryrefslogtreecommitdiffstats
path: root/relative_me_babe
blob: e390a18d5b93cf85dd64fb1808341b82028dd094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
# -*- Mode: cperl -*-
# Copyright (C) 2000 by Chmouel Boudjnah <chmouel@mandrakesoft.com>
# Redistribution of this file is permitted under the terms of the GNU 
# Public License (GPL)
## description: Convert full link to relative links.

my $r=$ENV{RPM_BUILD_ROOT};
chdir($r) or "Can't cd to $ENV{RPM_BUILD_ROOT}: $!";

push my @files, split(/\n/, `find -type l 2> /dev/null`);
for (@files) {
    my $file = $_;
    my $link=readlink($file);
    if ($link =~ /^\//) {
	$link =~ s|^/||;
	# Ugly ? no simply chmou.
	(my $dirname = $file) =~ s|/[^/]*$||; $dirname =~ s|/[^/]+|../|g; $dirname =~ s|^\.||;
      	system("ln -sf $dirname$link $file");
    }
}