mirror of
https://github.com/void-linux/void-packages.git
synced 2025-06-06 15:13:51 +02:00
xbps{,-static}: merge two fixes from master.
- xbps-uchroot overlayfs fixes v2. - fix regression introduced in 0.58.
This commit is contained in:
parent
4351b38206
commit
3adf1a55ad
4 changed files with 233 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
||||||
# NOTE: keep this package synchronized with "srcpkgs/xbps"
|
# NOTE: keep this package synchronized with "srcpkgs/xbps"
|
||||||
pkgname=xbps-static
|
pkgname=xbps-static
|
||||||
version=0.58
|
version=0.58
|
||||||
revision=2
|
revision=4
|
||||||
# only musl
|
# only musl
|
||||||
archs="*-musl"
|
archs="*-musl"
|
||||||
wrksrc="xbps-${version}"
|
wrksrc="xbps-${version}"
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
commit 5b43614e80c5a334231f28e191f709b2679e6fc7
|
||||||
|
Author: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Mon Feb 3 09:19:54 2020 +0100
|
||||||
|
|
||||||
|
libxbps: fixed regression introduced in 0.58.
|
||||||
|
|
||||||
|
While looking for dependencies, we need to check
|
||||||
|
if xbps_rpool_get_pkg() returned a suitable match;
|
||||||
|
and then validate its result.
|
||||||
|
|
||||||
|
This fixes the update_and_install test case that
|
||||||
|
was reverted via #218.
|
||||||
|
|
||||||
|
--- lib/repo_pkgdeps.c
|
||||||
|
+++ lib/repo_pkgdeps.c
|
||||||
|
@@ -131,7 +131,6 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||||
|
const char *reqpkg, *pkgver_q, *reason = NULL;
|
||||||
|
char *pkgname, *reqpkgname;
|
||||||
|
int rv = 0;
|
||||||
|
- bool foundvpkg;
|
||||||
|
|
||||||
|
if (*depth >= MAX_DEPTH)
|
||||||
|
return ELOOP;
|
||||||
|
@@ -144,8 +143,9 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||||
|
assert(iter);
|
||||||
|
|
||||||
|
while ((obj = xbps_object_iterator_next(iter))) {
|
||||||
|
- foundvpkg = false;
|
||||||
|
+ bool error = false, foundvpkg = false;
|
||||||
|
reqpkg = xbps_string_cstring_nocopy(obj);
|
||||||
|
+
|
||||||
|
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
||||||
|
xbps_dbg_printf(xhp, "%s", "");
|
||||||
|
for (unsigned short x = 0; x < *depth; x++) {
|
||||||
|
@@ -345,6 +345,38 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||||
|
}
|
||||||
|
free(pkgname);
|
||||||
|
free(reqpkgname);
|
||||||
|
+ /*
|
||||||
|
+ * Installed package must be updated, check if dependency is
|
||||||
|
+ * satisfied.
|
||||||
|
+ */
|
||||||
|
+ if (!strcmp(reason, "update")) {
|
||||||
|
+ switch (xbps_pkgpattern_match(pkgver_q, reqpkg)) {
|
||||||
|
+ case 0: /* nomatch */
|
||||||
|
+ break;
|
||||||
|
+ case 1: /* match */
|
||||||
|
+ pkgname = xbps_pkg_name(pkgver_q);
|
||||||
|
+ assert(pkgname);
|
||||||
|
+ /*
|
||||||
|
+ * If there's an update in transaction,
|
||||||
|
+ * it's assumed version is greater.
|
||||||
|
+ * So dependency pattern matching didn't
|
||||||
|
+ * succeed... return ENODEV.
|
||||||
|
+ */
|
||||||
|
+ if (xbps_find_pkg_in_array(unsorted, pkgname, "update")) {
|
||||||
|
+ error = true;
|
||||||
|
+ rv = ENODEV;
|
||||||
|
+ }
|
||||||
|
+ free(pkgname);
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ error = true;
|
||||||
|
+ rv = EINVAL;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ if (error)
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* If package doesn't have rundeps, pass to the next one.
|
||||||
|
*/
|
158
srcpkgs/xbps/patches/xbps-uchroot-overlayfs.patch
Normal file
158
srcpkgs/xbps/patches/xbps-uchroot-overlayfs.patch
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
--- bin/xbps-uchroot/main.c
|
||||||
|
+++ bin/xbps-uchroot/main.c
|
||||||
|
@@ -52,6 +52,7 @@
|
||||||
|
#include <ftw.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
+#include <dirent.h>
|
||||||
|
|
||||||
|
#include <xbps.h>
|
||||||
|
#include "queue.h"
|
||||||
|
@@ -109,19 +110,16 @@ die(const char *fmt, ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
-ftw_cb(const char *fpath, const struct stat *sb UNUSED, int type,
|
||||||
|
- struct FTW *ftwbuf UNUSED)
|
||||||
|
+ftw_cb(const char *fpath, const struct stat *sb)
|
||||||
|
{
|
||||||
|
int sverrno = 0;
|
||||||
|
|
||||||
|
- if (type == FTW_F || type == FTW_SL || type == FTW_SLN) {
|
||||||
|
- if (unlink(fpath) == -1)
|
||||||
|
- sverrno = errno;
|
||||||
|
- } else if (type == FTW_D || type == FTW_DNR || type == FTW_DP) {
|
||||||
|
+ if (S_ISDIR(sb->st_mode)) {
|
||||||
|
if (rmdir(fpath) == -1)
|
||||||
|
sverrno = errno;
|
||||||
|
} else {
|
||||||
|
- return 0;
|
||||||
|
+ if (unlink(fpath) == -1)
|
||||||
|
+ sverrno = errno;
|
||||||
|
}
|
||||||
|
if (sverrno != 0) {
|
||||||
|
fprintf(stderr, "Failed to remove %s: %s\n", fpath, strerror(sverrno));
|
||||||
|
@@ -129,20 +127,68 @@ ftw_cb(const char *fpath, const struct stat *sb UNUSED, int type,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int
|
||||||
|
+walk_dir(const char *path,
|
||||||
|
+ int (*fn)(const char *fpath, const struct stat *sb))
|
||||||
|
+{
|
||||||
|
+ struct dirent **list;
|
||||||
|
+ struct stat sb;
|
||||||
|
+ const char *p;
|
||||||
|
+ char tmp_path[PATH_MAX] = {0};
|
||||||
|
+ int rv, i;
|
||||||
|
+
|
||||||
|
+ i = scandir(path, &list, NULL, alphasort);
|
||||||
|
+ if (i == -1) {
|
||||||
|
+ rv = -1;
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+ while (i--) {
|
||||||
|
+ p = list[i]->d_name;
|
||||||
|
+ if (strcmp(p, ".") == 0 || strcmp(p, "..") == 0)
|
||||||
|
+ continue;
|
||||||
|
+ if (strlen(path) + strlen(p) + 1 >= (PATH_MAX - 1)) {
|
||||||
|
+ errno = ENAMETOOLONG;
|
||||||
|
+ rv = -1;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ strncpy(tmp_path, path, PATH_MAX - 1);
|
||||||
|
+ strncat(tmp_path, "/", PATH_MAX - 1 - strlen(tmp_path));
|
||||||
|
+ strncat(tmp_path, p, PATH_MAX - 1 - strlen(tmp_path));
|
||||||
|
+ if (lstat(tmp_path, &sb) < 0) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ if (S_ISDIR(sb.st_mode)) {
|
||||||
|
+ if (walk_dir(tmp_path, fn) < 0) {
|
||||||
|
+ rv = -1;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ rv = fn(tmp_path, &sb);
|
||||||
|
+ if (rv != 0) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+out:
|
||||||
|
+ free(list);
|
||||||
|
+ return rv;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
cleanup_overlayfs(void)
|
||||||
|
{
|
||||||
|
if (tmpdir == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- if (!overlayfs_on_tmpfs) {
|
||||||
|
- /* recursively remove the temporary dir */
|
||||||
|
- if (nftw(tmpdir, ftw_cb, 20, FTW_MOUNT|FTW_PHYS|FTW_DEPTH) != 0) {
|
||||||
|
- fprintf(stderr, "Failed to remove directory tree %s: %s\n",
|
||||||
|
- tmpdir, strerror(errno));
|
||||||
|
- exit(EXIT_FAILURE);
|
||||||
|
- }
|
||||||
|
+ if (overlayfs_on_tmpfs)
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+ /* recursively remove the temporary dir */
|
||||||
|
+ if (walk_dir(tmpdir, ftw_cb) != 0) {
|
||||||
|
+ fprintf(stderr, "Failed to remove directory tree %s: %s\n",
|
||||||
|
+ tmpdir, strerror(errno));
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
+out:
|
||||||
|
rmdir(tmpdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -342,17 +388,16 @@ main(int argc, char **argv)
|
||||||
|
die("failed to create tmpdir directory");
|
||||||
|
if (chown(tmpdir, ruid, rgid) == -1)
|
||||||
|
die("chown tmpdir %s", tmpdir);
|
||||||
|
+ /*
|
||||||
|
+ * Register a signal handler to clean up temporary masterdir.
|
||||||
|
+ */
|
||||||
|
+ memset(&sa, 0, sizeof(sa));
|
||||||
|
+ sa.sa_handler = sighandler_cleanup;
|
||||||
|
+ sigaction(SIGINT, &sa, NULL);
|
||||||
|
+ sigaction(SIGTERM, &sa, NULL);
|
||||||
|
+ sigaction(SIGQUIT, &sa, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * Register a signal handler to clean up temporary masterdir.
|
||||||
|
- */
|
||||||
|
- memset(&sa, 0, sizeof(sa));
|
||||||
|
- sa.sa_handler = sighandler_cleanup;
|
||||||
|
- sigaction(SIGINT, &sa, NULL);
|
||||||
|
- sigaction(SIGTERM, &sa, NULL);
|
||||||
|
- sigaction(SIGQUIT, &sa, NULL);
|
||||||
|
-
|
||||||
|
clone_flags = (SIGCHLD|CLONE_NEWNS|CLONE_NEWIPC|CLONE_NEWUTS|CLONE_NEWPID);
|
||||||
|
container_flags = clone_flags & ~(CLONE_NEWNS|CLONE_NEWIPC|CLONE_NEWUTS|CLONE_NEWPID);
|
||||||
|
|
||||||
|
@@ -376,8 +421,6 @@ main(int argc, char **argv)
|
||||||
|
/* mount as private, systemd mounts it as shared by default */
|
||||||
|
if (mount(NULL, "/", "none", MS_PRIVATE|MS_REC, NULL) == -1)
|
||||||
|
die("Failed to mount / private");
|
||||||
|
- if (mount(NULL, "/", "none", MS_PRIVATE|MS_REMOUNT|MS_NOSUID, NULL) == -1)
|
||||||
|
- die("Failed to remount /");
|
||||||
|
|
||||||
|
/* setup our overlayfs if set */
|
||||||
|
if (overlayfs)
|
||||||
|
@@ -422,12 +465,6 @@ main(int argc, char **argv)
|
||||||
|
if (execvp(cmd, cmdargs) == -1)
|
||||||
|
die("Failed to execute command %s", cmd);
|
||||||
|
}
|
||||||
|
- /* Switch back to the gid/uid of invoking process also in the parent */
|
||||||
|
- if (setgid(rgid) == -1)
|
||||||
|
- die("setgid child");
|
||||||
|
- if (setuid(ruid) == -1)
|
||||||
|
- die("setuid child");
|
||||||
|
-
|
||||||
|
/* Wait until the child terminates */
|
||||||
|
while (waitpid(child, &child_status, 0) < 0) {
|
||||||
|
if (errno != EINTR)
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'xbps'
|
# Template file for 'xbps'
|
||||||
pkgname=xbps
|
pkgname=xbps
|
||||||
version=0.58
|
version=0.58
|
||||||
revision=3
|
revision=4
|
||||||
bootstrap=yes
|
bootstrap=yes
|
||||||
build_style=configure
|
build_style=configure
|
||||||
short_desc="XBPS package system utilities"
|
short_desc="XBPS package system utilities"
|
||||||
|
|
Loading…
Add table
Reference in a new issue