From: Nevo Hed <
nhed+...@starry.com>
The data archive may contain an entry for the root dir.
70df4de added code to strip trailing slashes, and for the root dir a
single slash is removed, yielding an blank line in the middle of the
pkg.list.
An empty line in the listing would cause a subsequent install to emit
error logs (at end).
This change replaces a lone path of "/" with "/." (as observed in dpkg).
Sample log (with my added quotes):
---------------
Reinstalling iputils (2021.12.15-1) on root.
Installing iputils (2021.12.15) on root.
Removing obsolete file "".
* remove_obsolesced_files: unlinking "" failed: No such file or directory.
* opkg_install_pkg: Failed to determine obsolete files from previously installed iputils
Configuring iputils.
---------------
Signed-off-by: Nevo Hed <
nhed+y...@starry.com>
---
libopkg/opkg_install.c | 4 ++--
libopkg/pkg.c | 7 ++++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index 354dc10..1a959cb 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -744,11 +744,11 @@ static int remove_obsolesced_files(pkg_t * pkg, pkg_t * old_pkg)
}
/* old file is obsolete */
- opkg_msg(NOTICE, "Removing obsolete file %s.\n", old->path);
+ opkg_msg(NOTICE, "Removing obsolete file \"%s\".\n", old->path);
if (!opkg_config->noaction) {
err = unlink(old->path);
if (err) {
- opkg_perror(ERROR, "unlinking %s failed", old->path);
+ opkg_perror(ERROR, "unlinking \"%s\" failed", old->path);
}
}
}
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 6b1bd8f..4de3ff0 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -1468,7 +1468,12 @@ static void pkg_write_filelist_helper(const char *key, void *entry_,
size_t size;
int unmatched_offline_root = opkg_config->offline_root
&& !str_starts_with(key, opkg_config->offline_root);
- char *entry = xstrdup(key);
+ char *entry = NULL;
+
+ if (key[1] == '\0' && key[0] == '/')
+ entry = xstrdup("/.");
+ else
+ entry = xstrdup(key);
size = strlen(entry);
if (size > 0 && entry[size-1] == '/')
--
2.37.3