From b8a68bfb194b6d99fbb14804abb2853414dbd288 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Thu, 21 Oct 1999 15:38:03 +0000 Subject: [PATCH] * Fixed the check that was added to dpkg-divert. * Removed the lib version checking. * Oops, somehow the --config feature went missing from update- alternatives --- ChangeLog | 7 +++++ debian/changelog | 3 --- scripts/dpkg-divert.pl | 6 ++++- scripts/update-alternatives.pl | 49 +++++++++++++++++++++++++++++++++- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69c255d6..3f5b2b40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Oct 21 10:22:43 EDT 1999 Ben Collins + + * Fixed the check that was added to dpkg-divert. + * Removed the lib version checking. + * Oops, somehow the --config feature went missing from update- + alternatives + Thu Oct 21 13:22:42 CEST 1999 Wichert Akkerman * Update copyright (taken from dpkg-iwj tree, with Ben added) diff --git a/debian/changelog b/debian/changelog index 82527e47..51a60657 100644 --- a/debian/changelog +++ b/debian/changelog @@ -52,9 +52,6 @@ dpkg (1.4.1.17) unstable; urgency=low say it's installed, and not that it is in an unconfigurable state * Fixed some compiler warnings - * Add function to libdpkg that dpkg can call to make sure it's - compiled version matches that of the library. If it fails, - complain loudly, but allow to proceed * Make dpkg check for uid 0 requirement, before checking the path since not being root, is probably the reason that the PATH is borked in the first place diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index 9728ec88..f8252373 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -183,8 +183,12 @@ sub checkrename { (@sdest= lstat($rdest)) || $! == &ENOENT || &quit("cannot stat new name \`$rdest': $!"); $exist{$rdest} = 1 unless $! != &ENOENT; + # Unfortunately we have to check for write access in both + # places, just having +w is not enough, since people do + # mount things RO, and we need to fail before we start + # mucking around with things foreach $file ($rsrc,$rdest) { - open (TMP, "a $file") || &quit("error checking \`$file': $!"); + open (TMP, ">> $file") || &quit("error checking \`$file': $!"); close TMP; if ($exist{$file} == 1) { unlink ("$file"); diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl index 28392846..cf948473 100755 --- a/scripts/update-alternatives.pl +++ b/scripts/update-alternatives.pl @@ -16,6 +16,7 @@ Usage: update-alternatives --install update-alternatives --remove update-alternatives --auto update-alternatives --display + update-alternatives --config is the name in /etc/alternatives. is the name referred to. is the link pointing to /etc/alternatives/. @@ -66,7 +67,7 @@ while (@ARGV) { @ARGV >= 2 || &badusage("--remove needs "); ($name,$apath,@ARGV) = @ARGV; $mode= 'remove'; - } elsif (m/^--(display|auto)$/) { + } elsif (m/^--(display|auto|config)$/) { &checkmanymodes; @ARGV || &badusage("--$1 needs "); $mode= $1; @@ -173,6 +174,15 @@ for ($i=0; $i<=$#versions; $i++) { } } +if ($mode eq 'config') { + if (!$dataread) { + &pr("No alternatives for $name."); + } else { + &config_alternatives($name); + exit 0; + } +} + if (defined($linkname= readlink("$altdir/$name"))) { if ($linkname eq $best) { $state= 'expected'; @@ -422,6 +432,43 @@ if ($manual eq 'auto') { } } +sub config_message { + if ($#versions == 0) { + print "\nThere is only 1 program which provides $name\n"; + print "($versions[0]). Nothing to configure.\n"; + return; + } + printf(STDOUT "\nThere are %s programs which provide \`$name'.\n\n", $#versions+1); + printf(STDOUT " Selection Command\n"); + printf(STDOUT "-----------------------------------------------\n"); + for ($i=0; $i<=$#versions; $i++) { + if ($best eq $versions[$i]) { + printf(STDOUT "* %s %s\n", $i+1, $versions[$i]); + } else { + printf(STDOUT " %s %s\n", $i+1, $versions[$i]); + } + } + printf(STDOUT "\nEnter to keep the default[*], or type selection number: "); +} + +sub config_alternatives { + do { + &config_message; + if ($#versions == 0) { return; } + $preferred=; + chop($preferred); + } until $preferred eq '' || $preferred>=1 && $preferred<=$#versions+1 && + ($preferred =~ m/[0-9]*/); + if ($preferred ne '') { + $preferred--; + my $spath = $versions[$preferred]; + symlink("$spath","$altdir/$name.dpkg-tmp") || + &quit("unable to make $altdir/$name.dpkg-tmp a symlink to $spath: $!"); + rename_mv("$altdir/$name.dpkg-tmp","$altdir/$name") || + &quit("unable to install $altdir/$name.dpkg-tmp as $altdir/$name: $!"); + } +} + sub pr { print(STDOUT "@_\n") || &quit("error writing stdout: $!"); } sub paf { $_[0] =~ m/\n/ && &quit("newlines prohibited in update-alternatives files ($_[0])"); -- 2.39.5