Просмотр исходного кода

* Fixed the check that was added to dpkg-divert.
* Removed the lib version checking.
* Oops, somehow the --config feature went missing from update-
alternatives

Ben Collins лет назад: 27
Родитель
Сommit
b8a68bfb19
4 измененных файлов с 60 добавлено и 5 удалено
  1. 7 0
      ChangeLog
  2. 0 3
      debian/changelog
  3. 5 1
      scripts/dpkg-divert.pl
  4. 48 1
      scripts/update-alternatives.pl

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+Thu Oct 21 10:22:43 EDT 1999 Ben Collins <bcollins.debian.org>
+
+  * 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 <wakkerma@debian.org>
 
   * Update copyright (taken from dpkg-iwj tree, with Ben added)

+ 0 - 3
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

+ 5 - 1
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");

+ 48 - 1
scripts/update-alternatives.pl

@@ -16,6 +16,7 @@ Usage: update-alternatives --install <link> <name> <path> <priority>
        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>.
@@ -66,7 +67,7 @@ while (@ARGV) {
         @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;
@@ -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=<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])");