[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#51807: update-alternatives --config does not handle slaves



Package: dpkg
Version: 1.6.1
Severity: normal

Hi Wichert, Ben, whoever ;)

I just installed the current dpkg package. Great work! 

Anyway, I found a bug in update-alternatives: The --config command does 
not update the slave links. I attached a patch which works for me. Could 
you please apply this to the next dpkg?

Thanks
	Torsten
--- /usr/sbin/update-alternatives	Fri Nov 26 20:24:47 1999
+++ update-alternatives	Thu Dec  2 20:27:27 1999
@@ -96,6 +96,23 @@
 $mode || &badusage("need --display, --install, --remove or --auto");
 $mode eq 'install' || !%slavelink || &badusage("--slave only allowed with --install");
 
+# Global variables set up in the following loop:
+#   $manual:	 Either "auto" or "manual" - state of the alternative
+#   $link:	 Name of the link managed as alternative (e.g. /usr/bin/editor)
+#   @slavenames: The list of slave alternatives
+#		 (e.g. "editor.1.gz", "editor.conf")
+#   %slavenum:   Maps the name of a slave to its slave number
+#		 ($slavenum{editor.1.gz} would be 0)
+#   @slavelinks: The list of slave links indexed by number
+#		 (e.g. $slavelinks[0] == "/usr/share/man/man1/editor.1.gz")
+
+#   @versions:   The names of the alternative versions
+#		 (e.g. "/usr/bin/elvis", "/usr/bin/vim", "/usr/bin/emacs")
+#   %versionnum: Maps the name of a version to its version number
+#		 (e.g. $versionnum{/usr/bin/vim} == 1)
+#   %slavepath:  Maps the version and slave numbers to the alt. path
+#                (e.g. $slavepath{2,0} == "/usr/share/man/man1/emacs.1.gz")
+
 if (open(AF,"$admindir/$name")) {
     $manual= &gl("manflag");
     $manual eq 'auto' || $manual eq 'manual' || &badfmt("manflag");
@@ -466,6 +483,13 @@
 	    &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: $!");
+	# Link slaves...
+	for( my $slnum = 0; $slnum < @slavenames; $slnum++ ) {
+	    my $slave = $slavenames[$slnum];
+	    checked_symlink($slavepath{$preferred,$slnum}, 
+	                    "$altdir/$slave.dpkg-tmp");
+	    checked_mv("$altdir/$slave.dpkg-tmp", "$altdir/$slave");
+	}
     }
 }
 
@@ -485,5 +509,15 @@
 }
 sub rename_mv {
 	return (rename($_[0], $_[1]) || (system(("mv", $_[0], $_[1])) == 0));
+}
+sub checked_symlink {
+	my ($filename, $linkname) = @_;
+	symlink($filename, $linkname) ||
+	    &quit("unable to make $linkname a symlink to $filename: $!");
+}
+sub checked_mv {
+        my ($source, $dest) = @_;
+	rename_mv($source, $dest) ||
+	    &quit("unable to install $source as $dest: $!");
 }
 exit(0);

Reply to: