New pkgdb (0.21) and repo index (1.7) format, see NEWS for info.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include <assert.h>
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
|
||||
@@ -34,7 +35,8 @@ void
|
||||
state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
const char *version;
|
||||
const char *instver, *newver;
|
||||
char *pkgname;
|
||||
bool syslog_enabled = false;
|
||||
|
||||
(void)cbdata;
|
||||
@@ -59,36 +61,44 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
printf("\n[*] Configuring unpacked packages\n");
|
||||
break;
|
||||
case XBPS_STATE_REPOSYNC:
|
||||
printf("[*] Updating `%s' ...\n", xscd->arg0);
|
||||
printf("[*] Updating `%s' ...\n", xscd->arg);
|
||||
break;
|
||||
case XBPS_STATE_VERIFY:
|
||||
printf("%s: checking binary pkg integrity ...\n", xscd->arg0);
|
||||
printf("%s: checking binary pkg integrity ...\n", xscd->arg);
|
||||
break;
|
||||
case XBPS_STATE_XBPS_UPDATE:
|
||||
printf("A new update for xbps has been found; this package "
|
||||
"must be updated independently. After this update you can "
|
||||
"continue updating your system.\n\n");
|
||||
break;
|
||||
case XBPS_STATE_CONFIG_FILE:
|
||||
if (xscd->desc != NULL)
|
||||
printf("%s\n", xscd->desc);
|
||||
break;
|
||||
case XBPS_STATE_REMOVE:
|
||||
printf("%s-%s: removing ...\n", xscd->arg0, xscd->arg1);
|
||||
printf("%s: removing ...\n", xscd->arg);
|
||||
break;
|
||||
case XBPS_STATE_CONFIGURE:
|
||||
printf("%s-%s: configuring ...\n", xscd->arg0, xscd->arg1);
|
||||
printf("%s: configuring ...\n", xscd->arg);
|
||||
break;
|
||||
case XBPS_STATE_REGISTER:
|
||||
case XBPS_STATE_UNREGISTER:
|
||||
/* empty */
|
||||
break;
|
||||
case XBPS_STATE_UNPACK:
|
||||
printf("%s-%s: unpacking ...\n", xscd->arg0, xscd->arg1);
|
||||
printf("%s: unpacking ...\n", xscd->arg);
|
||||
break;
|
||||
case XBPS_STATE_INSTALL:
|
||||
/* empty */
|
||||
break;
|
||||
case XBPS_STATE_UPDATE:
|
||||
pkgd = xbps_pkgdb_get_pkg(xscd->xhp, xscd->arg0);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
|
||||
printf("%s-%s: updating to %s ...\n", xscd->arg0,
|
||||
version, xscd->arg1);
|
||||
pkgname = xbps_pkg_name(xscd->arg);
|
||||
assert(pkgname);
|
||||
newver = xbps_pkg_version(xscd->arg);
|
||||
pkgd = xbps_pkgdb_get_pkg(xscd->xhp, pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "version", &instver);
|
||||
printf("%s-%s: updating to %s ...\n", pkgname, instver, newver);
|
||||
free(pkgname);
|
||||
break;
|
||||
/* success */
|
||||
case XBPS_STATE_REMOVE_FILE:
|
||||
@@ -101,27 +111,24 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
}
|
||||
break;
|
||||
case XBPS_STATE_INSTALL_DONE:
|
||||
printf("%s-%s: installed successfully.\n",
|
||||
xscd->arg0, xscd->arg1);
|
||||
printf("%s: installed successfully.\n", xscd->arg);
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Installed `%s-%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
syslog(LOG_NOTICE, "Installed `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
case XBPS_STATE_UPDATE_DONE:
|
||||
printf("%s-%s: updated successfully.\n",
|
||||
xscd->arg0, xscd->arg1);
|
||||
printf("%s: updated successfully.\n", xscd->arg);
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Updated `%s' to `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
syslog(LOG_NOTICE, "Updated `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
case XBPS_STATE_REMOVE_DONE:
|
||||
printf("%s-%s: removed successfully.\n",
|
||||
xscd->arg0, xscd->arg1);
|
||||
printf("%s: removed successfully.\n", xscd->arg);
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
syslog(LOG_NOTICE, "Removed `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
/* errors */
|
||||
@@ -152,7 +159,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf(xscd->xhp,
|
||||
"unknown state %d\n", xscd->state);
|
||||
"%s: unknown state %d\n", xscd->arg, xscd->state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -75,20 +75,18 @@ static void
|
||||
show_actions(prop_object_iterator_t iter)
|
||||
{
|
||||
prop_object_t obj;
|
||||
const char *repoloc, *trans, *pkgname, *version, *fname, *arch;
|
||||
const char *repoloc, *trans, *pkgver, *arch;
|
||||
|
||||
repoloc = trans = pkgname = version = fname = arch = NULL;
|
||||
repoloc = trans = pkgver = arch = NULL;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
printf("%s %s %s", pkgname, trans, version);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &fname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
if (repoloc && fname && arch)
|
||||
printf(" %s %s %s", repoloc, fname, arch);
|
||||
printf("%s %s %s", pkgver, arch, trans);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "repository", &repoloc);
|
||||
if (repoloc)
|
||||
printf(" %s", repoloc);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.Dd February 20, 2013
|
||||
.Dd March 4, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-install 8
|
||||
.Sh NAME
|
||||
@@ -95,13 +95,13 @@ architecture.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/db/xbps/.<pkgname>.plist
|
||||
.It Ar /etc/xbps/xbps.conf
|
||||
Default XBPS configuration file.
|
||||
Default configuration file.
|
||||
.It Ar /var/db/xbps/.<pkgname>.plist
|
||||
Package metadata properties.
|
||||
.It Ar /var/db/xbps/pkgdb.plist
|
||||
XBPS package database.
|
||||
.It Ar /var/db/xbps/pkgdb-0.21.plist
|
||||
Default package database (0.21 format). Keeps track of installed packages and properties.
|
||||
.It Ar /var/cache/xbps
|
||||
Default XBPS cache directory.
|
||||
Default cache directory to store downloaded binary packages.
|
||||
.Sh SEE ALSO
|
||||
.Xr xbps-create 8 ,
|
||||
.Xr xbps-dgraph 8 ,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -48,24 +48,34 @@ static void *
|
||||
pkgdb_thread_worker(void *arg)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t array;
|
||||
prop_object_t obj;
|
||||
struct thread_data *thd = arg;
|
||||
const char *pkgname, *pkgver;
|
||||
const char *pkgver;
|
||||
char *pkgname;
|
||||
unsigned int i;
|
||||
int rv;
|
||||
|
||||
array = prop_dictionary_all_keys(thd->xhp->pkgdb);
|
||||
assert(array);
|
||||
|
||||
/* process pkgs from start until end */
|
||||
for (i = thd->start; i < thd->end; i++) {
|
||||
pkgd = prop_array_get(thd->xhp->pkgdb, i);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
|
||||
obj = prop_array_get(array, i);
|
||||
pkgd = prop_dictionary_get_keysym(thd->xhp->pkgdb, obj);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
if (thd->xhp->flags & XBPS_FLAG_VERBOSE)
|
||||
printf("Checking %s ...\n", pkgver);
|
||||
|
||||
pkgname = xbps_pkg_name(pkgver);
|
||||
assert(pkgname);
|
||||
rv = check_pkg_integrity(thd->xhp, pkgd, pkgname);
|
||||
free(pkgname);
|
||||
if (rv != 0)
|
||||
fprintf(stderr, "pkgdb[%d] failed for %s: %s\n",
|
||||
thd->thread_num, pkgver, strerror(rv));
|
||||
}
|
||||
prop_object_release(array);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -84,7 +94,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
|
||||
thd = calloc(maxthreads, sizeof(*thd));
|
||||
assert(thd);
|
||||
|
||||
slicecount = prop_array_count(xhp->pkgdb) / maxthreads;
|
||||
slicecount = prop_dictionary_count(xhp->pkgdb) / maxthreads;
|
||||
pkgcount = 0;
|
||||
|
||||
for (i = 0; i < maxthreads; i++) {
|
||||
@@ -92,7 +102,7 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
|
||||
thd[i].xhp = xhp;
|
||||
thd[i].start = pkgcount;
|
||||
if (i + 1 >= maxthreads)
|
||||
thd[i].end = prop_array_count(xhp->pkgdb);
|
||||
thd[i].end = prop_dictionary_count(xhp->pkgdb);
|
||||
else
|
||||
thd[i].end = pkgcount + slicecount;
|
||||
pthread_create(&thd[i].thread, NULL,
|
||||
@@ -141,13 +151,8 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
propsd = prop_dictionary_internalize_from_file(buf);
|
||||
free(buf);
|
||||
if (propsd == NULL) {
|
||||
printf("%s: unexistent metafile, converting to 0.18 "
|
||||
"format...\n", pkgname);
|
||||
if ((rv = convert_pkgd_metadir(xhp, opkgd)) != 0)
|
||||
return rv;
|
||||
|
||||
return 0;
|
||||
|
||||
xbps_error_printf("%s: unexistent metafile!\n", pkgname);
|
||||
return EINVAL;
|
||||
} else if (prop_dictionary_count(propsd) == 0) {
|
||||
xbps_error_printf("%s: incomplete metadata file.\n", pkgname);
|
||||
prop_object_release(propsd);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,136 +38,81 @@
|
||||
#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.
|
||||
* Convert pkgdb format to 0.21.
|
||||
*/
|
||||
int
|
||||
convert_pkgd_metadir(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
static void
|
||||
pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
|
||||
{
|
||||
prop_dictionary_t filesd, propsd;
|
||||
prop_array_t array;
|
||||
prop_data_t data;
|
||||
const char *pkgname;
|
||||
char *buf, *sha256, *propsf, *filesf;
|
||||
prop_array_t array, rdeps;
|
||||
prop_dictionary_t pkgdb, pkgd;
|
||||
size_t i;
|
||||
char *pkgname, *plist;
|
||||
|
||||
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);
|
||||
plist = xbps_xasprintf("%s/pkgdb.plist", xhp->metadir);
|
||||
if (access(plist, R_OK) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
/* missing file, no conversion needed */
|
||||
free(plist);
|
||||
return;
|
||||
}
|
||||
xbps_error_printf("cannot read %s: %s\n",
|
||||
plist, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* Merge REMOVE script */
|
||||
if ((data = create_script_blob(xhp, "REMOVE", pkgname))) {
|
||||
prop_dictionary_set(propsd, "remove-script", data);
|
||||
prop_object_release(data);
|
||||
|
||||
array = prop_array_internalize_from_zfile(plist);
|
||||
if (prop_object_type(array) != PROP_TYPE_ARRAY) {
|
||||
xbps_error_printf("unknown object type for %s\n",
|
||||
plist, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* 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;
|
||||
|
||||
pkgdb = prop_dictionary_create();
|
||||
assert(pkgdb);
|
||||
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
pkgd = prop_array_get(array, i);
|
||||
prop_dictionary_get_cstring(pkgd, "pkgname", &pkgname);
|
||||
rdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
/* remove unneeded objs */
|
||||
prop_dictionary_remove(pkgd, "pkgname");
|
||||
prop_dictionary_remove(pkgd, "version");
|
||||
if (prop_array_count(rdeps) == 0)
|
||||
prop_dictionary_remove(pkgd, "run_depends");
|
||||
|
||||
prop_dictionary_set(pkgdb, pkgname, pkgd);
|
||||
free(pkgname);
|
||||
}
|
||||
/* 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));
|
||||
if (prop_array_count(array) != prop_dictionary_count(pkgdb)) {
|
||||
xbps_error_printf("failed conversion! unmatched obj count "
|
||||
"(got %zu, need %zu)\n", prop_dictionary_count(pkgdb),
|
||||
prop_array_count(array));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
buf = xbps_xasprintf("%s/metadata/%s/INSTALL", xhp->metadir, pkgname);
|
||||
if (access(buf, R_OK) == 0)
|
||||
remove(buf);
|
||||
free(buf);
|
||||
if (!prop_dictionary_externalize_to_file(pkgdb, plist_new)) {
|
||||
xbps_error_printf("failed to write %s: %s\n",
|
||||
plist_new, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
buf = xbps_xasprintf("%s/metadata/%s/REMOVE", xhp->metadir, pkgname);
|
||||
if (access(buf, R_OK) == 0)
|
||||
remove(buf);
|
||||
free(buf);
|
||||
prop_object_release(array);
|
||||
prop_object_release(pkgdb);
|
||||
free(plist);
|
||||
|
||||
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;
|
||||
printf("Conversion to 0.21 pkgdb format successfully\n");
|
||||
}
|
||||
|
||||
void
|
||||
convert_pkgdb_format(struct xbps_handle *xhp)
|
||||
{
|
||||
char *plist;
|
||||
|
||||
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
|
||||
if ((access(plist, R_OK) == -1) && (errno == ENOENT))
|
||||
pkgdb_format_021(xhp, plist);
|
||||
|
||||
free(plist);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2012-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,6 +42,6 @@ CHECK_PKG_DECL(rundeps);
|
||||
CHECK_PKG_DECL(symlinks);
|
||||
|
||||
/* from convert.c */
|
||||
int convert_pkgd_metadir(struct xbps_handle *, prop_dictionary_t);
|
||||
void convert_pkgdb_format(struct xbps_handle *);
|
||||
|
||||
#endif /* !_XBPS_PKGDB_DEFS_H_ */
|
||||
|
||||
@@ -46,6 +46,7 @@ usage(bool fail)
|
||||
" -h --help Print usage help\n"
|
||||
" -m --mode <auto|manual> Change PKGNAME to automatic or manual mode\n"
|
||||
" -r --rootdir <dir> Full path to rootdir\n"
|
||||
" -u --update Update pkgdb to the latest format\n"
|
||||
" -v --verbose Verbose messages\n"
|
||||
" -V --version Show XBPS version\n");
|
||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
@@ -73,7 +74,7 @@ change_pkg_instmode(struct xbps_handle *xhp,
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char *shortopts = "aC:dhm:r:Vv";
|
||||
const char *shortopts = "aC:dhm:r:uVv";
|
||||
const struct option longopts[] = {
|
||||
{ "all", no_argument, NULL, 'a' },
|
||||
{ "config", required_argument, NULL, 'C' },
|
||||
@@ -81,6 +82,7 @@ main(int argc, char **argv)
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "mode", required_argument, NULL, 'm' },
|
||||
{ "rootdir", required_argument, NULL, 'r' },
|
||||
{ "update", no_argument, NULL, 'u' },
|
||||
{ "verbose", no_argument, NULL, 'v' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
@@ -88,7 +90,7 @@ main(int argc, char **argv)
|
||||
struct xbps_handle xh;
|
||||
const char *conffile = NULL, *rootdir = NULL, *instmode = NULL;
|
||||
int c, i, rv, flags = 0;
|
||||
bool all = false;
|
||||
bool update_format = false, all = false;
|
||||
|
||||
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
@@ -110,6 +112,9 @@ main(int argc, char **argv)
|
||||
case 'r':
|
||||
rootdir = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
update_format = true;
|
||||
break;
|
||||
case 'v':
|
||||
flags |= XBPS_FLAG_VERBOSE;
|
||||
break;
|
||||
@@ -122,7 +127,7 @@ main(int argc, char **argv)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
if (!all && (argc == optind))
|
||||
if (!update_format && !all && (argc == optind))
|
||||
usage(true);
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
@@ -136,7 +141,9 @@ main(int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (instmode) {
|
||||
if (update_format)
|
||||
convert_pkgdb_format(&xh);
|
||||
else if (instmode) {
|
||||
if ((strcmp(instmode, "auto")) && (strcmp(instmode, "manual")))
|
||||
usage(true);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.Dd February 20, 2013
|
||||
.Dd March 4, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-pkgdb 8
|
||||
.Sh NAME
|
||||
@@ -13,7 +13,8 @@ The
|
||||
.Nm
|
||||
utility can check/fix issues and modify the package database (pkgdb).
|
||||
It's able to check for missing dependencies, modified files and symlinks,
|
||||
and more errors that have been fixed in newer versions of xbps.
|
||||
and more errors that have been fixed in newer versions of xbps. A mode to update
|
||||
the format to the latest version is also available.
|
||||
This is the list of things that
|
||||
.Nm
|
||||
currently does:
|
||||
@@ -29,6 +30,8 @@ Checks that all required dependencies for a package are resolved.
|
||||
.It Sy OBSOLETE METADATA CHECK
|
||||
Checks that the package database does not contain obsolete data from previous
|
||||
XBPS versions and removes them if found.
|
||||
.It Sy FORMAT CONVERSION
|
||||
Updates the pkgdb format to the latest version.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width -x
|
||||
.It Fl a, Fl -all
|
||||
@@ -45,14 +48,23 @@ Switches
|
||||
to the specified installation mode: automatic or manual mode.
|
||||
.It Fl r, Fl -rootdir Ar dir
|
||||
Specifies a full path for the target root directory.
|
||||
.It Fl u, Fl -update
|
||||
Updates the pkgdb format to the latest version making the necessary conversions
|
||||
automatically. Usually this is needed only in rare circumstances.
|
||||
.It Fl v, Fl -verbose
|
||||
Enables verbose messages.
|
||||
.It Fl V, Fl -version
|
||||
Shows the XBPS version.
|
||||
.Sh FILES
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
|
||||
.Bl -tag -width /var/db/xbps/.<pkgname>.plist
|
||||
.It Ar /etc/xbps/xbps.conf
|
||||
Default XBPS configuration file.
|
||||
Default configuration file.
|
||||
.It Ar /var/db/xbps/.<pkgname>.plist
|
||||
Package metadata properties.
|
||||
.It Ar /var/db/xbps/pkgdb-0.21.plist
|
||||
Default package database (0.21 format). Keeps track of installed packages and properties.
|
||||
.It Ar /var/cache/xbps
|
||||
Default cache directory to store downloaded binary packages.
|
||||
.Sh SEE ALSO
|
||||
.Xr xbps-create 8 ,
|
||||
.Xr xbps-dgraph 8 ,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,9 +33,9 @@
|
||||
#endif
|
||||
|
||||
/* from show-deps.c */
|
||||
int show_pkg_deps(struct xbps_handle *, const char *);
|
||||
int show_pkg_deps(struct xbps_handle *, const char *, bool);
|
||||
int show_pkg_revdeps(struct xbps_handle *, const char *);
|
||||
int repo_show_pkg_deps(struct xbps_handle *, const char *);
|
||||
int repo_show_pkg_deps(struct xbps_handle *, const char *, bool);
|
||||
int repo_show_pkg_revdeps(struct xbps_handle *, const char *);
|
||||
|
||||
/* from show-info-files.c */
|
||||
@@ -56,8 +56,6 @@ int repo_ownedby(struct xbps_handle *, int, char **);
|
||||
|
||||
/* From list.c */
|
||||
size_t get_maxcols(void);
|
||||
int list_strings_sep_in_array(struct xbps_handle *,
|
||||
prop_object_t, void *, bool *);
|
||||
size_t find_longest_pkgver(struct xbps_handle *, prop_object_t);
|
||||
|
||||
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
|
||||
|
||||
@@ -241,19 +241,3 @@ find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o)
|
||||
|
||||
return ffl.len;
|
||||
}
|
||||
|
||||
int
|
||||
list_strings_sep_in_array(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
const char *sep = arg;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ usage(bool fail)
|
||||
" -s --search PATTERN(s) Search for packages matching PATTERN(s)\n"
|
||||
" -f --files Show files for PKGNAME\n"
|
||||
" -p --property PROP,... Show properties for PKGNAME\n"
|
||||
" -x --deps Show dependencies for PKGNAME\n"
|
||||
" -x --deps Show dependencies for PKGNAME (set it twice for a full dependency tree)\n"
|
||||
" -X --revdeps Show reverse dependencies for PKGNAME\n");
|
||||
|
||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
@@ -90,16 +90,16 @@ main(int argc, char **argv)
|
||||
};
|
||||
struct xbps_handle xh;
|
||||
const char *rootdir, *cachedir, *conffile, *props, *defrepo;
|
||||
int c, flags, rv;
|
||||
int c, flags, rv, show_deps = 0;
|
||||
bool list_pkgs, list_repos, orphans, own;
|
||||
bool list_manual, show_prop, show_files, show_deps, show_rdeps;
|
||||
bool show, search, repo_mode, opmode;
|
||||
bool list_manual, show_prop, show_files, show_rdeps;
|
||||
bool show, search, repo_mode, opmode, fulldeptree;
|
||||
|
||||
rootdir = cachedir = conffile = defrepo = props = NULL;
|
||||
flags = rv = c = 0;
|
||||
list_pkgs = list_repos = orphans = search = own = false;
|
||||
list_manual = show_prop = show_files = false;
|
||||
show = show_deps = show_rdeps = false;
|
||||
show = show_rdeps = fulldeptree = false;
|
||||
repo_mode = opmode = false;
|
||||
|
||||
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||
@@ -157,7 +157,8 @@ main(int argc, char **argv)
|
||||
printf("%s\n", XBPS_RELVER);
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'x':
|
||||
show_deps = opmode = true;
|
||||
show_deps++;
|
||||
opmode = true;
|
||||
break;
|
||||
case 'X':
|
||||
show_rdeps = opmode = true;
|
||||
@@ -234,10 +235,13 @@ main(int argc, char **argv)
|
||||
|
||||
} else if (show_deps) {
|
||||
/* show-deps mode */
|
||||
if (show_deps > 1)
|
||||
fulldeptree = true;
|
||||
|
||||
if (repo_mode)
|
||||
rv = repo_show_pkg_deps(&xh, argv[optind]);
|
||||
rv = repo_show_pkg_deps(&xh, argv[optind], fulldeptree);
|
||||
else
|
||||
rv = show_pkg_deps(&xh, argv[optind]);
|
||||
rv = show_pkg_deps(&xh, argv[optind], fulldeptree);
|
||||
|
||||
} else if (show_rdeps) {
|
||||
/* show-rdeps mode */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,22 +33,64 @@
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname)
|
||||
static void
|
||||
print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
|
||||
bool full, bool repo, bool origin, int *indent)
|
||||
{
|
||||
prop_dictionary_t propsd;
|
||||
int rv = 0;
|
||||
prop_array_t currdeps;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *pkgdep;
|
||||
size_t i;
|
||||
int j;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
if (!origin)
|
||||
(*indent)++;
|
||||
|
||||
propsd = xbps_pkgdb_get_pkg_metadata(xhp, pkgname);
|
||||
if (propsd == NULL)
|
||||
for (i = 0; i < prop_array_count(rdeps); i++) {
|
||||
prop_array_get_cstring_nocopy(rdeps, i, &pkgdep);
|
||||
if (!origin || !full)
|
||||
for (j = 0; j < *indent; j++)
|
||||
putchar(' ');
|
||||
|
||||
printf("%s\n", pkgdep);
|
||||
if (!full)
|
||||
continue;
|
||||
|
||||
if (repo) {
|
||||
pkgd = xbps_rpool_get_pkg(xhp, pkgdep);
|
||||
if (pkgd == NULL)
|
||||
pkgd = xbps_rpool_get_virtualpkg(xhp, pkgdep);
|
||||
} else {
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgdep);
|
||||
if (pkgd == NULL)
|
||||
pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgdep);
|
||||
}
|
||||
if (pkgd != NULL) {
|
||||
currdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (currdeps != NULL)
|
||||
print_rdeps(xhp, currdeps,
|
||||
full, repo, false, indent);
|
||||
}
|
||||
}
|
||||
(*indent)--;
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full)
|
||||
{
|
||||
prop_array_t rdeps;
|
||||
prop_dictionary_t pkgd;
|
||||
int indent = 0;
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
rv = xbps_callback_array_iter_in_dict(xhp, propsd, "run_depends",
|
||||
list_strings_sep_in_array, NULL);
|
||||
rdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (rdeps != NULL)
|
||||
print_rdeps(xhp, rdeps, full, false, true, &indent);
|
||||
|
||||
return rv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -58,8 +100,7 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||
const char *pkgdep;
|
||||
size_t i;
|
||||
|
||||
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg);
|
||||
if (reqby) {
|
||||
if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) {
|
||||
for (i = 0; i < prop_array_count(reqby); i++) {
|
||||
prop_array_get_cstring_nocopy(reqby, i, &pkgdep);
|
||||
printf("%s\n", pkgdep);
|
||||
@@ -69,16 +110,19 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
||||
}
|
||||
|
||||
int
|
||||
repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern)
|
||||
repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
|
||||
{
|
||||
prop_array_t rdeps;
|
||||
prop_dictionary_t pkgd;
|
||||
int indent = 0;
|
||||
|
||||
if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
|
||||
((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
|
||||
return errno;
|
||||
|
||||
(void)xbps_callback_array_iter_in_dict(xhp, pkgd,
|
||||
"run_depends", list_strings_sep_in_array, NULL);
|
||||
rdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (rdeps != NULL)
|
||||
print_rdeps(xhp, rdeps, full, true, true, &indent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -295,8 +295,7 @@ repo_show_pkg_info(struct xbps_handle *xhp,
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
|
||||
((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
|
||||
if ((pkgd = xbps_rpool_get_pkg_plist(xhp, pattern, "./props.plist")) == NULL)
|
||||
return errno;
|
||||
|
||||
if (option)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.Dd February 20, 2013
|
||||
.Dd March 4, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-query 8
|
||||
.Sh NAME
|
||||
@@ -139,6 +139,7 @@ Multiple properties can be specified by delimiting them with commas.
|
||||
.It Fl x, Fl -deps Ar PKG
|
||||
Show the required dependencies for
|
||||
.Ar PKG .
|
||||
Only direct dependencies are shown. To see a full dependency tree set it twice.
|
||||
.It Fl X, Fl -revdeps Ar PKG
|
||||
Show the reverse dependencies for
|
||||
.Ar PKG .
|
||||
@@ -152,13 +153,13 @@ architecture.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/db/xbps/.<pkgname>.plist
|
||||
.It Ar /etc/xbps/xbps.conf
|
||||
Default XBPS configuration file.
|
||||
Default configuration file.
|
||||
.It Ar /var/db/xbps/.<pkgname>.plist
|
||||
Package metadata properties.
|
||||
.It Ar /var/db/xbps/pkgdb.plist
|
||||
XBPS package database.
|
||||
.It Ar /var/db/xbps/pkgdb-0.21.plist
|
||||
Default package database (0.21 format). Keeps track of installed packages and properties.
|
||||
.It Ar /var/cache/xbps
|
||||
Default XBPS cache directory.
|
||||
Default cache directory to store downloaded binary packages.
|
||||
.Sh SEE ALSO
|
||||
.Xr xbps-create 8 ,
|
||||
.Xr xbps-dgraph 8 ,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2012-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -65,7 +65,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbd)
|
||||
switch (xscd->state) {
|
||||
/* notifications */
|
||||
case XBPS_STATE_CONFIGURE:
|
||||
printf("%s-%s: configuring ...\n", xscd->arg0, xscd->arg1);
|
||||
printf("%s: configuring ...\n", xscd->arg);
|
||||
break;
|
||||
/* errors */
|
||||
case XBPS_STATE_CONFIGURE_FAIL:
|
||||
@@ -75,7 +75,7 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbd)
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf(xscd->xhp,
|
||||
"unknown state %d\n", xscd->state);
|
||||
"%s: unknown state %d\n", xscd->arg, xscd->state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.Dd November 6, 2012
|
||||
.Dd March 4, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-reconfigure 8
|
||||
.Sh NAME
|
||||
@@ -48,6 +48,16 @@ Specifies a full path for the target root directory.
|
||||
Enables verbose messages.
|
||||
.It Fl V, Fl -version
|
||||
Shows the XBPS version.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/db/xbps/.<pkgname>.plist
|
||||
.It Ar /etc/xbps/xbps.conf
|
||||
Default configuration file.
|
||||
.It Ar /var/db/xbps/.<pkgname>.plist
|
||||
Package metadata properties.
|
||||
.It Ar /var/db/xbps/pkgdb-0.21.plist
|
||||
Default package database (0.21 format). Keeps track of installed packages and properties.
|
||||
.It Ar /var/cache/xbps
|
||||
Default cache directory to store downloaded binary packages.
|
||||
.Sh SEE ALSO
|
||||
.Xr xbps-create 8 ,
|
||||
.Xr xbps-dgraph 8 ,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -79,7 +79,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
case XBPS_STATE_UNREGISTER:
|
||||
break;
|
||||
case XBPS_STATE_REMOVE:
|
||||
printf("Removing `%s-%s' ...\n", xscd->arg0, xscd->arg1);
|
||||
printf("Removing `%s' ...\n", xscd->arg);
|
||||
break;
|
||||
/* success */
|
||||
case XBPS_STATE_REMOVE_FILE:
|
||||
@@ -92,11 +92,10 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
}
|
||||
break;
|
||||
case XBPS_STATE_REMOVE_DONE:
|
||||
printf("Removed `%s-%s' successfully.\n",
|
||||
xscd->arg0, xscd->arg1);
|
||||
printf("Removed `%s' successfully.\n", xscd->arg);
|
||||
if (syslog_enabled)
|
||||
syslog(LOG_NOTICE, "Removed `%s-%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg0, xscd->arg1,
|
||||
syslog(LOG_NOTICE, "Removed `%s' successfully "
|
||||
"(rootdir: %s).", xscd->arg,
|
||||
xscd->xhp->rootdir);
|
||||
break;
|
||||
/* errors */
|
||||
@@ -119,8 +118,7 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf(xscd->xhp,
|
||||
"%s-%s: unknown state %d\n",
|
||||
xscd->arg0, xscd->arg1, xscd->state);
|
||||
"%s: unknown state %d\n", xscd->arg, xscd->state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.Dd November 21, 2012
|
||||
.Dd March 4, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-remove 8
|
||||
.Sh NAME
|
||||
@@ -87,13 +87,13 @@ Shows the XBPS version.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/db/xbps/.<pkgname>.plist
|
||||
.It Ar /etc/xbps/xbps.conf
|
||||
Default XBPS configuration file.
|
||||
Default configuration file.
|
||||
.It Ar /var/db/xbps/.<pkgname>.plist
|
||||
Package metadata properties.
|
||||
.It Ar /var/db/xbps/pkgdb.plist
|
||||
XBPS package database.
|
||||
.It Ar /var/db/xbps/pkgdb-0.21.plist
|
||||
Default package database (0.21 format). Keeps track of installed packages and properties.
|
||||
.It Ar /var/cache/xbps
|
||||
Default XBPS cache directory.
|
||||
Default cache directory to store downloaded binary packages.
|
||||
.Sh SEE ALSO
|
||||
.Xr xbps-create 8 ,
|
||||
.Xr xbps-dgraph 8 ,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2012-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -48,9 +48,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
prop_dictionary_t filespkgd;
|
||||
prop_object_t obj, fileobj;
|
||||
struct stat st;
|
||||
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver;
|
||||
const char *pkgver, *arch, *oldarch;
|
||||
char *sha256, *filen, *repodir, *buf;
|
||||
const char *oldpkgver, *arch, *oldarch;
|
||||
char *pkgver, *pkgname, *sha256, *repodir, *buf;
|
||||
char *tmpfilen, *tmprepodir, *plist, *plistf;
|
||||
size_t x;
|
||||
int i, ret = 0;
|
||||
@@ -100,7 +99,6 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
if ((tmpfilen = strdup(argv[i])) == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
filen = basename(tmpfilen);
|
||||
/*
|
||||
* Read metadata props plist dictionary from binary package.
|
||||
*/
|
||||
@@ -114,17 +112,15 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture",
|
||||
&arch);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring(newpkgd, "pkgver", &pkgver);
|
||||
if (!xbps_pkg_arch_match(xhp, arch, NULL)) {
|
||||
fprintf(stderr, "index: ignoring %s, unmatched "
|
||||
"arch (%s)\n", pkgver, arch);
|
||||
prop_object_release(newpkgd);
|
||||
continue;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "pkgname",
|
||||
&pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "version",
|
||||
&version);
|
||||
pkgname = xbps_pkg_name(pkgver);
|
||||
assert(pkgname);
|
||||
/*
|
||||
* Check if this package exists already in the index, but first
|
||||
* checking the version. If current package version is greater
|
||||
@@ -133,25 +129,26 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
*/
|
||||
curpkgd = prop_dictionary_get(idx, pkgname);
|
||||
if (curpkgd == NULL) {
|
||||
if (errno && errno != ENOENT)
|
||||
if (errno && errno != ENOENT) {
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
return errno;
|
||||
}
|
||||
} else {
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"filename", &oldfilen);
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"pkgver", &oldpkgver);
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"architecture", &oldarch);
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"version", ®ver);
|
||||
ret = xbps_cmpver(version, regver);
|
||||
ret = xbps_cmpver(pkgver, oldpkgver);
|
||||
if (ret <= 0) {
|
||||
/* Same version or index version greater */
|
||||
fprintf(stderr, "index: skipping `%s-%s' "
|
||||
fprintf(stderr, "index: skipping `%s' "
|
||||
"(%s), already registered.\n",
|
||||
pkgname, version, arch);
|
||||
pkgver, arch);
|
||||
prop_object_release(newpkgd);
|
||||
free(tmpfilen);
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@@ -167,32 +164,57 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
* We have the dictionary now, add the required
|
||||
* objects for the index.
|
||||
*/
|
||||
if (!prop_dictionary_set_cstring(newpkgd, "filename", filen))
|
||||
if ((sha256 = xbps_file_hash(argv[i])) == NULL) {
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
return errno;
|
||||
|
||||
if ((sha256 = xbps_file_hash(argv[i])) == NULL)
|
||||
return errno;
|
||||
|
||||
}
|
||||
if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256",
|
||||
sha256))
|
||||
sha256)) {
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
return errno;
|
||||
}
|
||||
|
||||
free(sha256);
|
||||
if (stat(argv[i], &st) == -1)
|
||||
if (stat(argv[i], &st) == -1) {
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
return errno;
|
||||
}
|
||||
|
||||
if (!prop_dictionary_set_uint64(newpkgd, "filename-size",
|
||||
(uint64_t)st.st_size)) {
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
return errno;
|
||||
}
|
||||
/*
|
||||
* Remove obsolete package objects.
|
||||
*/
|
||||
prop_dictionary_remove(newpkgd, "archive-compression-type");
|
||||
prop_dictionary_remove(newpkgd, "build-date");
|
||||
prop_dictionary_remove(newpkgd, "build_date");
|
||||
prop_dictionary_remove(newpkgd, "conf_files");
|
||||
prop_dictionary_remove(newpkgd, "filename");
|
||||
prop_dictionary_remove(newpkgd, "homepage");
|
||||
prop_dictionary_remove(newpkgd, "license");
|
||||
prop_dictionary_remove(newpkgd, "maintainer");
|
||||
prop_dictionary_remove(newpkgd, "packaged-with");
|
||||
prop_dictionary_remove(newpkgd, "source-revisions");
|
||||
prop_dictionary_remove(newpkgd, "long_desc");
|
||||
prop_dictionary_remove(newpkgd, "pkgname");
|
||||
prop_dictionary_remove(newpkgd, "version");
|
||||
/*
|
||||
* Add new pkg dictionary into the index.
|
||||
*/
|
||||
if (!prop_dictionary_set(idx, pkgname, newpkgd))
|
||||
if (!prop_dictionary_set(idx, pkgname, newpkgd)) {
|
||||
free(pkgname);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
flush = true;
|
||||
printf("index: added `%s-%s' (%s).\n", pkgname, version, arch);
|
||||
printf("index: added `%s' (%s).\n", pkgver, arch);
|
||||
free(tmpfilen);
|
||||
/*
|
||||
* Add new pkg dictionary into the index-files.
|
||||
@@ -200,8 +222,11 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
found = false;
|
||||
newpkgfilesd = xbps_get_pkg_plist_from_binpkg(argv[i],
|
||||
"./files.plist");
|
||||
if (newpkgfilesd == NULL)
|
||||
if (newpkgfilesd == NULL) {
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* Find out if binary pkg stored in index contain any file */
|
||||
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files");
|
||||
@@ -226,6 +251,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
if (!found) {
|
||||
prop_object_release(newpkgfilesd);
|
||||
prop_object_release(newpkgd);
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
continue;
|
||||
}
|
||||
/* create pkg files array */
|
||||
@@ -276,6 +303,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
||||
printf("index-files: added `%s' (%s)\n", pkgver, arch);
|
||||
files_flush = true;
|
||||
prop_object_release(newpkgd);
|
||||
free(pkgver);
|
||||
free(pkgname);
|
||||
}
|
||||
|
||||
if (flush && !prop_dictionary_externalize_to_zfile(idx, plist)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2012-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -54,7 +54,8 @@ cleaner_thread(void *arg)
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t array;
|
||||
struct thread_data *thd = arg;
|
||||
const char *pkgver, *filen, *sha256;
|
||||
char *filen;
|
||||
const char *pkgver, *arch, *sha256;
|
||||
unsigned int i;
|
||||
|
||||
/* process pkgs from start until end */
|
||||
@@ -63,8 +64,9 @@ cleaner_thread(void *arg)
|
||||
for (i = thd->start; i < thd->end; i++) {
|
||||
obj = prop_array_get(array, i);
|
||||
pkgd = prop_dictionary_get_keysym(thd->idx, obj);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
filen = xbps_xasprintf("%s.%s.xbps");
|
||||
xbps_dbg_printf(thd->xhp, "thread[%d] checking %s\n",
|
||||
thd->thread_num, pkgver);
|
||||
if (access(filen, R_OK) == -1) {
|
||||
@@ -73,6 +75,7 @@ cleaner_thread(void *arg)
|
||||
* broken or simply unexistent; either way, remove it.
|
||||
*/
|
||||
prop_array_add_cstring_nocopy(thd->result, pkgver);
|
||||
free(filen);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@@ -82,6 +85,7 @@ cleaner_thread(void *arg)
|
||||
"filename-sha256", &sha256);
|
||||
if (xbps_file_hash_check(filen, sha256) != 0)
|
||||
prop_array_add_cstring_nocopy(thd->result, pkgver);
|
||||
free(filen);
|
||||
}
|
||||
prop_object_release(array);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2012-2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
Reference in New Issue
Block a user