New pkg metadata structure for 0.18. See the NEWS file for info.

This commit is contained in:
Juan RP
2012-11-16 16:55:35 +01:00
parent db4b542d40
commit 34bd49f85a
28 changed files with 672 additions and 534 deletions

View File

@@ -510,9 +510,9 @@ main(int argc, char **argv)
/*
* Internalize the plist file of the target installed package.
*/
plistd = xbps_dictionary_from_metadata_plist(&xh, argv[0], XBPS_PKGPROPS);
plistd = xbps_pkgd_from_metadir(&xh, argv[0]);
if (plistd == NULL)
die("cannot internalize %s from %s", XBPS_PKGPROPS, argv[0]);
die("cannot internalize %s metadata file", argv[0]);
/*
* Create the output FILE.

View File

@@ -173,8 +173,6 @@ main(int argc, char **argv)
xh.repository = defrepo;
if (flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb_verbose;
else
xh.unpack_cb = unpack_progress_cb;
if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("Failed to initialize libxbps: %s\n",

View File

@@ -49,46 +49,48 @@ state_cb(struct xbps_handle *xhp,
switch (xscd->state) {
/* notifications */
case XBPS_STATE_TRANS_DOWNLOAD:
printf("[*] Downloading binary packages\n");
printf("\n[*] Downloading binary packages\n");
break;
case XBPS_STATE_TRANS_VERIFY:
printf("[*] Verifying binary package integrity\n");
printf("\n[*] Verifying binary package integrity\n");
break;
case XBPS_STATE_TRANS_RUN:
printf("[*] Running transaction tasks\n");
printf("\n[*] Running transaction tasks\n");
break;
case XBPS_STATE_TRANS_CONFIGURE:
printf("[*] Configuring unpacked packages\n");
printf("\n[*] Configuring unpacked packages\n");
break;
case XBPS_STATE_REPOSYNC:
printf("[*] Updating `%s/%s' ...\n",
xscd->arg0, xscd->arg1);
break;
case XBPS_STATE_VERIFY:
printf("%s: checking binary pkg integrity ...\n", xscd->arg0);
break;
case XBPS_STATE_CONFIG_FILE:
if (xscd->desc != NULL)
printf("%s\n", xscd->desc);
break;
case XBPS_STATE_REMOVE:
printf("Removing `%s-%s' ...\n", xscd->arg0, xscd->arg1);
printf("%s-%s: removing ...\n", xscd->arg0, xscd->arg1);
break;
case XBPS_STATE_CONFIGURE:
printf("Configuring `%s-%s' ...\n", xscd->arg0, xscd->arg1);
printf("%s-%s: configuring ...\n", xscd->arg0, xscd->arg1);
break;
case XBPS_STATE_REGISTER:
case XBPS_STATE_UNREGISTER:
/* empty */
break;
case XBPS_STATE_UNPACK:
printf("Unpacking `%s-%s' ...\n", xscd->arg0, xscd->arg1);
printf("%s-%s: unpacking ...\n", xscd->arg0, xscd->arg1);
break;
case XBPS_STATE_INSTALL:
printf("Installing `%s-%s' ...\n", xscd->arg0, xscd->arg1);
printf("%s-%s: installing ...\n", xscd->arg0, xscd->arg1);
break;
case XBPS_STATE_UPDATE:
pkgd = xbps_find_pkg_dict_installed(xhp, xscd->arg0, false);
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
printf("Updating `%s' (`%s' to `%s') ...\n", xscd->arg0,
printf("%s-%s: updating to %s ...\n", xscd->arg0,
version, xscd->arg1);
break;
/* success */
@@ -102,7 +104,7 @@ state_cb(struct xbps_handle *xhp,
}
break;
case XBPS_STATE_INSTALL_DONE:
printf("Installed `%s-%s' successfully.\n",
printf("%s-%s: installed successfully.\n",
xscd->arg0, xscd->arg1);
if (syslog_enabled)
syslog(LOG_NOTICE, "Installed `%s-%s' successfully "
@@ -110,7 +112,7 @@ state_cb(struct xbps_handle *xhp,
xhp->rootdir);
break;
case XBPS_STATE_UPDATE_DONE:
printf("Updated `%s' to `%s' successfully.\n",
printf("%s-%s: updated successfully.\n",
xscd->arg0, xscd->arg1);
if (syslog_enabled)
syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully "
@@ -118,7 +120,7 @@ state_cb(struct xbps_handle *xhp,
xhp->rootdir);
break;
case XBPS_STATE_REMOVE_DONE:
printf("Removed `%s-%s' successfully.\n",
printf("%s-%s: removed successfully.\n",
xscd->arg0, xscd->arg1);
if (syslog_enabled)
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "

View File

@@ -314,7 +314,7 @@ exec_transaction(struct xbps_handle *xhp, size_t maxcols, bool yes, bool drun)
* It's time to run the transaction!
*/
if ((rv = xbps_transaction_commit(xhp)) == 0) {
printf("%u installed, %u updated, "
printf("\n%u installed, %u updated, "
"%u configured, %u removed.\n", trans->inst_pkgcnt,
trans->up_pkgcnt, trans->cf_pkgcnt + trans->inst_pkgcnt,
trans->rm_pkgcnt);

View File

@@ -2,9 +2,10 @@ TOPDIR = ../..
-include $(TOPDIR)/config.mk
BIN = xbps-pkgdb
OBJS = main.o check.o check_pkg_automatic.o check_pkg_files.o
OBJS = main.o check.o check_pkg_files.o
OBJS += check_pkg_requiredby.o check_pkg_rundeps.o
OBJS += check_pkg_symlinks.o check_pkg_unneeded.o
OBJS += convert.o
MAN = $(BIN).8

View File

@@ -59,9 +59,6 @@ cb_pkg_integrity(struct xbps_handle *xhp,
cpkg->npkgs, cpkg->totalpkgs, pkgname, version);
if (check_pkg_integrity(xhp, obj, pkgname, false, &flush) != 0)
cpkg->nbrokenpkgs++;
else
printf("\033[1A\033[K");
if (flush && !cpkg->flush)
cpkg->flush = flush;
@@ -100,13 +97,16 @@ check_pkg_integrity(struct xbps_handle *xhp,
bool flush,
bool *setflush)
{
prop_dictionary_t opkgd, propsd, filesd;
prop_dictionary_t opkgd, propsd;
const char *sha256;
char *buf;
int rv = 0;
bool pkgdb_update = false, broken = false;
propsd = filesd = opkgd = NULL;
propsd = opkgd = NULL;
/* find real pkg by name */
opkgd = pkgd;
if (pkgd == NULL) {
opkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
if (opkgd == NULL) {
@@ -122,27 +122,33 @@ check_pkg_integrity(struct xbps_handle *xhp,
/*
* Check for props.plist metadata file.
*/
propsd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS);
propsd = xbps_pkgd_from_metadir(xhp, pkgname);
if (propsd == NULL) {
xbps_error_printf("%s: unexistent %s or invalid metadata "
"file.\n", pkgname, XBPS_PKGPROPS);
broken = true;
goto out;
printf("%s: unexistent metafile, converting to 0.18 "
"format...\n", pkgname);
if ((rv = convert_pkgd_metadir(xhp, opkgd)) != 0)
goto out;
pkgdb_update = true;
goto out1;
} else if (prop_dictionary_count(propsd) == 0) {
xbps_error_printf("%s: incomplete %s metadata file.\n",
pkgname, XBPS_PKGPROPS);
xbps_error_printf("%s: incomplete metadata file.\n", pkgname);
broken = true;
goto out;
}
/*
* Check for files.plist metadata file.
*/
filesd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
if (filesd == NULL) {
xbps_error_printf("%s: unexistent %s or invalid metadata "
"file.\n", pkgname, XBPS_PKGFILES);
broken = true;
goto out;
prop_dictionary_get_cstring_nocopy(opkgd, "metafile-sha256", &sha256);
if (sha256 != NULL) {
buf = xbps_xasprintf("%s/.%s.plist",
xhp->metadir, pkgname);
rv = xbps_file_hash_check(buf, sha256);
free(buf);
if (rv == ERANGE) {
broken = true;
fprintf(stderr, "%s: metadata file has been "
"modified!\n", pkgname);
goto out;
}
}
#define RUN_PKG_CHECK(x, name, arg, arg2) \
@@ -158,13 +164,13 @@ do { \
} while (0)
/* Execute pkg checks */
RUN_PKG_CHECK(xhp, files, filesd, &pkgdb_update);
RUN_PKG_CHECK(xhp, symlinks, filesd, &pkgdb_update);
RUN_PKG_CHECK(xhp, files, propsd, &pkgdb_update);
RUN_PKG_CHECK(xhp, symlinks, propsd, &pkgdb_update);
RUN_PKG_CHECK(xhp, rundeps, propsd, &pkgdb_update);
RUN_PKG_CHECK(xhp, requiredby, pkgd ? pkgd : opkgd, &pkgdb_update);
RUN_PKG_CHECK(xhp, autoinstall, pkgd ? pkgd : opkgd, &pkgdb_update);
RUN_PKG_CHECK(xhp, unneeded, pkgd ? pkgd : opkgd, &pkgdb_update);
RUN_PKG_CHECK(xhp, requiredby, opkgd, &pkgdb_update);
RUN_PKG_CHECK(xhp, unneeded, opkgd, &pkgdb_update);
out1:
if (flush && pkgdb_update) {
if (!xbps_pkgdb_replace_pkgd(xhp, opkgd, pkgname, false, true)) {
rv = EINVAL;
@@ -177,8 +183,6 @@ do { \
#undef RUN_PKG_CHECK
out:
if (prop_object_type(filesd) == PROP_TYPE_DICTIONARY)
prop_object_release(filesd);
if (prop_object_type(propsd) == PROP_TYPE_DICTIONARY)
prop_object_release(propsd);
if (broken)

View File

@@ -1,77 +0,0 @@
/*-
* Copyright (c) 2011-2012 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <sys/param.h>
#include <xbps_api.h>
#include "defs.h"
/*
* Checks package integrity of an installed package.
* The following task is accomplished in this file:
*
* o Check if package was installed manually, but currently
* other packages are depending on it. This package shall be
* changed to automatic mode, i.e installed as dependency of
* those packages.
*
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
*/
int
check_pkg_autoinstall(struct xbps_handle *xhp,
const char *pkgname,
void *arg,
bool *pkgdb_update)
{
prop_dictionary_t pkgd = arg;
prop_array_t reqby;
bool autoinst = false;
(void)xhp;
/*
* Check if package has been installed manually but any other
* package is currently depending on it; in that case the package
* must be in automatic mode.
*/
if (prop_dictionary_get_bool(pkgd, "automatic-install", &autoinst)) {
reqby = prop_dictionary_get(pkgd, "requiredby");
if (reqby != NULL && prop_array_count(reqby) && !autoinst) {
/* pkg has reversedeps and was installed manually */
prop_dictionary_set_bool(pkgd,
"automatic-install", true);
*pkgdb_update = true;
printf("%s: changed to automatic install mode.\n",
pkgname);
}
}
return 0;
}

View File

@@ -65,8 +65,7 @@ check_reqby_pkg_cb(struct xbps_handle *xhp,
* Internalize current pkg props dictionary from its
* installed metadata directory.
*/
curpkg_propsd =
xbps_dictionary_from_metadata_plist(xhp, curpkgn, XBPS_PKGPROPS);
curpkg_propsd = xbps_pkgd_from_metadir(xhp, curpkgn);
if (curpkg_propsd == NULL) {
xbps_error_printf("%s: missing %s metadata file!\n",
curpkgn, XBPS_PKGPROPS);

173
bin/xbps-pkgdb/convert.c Normal file
View File

@@ -0,0 +1,173 @@
/*-
* Copyright (c) 2012 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <xbps_api.h>
#include "defs.h"
static prop_data_t
create_script_blob(struct xbps_handle *xhp,
const char *file,
const char *pkgname)
{
prop_data_t data;
struct stat st;
void *mf;
char *buf;
int fd;
buf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir, pkgname, file);
if ((fd = open(buf, O_RDONLY)) == -1) {
free(buf);
if (errno != ENOENT)
fprintf(stderr, "%s: can't read INSTALL script: %s\n",
pkgname, strerror(errno));
return NULL;
}
if (stat(buf, &st) == -1) {
free(buf);
fprintf(stderr, "%s: failed to stat %s script: %s\n",
pkgname, file, strerror(errno));
return NULL;
}
free(buf);
mf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (mf == MAP_FAILED) {
close(fd);
fprintf(stderr, "%s: failed to map INSTALL script: %s\n",
pkgname, strerror(errno));
return NULL;
}
data = prop_data_create_data(mf, st.st_size);
munmap(mf, st.st_size);
return data;
}
/*
* Converts package metadata format to 0.18.
*/
int
convert_pkgd_metadir(struct xbps_handle *xhp, prop_dictionary_t pkgd)
{
prop_dictionary_t filesd, propsd;
prop_array_t array;
prop_data_t data;
const char *pkgname;
char *buf, *sha256, *propsf, *filesf;
prop_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
/* Merge XBPS_PKGFILES */
propsf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir,
pkgname, XBPS_PKGPROPS);
propsd = prop_dictionary_internalize_from_zfile(propsf);
assert(propsd);
filesf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir,
pkgname, XBPS_PKGFILES);
filesd = prop_dictionary_internalize_from_zfile(filesf);
assert(filesd);
array = prop_dictionary_get(filesd, "files");
if (array && prop_array_count(array))
prop_dictionary_set(propsd, "files", array);
array = prop_dictionary_get(filesd, "conf_files");
if (array && prop_array_count(array))
prop_dictionary_set(propsd, "conf_files", array);
array = prop_dictionary_get(filesd, "dirs");
if (array && prop_array_count(array))
prop_dictionary_set(propsd, "dirs", array);
array = prop_dictionary_get(filesd, "links");
if (array && prop_array_count(array))
prop_dictionary_set(propsd, "links", array);
prop_object_release(filesd);
/* Merge INSTALL script */
if ((data = create_script_blob(xhp, "INSTALL", pkgname))) {
prop_dictionary_set(propsd, "install-script", data);
prop_object_release(data);
}
/* Merge REMOVE script */
if ((data = create_script_blob(xhp, "REMOVE", pkgname))) {
prop_dictionary_set(propsd, "remove-script", data);
prop_object_release(data);
}
/* Externalize pkg metaplist */
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
if (!prop_dictionary_externalize_to_file(propsd, buf)) {
fprintf(stderr, "%s: can't externalize plist: %s\n",
pkgname, strerror(errno));
return -1;
}
/* create sha256 hash for pkg plist */
sha256 = xbps_file_hash(buf);
free(buf);
assert(sha256);
prop_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
free(sha256);
/* Remove old files/dir */
if ((remove(propsf) == -1) || (remove(filesf) == -1))
fprintf(stderr, "%s: failed to remove %s: %s\n",
pkgname, propsf, strerror(errno));
buf = xbps_xasprintf("%s/metadata/%s/INSTALL", xhp->metadir, pkgname);
if (access(buf, R_OK) == 0)
remove(buf);
free(buf);
buf = xbps_xasprintf("%s/metadata/%s/REMOVE", xhp->metadir, pkgname);
if (access(buf, R_OK) == 0)
remove(buf);
free(buf);
buf = xbps_xasprintf("%s/metadata/%s", xhp->metadir, pkgname);
remove(buf);
free(buf);
buf = xbps_xasprintf("%s/metadata", xhp->metadir);
remove(buf);
free(buf);
return 0;
}

View File

@@ -40,11 +40,13 @@ int check_pkg_integrity_all(struct xbps_handle *);
#define CHECK_PKG_DECL(type) \
int check_pkg_##type (struct xbps_handle *, const char *, void *, bool *)
CHECK_PKG_DECL(autoinstall);
CHECK_PKG_DECL(unneeded);
CHECK_PKG_DECL(files);
CHECK_PKG_DECL(rundeps);
CHECK_PKG_DECL(symlinks);
CHECK_PKG_DECL(requiredby);
/* from convert.c */
int convert_pkgd_metadir(struct xbps_handle *, prop_dictionary_t);
#endif /* !_XBPS_PKGDB_DEFS_H_ */

View File

@@ -34,6 +34,12 @@
#include <xbps_api.h>
#include "defs.h"
struct ffdata {
int npatterns;
char **patterns;
const char *repouri;
};
static int
match_files_by_pattern(prop_dictionary_t pkg_filesd,
prop_dictionary_keysym_t key,
@@ -48,7 +54,6 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
int i;
keyname = prop_dictionary_keysym_cstring_nocopy(key);
array = prop_dictionary_get_keysym(pkg_filesd, key);
if (strcmp(keyname, "files") == 0)
typestr = "regular file";
@@ -56,10 +61,14 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
typestr = "directory";
else if (strcmp(keyname, "links") == 0)
typestr = "link";
else
else if (strcmp(keyname, "conf_files") == 0)
typestr = "configuration file";
else
return 0;
array = prop_dictionary_get_keysym(pkg_filesd, key);
iter = prop_array_iterator(array);
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr);
for (i = 0; i < npatterns; i++) {
@@ -73,61 +82,45 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
return 0;
}
int
ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
static int
ownedby_pkgdb_cb(struct xbps_handle *xhp, prop_object_t obj, void *arg, bool *done)
{
prop_dictionary_t pkg_filesd;
prop_dictionary_t pkgmetad;
prop_array_t files_keys;
DIR *dirp;
struct dirent *dp;
char *path;
struct ffdata *ffd = arg;
unsigned int i;
const char *pkgname;
int rv = 0;
unsigned int i, count;
path = xbps_xasprintf("%s/metadata", xhp->metadir);
if ((dirp = opendir(path)) == NULL) {
free(path);
return -1;
}
(void)done;
while ((dp = readdir(dirp)) != NULL) {
if ((strcmp(dp->d_name, ".") == 0) ||
(strcmp(dp->d_name, "..") == 0))
continue;
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
pkgmetad = xbps_pkgd_from_metadir(xhp, pkgname);
pkg_filesd = xbps_dictionary_from_metadata_plist(xhp,
dp->d_name, XBPS_PKGFILES);
if (pkg_filesd == NULL) {
if (errno == ENOENT)
continue;
rv = -1;
break;
}
files_keys = prop_dictionary_all_keys(pkg_filesd);
count = prop_array_count(files_keys);
for (i = 0; i < count; i++) {
rv = match_files_by_pattern(pkg_filesd,
prop_array_get(files_keys, i),
npatterns, patterns, dp->d_name);
if (rv == -1)
break;
}
prop_object_release(files_keys);
prop_object_release(pkg_filesd);
files_keys = prop_dictionary_all_keys(pkgmetad);
for (i = 0; i < prop_array_count(files_keys); i++) {
rv = match_files_by_pattern(pkgmetad,
prop_array_get(files_keys, i),
ffd->npatterns, ffd->patterns, pkgname);
if (rv == -1)
break;
}
(void)closedir(dirp);
free(path);
prop_object_release(files_keys);
prop_object_release(pkgmetad);
return rv;
}
struct ffdata {
int npatterns;
char **patterns;
const char *repouri;
};
int
ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
{
struct ffdata ffd;
ffd.npatterns = npatterns;
ffd.patterns = patterns;
return xbps_pkgdb_foreach_cb(xhp, ownedby_pkgdb_cb, &ffd);
}
static void
repo_match_files_by_pattern(struct xbps_handle *xhp,

View File

@@ -44,8 +44,7 @@ show_pkg_deps(struct xbps_handle *xhp, const char *pkgname)
/*
* Check for props.plist metadata file.
*/
propsd = xbps_dictionary_from_metadata_plist(xhp,
pkgname, XBPS_PKGPROPS);
propsd = xbps_pkgd_from_metadir(xhp, pkgname);
if (propsd == NULL)
return ENOENT;

View File

@@ -31,26 +31,33 @@
#include <limits.h>
#include <libgen.h>
#include <fnmatch.h>
#include <assert.h>
#include <xbps_api.h>
#include "defs.h"
static void
print_value_obj(const char *keyname, prop_object_t obj, bool raw)
print_value_obj(const char *keyname, prop_object_t obj,
const char *indent, bool raw)
{
const char *value;
prop_array_t allkeys;
prop_object_t obj2, keysym;
const char *ksymname, *value;
size_t i;
char size[8];
if (indent == NULL)
indent = "";
switch (prop_object_type(obj)) {
case PROP_TYPE_STRING:
if (!raw)
printf("%s: ", keyname);
printf("%s%s: ", indent, keyname);
printf("%s\n", prop_string_cstring_nocopy(obj));
break;
case PROP_TYPE_NUMBER:
if (!raw)
printf("%s: ", keyname);
printf("%s%s: ", indent, keyname);
if (xbps_humanize_number(size,
(int64_t)prop_number_unsigned_integer_value(obj)) == -1)
printf("%ju\n",
@@ -60,20 +67,53 @@ print_value_obj(const char *keyname, prop_object_t obj, bool raw)
break;
case PROP_TYPE_BOOL:
if (!raw)
printf("%s: ", keyname);
printf("%s%s: ", indent, keyname);
printf("%s\n", prop_bool_true(obj) ? "yes" : "no");
break;
case PROP_TYPE_ARRAY:
if (!raw)
printf("%s:\n", keyname);
printf("%s%s:\n", indent, keyname);
for (i = 0; i < prop_array_count(obj); i++) {
prop_array_get_cstring_nocopy(obj, i, &value);
printf("%s%s%s", !raw ? "\t" : "", value,
!raw ? "\n" : " ");
obj2 = prop_array_get(obj, i);
if (prop_object_type(obj2) == PROP_TYPE_STRING) {
value = prop_string_cstring_nocopy(obj2);
printf("%s%s%s%s", indent, !raw ? "\t" : "",
value, !raw ? "\n" : "");
} else {
print_value_obj(keyname, obj2, " ", raw);
}
}
if (raw)
printf("\n");
break;
case PROP_TYPE_DICTIONARY:
allkeys = prop_dictionary_all_keys(obj);
for (i = 0; i < prop_array_count(allkeys); i++) {
keysym = prop_array_get(allkeys, i);
ksymname = prop_dictionary_keysym_cstring_nocopy(keysym);
obj2 = prop_dictionary_get_keysym(obj, keysym);
print_value_obj(ksymname, obj2, " ", raw);
}
prop_object_release(allkeys);
if (raw)
printf("\n");
break;
case PROP_TYPE_DATA:
if (!raw) {
xbps_humanize_number(size, (int64_t)prop_data_size(obj));
printf("%s%s: %s\n", indent, keyname, size);
} else {
FILE *f;
char buf[BUFSIZ-1];
f = fmemopen(prop_data_data(obj),
prop_data_size(obj), "r");
assert(f);
while (fgets(buf, BUFSIZ-1, f))
printf("%s", buf);
fclose(f);
}
break;
default:
xbps_warn_printf("unknown obj type (key %s)\n",
keyname);
@@ -91,7 +131,7 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
obj = prop_dictionary_get(d, keys);
if (obj == NULL)
return;
print_value_obj(keys, obj, true);
print_value_obj(keys, obj, NULL, true);
return;
}
key = strdup(keys);
@@ -102,7 +142,7 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
obj = prop_dictionary_get(d, p);
if (obj == NULL)
continue;
print_value_obj(p, obj, true);
print_value_obj(p, obj, NULL, true);
}
free(key);
}
@@ -120,11 +160,15 @@ show_pkg_info(prop_dictionary_t dict)
keysym = prop_array_get(all_keys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(keysym);
obj = prop_dictionary_get_keysym(dict, keysym);
/* ignore run_depends, it's shown via 'show-deps' */
if (strcmp(keyname, "run_depends") == 0)
/* ignore objs shown by other targets */
if ((strcmp(keyname, "run_depends") == 0) ||
(strcmp(keyname, "requiredby") == 0) ||
(strcmp(keyname, "files") == 0) ||
(strcmp(keyname, "dirs") == 0) ||
(strcmp(keyname, "links") == 0))
continue;
print_value_obj(keyname, obj, false);
print_value_obj(keyname, obj, NULL, false);
}
prop_object_release(all_keys);
}
@@ -142,7 +186,9 @@ show_pkg_files(prop_dictionary_t filesd)
for (i = 0; i < prop_array_count(allkeys); i++) {
ksym = prop_array_get(allkeys, i);
keyname = prop_dictionary_keysym_cstring_nocopy(ksym);
if (strcmp(keyname, "dirs") == 0)
if ((strcmp(keyname, "files") &&
(strcmp(keyname, "conf_files") &&
(strcmp(keyname, "links")))))
continue;
array = prop_dictionary_get(filesd, keyname);
@@ -174,7 +220,7 @@ show_pkg_info_from_metadir(struct xbps_handle *xhp,
const char *instdate, *pname;
bool autoinst;
d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS);
d = xbps_pkgd_from_metadir(xhp, pkgname);
if (d == NULL)
return ENOENT;
@@ -207,7 +253,7 @@ show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkgname)
prop_dictionary_t d;
int rv = 0;
d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
d = xbps_pkgd_from_metadir(xhp, pkgname);
if (d == NULL)
return ENOENT;

View File

@@ -65,7 +65,7 @@ state_cb(struct xbps_handle *xhp, struct xbps_state_cb_data *xscd, void *cbd)
switch (xscd->state) {
/* notifications */
case XBPS_STATE_CONFIGURE:
printf("Configuring `%s-%s' ...\n", xscd->arg0, xscd->arg1);
printf("%s-%s: configuraring ...\n", xscd->arg0, xscd->arg1);
break;
/* errors */
case XBPS_STATE_CONFIGURE_FAIL: