summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-03-30 14:35:23 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-03-30 14:35:23 +0000
commit18011f2e9d699e37c6da8bec2d02de2b84a96a85 (patch)
treefdf782dfce0c929d31fe317a8b22c62518c19f56 /perl-install/common.pm
parented9b8286889057ba6a4983d4afb266d74cac20f0 (diff)
downloaddrakx-backup-do-not-use-18011f2e9d699e37c6da8bec2d02de2b84a96a85.tar
drakx-backup-do-not-use-18011f2e9d699e37c6da8bec2d02de2b84a96a85.tar.gz
drakx-backup-do-not-use-18011f2e9d699e37c6da8bec2d02de2b84a96a85.tar.bz2
drakx-backup-do-not-use-18011f2e9d699e37c6da8bec2d02de2b84a96a85.tar.xz
drakx-backup-do-not-use-18011f2e9d699e37c6da8bec2d02de2b84a96a85.zip
no_comment
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm24
1 files changed, 23 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 777038e2e..3d38e91a4 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -8,7 +8,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int
%EXPORT_TAGS = (
common => [ qw(__ even odd arch min max sqr sum and_ or_ sign product bool invbool listlength bool2text bool2yesno text2bool to_int to_float ikeys member divide is_empty_array_ref is_empty_hash_ref add2hash add2hash_ set_new set_add round round_up round_down first second top uniq translate untranslate warp_text formatAlaTeX formatLines deref) ],
functional => [ qw(fold_left compose map_index grep_index map_each grep_each list2kv map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie) ],
- file => [ qw(dirname basename touch all glob_ cat_ output symlinkf chop_ mode typeFromMagic) ],
+ file => [ qw(dirname basename touch all glob_ cat_ output symlinkf chop_ mode typeFromMagic expand_symlinks) ],
system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ salt getVarsFromSh setVarsInSh setVarsInCsh substInFile availableRam availableMemory removeXiBSuffix template2file formatTime) ],
constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ],
);
@@ -96,6 +96,28 @@ sub remove_spaces { local $_ = shift; s/^ +//; s/ +$//; $_ }
sub mode { my @l = stat $_[0] or die "unable to get mode of file $_[0]: $!\n"; $l[2] }
sub psizeof { length pack $_[0] }
+sub concat_symlink {
+ my ($f, $l) = @_;
+ $l =~ m|^\.\./(/.*)| and return $1;
+
+ $f =~ s|/$||;
+ while ($l =~ s|^\.\./||) {
+ $f =~ s|/[^/]+$|| or die "concat_symlink: $f $l\n";
+ }
+ "$f/$l";
+}
+
+sub expand_symlinks {
+ my ($first, @l) = split '/', $_[0];
+ $first eq '' or die "expand_symlinks: $_[0] is relative\n";
+ my ($f, $l);
+ foreach (@l) {
+ $f .= "/$_";
+ $f = concat_symlink($f, "../$l") while $l = readlink $f;
+ }
+ $f;
+}
+
sub arch() {
require Config;
Config->import;