Welcome pkgdb-0.38.
This commit is contained in:
@@ -5,6 +5,5 @@ BIN = xbps-pkgdb
|
||||
OBJS = main.o check.o check_pkg_files.o
|
||||
OBJS += check_pkg_rundeps.o
|
||||
OBJS += check_pkg_symlinks.o check_pkg_unneeded.o
|
||||
OBJS += convert.o
|
||||
|
||||
include $(TOPDIR)/mk/prog.mk
|
||||
|
@@ -72,12 +72,12 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
xbps_dictionary_t pkgd,
|
||||
const char *pkgname)
|
||||
{
|
||||
xbps_dictionary_t opkgd, propsd;
|
||||
xbps_dictionary_t opkgd, filesd;
|
||||
const char *sha256;
|
||||
char *buf;
|
||||
int rv = 0;
|
||||
|
||||
propsd = opkgd = NULL;
|
||||
filesd = opkgd = NULL;
|
||||
|
||||
/* find real pkg by name */
|
||||
opkgd = pkgd;
|
||||
@@ -89,17 +89,17 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
* Check for pkg files metadata file.
|
||||
*/
|
||||
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
|
||||
propsd = xbps_dictionary_internalize_from_file(buf);
|
||||
buf = xbps_xasprintf("%s/.%s-files.plist", xhp->metadir, pkgname);
|
||||
filesd = xbps_dictionary_internalize_from_file(buf);
|
||||
free(buf);
|
||||
if (propsd == NULL) {
|
||||
xbps_error_printf("%s: unexistent metafile!\n", pkgname);
|
||||
if (filesd == NULL) {
|
||||
xbps_error_printf("%s: unexistent files metafile!\n", pkgname);
|
||||
return EINVAL;
|
||||
} else if (xbps_dictionary_count(propsd) == 0) {
|
||||
} else if (xbps_dictionary_count(filesd) == 0) {
|
||||
xbps_error_printf("%s: incomplete metadata file.\n", pkgname);
|
||||
xbps_object_release(propsd);
|
||||
xbps_object_release(filesd);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
@@ -107,12 +107,12 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
*/
|
||||
xbps_dictionary_get_cstring_nocopy(opkgd, "metafile-sha256", &sha256);
|
||||
if (sha256 != NULL) {
|
||||
buf = xbps_xasprintf("%s/.%s.plist",
|
||||
buf = xbps_xasprintf("%s/.%s-files.plist",
|
||||
xhp->metadir, pkgname);
|
||||
rv = xbps_file_hash_check(buf, sha256);
|
||||
free(buf);
|
||||
if (rv == ERANGE) {
|
||||
xbps_object_release(propsd);
|
||||
xbps_object_release(filesd);
|
||||
fprintf(stderr, "%s: metadata file has been "
|
||||
"modified!\n", pkgname);
|
||||
return 1;
|
||||
@@ -130,12 +130,12 @@ do { \
|
||||
} while (0)
|
||||
|
||||
/* Execute pkg checks */
|
||||
RUN_PKG_CHECK(xhp, files, propsd);
|
||||
RUN_PKG_CHECK(xhp, symlinks, propsd);
|
||||
RUN_PKG_CHECK(xhp, rundeps, propsd);
|
||||
RUN_PKG_CHECK(xhp, files, filesd);
|
||||
RUN_PKG_CHECK(xhp, symlinks, filesd);
|
||||
RUN_PKG_CHECK(xhp, rundeps, opkgd);
|
||||
RUN_PKG_CHECK(xhp, unneeded, opkgd);
|
||||
|
||||
xbps_object_release(propsd);
|
||||
xbps_object_release(filesd);
|
||||
|
||||
#undef RUN_PKG_CHECK
|
||||
|
||||
|
@@ -1,117 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 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.h>
|
||||
#include "defs.h"
|
||||
|
||||
/*
|
||||
* Convert pkgdb format to 0.21.
|
||||
*/
|
||||
static void
|
||||
pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
|
||||
{
|
||||
xbps_array_t array, rdeps;
|
||||
xbps_dictionary_t pkgdb, pkgd;
|
||||
char *pkgname, *plist;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
array = xbps_array_internalize_from_zfile(plist);
|
||||
if (xbps_object_type(array) != XBPS_TYPE_ARRAY) {
|
||||
xbps_error_printf("unknown object type for %s\n",
|
||||
plist, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pkgdb = xbps_dictionary_create();
|
||||
assert(pkgdb);
|
||||
|
||||
for (unsigned int i = 0; i < xbps_array_count(array); i++) {
|
||||
pkgd = xbps_array_get(array, i);
|
||||
xbps_dictionary_get_cstring(pkgd, "pkgname", &pkgname);
|
||||
rdeps = xbps_dictionary_get(pkgd, "run_depends");
|
||||
/* remove unneeded objs */
|
||||
xbps_dictionary_remove(pkgd, "pkgname");
|
||||
xbps_dictionary_remove(pkgd, "version");
|
||||
if (xbps_array_count(rdeps) == 0)
|
||||
xbps_dictionary_remove(pkgd, "run_depends");
|
||||
|
||||
xbps_dictionary_set(pkgdb, pkgname, pkgd);
|
||||
free(pkgname);
|
||||
}
|
||||
|
||||
if (xbps_array_count(array) != xbps_dictionary_count(pkgdb)) {
|
||||
xbps_error_printf("failed conversion! unmatched obj count "
|
||||
"(got %zu, need %zu)\n", xbps_dictionary_count(pkgdb),
|
||||
xbps_array_count(array));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!xbps_dictionary_externalize_to_file(pkgdb, plist_new)) {
|
||||
xbps_error_printf("failed to write %s: %s\n",
|
||||
plist_new, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
xbps_object_release(array);
|
||||
xbps_object_release(pkgdb);
|
||||
free(plist);
|
||||
|
||||
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);
|
||||
}
|
@@ -151,9 +151,10 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "failed to lock pkgdb: %s\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (update_format)
|
||||
convert_pkgdb_format(&xh);
|
||||
else if (instmode) {
|
||||
if (update_format) {
|
||||
/* nothing to do; xbps_pkgdb_lock() runs the conversion for us */
|
||||
goto out;
|
||||
} else if (instmode) {
|
||||
if (argc == optind) {
|
||||
fprintf(stderr,
|
||||
"xbps-pkgdb: missing PKGNAME argument\n");
|
||||
@@ -181,6 +182,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_pkgdb_unlock(&xh);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
Reference in New Issue
Block a user