2012-11-02 19:34:25 +05:30
|
|
|
/*-
|
2015-01-11 13:41:38 +05:30
|
|
|
* Copyright (c) 2012-2015 Juan Romero Pardines.
|
2012-11-02 19:34:25 +05:30
|
|
|
* 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/stat.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <libgen.h>
|
|
|
|
#include <assert.h>
|
2013-06-10 13:58:39 +05:30
|
|
|
#include <fcntl.h>
|
2012-11-02 19:34:25 +05:30
|
|
|
|
2013-06-20 16:01:02 +05:30
|
|
|
#include <xbps.h>
|
2012-11-02 19:34:25 +05:30
|
|
|
#include "defs.h"
|
|
|
|
|
2015-09-02 18:26:40 +05:30
|
|
|
static int
|
|
|
|
set_build_date(const xbps_dictionary_t pkgd, time_t timestamp)
|
|
|
|
{
|
|
|
|
char outstr[64];
|
|
|
|
struct tm tmp;
|
|
|
|
|
|
|
|
if (!localtime_r(×tamp, &tmp))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", &tmp) == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (!xbps_dictionary_set_cstring(pkgd, "build-date", outstr))
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-20 22:21:22 +05:30
|
|
|
static bool
|
|
|
|
repodata_commit(struct xbps_handle *xhp, const char *repodir,
|
2019-06-17 10:54:05 +05:30
|
|
|
xbps_dictionary_t idx, xbps_dictionary_t meta, xbps_dictionary_t stage,
|
|
|
|
const char *compression)
|
|
|
|
{
|
2016-03-20 22:21:22 +05:30
|
|
|
xbps_object_iterator_t iter;
|
|
|
|
xbps_object_t keysym;
|
|
|
|
int rv;
|
|
|
|
xbps_dictionary_t oldshlibs, usedshlibs;
|
|
|
|
|
|
|
|
if (xbps_dictionary_count(stage) == 0) {
|
|
|
|
// Nothing to do.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find old shlibs-provides
|
|
|
|
*/
|
|
|
|
oldshlibs = xbps_dictionary_create();
|
|
|
|
usedshlibs = xbps_dictionary_create();
|
|
|
|
|
|
|
|
iter = xbps_dictionary_iterator(stage);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
const char *pkgname = xbps_dictionary_keysym_cstring_nocopy(keysym);
|
|
|
|
xbps_dictionary_t pkg = xbps_dictionary_get(idx, pkgname);
|
|
|
|
xbps_array_t pkgshlibs;
|
|
|
|
|
|
|
|
pkgshlibs = xbps_dictionary_get(pkg, "shlib-provides");
|
|
|
|
for (unsigned int i = 0; i < xbps_array_count(pkgshlibs); i++) {
|
|
|
|
const char *shlib = NULL;
|
|
|
|
xbps_array_get_cstring_nocopy(pkgshlibs, i, &shlib);
|
|
|
|
xbps_dictionary_set_cstring(oldshlibs, shlib, pkgname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xbps_object_iterator_release(iter);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* throw away all unused shlibs
|
|
|
|
*/
|
|
|
|
iter = xbps_dictionary_iterator(idx);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
const char *pkgname = xbps_dictionary_keysym_cstring_nocopy(keysym);
|
|
|
|
xbps_dictionary_t pkg = xbps_dictionary_get(stage, pkgname);
|
|
|
|
xbps_array_t pkgshlibs;
|
|
|
|
if (!pkg)
|
|
|
|
pkg = xbps_dictionary_get_keysym(idx, keysym);
|
|
|
|
pkgshlibs = xbps_dictionary_get(pkg, "shlib-requires");
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < xbps_array_count(pkgshlibs); i++) {
|
|
|
|
const char *shlib = NULL;
|
|
|
|
xbps_array_t users;
|
|
|
|
xbps_array_get_cstring_nocopy(pkgshlibs, i, &shlib);
|
|
|
|
if (!xbps_dictionary_get(oldshlibs, shlib))
|
|
|
|
continue;
|
|
|
|
users = xbps_dictionary_get(usedshlibs, shlib);
|
|
|
|
if (!users) {
|
|
|
|
users = xbps_array_create();
|
|
|
|
xbps_dictionary_set(usedshlibs, shlib, users);
|
|
|
|
}
|
|
|
|
xbps_array_add_cstring(users, pkgname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xbps_object_iterator_release(iter);
|
|
|
|
|
2018-06-28 16:58:06 +05:30
|
|
|
/*
|
|
|
|
* purge all packages that are fullfilled by the index and
|
|
|
|
* not in the stage.
|
|
|
|
*/
|
|
|
|
iter = xbps_dictionary_iterator(idx);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
xbps_dictionary_t pkg = xbps_dictionary_get_keysym(idx, keysym);
|
|
|
|
xbps_array_t pkgshlibs;
|
|
|
|
|
|
|
|
|
|
|
|
if (xbps_dictionary_get(stage,
|
|
|
|
xbps_dictionary_keysym_cstring_nocopy(keysym))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pkgshlibs = xbps_dictionary_get(pkg, "shlib-provides");
|
|
|
|
for (unsigned int i = 0; i < xbps_array_count(pkgshlibs); i++) {
|
|
|
|
const char *shlib;
|
|
|
|
xbps_array_get_cstring_nocopy(pkgshlibs, i, &shlib);
|
|
|
|
xbps_dictionary_remove(usedshlibs, shlib);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xbps_object_iterator_release(iter);
|
|
|
|
|
2016-03-20 22:21:22 +05:30
|
|
|
/*
|
|
|
|
* purge all packages that are fullfilled by the stage
|
|
|
|
*/
|
|
|
|
iter = xbps_dictionary_iterator(stage);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
xbps_dictionary_t pkg = xbps_dictionary_get_keysym(stage, keysym);
|
|
|
|
xbps_array_t pkgshlibs;
|
|
|
|
|
|
|
|
pkgshlibs = xbps_dictionary_get(pkg, "shlib-provides");
|
|
|
|
for (unsigned int i = 0; i < xbps_array_count(pkgshlibs); i++) {
|
|
|
|
const char *shlib;
|
|
|
|
xbps_array_get_cstring_nocopy(pkgshlibs, i, &shlib);
|
|
|
|
xbps_dictionary_remove(usedshlibs, shlib);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xbps_object_iterator_release(iter);
|
|
|
|
|
|
|
|
if (xbps_dictionary_count(usedshlibs) != 0) {
|
2016-03-22 14:15:48 +05:30
|
|
|
printf("Inconsistent shlibs:\n");
|
2016-03-20 22:21:22 +05:30
|
|
|
iter = xbps_dictionary_iterator(usedshlibs);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
const char *shlib = xbps_dictionary_keysym_cstring_nocopy(keysym),
|
|
|
|
*provider = NULL, *pre;
|
|
|
|
xbps_array_t users = xbps_dictionary_get(usedshlibs, shlib);
|
|
|
|
xbps_dictionary_get_cstring_nocopy(oldshlibs, shlib, &provider);
|
|
|
|
|
2016-03-27 06:29:07 +05:30
|
|
|
printf(" %s (provided by: %s; used by: ", shlib, provider);
|
2016-03-20 22:21:22 +05:30
|
|
|
pre = "";
|
|
|
|
for (unsigned int i = 0; i < xbps_array_count(users); i++) {
|
|
|
|
const char *user;
|
|
|
|
xbps_array_get_cstring_nocopy(users, i, &user);
|
|
|
|
xbps_dictionary_remove(usedshlibs, shlib);
|
|
|
|
printf("%s%s",pre, user);
|
|
|
|
pre = ", ";
|
|
|
|
}
|
2016-03-22 14:15:48 +05:30
|
|
|
printf(")\n");
|
2016-03-20 22:21:22 +05:30
|
|
|
}
|
2016-03-27 06:29:07 +05:30
|
|
|
xbps_object_iterator_release(iter);
|
|
|
|
iter = xbps_dictionary_iterator(stage);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
xbps_dictionary_t pkg = xbps_dictionary_get_keysym(stage, keysym);
|
|
|
|
const char *pkgver, *arch;
|
|
|
|
xbps_dictionary_get_cstring_nocopy(pkg, "pkgver", &pkgver);
|
|
|
|
xbps_dictionary_get_cstring_nocopy(pkg, "architecture", &arch);
|
|
|
|
printf("stage: added `%s' (%s)\n", pkgver, arch);
|
|
|
|
}
|
2016-03-20 22:21:22 +05:30
|
|
|
xbps_object_iterator_release(iter);
|
2019-06-17 10:54:05 +05:30
|
|
|
rv = repodata_flush(xhp, repodir, "stagedata", stage, NULL, compression);
|
2016-03-20 22:21:22 +05:30
|
|
|
}
|
|
|
|
else {
|
|
|
|
char *stagefile;
|
|
|
|
iter = xbps_dictionary_iterator(stage);
|
|
|
|
while ((keysym = xbps_object_iterator_next(iter))) {
|
|
|
|
const char *pkgname = xbps_dictionary_keysym_cstring_nocopy(keysym);
|
|
|
|
xbps_dictionary_t pkg = xbps_dictionary_get_keysym(stage, keysym);
|
|
|
|
const char *pkgver, *arch;
|
|
|
|
xbps_dictionary_get_cstring_nocopy(pkg, "pkgver", &pkgver);
|
|
|
|
xbps_dictionary_get_cstring_nocopy(pkg, "architecture", &arch);
|
|
|
|
printf("index: added `%s' (%s).\n", pkgver, arch);
|
|
|
|
xbps_dictionary_set(idx, pkgname, pkg);
|
|
|
|
}
|
|
|
|
xbps_object_iterator_release(iter);
|
|
|
|
stagefile = xbps_repo_path_with_name(xhp, repodir, "stagedata");
|
|
|
|
unlink(stagefile);
|
|
|
|
free(stagefile);
|
2019-06-17 10:54:05 +05:30
|
|
|
rv = repodata_flush(xhp, repodir, "repodata", idx, meta, compression);
|
2016-03-20 22:21:22 +05:30
|
|
|
}
|
|
|
|
xbps_object_release(usedshlibs);
|
|
|
|
xbps_object_release(oldshlibs);
|
|
|
|
return rv;
|
|
|
|
}
|
2015-09-02 18:26:40 +05:30
|
|
|
|
2012-11-02 19:34:25 +05:30
|
|
|
int
|
2019-06-17 10:54:05 +05:30
|
|
|
index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force, const char *compression)
|
2012-11-02 19:34:25 +05:30
|
|
|
{
|
2016-03-20 22:21:22 +05:30
|
|
|
xbps_dictionary_t idx, idxmeta, idxstage, binpkgd, curpkgd;
|
|
|
|
struct xbps_repo *repo = NULL, *stage = NULL;
|
2012-11-02 19:34:25 +05:30
|
|
|
struct stat st;
|
2015-03-25 16:30:59 +05:30
|
|
|
char *tmprepodir = NULL, *repodir = NULL, *rlockfname = NULL;
|
|
|
|
int rv = 0, ret = 0, rlockfd = -1;
|
2012-11-30 11:41:51 +05:30
|
|
|
|
2014-10-06 20:43:06 +05:30
|
|
|
assert(argv);
|
2013-06-10 13:58:39 +05:30
|
|
|
/*
|
|
|
|
* Read the repository data or create index dictionaries otherwise.
|
|
|
|
*/
|
2014-11-06 16:03:04 +05:30
|
|
|
if ((tmprepodir = strdup(argv[args])) == NULL)
|
2014-09-05 15:56:42 +05:30
|
|
|
return ENOMEM;
|
|
|
|
|
2012-11-02 19:34:25 +05:30
|
|
|
repodir = dirname(tmprepodir);
|
2015-03-25 16:30:59 +05:30
|
|
|
if (!xbps_repo_lock(xhp, repodir, &rlockfd, &rlockfname)) {
|
|
|
|
fprintf(stderr, "xbps-rindex: cannot lock repository "
|
|
|
|
"%s: %s\n", repodir, strerror(errno));
|
|
|
|
rv = -1;
|
2016-09-25 21:08:36 +05:30
|
|
|
goto earlyout;
|
2015-03-25 16:30:59 +05:30
|
|
|
}
|
2016-03-20 22:21:22 +05:30
|
|
|
repo = xbps_repo_public_open(xhp, repodir);
|
2014-09-15 15:45:42 +05:30
|
|
|
if (repo == NULL && errno != ENOENT) {
|
|
|
|
fprintf(stderr, "xbps-rindex: cannot open/lock repository "
|
|
|
|
"%s: %s\n", repodir, strerror(errno));
|
|
|
|
rv = -1;
|
2016-09-25 21:08:36 +05:30
|
|
|
goto earlyout;
|
2014-09-15 15:45:42 +05:30
|
|
|
}
|
2014-11-13 21:39:43 +05:30
|
|
|
if (repo) {
|
2015-05-22 15:50:49 +05:30
|
|
|
idx = xbps_dictionary_copy_mutable(repo->idx);
|
|
|
|
idxmeta = xbps_dictionary_copy_mutable(repo->idxmeta);
|
2013-12-24 15:13:55 +05:30
|
|
|
} else {
|
|
|
|
idx = xbps_dictionary_create();
|
2014-01-30 17:37:34 +05:30
|
|
|
idxmeta = NULL;
|
2013-10-07 13:53:14 +05:30
|
|
|
}
|
2016-03-20 22:21:22 +05:30
|
|
|
stage = xbps_repo_stage_open(xhp, repodir);
|
|
|
|
if (stage == NULL && errno != ENOENT) {
|
|
|
|
fprintf(stderr, "xbps-rindex: cannot open/lock stage repository "
|
|
|
|
"%s: %s\n", repodir, strerror(errno));
|
|
|
|
rv = -1;
|
2016-09-25 21:08:36 +05:30
|
|
|
goto earlyout;
|
2016-03-20 22:21:22 +05:30
|
|
|
}
|
|
|
|
if (stage) {
|
|
|
|
idxstage = xbps_dictionary_copy_mutable(stage->idx);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
idxstage = xbps_dictionary_create();
|
|
|
|
}
|
2012-11-02 19:34:25 +05:30
|
|
|
/*
|
|
|
|
* Process all packages specified in argv.
|
|
|
|
*/
|
2014-10-07 13:41:14 +05:30
|
|
|
for (int i = args; i < argmax; i++) {
|
|
|
|
const char *arch = NULL, *pkg = argv[i];
|
2014-10-05 13:05:42 +05:30
|
|
|
char *sha256 = NULL, *pkgver = NULL, *pkgname = NULL;
|
2014-10-06 20:43:06 +05:30
|
|
|
|
2014-10-07 13:41:14 +05:30
|
|
|
assert(pkg);
|
2012-11-02 19:34:25 +05:30
|
|
|
/*
|
|
|
|
* Read metadata props plist dictionary from binary package.
|
|
|
|
*/
|
2014-11-21 14:21:57 +05:30
|
|
|
binpkgd = xbps_archive_fetch_plist(pkg, "/props.plist");
|
2013-12-24 15:13:55 +05:30
|
|
|
if (binpkgd == NULL) {
|
2014-01-31 16:05:31 +05:30
|
|
|
fprintf(stderr, "index: failed to read %s metadata for "
|
2014-10-07 13:41:14 +05:30
|
|
|
"`%s', skipping!\n", XBPS_PKGPROPS, pkg);
|
2012-11-02 19:34:25 +05:30
|
|
|
continue;
|
|
|
|
}
|
2013-12-24 15:13:55 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(binpkgd, "architecture", &arch);
|
|
|
|
xbps_dictionary_get_cstring(binpkgd, "pkgver", &pkgver);
|
2012-11-30 11:41:51 +05:30
|
|
|
if (!xbps_pkg_arch_match(xhp, arch, NULL)) {
|
2013-12-24 15:13:55 +05:30
|
|
|
fprintf(stderr, "index: ignoring %s, unmatched arch (%s)\n", pkgver, arch);
|
|
|
|
xbps_object_release(binpkgd);
|
2014-10-05 11:36:12 +05:30
|
|
|
free(pkgver);
|
2012-11-30 11:41:51 +05:30
|
|
|
continue;
|
|
|
|
}
|
2013-03-05 08:38:42 +05:30
|
|
|
pkgname = xbps_pkg_name(pkgver);
|
|
|
|
assert(pkgname);
|
2012-11-02 19:34:25 +05:30
|
|
|
/*
|
|
|
|
* Check if this package exists already in the index, but first
|
|
|
|
* checking the version. If current package version is greater
|
|
|
|
* than current registered package, update the index; otherwise
|
|
|
|
* pass to the next one.
|
|
|
|
*/
|
2016-03-20 22:21:22 +05:30
|
|
|
curpkgd = xbps_dictionary_get(idxstage, pkgname);
|
|
|
|
if (curpkgd == NULL)
|
|
|
|
curpkgd = xbps_dictionary_get(idx, pkgname);
|
2012-11-02 19:34:25 +05:30
|
|
|
if (curpkgd == NULL) {
|
2013-03-05 08:38:42 +05:30
|
|
|
if (errno && errno != ENOENT) {
|
2014-01-31 16:05:31 +05:30
|
|
|
rv = errno;
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2013-03-05 08:38:42 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
2014-01-31 16:05:31 +05:30
|
|
|
goto out;
|
2013-03-05 08:38:42 +05:30
|
|
|
}
|
2013-05-02 14:16:30 +05:30
|
|
|
} else if (!force) {
|
2014-10-05 12:53:03 +05:30
|
|
|
char *opkgver = NULL, *oarch = NULL;
|
|
|
|
|
2013-05-02 14:16:30 +05:30
|
|
|
/* Only check version if !force */
|
2013-11-29 22:00:45 +05:30
|
|
|
xbps_dictionary_get_cstring(curpkgd, "pkgver", &opkgver);
|
|
|
|
xbps_dictionary_get_cstring(curpkgd, "architecture", &oarch);
|
|
|
|
ret = xbps_cmpver(pkgver, opkgver);
|
2014-09-23 00:53:40 +05:30
|
|
|
|
|
|
|
/*
|
2014-09-23 22:44:45 +05:30
|
|
|
* If the considered package reverts the package in the index,
|
|
|
|
* consider the current package as the newer one.
|
2014-09-23 00:53:40 +05:30
|
|
|
*/
|
2014-10-05 12:53:03 +05:30
|
|
|
if (ret < 0 && xbps_pkg_reverts(binpkgd, opkgver)) {
|
2014-09-23 00:53:40 +05:30
|
|
|
ret = 1;
|
|
|
|
/*
|
2014-09-23 22:44:45 +05:30
|
|
|
* If package in the index reverts considered package, consider the
|
2014-09-23 00:53:40 +05:30
|
|
|
* package in the index as the newer one.
|
|
|
|
*/
|
2014-10-05 12:53:03 +05:30
|
|
|
} else if (ret > 0 && xbps_pkg_reverts(curpkgd, pkgver)) {
|
2014-09-23 00:53:40 +05:30
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
2012-12-15 15:43:32 +05:30
|
|
|
if (ret <= 0) {
|
|
|
|
/* Same version or index version greater */
|
2013-12-24 15:13:55 +05:30
|
|
|
fprintf(stderr, "index: skipping `%s' (%s), already registered.\n", pkgver, arch);
|
|
|
|
xbps_object_release(binpkgd);
|
2013-11-29 22:00:45 +05:30
|
|
|
free(opkgver);
|
|
|
|
free(oarch);
|
2013-03-05 08:38:42 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
2012-11-02 19:34:25 +05:30
|
|
|
continue;
|
|
|
|
}
|
2013-11-29 22:00:45 +05:30
|
|
|
free(opkgver);
|
|
|
|
free(oarch);
|
2012-11-02 19:34:25 +05:30
|
|
|
}
|
2013-03-05 08:38:42 +05:30
|
|
|
/*
|
2013-12-24 15:13:55 +05:30
|
|
|
* Add additional objects for repository ops:
|
|
|
|
* - filename-size
|
|
|
|
* - filename-sha256
|
2013-03-05 08:38:42 +05:30
|
|
|
*/
|
2014-10-07 13:41:14 +05:30
|
|
|
if ((sha256 = xbps_file_hash(pkg)) == NULL) {
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2013-12-24 15:13:55 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
2014-01-31 16:05:31 +05:30
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
2013-12-24 15:13:55 +05:30
|
|
|
}
|
2013-12-30 14:57:54 +05:30
|
|
|
if (!xbps_dictionary_set_cstring(binpkgd, "filename-sha256", sha256)) {
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2014-10-05 11:01:07 +05:30
|
|
|
free(sha256);
|
2013-12-24 15:13:55 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
2014-01-31 16:05:31 +05:30
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
2013-12-24 15:13:55 +05:30
|
|
|
}
|
2014-10-05 11:01:07 +05:30
|
|
|
free(sha256);
|
2014-10-07 13:41:14 +05:30
|
|
|
if (stat(pkg, &st) == -1) {
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2013-12-24 15:13:55 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
2014-01-31 16:05:31 +05:30
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
2013-12-24 15:13:55 +05:30
|
|
|
}
|
2013-12-30 14:57:54 +05:30
|
|
|
if (!xbps_dictionary_set_uint64(binpkgd, "filename-size", (uint64_t)st.st_size)) {
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2013-12-24 15:13:55 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
2014-01-31 16:05:31 +05:30
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
2013-12-24 15:13:55 +05:30
|
|
|
}
|
2015-09-02 18:26:40 +05:30
|
|
|
if (set_build_date(binpkgd, st.st_mtime) < 0) {
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2015-09-02 18:26:40 +05:30
|
|
|
free(pkgver);
|
|
|
|
free(pkgname);
|
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2013-12-30 14:57:54 +05:30
|
|
|
/* Remove unneeded objects */
|
|
|
|
xbps_dictionary_remove(binpkgd, "pkgname");
|
|
|
|
xbps_dictionary_remove(binpkgd, "version");
|
2014-12-09 17:11:33 +05:30
|
|
|
xbps_dictionary_remove(binpkgd, "packaged-with");
|
2013-12-30 14:57:54 +05:30
|
|
|
|
2012-11-02 19:34:25 +05:30
|
|
|
/*
|
2016-03-20 22:21:22 +05:30
|
|
|
* Add new pkg dictionary into the stage index
|
2012-11-02 19:34:25 +05:30
|
|
|
*/
|
2016-03-20 22:21:22 +05:30
|
|
|
if (!xbps_dictionary_set(idxstage, pkgname, binpkgd)) {
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(binpkgd);
|
2013-03-05 08:38:42 +05:30
|
|
|
free(pkgname);
|
2014-10-05 13:05:42 +05:30
|
|
|
free(pkgver);
|
2014-01-31 16:05:31 +05:30
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
2013-03-05 08:38:42 +05:30
|
|
|
}
|
2013-12-24 15:13:55 +05:30
|
|
|
xbps_object_release(binpkgd);
|
|
|
|
free(pkgname);
|
2013-03-05 08:38:42 +05:30
|
|
|
free(pkgver);
|
2012-11-02 19:34:25 +05:30
|
|
|
}
|
2013-06-10 13:58:39 +05:30
|
|
|
/*
|
2013-10-07 13:53:14 +05:30
|
|
|
* Generate repository data files.
|
2013-06-10 13:58:39 +05:30
|
|
|
*/
|
2019-06-17 10:54:05 +05:30
|
|
|
if (!repodata_commit(xhp, repodir, idx, idxmeta, idxstage, compression)) {
|
2016-03-20 22:21:22 +05:30
|
|
|
fprintf(stderr, "%s: failed to write repodata: %s\n",
|
|
|
|
_XBPS_RINDEX, strerror(errno));
|
|
|
|
goto out;
|
2012-11-02 19:34:25 +05:30
|
|
|
}
|
2013-12-24 15:13:55 +05:30
|
|
|
printf("index: %u packages registered.\n", xbps_dictionary_count(idx));
|
2013-06-19 12:50:44 +05:30
|
|
|
|
2014-01-31 16:05:31 +05:30
|
|
|
out:
|
2016-09-25 21:08:36 +05:30
|
|
|
xbps_object_release(idx);
|
|
|
|
xbps_object_release(idxstage);
|
|
|
|
if (idxmeta)
|
|
|
|
xbps_object_release(idxmeta);
|
|
|
|
|
|
|
|
earlyout:
|
2014-09-05 15:56:42 +05:30
|
|
|
if (repo)
|
2015-01-11 13:41:38 +05:30
|
|
|
xbps_repo_close(repo);
|
2016-03-20 22:21:22 +05:30
|
|
|
if (stage)
|
|
|
|
xbps_repo_close(stage);
|
2015-03-25 16:30:59 +05:30
|
|
|
|
|
|
|
xbps_repo_unlock(rlockfd, rlockfname);
|
|
|
|
|
2014-09-05 15:56:42 +05:30
|
|
|
if (tmprepodir)
|
2014-04-20 13:32:54 +05:30
|
|
|
free(tmprepodir);
|
2014-09-05 15:56:42 +05:30
|
|
|
|
2013-10-05 15:08:04 +05:30
|
|
|
return rv;
|
2012-11-02 19:34:25 +05:30
|
|
|
}
|