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=6778b59ea0ec176000ed2ff0c7d4cdc72326f9ec

commit 6778b59ea0ec176000ed2ff0c7d4cdc72326f9ec
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Jun 27 15:32:15 2020 +0200

    u-a: Create alternatives directory if missing
    
    This will help with installation bootstrapping when dpkg has not yet
    been unpacked, or when using chroot style installations. Otherwise on
    normal operation this should never trigger.
    
    Reported-by: Johannes Schauer <[email protected]>
---
 debian/changelog            |  3 +++
 utils/update-alternatives.c | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index fce34bc71..f3d0250a3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
 dpkg (1.20.2) UNRELEASED; urgency=medium
 
   * dpkg: Do not include the architecture with --robot --version.
+  * update-alternatives: Create alternatives directory (/etc/alternatives)
+    if it is missing, to help with installation bootstrapping.
+    Reported by Johannes Schauer <[email protected]>.
   * Build system:
     - Set SHELL in the test environment.
     - Do not fail if po4a is not found, and search for it just once.
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index b4b2292c2..9b26552d2 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1916,6 +1916,17 @@ alternative_prepare_install_single(struct alternative 
*a, const char *name,
 {
        char *fntmp, *fn;
 
+       /* Create alternatives directory (/etc/alternatives) if missing. */
+       if (fsys_pathname_is_missing(altdir)) {
+               char *root_altdir = fsys_get_path(altdir);
+
+               if (make_path(root_altdir, 0755) < 0)
+                       syserr(_("cannot create alternatives directory '%s'"),
+                              root_altdir);
+
+               free(root_altdir);
+       }
+
        /* Create link in /etc/alternatives. */
        fntmp = xasprintf("%s/%s" ALT_TMP_EXT, altdir, name);
        fn = xasprintf("%s/%s", altdir, name);

-- 
Dpkg.Org's dpkg

Reply via email to