This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=e0e096046a8919a30b70d6bfd0443f25ceab3cdc

commit e0e096046a8919a30b70d6bfd0443f25ceab3cdc
Author: Guillem Jover <[email protected]>
AuthorDate: Thu Jun 25 13:28:50 2020 +0200

    Add Protected field support
    
    This field is intended to make it possible to move several of the
    current packages marked as Essential, so that they can be removed on
    installations where these do not make sense being installed.
    
    Protected packages have some of the properties of Essential, but not
    all. These are intended to be used mostly for packages that are involved
    in booting the system.
---
 Makefile.am                        |  1 +
 debian/changelog                   |  1 +
 debian/dpkg-dev.docs               |  1 +
 doc/protected-field.txt            | 74 ++++++++++++++++++++++++++++++++++++++
 lib/dpkg/dpkg-db.h                 |  2 ++
 lib/dpkg/parse.c                   |  1 +
 lib/dpkg/pkg.c                     |  1 +
 man/deb-control.pod                | 14 +++++---
 man/deb-src-control.pod            |  2 ++
 man/dpkg-query.pod                 |  2 ++
 man/dpkg.pod                       | 10 ++++++
 man/dsc.pod                        |  5 +++
 scripts/Dpkg/Control/FieldsCore.pm | 11 ++++--
 scripts/dpkg-source.pl             |  4 ++-
 scripts/t/Dpkg_Control_Fields.t    | 11 +++---
 src/archives.c                     | 25 ++++++++++---
 src/enquiry.c                      |  8 +++++
 src/force.c                        |  5 +++
 src/force.h                        |  1 +
 src/main.c                         |  3 +-
 src/main.h                         |  2 ++
 src/remove.c                       | 12 +++++--
 src/select.c                       |  4 ++-
 src/unpack.c                       |  1 +
 24 files changed, 178 insertions(+), 23 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ce184b364..2e4acce20 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,6 +48,7 @@ dist_doc_DATA = \
        doc/README.api \
        doc/README.feature-removal-schedule \
        doc/frontend.txt \
+       doc/protected-field.txt \
        doc/rootless-builds.txt \
        doc/triggers.txt \
        $(nil)
diff --git a/debian/changelog b/debian/changelog
index d4107d01b..821ed85f5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -33,6 +33,7 @@ dpkg (1.20.1) UNRELEASED; urgency=medium
   * dpkg: Add a new --robot option to be used with --version.
   * dpkg, dpkg-query: Document missing options in --help output.
   * Unify ellipsis formatting in programs --help output.
+  * Add Protected field support.
   * Portability:
     - libdpkg: When using uselocale(), include <xlocale.h> for locale_t if
       the header is available. Needed on BSDs.
diff --git a/debian/dpkg-dev.docs b/debian/dpkg-dev.docs
index 82b8ada6b..03ea9641c 100644
--- a/debian/dpkg-dev.docs
+++ b/debian/dpkg-dev.docs
@@ -1,3 +1,4 @@
 usr/share/doc/dpkg/frontend.txt
+usr/share/doc/dpkg/protected-field.txt
 usr/share/doc/dpkg/rootless-builds.txt
 usr/share/doc/dpkg/triggers.txt
diff --git a/doc/protected-field.txt b/doc/protected-field.txt
new file mode 100644
index 000000000..d98444099
--- /dev/null
+++ b/doc/protected-field.txt
@@ -0,0 +1,74 @@
+Support for a Protected field
+=============================
+
+Status: draft, experimental
+URL: https://wiki.debian.org/Teams/Dpkg/Spec/ProtectedField
+
+Summary
+-------
+
+The goal of the following proposal is to standardize a field to split
+part of the «Essential» packages, and add support for it in the package
+management stack. There is currently an Important field, that has the
+correct semantics but has a very confusing name and is only supported
+by apt anyway, so this new field would phase out that one.
+
+Background
+----------
+
+Our current use of «Essential: yes» is confused, and it includes several
+conflated things, some of which would be worth splitting up.
+
+We use «Essential» to:
+
+  * Denote that a package must be always installed and cannot be
+    removed (easily), because it is essential to the system in some way.
+  * Denote that a package must be functional even when just unpacked
+    (after having been configured once / fully bootstrapped).
+  * Mark auto-vivification, by making front-ends either complain very
+    loudly or reinstalling these packages when missing.
+  * Minimize dependency loops, by making these dependencies implicit.
+
+One problem is that the first point above includes being essential for
+the packaging system during upgrades/installation, for the operation
+of the system in general, and for the operation of the system during
+boot.
+
+The latter is not always necessary though, for example within a chroot,
+or some types of containers. There has been work on trying to trim down
+the pseudo-essential set as can be seen from:
+
+  <https://wiki.debian.org/Proposals/EssentialOnDiet>
+  <https://wiki.debian.org/BusterPriorityRequalification>
+
+And several of these switches made use of a pre-existing field called
+«Important», defined and currently only supported by apt, which had the
+following properties:
+
+  * These packages are not required to be installed.
+  * They do not have to be usable while unconfigured.
+  * Dependencies need to be spelled out.
+
+Proposal
+--------
+
+The proposal would be to add support for a new Protected field, with the
+following properties:
+
+  * Protected packages should not be trivial to remove (require a force
+    option for example, like «Essential»).
+  * Protected packages should not be required to be installed (i.e. once
+    removed they should not be automatically brought back by a front-end,
+    unlike «Essential»).
+  * Protected packages must be depended on explicitly (unlike «Essential»).
+  * Protected packages must be functional even when unpacked (think of
+    a boot loader or an init system; like «Essential»). [XXX: This one is
+    not entirely clear and might not match reality anyway, e.g. kernels,
+    which might require building an initramfs, etc.]
+
+This would make it possible to phase out the current «Important» field
+usage (because it has a name too confusing relative to the «Priority»
+value; and has small tooling coverage) and the usage of «Essential» for
+at least packages involved in the boot process, and perhaps also for
+packages essential for operation of the system in general (in contrast
+to packages required for the packaging system).
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 1ed116bd4..ed0298b9d 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -108,6 +108,8 @@ struct pkgbin {
   struct dependency *depends;
   /** The ‘essential’ flag, true = yes, false = no (absent). */
   bool essential;
+  /** The ‘protected’ flag, true = yes, false = no (absent). */
+  bool is_protected;
   enum pkgmultiarch multiarch;
   const struct dpkg_arch *arch;
   /** The following is the "pkgname:archqual" cached string, if this was a
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 6c9c1ccbd..7a1f52e8c 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -54,6 +54,7 @@ const struct fieldinfo fieldinfos[]= {
   /* Note: Capitalization of field name strings is important. */
   { FIELD("Package"),          f_name,            w_name                       
              },
   { FIELD("Essential"),        f_boolean,         w_booleandefno,   
PKGIFPOFF(essential)     },
+  { FIELD("Protected"),        f_boolean,         w_booleandefno,   
PKGIFPOFF(is_protected)  },
   { FIELD("Status"),           f_status,          w_status                     
              },
   { FIELD("Priority"),         f_priority,        w_priority                   
              },
   { FIELD("Section"),          f_section,         w_section                    
              },
diff --git a/lib/dpkg/pkg.c b/lib/dpkg/pkg.c
index 893d14e18..22bab5bca 100644
--- a/lib/dpkg/pkg.c
+++ b/lib/dpkg/pkg.c
@@ -99,6 +99,7 @@ void
 pkgbin_blank(struct pkgbin *pkgbin)
 {
        pkgbin->essential = false;
+       pkgbin->is_protected = false;
        pkgbin->depends = NULL;
        pkgbin->pkgname_archqual = NULL;
        pkgbin->description = NULL;
diff --git a/man/deb-control.pod b/man/deb-control.pod
index 053ded628..645905920 100644
--- a/man/deb-control.pod
+++ b/man/deb-control.pod
@@ -116,12 +116,18 @@ distribution policy.
 
 The approximate total size of the package's installed files, in KiB units.
 
+=item B<Protected:> B<yes>|B<no>
+
+This field is usually only needed when the answer is B<yes>.
+It denotes a package that is required for proper booting of the system.
+L<dpkg(1)> or any other installation tool will not allow a B<Protected>
+package to be removed (at least not without using one of the force options).
+
 =item B<Essential:> B<yes>|B<no>
 
-This field is usually only needed when the answer is B<yes>. It denotes
-a package that is required for proper operation of the system. Dpkg
-or any other installation tool will not allow an
-B<Essential>
+This field is usually only needed when the answer is B<yes>.
+It denotes a package that is required for proper operation of the system.
+L<dpkg(1)> or any other installation tool will not allow an B<Essential>
 package to be removed (at least not without using one of the force options).
 
 =item B<Build-Essential:> B<yes>|B<no>
diff --git a/man/deb-src-control.pod b/man/deb-src-control.pod
index 1815a2346..9f7b4121e 100644
--- a/man/deb-src-control.pod
+++ b/man/deb-src-control.pod
@@ -371,6 +371,8 @@ B<Build-Profiles> field, then this binary package is 
generated if and
 only if the condition expressed by the conjunctive normal form expression
 evaluates to true.
 
+=item B<Protected:> B<Byes>|B<no>
+
 =item B<Essential:> B<yes>|B<no>
 
 =item B<Build-Essential:> B<yes>|B<no>
diff --git a/man/dpkg-query.pod b/man/dpkg-query.pod
index b406bb4c0..d361ac97a 100644
--- a/man/dpkg-query.pod
+++ b/man/dpkg-query.pod
@@ -282,6 +282,8 @@ fields or fields stored in the binary package end up in it):
 
 =item B<Enhances>
 
+=item B<Protected>
+
 =item B<Essential>
 
 =item B<Filename> (internal, front-end related)
diff --git a/man/dpkg.pod b/man/dpkg.pod
index 0fb419a54..41e0e7fb8 100644
--- a/man/dpkg.pod
+++ b/man/dpkg.pod
@@ -440,6 +440,10 @@ Supports multi-arch fields and semantics (since dpkg 
1.16.2).
 
 Supports versioned B<Provides> (since dpkg 1.17.11).
 
+=item B<protected-field>
+
+Supports the B<Protected> field (since dpkg 1.20.1).
+
 =back
 
 =item B<--validate->I<thing string>
@@ -677,6 +681,12 @@ Remove a package, even if it's broken and marked to require
 reinstallation. This may, for example, cause parts of the package to
 remain on the system, which will then be forgotten by B<dpkg>.
 
+B<remove-protected>:
+Remove, even if the package is considered protected (since dpkg 1.20.1).
+Protected packages contain mostly important system boot infrastructure.
+Removing them might cause the whole system to be unable to boot, so use
+with caution.
+
 B<remove-essential>:
 Remove, even if the package is considered essential. Essential
 packages contain mostly very basic Unix commands. Removing them might
diff --git a/man/dsc.pod b/man/dsc.pod
index 93449d8d7..e78eff043 100644
--- a/man/dsc.pod
+++ b/man/dsc.pod
@@ -232,6 +232,11 @@ The normalized build-profile restriction formula from the 
binary package
 B<Build-Profile> field, with ORs converted to ‘+’ and ANDs to
 ‘,’.
 
+=item B<protected>
+
+If the binary package is protected, this key will contain the value of the
+B<Protected> field, that is a B<yes> value.
+
 =item B<essential>
 
 If the binary package is essential, this key will contain the value of the
diff --git a/scripts/Dpkg/Control/FieldsCore.pm 
b/scripts/Dpkg/Control/FieldsCore.pm
index f460433fc..255786fce 100644
--- a/scripts/Dpkg/Control/FieldsCore.pm
+++ b/scripts/Dpkg/Control/FieldsCore.pm
@@ -399,6 +399,10 @@ our %FIELDS = (
         name => 'Priority',
         allowed => CTRL_INFO_SRC | CTRL_INDEX_SRC | ALL_PKG,
     },
+    'protected' => {
+        name => 'Protected',
+        allowed => ALL_PKG,
+    },
     'provides' => {
         name => 'Provides',
         allowed => ALL_PKG,
@@ -609,14 +613,14 @@ our %FIELD_ORDER = (
     CTRL_PKG_DEB() => [
         qw(package package-type source version built-using kernel-version
         built-for-profiles auto-built-package architecture subarchitecture
-        installer-menu-item build-essential essential origin bugs
+        installer-menu-item build-essential essential protected origin bugs
         maintainer installed-size), @bin_dep_fields,
         qw(section priority multi-arch homepage description tag task)
     ],
     CTRL_INDEX_PKG() => [
         qw(package package-type source version built-using kernel-version
         built-for-profiles auto-built-package architecture subarchitecture
-        installer-menu-item build-essential essential origin bugs
+        installer-menu-item build-essential essential protected origin bugs
         maintainer installed-size), @bin_dep_fields,
         qw(filename size), @bin_checksums_fields,
         qw(section priority multi-arch homepage description tag task)
@@ -652,7 +656,8 @@ our %FIELD_ORDER = (
     ],
     CTRL_FILE_STATUS() => [
         # Same as fieldinfos in lib/dpkg/parse.c
-        qw(package essential status priority section installed-size origin
+        qw(package essential protected status priority section installed-size
+        origin
         maintainer bugs architecture multi-arch source version config-version
         replaces provides depends pre-depends recommends suggests breaks
         conflicts enhances conffiles description triggers-pending
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index 4dc47ab03..f803c9510 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -317,7 +317,9 @@ if ($options{opmode} =~ 
/^(build|print-format|(before|after)-build|commit)$/) {
             $profile =~ s/\s+/,/g;
             $pkg_summary .= " profile=$profile";
         }
-
+        if (defined $pkg->{'Protected'} and $pkg->{'Protected'} eq 'yes') {
+            $pkg_summary .= ' protected=yes';
+        }
         if (defined $pkg->{'Essential'} and $pkg->{'Essential'} eq 'yes') {
             $pkg_summary .= ' essential=yes';
         }
diff --git a/scripts/t/Dpkg_Control_Fields.t b/scripts/t/Dpkg_Control_Fields.t
index 8e0bd721b..84d548a87 100644
--- a/scripts/t/Dpkg_Control_Fields.t
+++ b/scripts/t/Dpkg_Control_Fields.t
@@ -20,7 +20,7 @@ use Test::More;
 use Test::Dpkg qw(:paths);
 
 BEGIN {
-    plan tests => 2438;
+    plan tests => 2460;
 
     use_ok('Dpkg::Control::Types');
     use_ok('Dpkg::Control::FieldsCore');
@@ -70,7 +70,7 @@ my %fields = (
         unordered => 1,
         fields => [
             qw(Architecture Build-Essential Build-Profiles Built-For-Profiles
-               Description Essential Homepage
+               Description Essential Protected Homepage
                Installer-Menu-Item Kernel-Version Multi-Arch
                Package Package-Type Priority Section Subarchitecture
                Tag Task), @bin_dep_fields
@@ -92,7 +92,7 @@ my %fields = (
             qw(Package Package-Type Source Version Built-Using Kernel-Version
                Built-For-Profiles Auto-Built-Package Architecture
                Subarchitecture Installer-Menu-Item
-               Build-Essential Essential Origin Bugs
+               Build-Essential Essential Protected Origin Bugs
                Maintainer Installed-Size), @bin_dep_fields,
             qw(Section Priority Multi-Arch Homepage Description Tag Task)
         ],
@@ -114,7 +114,7 @@ my %fields = (
             qw(Package Package-Type Source Version Built-Using Kernel-Version
                Built-For-Profiles Auto-Built-Package Architecture
                Subarchitecture Installer-Menu-Item
-               Build-Essential Essential Origin Bugs
+               Build-Essential Essential Protected Origin Bugs
                Maintainer Installed-Size), @bin_dep_fields, @bin_files,
             qw(Section Priority Multi-Arch Homepage Description Tag Task)
         ],
@@ -190,7 +190,8 @@ my %fields = (
     CTRL_FILE_STATUS() => {
         name => 'dpkg status',
         fields => [
-            qw(Package Essential Status Priority Section Installed-Size
+            qw(Package Essential Protected Status Priority Section
+               Installed-Size
                Origin Maintainer Bugs Architecture Multi-Arch Source
                Version Config-Version
                Replaces Provides Depends Pre-Depends
diff --git a/src/archives.c b/src/archives.c
index b147281e8..ee1ae51ed 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1246,6 +1246,19 @@ try_deconfigure_can(bool (*force_p)(struct deppossi *), 
struct pkginfo *pkg,
         return 0;
       }
     }
+    if (pkg->installed.is_protected) {
+      if (in_force(FORCE_REMOVE_PROTECTED)) {
+        warning(_("considering deconfiguration of protected\n"
+                  " package %s, to enable %s"),
+                pkg_name(pkg, pnaw_nonambig), action);
+      } else {
+        notice(_("no, %s is protected, will not deconfigure\n"
+                 " it in order to enable %s"),
+               pkg_name(pkg, pnaw_nonambig), action);
+        return 0;
+      }
+    }
+
     enqueue_deconfigure(pkg, removal);
     return 1;
   } else {
@@ -1343,11 +1356,13 @@ void check_conflict(struct dependency *dep, struct 
pkginfo *pkg,
       fixbyrm= dep->up;
       ensure_package_clientdata(fixbyrm);
     }
-    if (((pkg->available.essential && fixbyrm->installed.essential) ||
-         (((fixbyrm->want != PKG_WANT_INSTALL &&
-            fixbyrm->want != PKG_WANT_HOLD) ||
-           does_replace(pkg, &pkg->available, fixbyrm, &fixbyrm->installed)) &&
-          (!fixbyrm->installed.essential || 
in_force(FORCE_REMOVE_ESSENTIAL))))) {
+    if (((pkg->available.essential || pkg->available.is_protected) &&
+         (fixbyrm->installed.essential || fixbyrm->installed.is_protected)) ||
+        (((fixbyrm->want != PKG_WANT_INSTALL &&
+           fixbyrm->want != PKG_WANT_HOLD) ||
+          does_replace(pkg, &pkg->available, fixbyrm, &fixbyrm->installed)) &&
+         ((!fixbyrm->installed.essential || in_force(FORCE_REMOVE_ESSENTIAL)) 
||
+          (!fixbyrm->installed.is_protected || 
in_force(FORCE_REMOVE_PROTECTED))))) {
       if (fixbyrm->clientdata->istobe != PKG_ISTOBE_NORMAL &&
           fixbyrm->clientdata->istobe != PKG_ISTOBE_DECONFIGURE)
         internerr("package %s to be fixed by removal is not to be normal "
diff --git a/src/enquiry.c b/src/enquiry.c
index 4c67dffa7..b66c3ed8e 100644
--- a/src/enquiry.c
+++ b/src/enquiry.c
@@ -440,6 +440,14 @@ assertverprovides(const char *const *argv)
   return assert_version_support(argv, &version, _("versioned Provides"));
 }
 
+int
+assert_protected(const char *const *argv)
+{
+  struct dpkg_version version = { 0, "1.20.1", NULL };
+
+  return assert_version_support(argv, &version, _("Protected field"));
+}
+
 /**
  * Print a single package which:
  *  (a) is the target of one or more relevant predependencies.
diff --git a/src/force.c b/src/force.c
index 5fa005f2c..2e1fd78c9 100644
--- a/src/force.c
+++ b/src/force.c
@@ -205,6 +205,11 @@ static const struct forceinfo {
                FORCE_REMOVE_REINSTREQ,
                FORCETYPE_DAMAGE,
                N_("Remove packages which require installation"),
+       }, {
+               "remove-protected",
+               FORCE_REMOVE_PROTECTED,
+               FORCETYPE_DAMAGE,
+               N_("Remove a protected package"),
        }, {
                "remove-essential",
                FORCE_REMOVE_ESSENTIAL,
diff --git a/src/force.h b/src/force.h
index 986e7fa81..25a42fc25 100644
--- a/src/force.h
+++ b/src/force.h
@@ -53,6 +53,7 @@ enum force_flags {
        FORCE_STATOVERRIDE_ADD = DPKG_BIT(24),
        FORCE_STATOVERRIDE_DEL = DPKG_BIT(25),
        FORCE_SECURITY_MAC = DPKG_BIT(26),
+       FORCE_REMOVE_PROTECTED = DPKG_BIT(27),
        FORCE_ALL = 0xffffffff,
 };
 
diff --git a/src/main.c b/src/main.c
index 9b4fc5a04..5fa2a9f37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -128,7 +128,7 @@ usage(const struct cmdinfo *ci, const char *value)
 
   printf(_(
 "Assertable features: support-predepends, working-epoch, long-filenames,\n"
-"  multi-conrep, multi-arch, versioned-provides.\n"
+"  multi-conrep, multi-arch, versioned-provides protected-field.\n"
 "\n"));
 
   printf(_(
@@ -567,6 +567,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTION( "assert-multi-conrep",             0,  act_assertmulticonrep,    
assertmulticonrep ),
   ACTION( "assert-multi-arch",               0,  act_assertmultiarch,      
assertmultiarch ),
   ACTION( "assert-versioned-provides",       0,  act_assertverprovides,    
assertverprovides ),
+  ACTION( "assert-protected-field",          0,  act_assert_protected,     
assert_protected ),
   ACTION( "add-architecture",                0,  act_arch_add,             
arch_add        ),
   ACTION( "remove-architecture",             0,  act_arch_remove,          
arch_remove     ),
   ACTION( "print-architecture",              0,  act_printarch,            
printarch   ),
diff --git a/src/main.h b/src/main.h
index 5870c560a..e7fe820a7 100644
--- a/src/main.h
+++ b/src/main.h
@@ -98,6 +98,7 @@ enum action {
        act_assertmulticonrep,
        act_assertmultiarch,
        act_assertverprovides,
+       act_assert_protected,
 
        act_validate_pkgname,
        act_validate_trigname,
@@ -166,6 +167,7 @@ int assertlongfilenames(const char *const *argv);
 int assertmulticonrep(const char *const *argv);
 int assertmultiarch(const char *const *argv);
 int assertverprovides(const char *const *argv);
+int assert_protected(const char *const *argv);
 int validate_pkgname(const char *const *argv);
 int validate_trigname(const char *const *argv);
 int validate_archname(const char *const *argv);
diff --git a/src/remove.c b/src/remove.c
index b63d699e1..38657ba34 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -125,9 +125,14 @@ void deferred_remove(struct pkginfo *pkg) {
     return;
   }
 
-  if (pkg->installed.essential && pkg->status != PKG_STAT_CONFIGFILES)
-    forcibleerr(FORCE_REMOVE_ESSENTIAL,
-                _("this is an essential package; it should not be removed"));
+  if (pkg->status != PKG_STAT_CONFIGFILES) {
+    if (pkg->installed.essential)
+      forcibleerr(FORCE_REMOVE_ESSENTIAL,
+                  _("this is an essential package; it should not be removed"));
+    if (pkg->installed.is_protected)
+      forcibleerr(FORCE_REMOVE_PROTECTED,
+                  _("this is a protected package; it should not be removed"));
+  }
 
   debug(dbg_general, "checking dependencies for remove '%s'",
         pkg_name(pkg, pnaw_always));
@@ -378,6 +383,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
 
     pkg_set_status(pkg, PKG_STAT_CONFIGFILES);
     pkg->installed.essential = false;
+    pkg->installed.is_protected = false;
     modstatdb_note(pkg);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
 }
diff --git a/src/select.c b/src/select.c
index 5c8b16814..8ff392938 100644
--- a/src/select.c
+++ b/src/select.c
@@ -228,7 +228,9 @@ clearselections(const char *const *argv)
 
   iter = pkg_hash_iter_new();
   while ((pkg = pkg_hash_iter_next_pkg(iter))) {
-    if (!pkg->installed.essential && pkg->want != PKG_WANT_UNKNOWN)
+    if (!pkg->installed.essential &&
+        !pkg->installed.is_protected &&
+        pkg->want != PKG_WANT_UNKNOWN)
       pkg_set_want(pkg, PKG_WANT_DEINSTALL);
   }
   pkg_hash_iter_free(iter);
diff --git a/src/unpack.c b/src/unpack.c
index 23425c5dc..4a143666e 100644
--- a/src/unpack.c
+++ b/src/unpack.c
@@ -772,6 +772,7 @@ pkg_update_fields(struct pkginfo *pkg, struct 
fsys_namenode_queue *newconffiles)
 
   /* We copy the text fields. */
   pkg->installed.essential = pkg->available.essential;
+  pkg->installed.is_protected = pkg->available.is_protected;
   pkg->installed.multiarch = pkg->available.multiarch;
   pkg->installed.description = pkg->available.description;
   pkg->installed.maintainer = pkg->available.maintainer;

-- 
Dpkg.Org's dpkg

Reply via email to