PERFORCE change 167020 for review
David Forsythe
dforsyth at FreeBSD.org
Wed Aug 5 08:35:49 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167020
Change 167020 by dforsyth at squirrel on 2009/08/05 08:35:42
Add basic support for the rest of the pkg_info flags (at least the ones that the
lib can easily handle).
Affected files ...
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#42 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#37 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest_plist.c#4 edit
.. //depot/projects/soc2009/dforsyth_libpkg/pkg_info/main.c#28 edit
Differences ...
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#42 (text+ko) ====
@@ -115,6 +115,16 @@
return (pkg_manifest_name(p->pm));
}
+const char *
+pkg_cwd(struct pkg *p)
+{
+ pkg_check_magic(p, __func__);
+ if (pkg_parse_manifest(p) != PKG_OK)
+ return (NULL);
+
+ return ((const char *)pkg_manifest_cwd(p->pm));
+}
+
/* Retrieve pkg origin. @origin in plist. The directory of the port that
* this pkg was create from. */
@@ -214,6 +224,19 @@
}
const char *
+pkg_mtree_dirs(struct pkg *p)
+{
+ pkg_check_magic(p, __func__);
+ if (p->in_db == NULL)
+ return (p->mtree_dirs);
+
+ if (p->mtree_dirs == NULL &&
+ pkg_read_pkg_element_from_db(p, PKG_ELEM_MTREE) != PKG_OK)
+ return (NULL);
+ return (p->mtree_dirs);
+}
+
+const char *
pkg_required_by(struct pkg *p)
{
if (p->in_db != NULL)
@@ -453,6 +476,13 @@
return ((const char *)pkg_manifest_mtree_file(p->pm));
}
+const char *
+pkg_format_revision(struct pkg *p)
+{
+ pkg_parse_manifest(p);
+ return ((const char *)pkg_manifest_revision(p->pm));
+}
+
int
pkg_extract_in_place(struct pkg *p)
{
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#37 (text+ko) ====
@@ -44,6 +44,7 @@
const char *pkg_comment(struct pkg *p);
const char *pkg_description(struct pkg *p);
const char *pkg_display(struct pkg *p);
+const char *pkg_mtree_dirs(struct pkg *p);
/* tmp */
int pkg_set_mtree_dirs(struct pkg *p, const char *mtree_dirs);
@@ -81,6 +82,7 @@
const char *pkg_mtree_file(struct pkg *p);
+const char * pkg_format_revision(struct pkg *p);
int pkg_extract_in_place(struct pkg *p);
int pkg_preserve(struct pkg *p);
int pkg_complete(struct pkg *p);
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest_plist.c#4 (text+ko) ====
@@ -233,7 +233,7 @@
switch (cmd_id) {
case (PM_CWD):
status = (strlen(isolate) == 0) ?
- pkg_util_strdup(NULL, &st->cwd) : pkg_util_strdup(isolate, &st->cwd);
+ pkg_util_strdup(NULL, &pm->cwd) : pkg_util_strdup(isolate, &pm->cwd);
break;
case (PM_SRCDIR):
if (pm->srcdir != NULL) {
@@ -392,6 +392,9 @@
}
break;
case (PM_FILE):
+ /* Lazy chomp, fix it later. */
+ if (line[strlen(line) - 1] == '\n')
+ line[strlen(line) - 1] = '\0';
status = pkg_manifest_insert_pkg_file(pm, line, NULL, st->cwd, st->mode,
st->owner, st->group);
lpf = pkg_manifest_select_pkg_file(pm, line);
==== //depot/projects/soc2009/dforsyth_libpkg/pkg_info/main.c#28 (text+ko) ====
@@ -90,6 +90,12 @@
{
int opt;
+ if (argc == 1) {
+ flags |= OPT_MATCH_ALL;
+ flags |= OPT_SHOW_INDEX;
+ return;
+ }
+
while ((opt = getopt_long(argc, argv, opts, lopts, NULL)) != -1) {
switch (opt) {
case ('a'):
@@ -251,9 +257,13 @@
print_pkg_information(struct pkg *p)
{
int status;
+ const char *block_text;
const char *const *keylist;
status = OK;
+ if (info_prefix == NULL)
+ info_prefix = "";
+
if (flags & OPT_DEBUG_DUMP) {
pkg_dump(p, stdout);
return (status);
@@ -265,9 +275,6 @@
return (status);
}
- if (info_prefix == NULL)
- info_prefix = "";
-
if (!(flags & OPT_QUIET))
printf("%sInformation for %s:\n\n", info_prefix, pkg_ident(p));
else if (flags & OPT_QUIET)
@@ -277,12 +284,74 @@
if (flags & OPT_SHOW_DEPENDS) {
keylist = pkg_depends(p);
printf("Depends on:\n");
- if (keylist != NULL)
- /* For now use the keylist. Add pkg_depend_name function later. */
- while (*keylist != NULL) printf("Dependency: %s\n", *keylist++);
+ while (keylist != NULL && *keylist != NULL)
+ printf("Dependency: %s\n", *keylist++);
printf("\n");
}
+ if (flags & OPT_SHOW_REQUIRED_BY) {
+ block_text = pkg_required_by(p);
+ if (block_text != NULL)
+ printf("Required by:\n%s\n\n", block_text);
+ }
+ if (flags & OPT_SHOW_DESCRIPTION) {
+ block_text = pkg_description(p);
+ if (block_text != NULL)
+ printf("Description:\n%s\n\n", block_text);
+ }
+ if (flags & OPT_SHOW_DISPLAY) {
+ block_text = pkg_display(p);
+ if (block_text != NULL)
+ printf("Install notice:\n%s\n\n", block_text);
+ }
+ if (flags & OPT_SHOW_PLIST) {
+ printf("Packing list:\n");
+ printf("\tComment: PKG_FORMAT_REVISION:%s\n", pkg_format_revision(p));
+ printf("\tPackage name: %s\n", pkg_name(p));
+ printf("\tPackage origin: %s\n", pkg_origin(p));
+ printf("\tCWD to %s\n", pkg_cwd(p));
+ for (keylist = pkg_depends(p); keylist != NULL && *keylist != NULL; *keylist++)
+ printf("Dependency: %s\n\tdependency origin: %s\n",
+ *keylist, pkg_pkg_depend_origin(p, *keylist));
+ for (keylist = pkg_files(p); keylist != NULL && *keylist != NULL; *keylist++)
+ printf("File: %s\n\tComment: MD5: %s\n",
+ *keylist, pkg_pkg_file_md5(p, *keylist));
+ for (keylist = pkg_execs(p); keylist != NULL && *keylist != NULL; *keylist++)
+ printf("\tEXEC '%s'\n", *keylist);
+ for (keylist = pkg_unexecs(p); keylist != NULL && *keylist != NULL; *keylist++)
+ printf("\tUNEXEC '%s'\n", *keylist);
+ }
+ if (flags & OPT_SHOW_REQUIRE)
+ /* LOLWAT */;;
+ if (flags & OPT_SHOW_INSTALL)
+ /* LOLWAT */;;
+ if (flags & OPT_SHOW_DEINSTALL)
+ /* LOLWAT */;;
+ if (flags & OPT_SHOW_MTREE) {
+ block_text = pkg_mtree_dirs(p);
+ if (block_text != NULL)
+ printf("mtree file:\n%s\n", block_text);
+ }
+ if (flags & OPT_SHOW_PREFIX)
+ printf("Prefix(s):\n\tCWD to %s\n", pkg_cwd(p));
+ if (flags & OPT_SHOW_FILES) {
+ printf("Files:\n");
+ for (keylist = pkg_files(p); keylist != NULL && *keylist != NULL; *keylist++)
+ printf("%s/%s\n", pkg_cwd(p), *keylist);
+ printf("\n");
+ }
+ if (flags & OPT_SHOW_SIZE) {
+ /* Make a util function for this. */
+ }
+ if (flags & OPT_SHOW_CHECKSUM) {
+ for (keylist = pkg_files(p); keylist != NULL && *keylist != NULL; *keylist++)
+ /* Make a util function to handle this. */;;
+ }
+ if (flags & OPT_SHOW_ORIGIN)
+ printf("Origin:\n%s\n\n", pkg_origin(p));
+ if (flags & OPT_SHOW_FORMAT_REVISION)
+ printf("Packing list format revision:\n%s\n\n", pkg_format_revision(p));
+
return (status);
}
More information about the p4-projects
mailing list