diff options
author | Pascal Rigaux <pixel@mandriva.com> | 1999-11-02 19:48:21 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 1999-11-02 19:48:21 +0000 |
commit | 9176797a41f4acb22259ffa0b7e58d49b1bceac3 (patch) | |
tree | c655e423b29d899df9f332247e1640b142300a03 /perl-install/common.pm | |
parent | edeac12d2a69a099fdf5fec50e389699de21c2c2 (diff) | |
download | drakx-9176797a41f4acb22259ffa0b7e58d49b1bceac3.tar drakx-9176797a41f4acb22259ffa0b7e58d49b1bceac3.tar.gz drakx-9176797a41f4acb22259ffa0b7e58d49b1bceac3.tar.bz2 drakx-9176797a41f4acb22259ffa0b7e58d49b1bceac3.tar.xz drakx-9176797a41f4acb22259ffa0b7e58d49b1bceac3.zip |
no_comment
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r-- | perl-install/common.pm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index 09f39db3b..b32f9ff11 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -9,7 +9,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int common => [ qw(__ even odd min max sqr sum sign product bool invbool listlength bool2text 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) ], functional => [ qw(fold_left compose map_index grep_index map_each grep_each map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie) ], file => [ qw(dirname basename touch all glob_ cat_ symlinkf chop_ mode typeFromMagic) ], - system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ salt getVarsFromSh setVarsInSh setVarsInCsh substInFile) ], + system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ salt getVarsFromSh setVarsInSh setVarsInCsh substInFile availableRam availableMemory removeXiBSuffix) ], constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ], ); @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; @@ -325,6 +325,7 @@ sub setVarsInSh { my ($file, $l, @fields) = @_; @fields = keys %$l unless @fields; + my $b = 1; $b &&= $l->{$_} foreach @fields; $b or return; local *F; open F, "> $_[0]" or die "cannot create config file $file"; $l->{$_} and print F "$_=$l->{$_}\n" foreach @fields; @@ -333,6 +334,7 @@ sub setVarsInCsh { my ($file, $l, @fields) = @_; @fields = keys %$l unless @fields; + my $b = 1; $b &&= $l->{$_} foreach @fields; $b or return; local *F; open F, "> $_[0]" or die "cannot create config file $file"; $l->{$_} and print F "setenv $_ $l->{$_}\n" foreach @fields; @@ -409,6 +411,17 @@ sub typeFromMagic($@) { undef; } +sub availableRam() { sum map { /(\d+)/ } grep { /^(MemTotal):/ } cat_("/proc/meminfo"); } +sub availableMemory() { sum map { /(\d+)/ } grep { /^(MemTotal|SwapTotal):/ } cat_("/proc/meminfo"); } + +sub removeXiBSuffix($) { + local $_ = shift; + + /(\d+)k$/i and return $1 * 1024; + /(\d+)M$/i and return $1 * 1024 * 1024; + /(\d+)G$/i and return $1 * 1024 * 1024 * 1024; + $_; +} #-###################################################################################### #- Wonderful perl :( |