xbps: patches from master to fix issues with xbps-alternatives
https://github.com/voidlinux/xbps/pull/193
This commit is contained in:
parent
7fa094d35c
commit
fa7afa7965
4 changed files with 249 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
|||
# NOTE: keep this package synchronized with "srcpkgs/xbps".
|
||||
pkgname=xbps-static
|
||||
version=0.51
|
||||
revision=8
|
||||
revision=12
|
||||
build_style=configure
|
||||
short_desc="The XBPS package system utilities - static binaries"
|
||||
maintainer="Juan RP <xtraeme@voidlinux.eu>"
|
||||
|
|
78
srcpkgs/xbps/patches/issue-193-1.patch
Normal file
78
srcpkgs/xbps/patches/issue-193-1.patch
Normal file
|
@ -0,0 +1,78 @@
|
|||
--- lib/package_alternatives.c.orig
|
||||
+++ lib/package_alternatives.c
|
||||
@@ -249,8 +249,8 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname,
|
||||
const char *group)
|
||||
{
|
||||
xbps_array_t allkeys;
|
||||
- xbps_dictionary_t alternatives, pkg_alternatives, pkgd;
|
||||
- const char *pkgver;
|
||||
+ xbps_dictionary_t alternatives, pkg_alternatives, pkgd, prevpkgd, prevpkg_alts;
|
||||
+ const char *pkgver, *prevpkgname;
|
||||
int rv = 0;
|
||||
|
||||
assert(xhp);
|
||||
@@ -289,6 +289,20 @@ xbps_alternatives_set(struct xbps_handle *xhp, const char *pkgname,
|
||||
if (array == NULL)
|
||||
continue;
|
||||
|
||||
+ /* remove symlinks from previous alternative */
|
||||
+ xbps_array_get_cstring_nocopy(array, 0, &prevpkgname);
|
||||
+ if (prevpkgname && strcmp(pkgname, prevpkgname) != 0) {
|
||||
+ if ((prevpkgd = xbps_pkgdb_get_pkg(xhp, prevpkgname)) &&
|
||||
+ (prevpkg_alts = xbps_dictionary_get(prevpkgd, "alternatives")) &&
|
||||
+ xbps_dictionary_count(prevpkg_alts)) {
|
||||
+ rv = remove_symlinks(xhp,
|
||||
+ xbps_dictionary_get(prevpkg_alts, keyname),
|
||||
+ keyname);
|
||||
+ if (rv != 0)
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* put this alternative group at the head */
|
||||
xbps_remove_string_from_array(array, pkgname);
|
||||
kstr = xbps_string_create_cstring(pkgname);
|
||||
--- tests/xbps/xbps-alternatives/main.sh.orig
|
||||
+++ tests/xbps/xbps-alternatives/main.sh
|
||||
@@ -429,6 +429,35 @@ update_pkgs_body() {
|
||||
atf_check_equal $rv 0
|
||||
}
|
||||
|
||||
+atf_test_case less_entries
|
||||
+
|
||||
+less_entries_pkgs_head() {
|
||||
+ atf_set "descr" "xbps-alternatives: remove symlinks not provided by the new alternative"
|
||||
+}
|
||||
+less_entries_body() {
|
||||
+ mkdir -p repo pkg_A/usr/bin pkg_B/usr/bin
|
||||
+ touch pkg_A/usr/bin/A1 pkg_A/usr/bin/A2 pkg_B/usr/bin/B1
|
||||
+ cd repo
|
||||
+ xbps-create -A noarch -n A-1.1_1 -s "A pkg" --alternatives "1:1:/usr/bin/A1 1:2:/usr/bin/A2" ../pkg_A
|
||||
+ atf_check_equal $? 0
|
||||
+ xbps-create -A noarch -n B-1.1_1 -s "B pkg" --alternatives "1:1:/usr/bin/B1" ../pkg_B
|
||||
+ atf_check_equal $? 0
|
||||
+ xbps-rindex -d -a $PWD/*.xbps
|
||||
+ atf_check_equal $? 0
|
||||
+ cd ..
|
||||
+
|
||||
+ xbps-install -r root --repository=repo -ydv A B
|
||||
+ atf_check_equal $? 0
|
||||
+
|
||||
+ xbps-alternatives -r root -s B
|
||||
+ atf_check_equal $? 0
|
||||
+
|
||||
+ rv=1
|
||||
+ [ -e root/usr/bin/2 ] || rv=0
|
||||
+ atf_check_equal $rv 0
|
||||
+}
|
||||
+
|
||||
+
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case register_one
|
||||
atf_add_test_case register_one_dangling
|
||||
@@ -441,4 +470,5 @@ atf_init_test_cases() {
|
||||
atf_add_test_case set_pkg
|
||||
atf_add_test_case set_pkg_group
|
||||
atf_add_test_case update_pkgs
|
||||
+ atf_add_test_case less_entries
|
||||
}
|
169
srcpkgs/xbps/patches/issue-193-2.patch
Normal file
169
srcpkgs/xbps/patches/issue-193-2.patch
Normal file
|
@ -0,0 +1,169 @@
|
|||
--- lib/package_alternatives.c.orig
|
||||
+++ lib/package_alternatives.c
|
||||
@@ -145,99 +145,84 @@ remove_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
|
||||
static int
|
||||
create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname)
|
||||
{
|
||||
- unsigned int i, cnt;
|
||||
+ int rv;
|
||||
+ unsigned int i, n;
|
||||
+ char *alternative, *tok1, *tok2, *linkpath, *target, *dir, *p;
|
||||
|
||||
- cnt = xbps_array_count(a);
|
||||
- for (i = 0; i < cnt; i++) {
|
||||
- xbps_string_t str;
|
||||
- char *tgt_dup, *tgt_dir, *lnk_dup, *lnk_dir;
|
||||
- char *l, *lnk, *tgt = NULL;
|
||||
- const char *tgt0;
|
||||
- int rv;
|
||||
+ n = xbps_array_count(a);
|
||||
|
||||
- str = xbps_array_get(a, i);
|
||||
- l = left(xbps_string_cstring_nocopy(str));
|
||||
- assert(l);
|
||||
- tgt0 = right(xbps_string_cstring_nocopy(str));
|
||||
- assert(tgt0);
|
||||
- /* always create target dir, for dangling symlinks */
|
||||
- tgt_dup = strdup(tgt0);
|
||||
- assert(tgt_dup);
|
||||
- tgt_dir = dirname(tgt_dup);
|
||||
- if (strcmp(tgt_dir, ".")) {
|
||||
- tgt = xbps_xasprintf("%s%s", xhp->rootdir, tgt_dir);
|
||||
- if (xbps_mkpath(tgt, 0755) != 0) {
|
||||
- if (errno != EEXIST) {
|
||||
- rv = errno;
|
||||
- xbps_dbg_printf(xhp, "failed to create "
|
||||
- "target dir '%s' for group '%s': %s\n",
|
||||
- tgt, grname, strerror(errno));
|
||||
- free(tgt_dup);
|
||||
- free(tgt);
|
||||
- free(l);
|
||||
- return rv;
|
||||
- }
|
||||
- }
|
||||
- free(tgt);
|
||||
+ for (i = 0; i < n; i++) {
|
||||
+ alternative = xbps_string_cstring(xbps_array_get(a, i));
|
||||
+
|
||||
+ if (!(tok1 = strtok(alternative, ":")) ||
|
||||
+ !(tok2 = strtok(NULL, ":"))) {
|
||||
+ free(alternative);
|
||||
+ return -1;
|
||||
}
|
||||
- /* always create link dir, for dangling symlinks */
|
||||
- lnk_dup = strdup(l);
|
||||
- assert(lnk_dup);
|
||||
- lnk_dir = dirname(lnk_dup);
|
||||
- if (strcmp(lnk_dir, ".")) {
|
||||
- lnk = xbps_xasprintf("%s%s", xhp->rootdir, lnk_dir);
|
||||
- if (xbps_mkpath(lnk, 0755) != 0) {
|
||||
- if (errno != EEXIST) {
|
||||
- rv = errno;
|
||||
- xbps_dbg_printf(xhp, "failed to create symlink"
|
||||
- "dir '%s' for group '%s': %s\n",
|
||||
- lnk, grname, strerror(errno));
|
||||
- free(tgt_dup);
|
||||
- free(lnk_dup);
|
||||
- free(lnk);
|
||||
- free(l);
|
||||
- return rv;
|
||||
- }
|
||||
- }
|
||||
- free(lnk);
|
||||
+ target = strdup(tok2);
|
||||
+ dir = dirname(tok2);
|
||||
+
|
||||
+ /* add target dir to relative links */
|
||||
+ if (tok1[0] != '/')
|
||||
+ linkpath = xbps_xasprintf("%s/%s/%s", xhp->rootdir, dir, tok1);
|
||||
+ else
|
||||
+ linkpath = xbps_xasprintf("%s/%s", xhp->rootdir, tok1);
|
||||
+
|
||||
+ /* create target directory, necessary for dangling symlinks */
|
||||
+ dir = xbps_xasprintf("%s/%s", xhp->rootdir, dir);
|
||||
+ if (strcmp(dir, ".") && xbps_mkpath(dir, 0755) && errno != EEXIST) {
|
||||
+ rv = errno;
|
||||
+ xbps_dbg_printf(xhp,
|
||||
+ "failed to create target dir '%s' for group '%s': %s\n",
|
||||
+ dir, grname, strerror(errno));
|
||||
+ free(dir);
|
||||
+ goto err;
|
||||
}
|
||||
- free(lnk_dup);
|
||||
-
|
||||
- if (l[0] != '/') {
|
||||
- lnk = xbps_xasprintf("%s%s/%s", xhp->rootdir, tgt_dir, l);
|
||||
- free(tgt_dup);
|
||||
- tgt_dup = strdup(tgt0);
|
||||
- assert(tgt_dup);
|
||||
- tgt = strdup(basename(tgt_dup));
|
||||
- free(tgt_dup);
|
||||
- } else {
|
||||
- free(tgt_dup);
|
||||
- tgt = strdup(tgt0);
|
||||
- lnk = xbps_xasprintf("%s%s", xhp->rootdir, l);
|
||||
+ free(dir);
|
||||
+
|
||||
+ /* create link directory, necessary for dangling symlinks */
|
||||
+ p = strdup(linkpath);
|
||||
+ dir = dirname(p);
|
||||
+ if (strcmp(dir, ".") && xbps_mkpath(dir, 0755) && errno != EEXIST) {
|
||||
+ rv = errno;
|
||||
+ xbps_dbg_printf(xhp,
|
||||
+ "failed to create symlink dir '%s' for group '%s': %s\n",
|
||||
+ dir, grname, strerror(errno));
|
||||
+ free(p);
|
||||
+ goto err;
|
||||
}
|
||||
+ free(p);
|
||||
+
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_LINK_ADDED, 0, NULL,
|
||||
- "Creating '%s' alternatives group symlink: %s -> %s", grname, l, tgt);
|
||||
- unlink(lnk);
|
||||
- if (tgt[0] == '/') {
|
||||
- tgt_dup = relpath(lnk + strlen(xhp->rootdir), tgt);
|
||||
- free(tgt);
|
||||
- tgt = tgt_dup;
|
||||
+ "Creating '%s' alternatives group symlink: %s -> %s",
|
||||
+ grname, tok1, target);
|
||||
+
|
||||
+ if (target[0] == '/') {
|
||||
+ p = relpath(linkpath + strlen(xhp->rootdir), target);
|
||||
+ free(target);
|
||||
+ target = p;
|
||||
}
|
||||
- if ((rv = symlink(tgt, lnk)) != 0) {
|
||||
- xbps_dbg_printf(xhp, "failed to create alt symlink '%s'"
|
||||
- "for group '%s': %s\n", lnk, grname,
|
||||
- strerror(errno));
|
||||
- free(tgt);
|
||||
- free(lnk);
|
||||
- free(l);
|
||||
- return rv;
|
||||
+
|
||||
+ unlink(linkpath);
|
||||
+ if ((rv = symlink(target, linkpath)) != 0) {
|
||||
+ xbps_dbg_printf(xhp,
|
||||
+ "failed to create alt symlink '%s' for group '%s': %s\n",
|
||||
+ linkpath, grname, strerror(errno));
|
||||
+ goto err;
|
||||
}
|
||||
- free(tgt);
|
||||
- free(lnk);
|
||||
- free(l);
|
||||
+
|
||||
+ free(alternative);
|
||||
+ free(target);
|
||||
+ free(linkpath);
|
||||
}
|
||||
|
||||
return 0;
|
||||
+
|
||||
+err:
|
||||
+ free(alternative);
|
||||
+ free(target);
|
||||
+ free(linkpath);
|
||||
+ return rv;
|
||||
}
|
||||
|
||||
int
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'xbps'
|
||||
pkgname=xbps
|
||||
version=0.51
|
||||
revision=11
|
||||
revision=12
|
||||
bootstrap=yes
|
||||
build_style=configure
|
||||
short_desc="The XBPS package system utilities"
|
||||
|
|
Loading…
Reference in a new issue