Procházet zdrojové kódy

dpkg: Always spawn a new shell on conffile prompt

Stop supporting self backgrounding, remove DPKG_NO_TSTP environment
variable support, as we always spawn a shell now.

This will allow setting useful environment variables for the user to use
with other tools. And is less confusing, as the action to go back to
dpkg does not depend on how dpkg was run.

Closes: #38334
Guillem Jover před 16 roky
rodič
revize
6f037003e8
6 změnil soubory, kde provedl 30 přidání a 39 odebrání
  1. 0 2
      TODO
  2. 3 0
      debian/changelog
  3. 7 0
      doc/README.feature-removal-schedule
  4. 0 1
      lib/dpkg/dpkg.h
  5. 1 5
      man/dpkg.1
  6. 19 31
      src/configure.c

+ 0 - 2
TODO

@@ -91,8 +91,6 @@ TODO
    automatically.
    - Support for output format. (#214566)
 
- * Remove conffile background support? (#38334)
-
  * Propagate --admindir to programs run from maintainer scritpts. (#97076)
 
  * Fix conflicting action -%c, when short is 0.

+ 3 - 0
debian/changelog

@@ -95,6 +95,9 @@ dpkg (1.15.6) UNRELEASED; urgency=low
   * Change dpkg-dev to Depend on perl instead of perl5 and perl-modules.
   * Fix small memory leaks related to scandir() in dpkg-deb and libdpkg.
   * Fix dpkg-query and dpkg-trigger to actually print a version on --version.
+  * Always spawn a new shell on conffile prompt, instead of supporting
+    self backgrounding, remove DPKG_NO_TSTP environment variable support.
+    Closes: #38334
 
   [ Modestas Vainius ]
   * Implement symbol patterns (Closes: #563752). From now on, it is possible to

+ 7 - 0
doc/README.feature-removal-schedule

@@ -98,4 +98,11 @@ Why:
  Custom changelog parsers must be updated to support the new API (see
  dpkg-parsechangelog(1) and README.api).
 
+What: support for environment variable DPKG_NO_TSTP
+Status: removed
+Since: 1.15.6
+Why:
+ Having two ways to let the administrator get to a shell on conffile prompt
+ is confusing, it also difficults setting up a consistent environment to be
+ used by external programs.
 

+ 0 - 1
lib/dpkg/dpkg.h

@@ -87,7 +87,6 @@ DPKG_BEGIN_DECLS
 #define MAINTSCRIPTARCHENVVAR "DPKG_MAINTSCRIPT_ARCH"
 #define MAINTSCRIPTDPKGENVVAR "DPKG_RUNNING_VERSION"
 
-#define NOJOBCTRLSTOPENV    "DPKG_NO_TSTP"
 #define SHELLENV            "SHELL"
 #define DEFAULTSHELL        "sh"
 #define PAGERENV            "PAGER"

+ 1 - 5
man/dpkg.1

@@ -1,4 +1,4 @@
-.TH dpkg 1 "2009-11-12" "Debian Project" "dpkg suite"
+.TH dpkg 1 "2010-02-20" "Debian Project" "dpkg suite"
 .SH NAME
 dpkg \- package manager for Debian
 .
@@ -613,10 +613,6 @@ for more information about them:
 .
 .SH ENVIRONMENT VARIABLES
 .TP
-.B DPKG_NO_TSTP
-Define this to something if you prefer \fBdpkg\fP starting a new
-shell rather than suspending itself, while doing a shell escape.
-.TP
 .B SHELL
 The program \fBdpkg\fP will execute when starting a new shell.
 .TP

+ 19 - 31
src/configure.c

@@ -57,7 +57,6 @@ static int conffoptcells[2][2] = {
 
 static void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn);
 static void showdiff(const char *old, const char *new);
-static void suspend(void);
 static enum conffopt promptconfaction(struct pkginfo *pkg, const char *cfgfile,
                                       const char *realold, const char *realnew,
                                       int useredited, int distedited,
@@ -516,44 +515,33 @@ showdiff(const char *old, const char *new)
 }
 
 /**
- * Suspend dpkg temporarily.
+ * Spawn a new shell.
  *
- * Either create a subprocess and execute a shell or background the current
- * process to allow the user to manually solve the conffile conflict.
+ * Create a subprocess and execute a shell to allow the user to manually
+ * solve the conffile conflict.
  */
 static void
-suspend(void)
+spawn_shell(void)
 {
-	const char *env;
 	pid_t pid;
 
-	env = getenv(NOJOBCTRLSTOPENV);
-	if (env && *env) {
-		/* Do not job control to suspend but fork and start a new
-		 * shell instead. */
+	fputs(_("Type `exit' when you're done.\n"), stderr);
 
-		fputs(_("Type `exit' when you're done.\n"), stderr);
-
-		pid = subproc_fork();
-		if (!pid) {
-			/* Child process */
-			const char *shell;
-
-			shell = getenv(SHELLENV);
-			if (!shell || !*shell)
-				shell = DEFAULTSHELL;
+	pid = subproc_fork();
+	if (!pid) {
+		/* Child process */
+		const char *shell;
 
-			execlp(shell, shell, "-i", NULL);
-			ohshite(_("failed to exec shell (%.250s)"), shell);
-		}
+		shell = getenv(SHELLENV);
+		if (!shell || !*shell)
+			shell = DEFAULTSHELL;
 
-		/* Parent process. */
-		subproc_wait(pid, "shell");
-	} else {
-		fputs(_("Don't forget to foreground (`fg') this "
-		        "process when you're done !\n"), stderr);
-		kill(-getpgid(0), SIGTSTP);
+		execlp(shell, shell, "-i", NULL);
+		ohshite(_("failed to exec shell (%.250s)"), shell);
 	}
+
+	/* Parent process. */
+	subproc_wait(pid, "shell");
 }
 
 /**
@@ -653,7 +641,7 @@ promptconfaction(struct pkginfo *pkg, const char *cfgfile,
 		          "    Y or I  : install the package maintainer's version\n"
 		          "    N or O  : keep your currently-installed version\n"
 		          "      D     : show the differences between the versions\n"
-		          "      Z     : background this process to examine the situation\n"));
+		          "      Z     : start a shell to examine the situation\n"));
 
 		if (what & cfof_keep)
 			fprintf(stderr, _(" The default action is to keep your current version.\n"));
@@ -698,7 +686,7 @@ promptconfaction(struct pkginfo *pkg, const char *cfgfile,
 			showdiff(realold, realnew);
 
 		if (cc == 'z')
-			suspend();
+			spawn_shell();
 	} while (!strchr("yino", cc));
 
 	log_message("conffile %s %s", cfgfile,