Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Allow pkg create -M ./plop.ucl -p ./plop.plist
Baptiste Daroussin committed 11 years ago
commit f0667655c403563c448fef2cd4548811ccdbb504
parent 7293519
4 files changed +56 -4
modified libpkg/pkg.h.in
@@ -1121,7 +1121,8 @@ int pkg_create_installed(const char *, pkg_formats, struct pkg *);
 * Create package from stage install using just the manifest --
 * no old pkg_tools compatibility stuff
 */
-
int pkg_create_from_manifest(const char *, pkg_formats, const char *, const char *);
+
int pkg_create_from_manifest(const char *, pkg_formats, const char *,
+
    const char *, const char *);

/**
 * Create package from stage install with a metadata directory
modified libpkg/pkg_create.c
@@ -233,7 +233,7 @@ static const char * const scripts[] = {
 * from the manifest */
int
pkg_create_from_manifest(const char *outdir, pkg_formats format,
-
    const char *rootdir, const char *manifest)
+
    const char *rootdir, const char *manifest, const char *plist)
{
	struct pkg	*pkg = NULL;
	struct packing	*pkg_archive = NULL;
@@ -260,6 +260,12 @@ pkg_create_from_manifest(const char *outdir, pkg_formats format,
		pkg->abi = strdup(arch);
	}

+
	if (plist != NULL &&
+
	    ports_parse_plist(pkg, plist, rootdir) != EPKG_OK) {
+
		ret = EPKG_FATAL;
+
		goto cleanup;
+
	}
+

	/* Create the archive */
	pkg_archive = pkg_create_archive(outdir, pkg, format, 0);
	if (pkg_archive == NULL) {
modified src/create.c
@@ -1,5 +1,5 @@
/*-
-
 * Copyright (c) 2011-2012 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * Copyright (c) 2011-2015 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
 * Copyright (c) 2011 Will Andrews <will@FreeBSD.org>
 * Copyright (c) 2015 Matthew Seaman <matthew@FreeBSD.org>
@@ -314,7 +314,7 @@ exec_create(int argc, char **argv)
		    plist) == EPKG_OK ? EX_OK : EX_SOFTWARE);
	} else  { /* (manifest != NULL) */
		return (pkg_create_from_manifest(outdir, fmt, rootdir,
-
		    manifest) == EPKG_OK ? EX_OK : EX_SOFTWARE);
+
		    manifest, plist) == EPKG_OK ? EX_OK : EX_SOFTWARE);
	}
}

modified tests/frontend/create.shin
@@ -347,6 +347,50 @@ scripts {
}

EOF
+

+
	atf_check \
+
		-o file:output.ucl \
+
		-e empty \
+
		-s exit:0 \
+
		pkg info -R --raw-format=ucl -F test-1.txz
+
}
+

+
atf_test_case create_from_manifest_and_plist
+
create_from_manifest_and_plist_head() {
+
	atf_set "descr" "Testing pkg create with manifest and plist"
+
}
+

+
create_from_manifest_and_plist_body() {
+
	genmanifest
+
	touch testfile
+
	genplist "testfile"
+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		-s exit:0 \
+
		pkg create -M ./+MANIFEST -p test.plist -r ${TMPDIR}
+

+
	cat << EOF > output.ucl
+
name = "test";
+
origin = "test";
+
version = "1";
+
comment = "a test";
+
maintainer = "test";
+
www = "http://test";
+
abi = "*";
+
arch = "*";
+
prefix = "/";
+
flatsize = 0;
+
desc = "Yet another test";
+
categories [
+
    "test",
+
]
+
files {
+
    /testfile = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
+
}
+

+
EOF
+

	atf_check \
		-o file:output.ucl \
		-e empty \
@@ -370,4 +414,5 @@ atf_init_test_cases() {
		atf_add_test_case create_from_plist_bad_fflags
	fi
	atf_add_test_case create_from_plist_with_keyword_arguments
+
	atf_add_test_case create_from_manifest_and_plist
}