aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rwxr-xr-xrelative_me_babe20
-rw-r--r--relink_symlinks25
-rwxr-xr-xspec-helper2
-rw-r--r--spec-helper.macros.in2
5 files changed, 29 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index cbc5cfe..90e5c2c 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,8 @@ VERSION:=$(shell rpm --qf %{VERSION} -q --specfile spec-helper.spec)
RELEASE:=$(shell rpm --qf %{RELEASE} -q --specfile spec-helper.spec)
TAG := $(shell echo "V$(VERSION)_$(RELEASE)" | tr -- '-.' '__')
-FILES= spec-helper clean_files clean_perl compress_files strip_files relative_me_babe lib_symlinks gprintify.py fix-mo translate_menu.pl \
- fixpamd gprintify remove_info_dir
+FILES=spec-helper clean_files clean_perl compress_files strip_files lib_symlinks gprintify.py fix-mo translate_menu.pl \
+ fixpamd gprintify remove_info_dir relink_symlinks
MACROSFILE = $(PACKAGE).macros
DISTFILES= AUTHORS Makefile ChangeLog Howto-spec-helper $(FILES) macroszification spec-helper.spec $(MACROSFILE).in
bindir=/usr/bin
diff --git a/relative_me_babe b/relative_me_babe
deleted file mode 100755
index f241487..0000000
--- a/relative_me_babe
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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 die "Can't cd to $ENV{RPM_BUILD_ROOT}: $!";
-
-push my @files, split(/\n/, `find -type l 2> /dev/null`);
-foreach my $file (@files) {
- my $link = readlink($file);
- if ($link =~ m!^/!) {
- $link =~ s|^/||;
- # Ugly ? no simply chmou.
- (my $dirname = $file) =~ s|/[^/]*$||; $dirname =~ s|/[^/]+|../|g; $dirname =~ s|^\.||;
- system("ln -sf $dirname$link $file");
- }
-}
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});
diff --git a/spec-helper b/spec-helper
index aa49114..c68b84f 100755
--- a/spec-helper
+++ b/spec-helper
@@ -62,7 +62,7 @@ done
test -z "$DONT_CLEANUP" && echo -n "Cleaning files..." && clean_files && echo "done"
test -z "$DONT_COMPRESS" && echo -n "Compressing files..." && compress_files && echo "done"
test -z "$DONT_STRIP" && echo -n "Stripping files..." && strip_files && echo "done"
-test -z "$DONT_RELINK" && echo -n "Relativisation of symlinks..." && relative_me_babe && echo "done"
+test -z "$DONT_RELINK" && echo -n "Relativisation of symlinks..." && relink_symlinks && echo "done"
test -z "$DONT_CLEAN_PERL" && echo -n "Clean perl..." && clean_perl && echo "done"
test -z "$DONT_SYMLINK_LIBS" && echo -n "Building libraries symlinks..." && lib_symlinks && echo "done"
test -z "$DONT_GPRINTIFY" && echo -n "printify initscripts..." && gprintify && echo "done"
diff --git a/spec-helper.macros.in b/spec-helper.macros.in
index f5074ba..e8c9a98 100644
--- a/spec-helper.macros.in
+++ b/spec-helper.macros.in
@@ -6,7 +6,7 @@
%{?!dont_clean_files: [ -n "$DONT_CLEANUP" ] || %_spec_helper_dir/clean_files} \
%{?!dont_compress: [ -n "$DONT_COMPRESS" ] || %_spec_helper_dir/compress_files} \
%{?!dont_strip: [ -n "$DONT_STRIP" ] || %_spec_helper_dir/strip_files} \
- %{?!dont_relink: [ -n "$DONT_RELINK" ] || %_spec_helper_dir/relative_me_babe} \
+ %{?!dont_relink: [ -n "$DONT_RELINK" ] || %_spec_helper_dir/relink_symlinks} \
%{?!dont_lceanup_perl: [ -n "$DONT_CLEAN_PERL" ] || %_spec_helper_dir/clean_perl} \
%{?!dont_symlinks_libs: [ -n "$DONT_SYMLINK_LIBS" ] || %_spec_helper_dir/lib_symlinks} \
%{?!dont_gprintify: [ -n "$DONT_GPRINTIFY" ] || %_spec_helper_dir/gprintify} \