bin: no point in cleaning up resources when it's exiting...
This commit is contained in:
parent
647aa0727f
commit
e2176ec4b6
@ -468,20 +468,6 @@ process_entry_memory(struct archive *ar, const void *src, const char *file)
|
|||||||
archive_entry_free(entry);
|
archive_entry_free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
destroy_xentry(struct xentry *xe)
|
|
||||||
{
|
|
||||||
assert(xe);
|
|
||||||
|
|
||||||
free(xe->file);
|
|
||||||
free(xe->type);
|
|
||||||
if (xe->target)
|
|
||||||
free(xe->target);
|
|
||||||
if (xe->hash)
|
|
||||||
free(xe->hash);
|
|
||||||
free(xe);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
process_archive(struct archive *ar,
|
process_archive(struct archive *ar,
|
||||||
struct archive_entry_linkresolver *resolver,
|
struct archive_entry_linkresolver *resolver,
|
||||||
@ -516,16 +502,14 @@ process_archive(struct archive *ar,
|
|||||||
while ((xe = TAILQ_FIRST(&xentry_list)) != NULL) {
|
while ((xe = TAILQ_FIRST(&xentry_list)) != NULL) {
|
||||||
TAILQ_REMOVE(&xentry_list, xe, entries);
|
TAILQ_REMOVE(&xentry_list, xe, entries);
|
||||||
if ((strcmp(xe->type, "metadata") == 0) ||
|
if ((strcmp(xe->type, "metadata") == 0) ||
|
||||||
(strcmp(xe->type, "dirs") == 0)) {
|
(strcmp(xe->type, "dirs") == 0))
|
||||||
destroy_xentry(xe);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
printf("%s: adding `%s' ...\n", pkgver, xe->file);
|
printf("%s: adding `%s' ...\n", pkgver, xe->file);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
process_entry_file(ar, resolver, xe, NULL);
|
process_entry_file(ar, resolver, xe, NULL);
|
||||||
destroy_xentry(xe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,8 +762,6 @@ main(int argc, char **argv)
|
|||||||
/* close and free archive */
|
/* close and free archive */
|
||||||
archive_write_free(ar);
|
archive_write_free(ar);
|
||||||
|
|
||||||
prop_object_release(pkg_propsd);
|
|
||||||
prop_object_release(pkg_filesd);
|
|
||||||
/*
|
/*
|
||||||
* Archive was created successfully; flush data to storage,
|
* Archive was created successfully; flush data to storage,
|
||||||
* set permissions and rename to dest file; from the caller's
|
* set permissions and rename to dest file; from the caller's
|
||||||
@ -794,6 +776,8 @@ main(int argc, char **argv)
|
|||||||
if (fchmod(pkg_fd, 0666 & ~myumask) == -1)
|
if (fchmod(pkg_fd, 0666 & ~myumask) == -1)
|
||||||
die("cannot fchmod() %s:", tname);
|
die("cannot fchmod() %s:", tname);
|
||||||
|
|
||||||
|
close(pkg_fd);
|
||||||
|
|
||||||
if (rename(tname, binpkg) == -1)
|
if (rename(tname, binpkg) == -1)
|
||||||
die("cannot rename %s to %s:", tname, binpkg);
|
die("cannot rename %s to %s:", tname, binpkg);
|
||||||
|
|
||||||
@ -802,9 +786,5 @@ main(int argc, char **argv)
|
|||||||
printf("%s: binary package created successfully (%s)\n",
|
printf("%s: binary package created successfully (%s)\n",
|
||||||
pkgver, binpkg);
|
pkgver, binpkg);
|
||||||
|
|
||||||
free(binpkg);
|
|
||||||
free(pkgname);
|
|
||||||
close(pkg_fd);
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -525,8 +525,5 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
create_dot_graph(&xh, f, plistd, confd, revdeps);
|
create_dot_graph(&xh, f, plistd, confd, revdeps);
|
||||||
|
|
||||||
prop_object_release(confd);
|
|
||||||
xbps_end(&xh);
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,6 @@
|
|||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
static struct xbps_handle xh;
|
|
||||||
|
|
||||||
static void __attribute__((noreturn))
|
static void __attribute__((noreturn))
|
||||||
usage(bool fail)
|
usage(bool fail)
|
||||||
{
|
{
|
||||||
@ -62,13 +60,6 @@ usage(bool fail)
|
|||||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((noreturn))
|
|
||||||
cleanup_sighandler(int signum)
|
|
||||||
{
|
|
||||||
xbps_end(&xh);
|
|
||||||
_exit(signum);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -90,8 +81,8 @@ main(int argc, char **argv)
|
|||||||
{ "yes", no_argument, NULL, 'y' },
|
{ "yes", no_argument, NULL, 'y' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
struct xbps_handle xh;
|
||||||
struct xferstat xfer;
|
struct xferstat xfer;
|
||||||
struct sigaction sa;
|
|
||||||
const char *rootdir, *cachedir, *conffile, *defrepo;
|
const char *rootdir, *cachedir, *conffile, *defrepo;
|
||||||
int i, c, flags, rv;
|
int i, c, flags, rv;
|
||||||
bool skip_sync, yes, reinstall, drun, update;
|
bool skip_sync, yes, reinstall, drun, update;
|
||||||
@ -176,15 +167,6 @@ main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Register a signal handler to clean up resources used by libxbps.
|
|
||||||
*/
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sa_handler = cleanup_sighandler;
|
|
||||||
sigaction(SIGHUP, &sa, NULL);
|
|
||||||
sigaction(SIGINT, &sa, NULL);
|
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
|
||||||
|
|
||||||
maxcols = get_maxcols();
|
maxcols = get_maxcols();
|
||||||
/*
|
/*
|
||||||
* Check that we have write permission on rootdir, metadir
|
* Check that we have write permission on rootdir, metadir
|
||||||
@ -197,8 +179,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Not enough permissions on "
|
fprintf(stderr, "Not enough permissions on "
|
||||||
"rootdir/cachedir/metadir: %s\n",
|
"rootdir/cachedir/metadir: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
rv = errno;
|
exit(errno);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +187,7 @@ main(int argc, char **argv)
|
|||||||
if (!skip_sync || !drun) {
|
if (!skip_sync || !drun) {
|
||||||
rv = xbps_rpool_sync(&xh, XBPS_PKGINDEX, NULL);
|
rv = xbps_rpool_sync(&xh, XBPS_PKGINDEX, NULL);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
goto out;
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update && (argc == optind)) {
|
if (update && (argc == optind)) {
|
||||||
@ -217,7 +198,7 @@ main(int argc, char **argv)
|
|||||||
for (i = optind; i < argc; i++) {
|
for (i = optind; i < argc; i++) {
|
||||||
rv = update_pkg(&xh, argv[i]);
|
rv = update_pkg(&xh, argv[i]);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
goto out;
|
exit(rv);
|
||||||
}
|
}
|
||||||
rv = exec_transaction(&xh, maxcols, yes, drun);
|
rv = exec_transaction(&xh, maxcols, yes, drun);
|
||||||
} else if (!update) {
|
} else if (!update) {
|
||||||
@ -225,12 +206,10 @@ main(int argc, char **argv)
|
|||||||
for (i = optind; i < argc; i++) {
|
for (i = optind; i < argc; i++) {
|
||||||
rv = install_new_pkg(&xh, argv[i], reinstall);
|
rv = install_new_pkg(&xh, argv[i], reinstall);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
goto out;
|
exit(rv);
|
||||||
}
|
}
|
||||||
rv = exec_transaction(&xh, maxcols, yes, drun);
|
rv = exec_transaction(&xh, maxcols, yes, drun);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv);
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,6 @@ check_pkg_integrity_all(struct xbps_handle *xhp)
|
|||||||
for (i = 0; i < maxthreads; i++)
|
for (i = 0; i < maxthreads; i++)
|
||||||
pthread_join(thd[i].thread, NULL);
|
pthread_join(thd[i].thread, NULL);
|
||||||
|
|
||||||
free(thd);
|
|
||||||
|
|
||||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) {
|
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) {
|
||||||
xbps_error_printf("failed to write pkgdb: %s\n",
|
xbps_error_printf("failed to write pkgdb: %s\n",
|
||||||
strerror(rv));
|
strerror(rv));
|
||||||
|
@ -122,6 +122,5 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,6 @@ list_orphans(struct xbps_handle *xhp)
|
|||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||||
printf("%s\n", pkgver);
|
printf("%s\n", pkgver);
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -260,6 +260,5 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv);
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
|
|||||||
prop_array_get_cstring_nocopy(reqby, i, &pkgdep);
|
prop_array_get_cstring_nocopy(reqby, i, &pkgdep);
|
||||||
printf("%s\n", pkgdep);
|
printf("%s\n", pkgdep);
|
||||||
}
|
}
|
||||||
prop_object_release(reqby);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,6 @@ show_pkg_info(prop_dictionary_t dict)
|
|||||||
|
|
||||||
print_value_obj(keyname, obj, NULL, false);
|
print_value_obj(keyname, obj, NULL, false);
|
||||||
}
|
}
|
||||||
prop_object_release(all_keys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -210,7 +209,6 @@ show_pkg_files(prop_dictionary_t filesd)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prop_object_release(allkeys);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -286,7 +284,6 @@ int
|
|||||||
repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
|
repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
int rv;
|
|
||||||
|
|
||||||
pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "./files.plist");
|
pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "./files.plist");
|
||||||
if (pkgd == NULL) {
|
if (pkgd == NULL) {
|
||||||
@ -297,8 +294,5 @@ repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = show_pkg_files(pkgd);
|
return show_pkg_files(pkgd);
|
||||||
prop_object_release(pkgd);
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,5 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
#include "../xbps-install/defs.h"
|
#include "../xbps-install/defs.h"
|
||||||
|
|
||||||
static struct xbps_handle xh;
|
|
||||||
|
|
||||||
static void __attribute__((noreturn))
|
static void __attribute__((noreturn))
|
||||||
usage(bool fail)
|
usage(bool fail)
|
||||||
{
|
{
|
||||||
@ -64,13 +62,6 @@ usage(bool fail)
|
|||||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((noreturn))
|
|
||||||
cleanup_sighandler(int signum)
|
|
||||||
{
|
|
||||||
xbps_end(&xh);
|
|
||||||
_exit(signum);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
|
state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
|
||||||
{
|
{
|
||||||
@ -256,7 +247,7 @@ main(int argc, char **argv)
|
|||||||
{ "yes", no_argument, NULL, 'y' },
|
{ "yes", no_argument, NULL, 'y' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
struct sigaction sa;
|
struct xbps_handle xh;
|
||||||
const char *rootdir, *cachedir, *conffile;
|
const char *rootdir, *cachedir, *conffile;
|
||||||
int i, c, flags, rv;
|
int i, c, flags, rv;
|
||||||
bool yes, drun, recursive, ignore_revdeps, clean_cache;
|
bool yes, drun, recursive, ignore_revdeps, clean_cache;
|
||||||
@ -337,15 +328,6 @@ main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Register a signal handler to clean up resources used by libxbps.
|
|
||||||
*/
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sa_handler = cleanup_sighandler;
|
|
||||||
sigaction(SIGHUP, &sa, NULL);
|
|
||||||
sigaction(SIGINT, &sa, NULL);
|
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
|
||||||
|
|
||||||
maxcols = get_maxcols();
|
maxcols = get_maxcols();
|
||||||
/*
|
/*
|
||||||
* Check that we have write permission on rootdir, metadir
|
* Check that we have write permission on rootdir, metadir
|
||||||
@ -358,15 +340,14 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Not enough permissions on "
|
fprintf(stderr, "Not enough permissions on "
|
||||||
"rootdir/cachedir/metadir: %s\n",
|
"rootdir/cachedir/metadir: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
rv = errno;
|
exit(errno);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clean_cache) {
|
if (clean_cache) {
|
||||||
rv = cachedir_clean(&xh);
|
rv = cachedir_clean(&xh);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
goto out;
|
exit(rv);;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orphans) {
|
if (orphans) {
|
||||||
@ -374,10 +355,9 @@ main(int argc, char **argv)
|
|||||||
if (rv != ENOENT) {
|
if (rv != ENOENT) {
|
||||||
fprintf(stderr, "Failed to queue package "
|
fprintf(stderr, "Failed to queue package "
|
||||||
"orphans: %s\n", strerror(rv));
|
"orphans: %s\n", strerror(rv));
|
||||||
goto out;
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
rv = 0;
|
exit(EXIT_SUCCESS);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,19 +366,15 @@ main(int argc, char **argv)
|
|||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
continue;
|
continue;
|
||||||
else if (rv != EEXIST)
|
else if (rv != EEXIST)
|
||||||
goto out;
|
exit(rv);
|
||||||
else
|
else
|
||||||
reqby_force = true;
|
reqby_force = true;
|
||||||
}
|
}
|
||||||
if (reqby_force && !ignore_revdeps) {
|
if (reqby_force && !ignore_revdeps)
|
||||||
rv = EINVAL;
|
exit(EXIT_FAILURE);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orphans || (argc > optind))
|
if (orphans || (argc > optind))
|
||||||
rv = exec_transaction(&xh, maxcols, yes, drun);
|
rv = exec_transaction(&xh, maxcols, yes, drun);
|
||||||
|
|
||||||
out:
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv);
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
idx = idxfiles = newpkgd = newpkgfilesd = curpkgd = NULL;
|
idx = idxfiles = newpkgd = newpkgfilesd = curpkgd = NULL;
|
||||||
tmpfilen = tmprepodir = plist = plistf = NULL;
|
tmpfilen = tmprepodir = plist = plistf = NULL;
|
||||||
|
|
||||||
if ((tmprepodir = strdup(argv[0])) == NULL) {
|
if ((tmprepodir = strdup(argv[0])) == NULL)
|
||||||
rv = ENOMEM;
|
return ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
repodir = dirname(tmprepodir);
|
repodir = dirname(tmprepodir);
|
||||||
|
|
||||||
/* Internalize index or create it if doesn't exist */
|
/* Internalize index or create it if doesn't exist */
|
||||||
@ -73,8 +72,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||||
plist, strerror(errno));
|
plist, strerror(errno));
|
||||||
rv = -1;
|
return -1;
|
||||||
goto out;
|
|
||||||
} else {
|
} else {
|
||||||
idx = prop_dictionary_create();
|
idx = prop_dictionary_create();
|
||||||
assert(idx);
|
assert(idx);
|
||||||
@ -88,8 +86,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||||
plistf, strerror(errno));
|
plistf, strerror(errno));
|
||||||
rv = -1;
|
return -1;
|
||||||
goto out;
|
|
||||||
} else {
|
} else {
|
||||||
idxfiles = prop_dictionary_create();
|
idxfiles = prop_dictionary_create();
|
||||||
assert(idx);
|
assert(idx);
|
||||||
@ -100,10 +97,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
* Process all packages specified in argv.
|
* Process all packages specified in argv.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if ((tmpfilen = strdup(argv[i])) == NULL) {
|
if ((tmpfilen = strdup(argv[i])) == NULL)
|
||||||
rv = ENOMEM;
|
return ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
filen = basename(tmpfilen);
|
filen = basename(tmpfilen);
|
||||||
/*
|
/*
|
||||||
* Read metadata props plist dictionary from binary package.
|
* Read metadata props plist dictionary from binary package.
|
||||||
@ -137,12 +133,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
curpkgd = prop_dictionary_get(idx, pkgname);
|
curpkgd = prop_dictionary_get(idx, pkgname);
|
||||||
if (curpkgd == NULL) {
|
if (curpkgd == NULL) {
|
||||||
if (errno && errno != ENOENT) {
|
if (errno && errno != ENOENT)
|
||||||
prop_object_release(newpkgd);
|
return errno;
|
||||||
free(tmpfilen);
|
|
||||||
rv = errno;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||||
"filename", &oldfilen);
|
"filename", &oldfilen);
|
||||||
@ -170,12 +162,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
oldpkgver, oldarch);
|
oldpkgver, oldarch);
|
||||||
rv = remove_pkg(repodir,
|
rv = remove_pkg(repodir,
|
||||||
oldarch, oldfilen);
|
oldarch, oldfilen);
|
||||||
if (rv != 0) {
|
if (rv != 0)
|
||||||
prop_object_release(newpkgd);
|
return rv;
|
||||||
free(tmpfilen);
|
|
||||||
free(buf);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
printf("index: removed obsolete binpkg %s.\n", buf);
|
printf("index: removed obsolete binpkg %s.\n", buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
prop_object_release(newpkgd);
|
prop_object_release(newpkgd);
|
||||||
@ -190,13 +179,9 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
buf2 = strdup(oldpkgver);
|
buf2 = strdup(oldpkgver);
|
||||||
assert(buf2);
|
assert(buf2);
|
||||||
rv = remove_pkg(repodir, oldarch, oldfilen);
|
rv = remove_pkg(repodir, oldarch, oldfilen);
|
||||||
if (rv != 0) {
|
if (rv != 0)
|
||||||
free(buf);
|
return rv;
|
||||||
free(buf2);
|
|
||||||
prop_object_release(newpkgd);
|
|
||||||
free(tmpfilen);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
prop_dictionary_remove(idx, pkgname);
|
prop_dictionary_remove(idx, pkgname);
|
||||||
free(buf2);
|
free(buf2);
|
||||||
printf("index: removed obsolete entry/binpkg %s.\n", buf);
|
printf("index: removed obsolete entry/binpkg %s.\n", buf);
|
||||||
@ -206,49 +191,30 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
* We have the dictionary now, add the required
|
* We have the dictionary now, add the required
|
||||||
* objects for the index.
|
* objects for the index.
|
||||||
*/
|
*/
|
||||||
if (!prop_dictionary_set_cstring(newpkgd, "filename", filen)) {
|
if (!prop_dictionary_set_cstring(newpkgd, "filename", filen))
|
||||||
rv = errno;
|
return errno;
|
||||||
prop_object_release(newpkgd);
|
|
||||||
free(tmpfilen);
|
if ((sha256 = xbps_file_hash(argv[i])) == NULL)
|
||||||
goto out;
|
return errno;
|
||||||
}
|
|
||||||
if ((sha256 = xbps_file_hash(argv[i])) == NULL) {
|
|
||||||
rv = errno;
|
|
||||||
prop_object_release(newpkgd);
|
|
||||||
free(tmpfilen);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256",
|
if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256",
|
||||||
sha256)) {
|
sha256))
|
||||||
|
return errno;
|
||||||
|
|
||||||
free(sha256);
|
free(sha256);
|
||||||
prop_object_release(newpkgd);
|
if (stat(argv[i], &st) == -1)
|
||||||
free(tmpfilen);
|
return errno;
|
||||||
rv = errno;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
free(sha256);
|
|
||||||
if (stat(argv[i], &st) == -1) {
|
|
||||||
prop_object_release(newpkgd);
|
|
||||||
free(tmpfilen);
|
|
||||||
rv = errno;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (!prop_dictionary_set_uint64(newpkgd, "filename-size",
|
if (!prop_dictionary_set_uint64(newpkgd, "filename-size",
|
||||||
(uint64_t)st.st_size)) {
|
(uint64_t)st.st_size)) {
|
||||||
prop_object_release(newpkgd);
|
return errno;
|
||||||
free(tmpfilen);
|
|
||||||
rv = errno;
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Add new pkg dictionary into the index.
|
* Add new pkg dictionary into the index.
|
||||||
*/
|
*/
|
||||||
if (!prop_dictionary_set(idx, pkgname, newpkgd)) {
|
if (!prop_dictionary_set(idx, pkgname, newpkgd))
|
||||||
prop_object_release(newpkgd);
|
return EINVAL;
|
||||||
free(tmpfilen);
|
|
||||||
rv = EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
flush = true;
|
flush = true;
|
||||||
printf("index: added `%s-%s' (%s).\n", pkgname, version, arch);
|
printf("index: added `%s-%s' (%s).\n", pkgname, version, arch);
|
||||||
free(tmpfilen);
|
free(tmpfilen);
|
||||||
@ -258,10 +224,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
found = false;
|
found = false;
|
||||||
newpkgfilesd = xbps_get_pkg_plist_from_binpkg(argv[i],
|
newpkgfilesd = xbps_get_pkg_plist_from_binpkg(argv[i],
|
||||||
"./files.plist");
|
"./files.plist");
|
||||||
if (newpkgfilesd == NULL) {
|
if (newpkgfilesd == NULL)
|
||||||
rv = EINVAL;
|
return EINVAL;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find out if binary pkg stored in index contain any file */
|
/* Find out if binary pkg stored in index contain any file */
|
||||||
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files");
|
pkg_cffiles = prop_dictionary_get(newpkgfilesd, "conf_files");
|
||||||
@ -341,32 +305,18 @@ index_add(struct xbps_handle *xhp, int argc, char **argv)
|
|||||||
if (flush && !prop_dictionary_externalize_to_zfile(idx, plist)) {
|
if (flush && !prop_dictionary_externalize_to_zfile(idx, plist)) {
|
||||||
fprintf(stderr, "index: failed to externalize plist: %s\n",
|
fprintf(stderr, "index: failed to externalize plist: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
rv = -1;
|
return -1;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
if (files_flush &&
|
if (files_flush &&
|
||||||
!prop_dictionary_externalize_to_zfile(idxfiles, plistf)) {
|
!prop_dictionary_externalize_to_zfile(idxfiles, plistf)) {
|
||||||
fprintf(stderr, "index-files: failed to externalize "
|
fprintf(stderr, "index-files: failed to externalize "
|
||||||
"plist: %s\n", strerror(errno));
|
"plist: %s\n", strerror(errno));
|
||||||
rv = -1;
|
return -1;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
printf("index: %u packages registered.\n",
|
printf("index: %u packages registered.\n",
|
||||||
prop_dictionary_count(idx));
|
prop_dictionary_count(idx));
|
||||||
printf("index-files: %u packages registered.\n",
|
printf("index-files: %u packages registered.\n",
|
||||||
prop_dictionary_count(idxfiles));
|
prop_dictionary_count(idxfiles));
|
||||||
|
|
||||||
out:
|
return 0;
|
||||||
if (tmprepodir)
|
|
||||||
free(tmprepodir);
|
|
||||||
if (plist)
|
|
||||||
free(plist);
|
|
||||||
if (plistf)
|
|
||||||
free(plistf);
|
|
||||||
if (idx)
|
|
||||||
prop_object_release(idx);
|
|
||||||
if (idxfiles)
|
|
||||||
prop_object_release(idxfiles);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
@ -113,29 +113,23 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
|
|||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||||
plist, strerror(errno));
|
plist, strerror(errno));
|
||||||
free(plist);
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else
|
||||||
free(plist);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
idxfiles = prop_dictionary_internalize_from_zfile(plistf);
|
idxfiles = prop_dictionary_internalize_from_zfile(plistf);
|
||||||
if (idxfiles == NULL) {
|
if (idxfiles == NULL) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
fprintf(stderr, "index: cannot read `%s': %s\n",
|
fprintf(stderr, "index: cannot read `%s': %s\n",
|
||||||
plistf, strerror(errno));
|
plistf, strerror(errno));
|
||||||
rv = -1;
|
return -1;
|
||||||
goto out;
|
} else
|
||||||
} else {
|
return 0;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (chdir(repodir) == -1) {
|
if (chdir(repodir) == -1) {
|
||||||
fprintf(stderr, "index: cannot chdir to %s: %s\n",
|
fprintf(stderr, "index: cannot chdir to %s: %s\n",
|
||||||
repodir, strerror(errno));
|
repodir, strerror(errno));
|
||||||
rv = -1;
|
return -1;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
printf("Cleaning `%s' index, please wait...\n", repodir);
|
printf("Cleaning `%s' index, please wait...\n", repodir);
|
||||||
|
|
||||||
@ -177,7 +171,6 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
|
|||||||
}
|
}
|
||||||
prop_object_release(thd[i].result);
|
prop_object_release(thd[i].result);
|
||||||
}
|
}
|
||||||
free(thd);
|
|
||||||
if (!flush)
|
if (!flush)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -192,14 +185,5 @@ out:
|
|||||||
printf("index-files: %u packages registered.\n",
|
printf("index-files: %u packages registered.\n",
|
||||||
prop_dictionary_count(idxfiles));
|
prop_dictionary_count(idxfiles));
|
||||||
|
|
||||||
if (plist)
|
|
||||||
free(plist);
|
|
||||||
if (plistf)
|
|
||||||
free(plistf);
|
|
||||||
if (idx)
|
|
||||||
prop_object_release(idx);
|
|
||||||
if (idxfiles)
|
|
||||||
prop_object_release(idxfiles);
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,5 @@ main(int argc, char **argv)
|
|||||||
else if (rm_mode)
|
else if (rm_mode)
|
||||||
rv = remove_obsoletes(&xh, argv[optind]);
|
rv = remove_obsoletes(&xh, argv[optind]);
|
||||||
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -119,13 +119,10 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
|||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
fprintf(stderr, "xbps-rindex: cannot read `%s': %s\n",
|
fprintf(stderr, "xbps-rindex: cannot read `%s': %s\n",
|
||||||
plist, strerror(errno));
|
plist, strerror(errno));
|
||||||
free(plist);
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else
|
||||||
free(plist);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* initialize repository index */
|
/* initialize repository index */
|
||||||
ri.repod = idx;
|
ri.repod = idx;
|
||||||
ri.uri = repodir;
|
ri.uri = repodir;
|
||||||
@ -134,13 +131,11 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
|||||||
if (chdir(repodir) == -1) {
|
if (chdir(repodir) == -1) {
|
||||||
fprintf(stderr, "xbps-rindex: cannot chdir to %s: %s\n",
|
fprintf(stderr, "xbps-rindex: cannot chdir to %s: %s\n",
|
||||||
repodir, strerror(errno));
|
repodir, strerror(errno));
|
||||||
prop_object_release(idx);
|
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
if ((dirp = opendir(repodir)) == NULL) {
|
if ((dirp = opendir(repodir)) == NULL) {
|
||||||
fprintf(stderr, "xbps-rindex: failed to open %s: %s\n",
|
fprintf(stderr, "xbps-rindex: failed to open %s: %s\n",
|
||||||
repodir, strerror(errno));
|
repodir, strerror(errno));
|
||||||
prop_object_release(idx);
|
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
while ((dp = readdir(dirp))) {
|
while ((dp = readdir(dirp))) {
|
||||||
@ -180,9 +175,5 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
|||||||
for (i = 0; i < maxthreads; i++)
|
for (i = 0; i < maxthreads; i++)
|
||||||
pthread_join(thd[i].thread, NULL);
|
pthread_join(thd[i].thread, NULL);
|
||||||
|
|
||||||
free(thd);
|
|
||||||
prop_object_release(array);
|
|
||||||
prop_object_release(idx);
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -156,10 +156,9 @@ main(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
|
|
||||||
dict = xbps_pkgdb_get_pkg(&xh, argv[1]);
|
dict = xbps_pkgdb_get_pkg(&xh, argv[1]);
|
||||||
if (dict == NULL) {
|
if (dict == NULL)
|
||||||
rv = errno;
|
exit(EXIT_FAILURE);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
|
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
|
||||||
printf("%s\n", version);
|
printf("%s\n", version);
|
||||||
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
|
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
|
||||||
@ -278,7 +277,6 @@ main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
xbps_end(&xh);
|
|
||||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user