summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-12-02 20:52:37 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-12-02 20:52:37 +0000
commit58a833eef06f5ebac63dbc025c6b0dd00753bb2d (patch)
treec205db0cec57c8fec0932290aa443c73f88cb9c2 /perl-install/common.pm
parent9519d51eb29b0a5881bc859e1c2b9b3b3a8abfa6 (diff)
downloaddrakx-58a833eef06f5ebac63dbc025c6b0dd00753bb2d.tar
drakx-58a833eef06f5ebac63dbc025c6b0dd00753bb2d.tar.gz
drakx-58a833eef06f5ebac63dbc025c6b0dd00753bb2d.tar.bz2
drakx-58a833eef06f5ebac63dbc025c6b0dd00753bb2d.tar.xz
drakx-58a833eef06f5ebac63dbc025c6b0dd00753bb2d.zip
(set_alternative): simplify
(files_exist): simplify
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm38
1 files changed, 8 insertions, 30 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 37f53a1db..73d4ed9d8 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -189,39 +189,17 @@ sub join_lines {
sub set_alternative {
my ($command, $executable) = @_;
- local *F;
- # Read the list of executables for the given command to find the number
- # of the desired executable
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
- "/bin/sh -c \"export LC_ALL=C; /bin/echo | update-alternatives --config $command \" |" or
- die "Could not run \"update-alternatives\"!";
- my $choice = 0;
- while (my $line = <F>) {
- chomp $line;
- if ($line =~ m/^[\* ][\+ ]\s*([0-9]+)\s+(\S+)\s*$/) { # list entry?
- if ($2 eq $executable) {
- $choice = $1;
- last;
- }
- }
- }
- close F;
- # If the executable was found, assign the command to it
- if ($choice > 0) {
- system(($::testing ? $::prefix : "chroot $::prefix/ ") .
- "/bin/sh -c \"/bin/echo $choice | update-alternatives --config $command > /dev/null 2>&1\"");
- }
- return 1;
-}
-sub files_exist {
- my @files = @_;
- foreach my $file (@files) {
- return 0 unless -f "$::prefix$file"
- }
- return 1;
+ #- check the existance of $executable as an alternative for $command
+ #- (is this needed???)
+ run_program::rooted_get_stdout($::prefix, 'update-alternatives', '--display', $command) =~ /^\Q$executable /m or return;
+
+ #- this doesn't handle relative symlink, but neither does update-alternatives ;p
+ symlinkf $executable, "$::prefix/etc/alternatives/$command";
}
+sub files_exist { and_(map { -f "$::prefix$_" } @_) }
+
sub set_permissions {
my ($file, $perms, $owner, $group) = @_;
# We only need to set the permissions during installation to be able to