Skip to content

Commit

Permalink
Now message are stored in the database
Browse files Browse the repository at this point in the history
  • Loading branch information
bapt committed Jan 14, 2011
1 parent bd40191 commit 2adeb18
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
6 changes: 6 additions & 0 deletions libpkg/pkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pkg_get(struct pkg *pkg, pkg_attr attr) {
return (sbuf_get(pkg->desc));
case PKG_MTREE:
return (sbuf_get(pkg->mtree));
case PKG_MESSAGE:
return (sbuf_get(pkg->message));
}

return (NULL);
Expand All @@ -52,6 +54,8 @@ pkg_set(struct pkg *pkg, pkg_attr attr, const char *value)
return (sbuf_set(&pkg->desc, value));
case PKG_MTREE:
return (sbuf_set(&pkg->mtree, value));
case PKG_MESSAGE:
return (sbuf_set(&pkg->message, value));
}

return (-1);
Expand Down Expand Up @@ -219,6 +223,7 @@ pkg_reset(struct pkg *pkg)
sbuf_reset(pkg->comment);
sbuf_reset(pkg->desc);
sbuf_reset(pkg->mtree);
sbuf_reset(pkg->message);

array_reset(&pkg->deps, &pkg_free_void);
array_reset(&pkg->rdeps, &pkg_free_void);
Expand All @@ -238,6 +243,7 @@ pkg_free(struct pkg *pkg)
sbuf_free(pkg->comment);
sbuf_free(pkg->desc);
sbuf_free(pkg->mtree);
sbuf_free(pkg->message);

array_free(&pkg->deps, &pkg_free_void);
array_free(&pkg->rdeps, &pkg_free_void);
Expand Down
5 changes: 3 additions & 2 deletions libpkg/pkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ typedef enum {
} pkg_t;

typedef enum {
PKG_ORIGIN = 0,
PKG_ORIGIN,
PKG_NAME,
PKG_VERSION,
PKG_COMMENT,
PKG_DESC,
PKG_MTREE
PKG_MTREE,
PKG_MESSAGE
} pkg_attr;


Expand Down
2 changes: 1 addition & 1 deletion libpkg/pkg_ports.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *prefix)
} else if (STARTS_WITH(plist_p, "@exec ")) {
/* TODO */
}else {
warnx("%s is deprecated, ignoring\n", plist_p);
warnx("%s is deprecated, ignoring", plist_p);
}
} else if (strlen(plist_p) > 0){
buf = plist_p;
Expand Down
1 change: 1 addition & 0 deletions libpkg/pkg_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct pkg {
struct sbuf *comment;
struct sbuf *desc;
struct sbuf *mtree;
struct sbuf *message;
struct array deps;
struct array rdeps;
struct array conflicts;
Expand Down
8 changes: 5 additions & 3 deletions libpkg/pkgdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pkgdb_init(sqlite3 *sdb)
"comment TEXT,"
"desc TEXT,"
"mtree TEXT,"
"message TEXT,"
"automatic INTEGER"
");"
"CREATE TABLE options ("
Expand Down Expand Up @@ -494,8 +495,8 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)

sqlite3_exec(db->sqlite, "BEGIN TRANSACTION;", NULL, NULL, NULL);

sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO packages (origin, name, version, comment, desc, mtree)"
"VALUES (?1, ?2, ?3, ?4, ?5, ?6);",
sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO packages (origin, name, version, comment, desc, mtree, message) "
"VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
-1, &stmt_pkg, NULL);

sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO deps (origin, name, version, package_id)"
Expand All @@ -515,7 +516,8 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
sqlite3_bind_text(stmt_pkg, 3, pkg_get(pkg, PKG_VERSION), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_pkg, 4, pkg_get(pkg, PKG_COMMENT), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_pkg, 5, pkg_get(pkg, PKG_DESC), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_pkg, 5, pkg_get(pkg, PKG_MTREE), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_pkg, 6, pkg_get(pkg, PKG_MTREE), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_pkg, 7, pkg_get(pkg, PKG_MESSAGE), -1, SQLITE_STATIC);

sqlite3_step(stmt_pkg);

Expand Down
6 changes: 4 additions & 2 deletions pkg/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ exec_register(int argc, char **argv)
int ret = 0;

pkg_new(&pkg);
while ((ch = getopt(argc, argv, "vc:d:f:p:P:m:o:O:C:n:")) != -1) {
while ((ch = getopt(argc, argv, "vc:d:f:p:P:m:o:C:n:M:")) != -1) {
switch (ch) {
case 'O':
case 'v':
/* IGNORE */
break;
Expand Down Expand Up @@ -69,6 +68,9 @@ exec_register(int argc, char **argv)
case 'C':
conflicts = strdup(optarg);
break;
case 'M':
ret += pkg_set_from_file(pkg, PKG_MESSAGE, optarg);
break;
default:
printf("%c\n", ch);
usage_register();
Expand Down
16 changes: 10 additions & 6 deletions ports/bsd.port.mk.patch
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
--- /usr/ports/Mk/bsd.port.mk.prepkgng 2011-01-14 00:14:59.962893785 +0100
+++ /usr/ports/Mk/bsd.port.mk 2011-01-14 14:52:55.642893124 +0100
@@ -2493,6 +2493,9 @@
+++ /usr/ports/Mk/bsd.port.mk 2011-01-14 18:12:25.129947229 +0100
@@ -2493,6 +2493,12 @@

.if !defined(PKG_ARGS)
PKG_ARGS= -v -c -${COMMENT:Q} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`cd ${.CURDIR} && ${MAKE} actual-package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u -t : -k 2`" ${EXTRA_PKG_ARGS} $${_LATE_PKG_ARGS}
+.if defined(PKGNG)
+PKG_ARGS+= -n ${PKGNAME}
+.if exists(${PKGMESSAGE})
+PKG_ARGS+= -M ${PKGMESSAGE}
+.endif
+.endif
.if !defined(NO_MTREE)
PKG_ARGS+= -m ${MTREE_FILE}
.endif
@@ -5552,6 +5555,7 @@
@@ -5552,6 +5558,7 @@
fi; \
done

+.if !defined(PKGNG)
ACTUAL-PACKAGE-DEPENDS?= \
if [ "${_LIB_RUN_DEPENDS}" != " " ]; then \
origins=$$(for pkgname in ${PKG_DBDIR}/*; do \
@@ -5579,8 +5583,21 @@
@@ -5579,8 +5586,21 @@
shift 2; \
done; \
done; \
Expand All @@ -41,19 +44,20 @@

# Print out package names.

@@ -5993,6 +6010,7 @@
@@ -5993,6 +6013,7 @@
fi
@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
.endif
+.if !defined(PKGNG)
@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
${ECHO_MSG} "===> Registering installation for ${PKGNAME}"; \
${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
@@ -6031,6 +6049,10 @@
@@ -6031,6 +6052,11 @@
${RM} -f /tmp/${PKGNAME}-required-by; \
fi
.else
+ @${ECHO_MSG} "===> Registering installation for ${PKGNAME}"
+
+ @${PKG_CMD} ${PKG_ARGS}
+.endif
+.else
Expand Down

0 comments on commit 2adeb18

Please sign in to comment.