[Debconf-devel] Bug#989567: debconf.postinst is completely unnecessary unless upgrading from pre-etch

Helmut Grohne helmut at subdivi.de
Fri Jun 11 06:14:29 BST 2021


Hi Chris,

On Thu, Jun 10, 2021 at 08:30:55PM +0200, Chris Hofstaedtler wrote:
> * Helmut Grohne <helmut at subdivi.de> [210610 18:30]:
> [..]
> > -			/usr/share/debconf/transition_db.pl
> > -		/usr/share/debconf/fix_db.pl
> 
> From a very quick look, these scripts could also then be removed,
> possibly?

I fully concur. Thank you. Patch updated.

Helmut
-------------- next part --------------
diff --minimal -Nru debconf-1.5.76/Makefile debconf-1.5.76+nmu1/Makefile
--- debconf-1.5.76/Makefile	2021-03-20 14:14:50.000000000 +0100
+++ debconf-1.5.76+nmu1/Makefile	2021-06-07 20:02:34.000000000 +0200
@@ -63,7 +63,6 @@
 	# Other libs and helper stuff.
 	install -m 0644 confmodule.sh confmodule $(prefix)/usr/share/debconf/
 	install frontend $(prefix)/usr/share/debconf/
-	install -m 0755 transition_db.pl fix_db.pl $(prefix)/usr/share/debconf/
 	# Install essential programs.
 	install -d $(prefix)/usr/sbin $(prefix)/usr/bin
 	find . -maxdepth 1 -perm /100 -type f -name 'dpkg-*' | \
diff --minimal -Nru debconf-1.5.76/debian/changelog debconf-1.5.76+nmu1/debian/changelog
--- debconf-1.5.76/debian/changelog	2021-03-20 14:14:50.000000000 +0100
+++ debconf-1.5.76+nmu1/debian/changelog	2021-06-07 20:02:34.000000000 +0200
@@ -1,3 +1,11 @@
+debconf (1.5.76+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Delete debconf postinst script and associated scripts as they only handle
+    upgrades from pre-etch.  (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Mon, 07 Jun 2021 20:02:34 +0200
+
 debconf (1.5.76) unstable; urgency=medium
 
   [ Colin Watson ]
diff --minimal -Nru debconf-1.5.76/debian/postinst debconf-1.5.76+nmu1/debian/postinst
--- debconf-1.5.76/debian/postinst	2021-03-20 14:14:50.000000000 +0100
+++ debconf-1.5.76+nmu1/debian/postinst	1970-01-01 01:00:00.000000000 +0100
@@ -1,72 +0,0 @@
-#!/bin/sh
-set -e
-
-if [ -z "$DEBIAN_HAS_FRONTEND" ] && [ "$1" = configure ] && [ -n "$2" ] && \
-   dpkg --compare-versions "$2" lt 1.1.0; then
-	# Transition from old database format before debconf starts up.
-	if dpkg --compare-versions "$2" lt 0.9.00; then
-		if [ -e /var/lib/debconf/config.db -o -e /var/lib/debconf/templates.db ]; then
-			/usr/share/debconf/transition_db.pl
-		fi
-		# This package used to add itself to apt.conf. That could result in
-		# a zero-byte file, since it no longer does. Detect that and remove
-		# the file.
-		if [ ! -s /etc/apt/apt.conf ]; then
-			rm -f /etc/apt/apt.conf
-		fi
-	fi
-	
-	# Fix up broken db's before debconf starts up.
-	if dpkg --compare-versions "$2" lt 1.0.25; then
-		/usr/share/debconf/fix_db.pl
-	fi
-	
-	# configdb splits into passworded and non-passworded parts, before debconf
-	# starts up. Do so only if the debconf.conf has the new databases in it.
-	if dpkg --compare-versions "$2" lt 1.1.0 &&
-	   perl -e 'use Debconf::Db; Debconf::Db->load; for (@ARGV) { exit 1 unless
-	            Debconf::DbDriver->driver($_) }' config passwords; then
-	   	# copies in only the passwords, of course
-	   	debconf-copydb config passwords
-		# makes a new config with only non-passwords in it
-		debconf-copydb config newconfig \
-			-c Name:newconfig \
-			-c Driver:File \
-			-c Reject-Type:password \
-			-c Filename:/var/cache/debconf/newconfig.dat \
-			-c Mode:644
-		mv -f /var/cache/debconf/newconfig.dat /var/cache/debconf/config.dat
-	fi
-fi
-
-. /usr/share/debconf/confmodule
-
-if [ "$1" = configure ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt 1.3.11; then
-	# Remove old debconf database, and associated cruft in /var/lib/debconf.
-	# In fact, the whole directory can go! Earlier versions of debconf in the
-	# 0.9.x series kept it just in case, so make sure to delete it on upgrade
-	# from any of those versions, or even older versions.
-	if dpkg --compare-versions "$2" lt 0.9.50; then
-		rm -rf /var/lib/debconf
-	fi
-
-	# Kill db cruft.
-	if dpkg --compare-versions "$2" lt 0.9.73; then
-		# It may not be present, if upgrading from long ago.
-		db_unregister foo/bar || true
-		db_unregister debconf/switch-to-slang || true
-	fi
-	if dpkg --compare-versions "$2" lt 1.3.11; then
-		db_unregister debconf/showold || true
-	fi
-
-	# The Text frontend became the Readline frontend.
-	if dpkg --compare-versions "$2" lt 1.0.10; then
-		db_get debconf/frontend || true
-		if [ "$RET" = Text ]; then
-			db_set debconf/frontend Readline || true
-		fi
-	fi
-fi
-
-#DEBHELPER#
diff --minimal -Nru debconf-1.5.76/fix_db.pl debconf-1.5.76+nmu1/fix_db.pl
--- debconf-1.5.76/fix_db.pl	2021-03-20 14:14:50.000000000 +0100
+++ debconf-1.5.76+nmu1/fix_db.pl	1970-01-01 01:00:00.000000000 +0100
@@ -1,97 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-use Debconf::Db;
-use Debconf::Log q{warn};
-
-Debconf::Db->load;
-
-if (! @ARGV || $ARGV[0] ne 'end') {
-	# These actions need to be repeated until the db is consistent.
-	my $fix=0;
-	my $ok;
-	my $counter=0;
-	do {
-		$ok=1;
-	
-		# There is no iterator method in the templates object, so I will do
-		# some nasty hacking to get them all. Oh well. Nothing else needs to 
-		# iterate templates..
-		my %templates=();
-		my $ti=$Debconf::Db::templates->iterator;
-		while (my $t=$ti->iterate) {
-			$templates{$t}=Debconf::Template->get($t);
-		}
-	
-		my %questions=();
-		my $qi=Debconf::Question->iterator;
-		while (my $q=$qi->iterate) {
-			# I have seen instances where a question would have no associated
-			# template field. Always a bug.
-			if (! defined $q->template) {
-				warn "question \"".$q->name."\" has no template field; removing it.";
-				$q->addowner("killme",""); # make sure it has one owner at least, so removal is triggered
-				foreach my $owner (split(/, /, $q->owners)) {
-					$q->removeowner($owner);
-				}
-				$ok=0;
-				$fix=1;
-			}
-			elsif (! exists $templates{$q->template->template}) {
-				warn "question \"".$q->name."\" uses nonexistant template ".$q->template->template."; removing it.";
-				foreach my $owner (split(/, /, $q->owners)) {
-					$q->removeowner($owner);
-				}
-				$ok=0;
-				$fix=1;
-			}
-			else {
-				$questions{$q->name}=$q;
-			}
-		}
-		
-		# I had a report of a templates db that had templates that claimed to
-		# be owned by their matching questions -- but the questions didn't exist!
-		# Check for such a thing.
-		foreach my $t (keys %templates) {
-			# Object has no owners method (not otherwise needed), so I'll do 
-			# some nasty grubbing.
-			my @owners=$Debconf::Db::templates->owners($t);
-			if (! @owners) {
-				warn "template \"$t\" has no owners; removing it.";
-				$Debconf::Db::templates->addowner($t, "killme","");
-				$Debconf::Db::templates->removeowner($t, "killme");
-				$fix=1;
-			}
-			foreach my $q (@owners) {
-				if (! exists $questions{$q}) {
-					warn "template \"$t\" claims to be used by nonexistant question \"$q\"; removing that.";
-					$Debconf::Db::templates->removeowner($t, $q);
-					$ok=0;
-					$fix=1;
-				}
-			}
-		}
-		$counter++;
-	} until ($ok || $counter > 20);
-
-	# If some fixes were done, save them and then fork a new process
-	# to do the final fixes. Seems to be necessary to do this is the db was
-	# really screwed up.
-	if ($fix) {
-		Debconf::Db->save;
-		exec($0, "end");
-		die "exec of self failed";
-	}
-}
-
-# A bug in debconf between 0.5.x and 0.9.79 caused some shared templates
-# owners to not be registered. The fix is nasty; we have to load up all
-# templates belonging to all installed packages all over again.
-# This also means that if any of the stuff above resulted in a necessary
-# question and template being deleted, it will be reinstated now.
-foreach my $templatefile (glob("/var/lib/dpkg/info/*.templates")) {
-	my ($package) = $templatefile =~ m:/var/lib/dpkg/info/(.*?).templates:;
-        Debconf::Template->load($templatefile, $package);
-}
-
-Debconf::Db->save;
diff --minimal -Nru debconf-1.5.76/transition_db.pl debconf-1.5.76+nmu1/transition_db.pl
--- debconf-1.5.76/transition_db.pl	2021-03-20 14:14:50.000000000 +0100
+++ debconf-1.5.76+nmu1/transition_db.pl	1970-01-01 01:00:00.000000000 +0100
@@ -1,116 +0,0 @@
-#!/usr/bin/perl -w
-# Disgusting hack to transition from debconf's even more disgusting old
-# database to its nice bright sparkling new one.
-use strict;
-use Debconf::Db;
-use Debconf::Question;
-use Debconf::Template;
-
-my $dir = shift || '/var/lib/debconf';
-
-Debconf::Db->load;
-
-our %questions;
-our %templates;
-
-# Load order is important.
-foreach my $thing (qw(templates debconf)) {
-	if (-e "$dir/$thing.db") {
-		eval qq{require "$dir/$thing.db"};
-		print STDERR $@ if $@;
-	}
-	else {
-		print STDERR "Skipping $dir/$thing.db: DNE\n";
-	}
-}
-
-# So this is a bitch. In the questions objects, there are things like
-# template' => $templates{'apt-setup/security-updates-failed'}
-# Well, I want the template *name*, not a ref to it. But there is no way at
-# all to go from the name to a ref except for walking the whole hash.
-# Instead of doing that below, add some _name fields to the templates hash
-# that contain their names.
-foreach my $t (keys %templates) {
-	$templates{$t}->{_name}=$t;
-}
-
-my $skipped=0;
-
-# Now make new Question objects for all the questions.
-foreach my $item (keys %questions) {
-	my @owners=grep { $_ ne '' } keys %{$questions{$item}->{owners}};
-	delete $questions{$item}, next unless @owners;
-
-	# Skip questions that have no listed owner.
-	next unless defined $questions{$item}->{template}->{_name};
-
-	# ->new needs to know the type of the question, which is stored in
-	# its associated template.
-	my $tname=$questions{$item}->{template}->{_name};
-	$skipped++, next unless defined $tname;
-	my $type=$templates{$tname}->{type};
-	my $question=Debconf::Question->new($item, pop(@owners), $type);
-	$question->addowner($_, '') foreach @owners;
-}
-
-# Now that all the Question objects are made, we can fill them in.
-# Have to do it in two passes to prevent duplicate questions trying to 
-# be made. This converts the templates too.
-my %seen_templates;
-foreach my $item (keys %questions) {
-	my $question=Debconf::Question->get($item);
-	# Make sure that the template used by this item exists.
-	my $tname=$questions{$item}->{template}->{_name};
-	# I'm not sure why, but some db's have undef templates.
-	$skipped++, next unless defined $tname;
-	my $template=Debconf::Template->get($tname);
-	unless (defined $template) {
-		$template=Debconf::Template->new($tname, $item, $templates{$tname}->{type});
-	}
-	unless ($seen_templates{$template}) {
-		# Delete every existing field, and then copy every field into
-		# it. I do this even if it already exists, because for all I
-		# know a db is being imported over top of a failed import or
-		# a different db.
-		$template->clearall;
-		foreach my $field (keys %{$templates{$tname}}) {
-			next if $field=~/^_name/; # except this one we added above.
-			$template->$field($templates{$tname}->{$field});
-		}
-	}
-	
-	# Copy over all significant values to the question.
-
-	# This old flag morphs into the seen flag, inverting meaning.
-	if (exists $questions{$item}->{flag_isdefault}) {
-		if ($questions{$item}->{flag_isdefault} eq 'false') {
-		    	$question->flag('seen', 'true');
-		}
-		delete $questions{$item}->{flag_isdefault};
-	}
-	# All other flags.
-	foreach my $flag (grep /^flag_/, keys %{$questions{$item}}) {
-		if ($questions{$item}->{$flag} eq 'true') {
-			$flag=~s/^flag_//;
-			$question->flag($flag, 'true');
-		}
-	}
-	# All variables.
-	foreach my $var (keys %{$questions{$item}->{variables}}) {
-		$question->variable($var,
-			$questions{$item}->{variables}->{$var});
-	}
-	if (exists $questions{$item}->{value} 
-		and defined $questions{$item}->{value}) {
-		$question->value($questions{$item}->{value});
-	}
-
-	# And finally, set its template.
-	$question->template($questions{$item}->{template}->{_name});
-}
-
-Debconf::Db->save;
-
-if ($skipped) {
-	print STDERR "While upgrading the debconf database, $skipped corrupt items were skipped.\n";
-}


More information about the Debconf-devel mailing list