Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
new option -d (dependency) to pkg register
Baptiste Daroussin committed 14 years ago
commit 879b115ae9ec0cb3a1f7a29c6f0d5de5890d9725
parent 3275886
6 files changed +38 -5
modified libpkg/pkg.c
@@ -109,6 +109,25 @@ pkg_flatsize(struct pkg *pkg)
	return (pkg->flatsize);
}

+
int
+
pkg_setautomatic(struct pkg *pkg)
+
{
+
	pkg->automatic = true;
+

+
	return (EPKG_OK);
+
}
+

+
int
+
pkg_isautomatic(struct pkg *pkg)
+
{
+
	if (pkg == NULL) {
+
		ERROR_BAD_ARG("pkg");
+
		return (-1);
+
	}
+

+
	return (pkg->automatic);
+
}
+

int64_t
pkg_new_flatsize(struct pkg *pkg)
{
@@ -415,6 +434,7 @@ pkg_new(struct pkg **pkg, pkg_t type)
		(*pkg)->fields[fields[i].id].optional = fields[i].optional;
	}

+
	(*pkg)->automatic = false;
	(*pkg)->type = type;

	return (EPKG_OK);
modified libpkg/pkg.h
@@ -263,6 +263,9 @@ int pkg_set(struct pkg *pkg, pkg_attr attr, const char *value);
 */
int pkg_set_from_file(struct pkg *pkg, pkg_attr attr, const char *file);

+
int pkg_setautomatic(struct pkg *pkg);
+
int pkg_isautomatic(struct pkg *pkg);
+

/**
 * Set the uncompressed size of the package.
 * @return An error code.
modified libpkg/pkg_private.h
@@ -4,6 +4,7 @@
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sbuf.h>
+
#include <stdbool.h>

#include <archive.h>

@@ -21,6 +22,7 @@ struct pkg {
		int type; /* for which pkg_t this field is defined */
		unsigned int optional :1;
	} fields[PKG_NUM_FIELDS];
+
	bool automatic;
	int64_t flatsize;
	int64_t new_flatsize;
	int64_t new_pkgsize;
modified libpkg/pkgdb.c
@@ -158,11 +158,11 @@ pkgdb_init(sqlite3 *sdb)
	"FOR EACH ROW BEGIN "
		"INSERT OR IGNORE INTO mtree (content) VALUES (NEW.mtree);"
		"INSERT OR REPLACE INTO packages(origin, name, version, comment, desc, mtree_id, "
-
		"message, arch, osversion, maintainer, www, prefix, flatsize) "
+
		"message, arch, osversion, maintainer, www, prefix, flatsize, automatic) "
		"VALUES (NEW.origin, NEW.name, NEW.version, NEW.comment, NEW.desc, "
		"(SELECT id FROM mtree WHERE content = NEW.mtree), "
		"NEW.message, NEW.arch, NEW.osversion, NEW.maintainer, NEW.www, NEW.prefix, "
-
		"NEW.flatsize);"
+
		"NEW.flatsize NEW.automatic);"
	"END;"
	"CREATE TABLE scripts ("
		"package_id INTEGER REFERENCES packages(id) ON DELETE CASCADE"
@@ -905,8 +905,8 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	const char sql_pkg[] = ""
		"INSERT INTO pkg_mtree( "
			"origin, name, version, comment, desc, mtree, message, arch, "
-
			"osversion, maintainer, www, prefix, flatsize) "
-
		"VALUES( ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13);";
+
			"osversion, maintainer, www, prefix, flatsize, automatic) "
+
		"VALUES( ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14);";
	const char sql_sel_pkg[] = ""
		"SELECT id FROM packages "
		"WHERE origin = ?1;";
@@ -963,6 +963,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	sqlite3_bind_text(stmt_pkg, 11, pkg_get(pkg, PKG_WWW), -1, SQLITE_STATIC);
	sqlite3_bind_text(stmt_pkg, 12, pkg_get(pkg, PKG_PREFIX), -1, SQLITE_STATIC);
	sqlite3_bind_int64(stmt_pkg, 13, pkg_flatsize(pkg));
+
	sqlite3_bind_int(stmt_pkg, 14, pkg_isautomatic(pkg));

	if ((ret = sqlite3_step(stmt_pkg)) != SQLITE_DONE) {
		if ( ret == SQLITE_CONSTRAINT)
modified pkg/register.c
@@ -80,7 +80,7 @@ exec_register(int argc, char **argv)
	}

	pkg_new(&pkg, PKG_INSTALLED);
-
	while ((ch = getopt(argc, argv, "a:f:m:i:l")) != -1) {
+
	while ((ch = getopt(argc, argv, "a:f:m:i:ld")) != -1) {
		switch (ch) {
			case 'f':
				if ((plist = strdup(optarg)) == NULL)
@@ -93,6 +93,9 @@ exec_register(int argc, char **argv)
			case 'a':
				arch = strdup(optarg);
				break;
+
			case 'd':
+
				pkg_setautomatic(pkg);
+
				break;
			case 'i':
				if ((input_path = strdup(optarg)) == NULL)
					errx(1, "cannot allocate memory");
modified ports/bsd.pkgng.mk
@@ -88,7 +88,11 @@ fake-pkg:
.if !defined(NO_MTREE)
	@${CP} ${MTREE_FILE} ${METADIR}/+MTREE_DIRS
.endif
+
.if defined(INSTALLS_DEPENDS)
+
	@${PKG_CMD} -a -l -m ${METADIR} -f ${TMPPLIST}
+
.else
	@${PKG_CMD} -l -m ${METADIR} -f ${TMPPLIST}
+
.endif
.else
	@${DO_NADA}
.endif