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
(@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");
update-alternatives --remove <name> <path>
update-alternatives --auto <name>
update-alternatives --display <name>
+ update-alternatives --config <name>
<name> is the name in /etc/alternatives.
<path> is the name referred to.
<link> is the link pointing to /etc/alternatives/<name>.
@ARGV >= 2 || &badusage("--remove needs <name> <path>");
($name,$apath,@ARGV) = @ARGV;
$mode= 'remove';
- } elsif (m/^--(display|auto)$/) {
+ } elsif (m/^--(display|auto|config)$/) {
&checkmanymodes;
@ARGV || &badusage("--$1 needs <name>");
$mode= $1;
}
}
+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';
}
}
+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=<STDIN>;
+ 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])");