Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
ABI: fix abi globs validation
Baptiste Daroussin committed 6 months ago
commit 609d7031207d5cda741693a72d513abc2d96d9d8
parent 523caa9
4 files changed +156 -3
modified libpkg/pkg_abi.c
@@ -60,6 +60,7 @@ static const struct {
	{ PKG_OS_DRAGONFLY, "dragonfly" },
	{ PKG_OS_LINUX, "Linux" },
	{ PKG_OS_DARWIN, "Darwin" },
+
	{ PKG_OS_ANY, "*" },
	{ -1, NULL },
};

@@ -79,6 +80,7 @@ static const struct {
	{ PKG_ARCH_POWERPC64LE, "powerpc64le"},
	{ PKG_ARCH_RISCV32, "riscv32"},
	{ PKG_ARCH_RISCV64, "riscv64"},
+
	{ PKG_ARCH_ANY,	"*"},
	{ -1, NULL },
};

@@ -222,6 +224,13 @@ pkg_abi_from_string(struct pkg_abi *abi, const char *string)

	char *version = strsep(&iter, ":");
	if (version == NULL) {
+
		if (abi->os == PKG_OS_ANY) {
+
			abi->major = 0;
+
			abi->minor = 0;
+
			abi->arch = PKG_ARCH_ANY;
+
			ret = true;
+
			goto out;
+
		}
		pkg_emit_error("Invalid ABI string '%s', "
		    "missing version and architecture", string);
		goto out;
@@ -247,6 +256,13 @@ pkg_abi_from_string(struct pkg_abi *abi, const char *string)
		}
	}
	if (errstr != NULL) {
+
		if (STREQ(version, "*")) {
+
			abi->major = 0;
+
			abi->minor = 0;
+
			abi->arch = PKG_ARCH_ANY;
+
			ret = true;
+
			goto out;
+
		}
		pkg_emit_error("Invalid version in ABI string '%s'", string);
		goto out;
	}
modified libpkg/pkg_solve.c
@@ -344,11 +344,14 @@ pkg_solve_handle_provide(struct pkg_solve_problem *problem,
			 * This might be reasonable behaviour on other OSes as
			 * well.
			 */
+
			dbg(2, "origin %s: %s", orig->name, orig->abi);
+
			dbg(2, "tgt %s: %s", pkg->name, pkg->abi);
			if (!pkg_abi_from_string(&oabi, orig->abi) ||
			    !pkg_abi_from_string(&pabi, pkg->abi))
				continue;
-
			if (oabi.os != pabi.os || oabi.arch != pabi.arch ||
-
			    oabi.os != PKG_OS_FREEBSD) {
+
			if (oabi.os != pabi.os ||
+
			    (oabi.arch != pabi.arch && oabi.arch != PKG_ARCH_ANY && pabi.arch != PKG_ARCH_ANY)  ||
+
			    (oabi.os != PKG_OS_FREEBSD && oabi.os != PKG_OS_ANY)) {
				dbg(2,
		"require %s: package %s-%s(%c) provides ABI %s, want %s",
				    pr->provide, pkg->name, pkg->version,
modified libpkg/private/pkg_abi.h
@@ -27,6 +27,7 @@ enum pkg_os {
	PKG_OS_DRAGONFLY,
	PKG_OS_LINUX,
	PKG_OS_DARWIN,
+
	PKG_OS_ANY,
};

/*
@@ -53,6 +54,7 @@ enum pkg_arch {
	PKG_ARCH_POWERPC64LE,
	PKG_ARCH_RISCV32,
	PKG_ARCH_RISCV64,
+
	PKG_ARCH_ANY,
};

/*
modified tests/frontend/upgrade.sh
@@ -13,7 +13,10 @@ tests_init \
	vital \
	vital_force \
	vital_force_cant_remove \
-
	upgrade_with_dependency
+
	upgrade_with_dependency \
+
	upgrade_glob_abi_os \
+
	upgrade_glob_abi_version \
+
	upgrade_glob_abi_arch \

issue1881_body() {
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg pkg1 pkg_a 1
@@ -509,3 +512,132 @@ ${JAILED}[2/2] Upgrading testb from 1.0 to 2.0...
		-s exit:0 \
		pkg -C ./pkg.conf upgrade -y
}
+

+
upgrade_glob_abi_os_body() {
+
	atf_skip_on Darwin Irrelevant on OSX
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "testa" "testa" "1.0" "/"
+
	cc -shared -Wl,-soname=libtesta.so.2 -o libtesta.so.2
+
	ln -s libtesta.so.2 libtesta.so
+
	cc -shared -Wl,-rpath=${TMPDIR} -L. -ltesta -o dep.so
+

+
	cat << EOF >> testa.ucl
+
shlibs_provided: [ "libtesta.so.2" ]
+
files: {
+
${TMPDIR}/libtesta.so.2: ""
+
}
+
EOF
+
	atf_check pkg create -M testa.ucl -o ./repo
+
	cat << EOF > pkg.conf
+
PKG_DBDIR=${TMPDIR}
+
REPOS_DIR=[]
+
repositories: {
+
	local: { url : file://${TMPDIR}/repo }
+
}
+
EOF
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "testb" "testb" "2.0"
+
	cat << EOF >> testb.ucl
+
shlibs_required: [ "libtesta.so.2" ]
+
files: {
+
	${TMPDIR}/dep.so: ""
+
}
+
EOF
+
	atf_check pkg create -M testb.ucl -o ./repo
+

+
	atf_check \
+
		-o inline:"Creating repository in ./repo:  done\nPacking files for repository:  done\n" \
+
		pkg -C ./pkg.conf repo ./repo
+

+
	atf_check \
+
		-o ignore \
+
		pkg -C ./pkg.conf update -f
+

+
	atf_check \
+
		pkg -C ./pkg.conf install -qy testb
+
}
+

+
upgrade_glob_abi_version_body() {
+
	atf_skip_on Darwin Irrelevant on OSX
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "testa" "testa" "1.0" "/" "${OS}:*"
+
	cc -shared -Wl,-soname=libtesta.so.2 -o libtesta.so.2
+
	ln -s libtesta.so.2 libtesta.so
+
	cc -shared -Wl,-rpath=${TMPDIR} -L. -ltesta -o dep.so
+

+
	cat << EOF >> testa.ucl
+
shlibs_provided: [ "libtesta.so.2" ]
+
files: {
+
${TMPDIR}/libtesta.so.2: ""
+
}
+
EOF
+
	atf_check pkg create -M testa.ucl -o ./repo
+
	cat << EOF > pkg.conf
+
PKG_DBDIR=${TMPDIR}
+
REPOS_DIR=[]
+
repositories: {
+
	local: { url : file://${TMPDIR}/repo }
+
}
+
EOF
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "testb" "testb" "2.0"
+
	cat << EOF >> testb.ucl
+
shlibs_required: [ "libtesta.so.2" ]
+
files: {
+
	${TMPDIR}/dep.so: ""
+
}
+
EOF
+
	atf_check pkg create -M testb.ucl -o ./repo
+

+
	atf_check \
+
		-o inline:"Creating repository in ./repo:  done\nPacking files for repository:  done\n" \
+
		pkg -C ./pkg.conf repo ./repo
+

+
	atf_check \
+
		-o ignore \
+
		pkg -C ./pkg.conf update -f
+

+
	atf_check \
+
		pkg -C ./pkg.conf install -qy testb
+
}
+

+
upgrade_glob_abi_arch_body() {
+
	atf_skip_on Darwin Irrelevant on OSX
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "testa" "testa" "1.0" "/" "${OS}:16:*"
+
	cc -shared -Wl,-soname=libtesta.so.2 -o libtesta.so.2
+
	ln -s libtesta.so.2 libtesta.so
+
	cc -shared -Wl,-rpath=${TMPDIR} -L. -ltesta -o dep.so
+

+
	cat << EOF >> testa.ucl
+
shlibs_provided: [ "libtesta.so.2" ]
+
files: {
+
${TMPDIR}/libtesta.so.2: ""
+
}
+
EOF
+
	atf_check pkg create -M testa.ucl -o ./repo
+
	cat << EOF > pkg.conf
+
PKG_DBDIR=${TMPDIR}
+
REPOS_DIR=[]
+
repositories: {
+
	local: { url : file://${TMPDIR}/repo }
+
}
+
EOF
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "testb" "testb" "2.0"
+
	cat << EOF >> testb.ucl
+
shlibs_required: [ "libtesta.so.2" ]
+
files: {
+
	${TMPDIR}/dep.so: ""
+
}
+
EOF
+
	atf_check pkg create -M testb.ucl -o ./repo
+

+
	atf_check \
+
		-o inline:"Creating repository in ./repo:  done\nPacking files for repository:  done\n" \
+
		pkg -C ./pkg.conf repo ./repo
+

+
	atf_check \
+
		-o ignore \
+
		pkg -C ./pkg.conf update -f
+

+
	atf_check \
+
		pkg -o ABI=${OS}:16:amd64 -o OSVERSION=1600000 -C ./pkg.conf install -qy testb
+
}