summaryrefslogtreecommitdiff
path: root/dh_link
diff options
context:
space:
mode:
Diffstat (limited to 'dh_link')
-rwxr-xr-xdh_link36
1 files changed, 34 insertions, 2 deletions
diff --git a/dh_link b/dh_link
index 7c51d06..5dd9da3 100755
--- a/dh_link
+++ b/dh_link
@@ -76,6 +76,39 @@ the X man page foo.1x
=cut
+# This expand_path expands all path "." and ".." components, but doesn't
+# resolve symbolic links.
+sub expand_path {
+ my $start = @_ ? shift : '.';
+ my @pathname = split(m:/+:,$start);
+
+ my $entry;
+ my @respath;
+ foreach $entry (@pathname) {
+ if ($entry eq '.' || $entry eq '') {
+ # Do nothing
+ }
+ elsif ($entry eq '..') {
+ if ($#respath == -1) {
+ # Do nothing
+ }
+ else {
+ pop @respath;
+ }
+ }
+ else {
+ push @respath, $entry;
+ }
+ }
+
+ my $result;
+ foreach $entry (@respath) {
+ $result .= '/' . $entry;
+ }
+ return $result;
+}
+
+
init();
foreach my $package (@{$dh{DOPACKAGES}}) {
@@ -126,9 +159,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
while (@links) {
my $dest=pop @links;
- my $src=pop @links;
+ my $src=expand_path(pop @links);
- # Relavatize src and dest.
$src=~s:^/::;
$dest=~s:^/::;