This is a request to upstream a patch that I am proposing to the Yocto / OpenEmbedded core projects. In the context of those projects, dpkg is run in an unusual environment for cross-development/installs. In this environment the location of what is normally the /etc/dpkg/dpkg.d directory can, in unusual circumstances be invalid. The other important paths are all passed as command line parameters instead.
This patch removes the error and message when /etc/dpkg/dpkg.d is missing and instead acts the same as if it were empty. This works around the conditions where the directory may be missing in an predictable sysroot cross environment. It appears that this directory is often empty, so there seems little reason to provide an error if the directory itself is missing in the first place. Text of the Yocto/OE patch email below: The dpkg binary contains a hard-coded CONFIGDIR path which normally points to /etc/dpkg. However, if /etc/dpkg/dpkg.cfg.d doesn't exist (ENOTDIR) it fails with an error, even though it does not fail when the directory exists but is empty (ENOENT). Normally this is not an issue, but when dpkg-native is built, CONFIGDIR points to a directory in the sysroot under work. If that binary is later cached in the sstate-cache and mirrored to another host that does not contain the same work directory, the dpkg binary fails due to this missing directory during certain packaging steps involving apt-get. This "leaks" information about the build host into the sstate-cache in an unintended way that causes a failure. The dpkg utility does not currently allow a command line or environment override of CONFIGDIR, so this patches dpkg so that a missing directory is the same as an empty one and the failure is avoided. The dpkg-native is always passed command line arguments and does not need, nor contain, any configuration data in this directory in the first place. Signed-off-by: Anders Oleson <[email protected]> Index: dpkg-1.18.7/lib/dpkg/options.c =================================================================== --- dpkg-1.18.7.orig/lib/dpkg/options.c +++ dpkg-1.18.7/lib/dpkg/options.c @@ -172,11 +172,8 @@ dpkg_options_load_dir(const char *prog, dlist_n = scandir(dirname, &dlist, valid_config_filename, alphasort); if (dlist_n < 0) { - if (errno == ENOENT) { free(dirname); return; - } else - ohshite(_("error opening configuration directory '%s'"), dirname); } for (i = 0; i < dlist_n; i++) {

