2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
2011-01-24 23:43:11 +05:30
|
|
|
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
2009-08-17 22:37:20 +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 <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-01-25 17:30:23 +05:30
|
|
|
#include <strings.h>
|
2009-08-17 22:37:20 +05:30
|
|
|
#include <errno.h>
|
2009-11-07 09:26:20 +05:30
|
|
|
#include <ctype.h>
|
2010-11-13 07:48:58 +05:30
|
|
|
#include <assert.h>
|
2010-11-19 18:10:13 +05:30
|
|
|
#include <unistd.h>
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
#include <xbps_api.h>
|
2011-01-22 17:10:19 +05:30
|
|
|
#include "../xbps-bin/defs.h"
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-10-15 19:47:31 +05:30
|
|
|
/* error messages in bold/red */
|
|
|
|
#define MSG_ERROR "\033[1m\033[31m"
|
|
|
|
/* warn messages in bold/yellow */
|
|
|
|
#define MSG_WARN "\033[1m\033[33m"
|
|
|
|
/* normal messages in bold */
|
|
|
|
#define MSG_NORMAL "\033[1m"
|
|
|
|
#define MSG_RESET "\033[m"
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
static void
|
|
|
|
write_plist_file(prop_dictionary_t dict, const char *file)
|
|
|
|
{
|
|
|
|
assert(dict != NULL || file != NULL);
|
|
|
|
|
2010-04-20 17:52:38 +05:30
|
|
|
if (!prop_dictionary_externalize_to_zfile(dict, file)) {
|
2009-08-17 22:37:20 +05:30
|
|
|
prop_object_release(dict);
|
2011-01-30 22:53:33 +05:30
|
|
|
xbps_error_printf("xbps-uhelper: couldn't write to %s: %s",
|
2009-08-17 22:37:20 +05:30
|
|
|
file, strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-15 16:29:44 +05:30
|
|
|
static void __attribute__((noreturn))
|
2009-08-17 22:37:20 +05:30
|
|
|
usage(void)
|
|
|
|
{
|
2011-07-27 20:43:54 +05:30
|
|
|
xbps_end(xbps_handle_get());
|
2011-06-04 17:07:53 +05:30
|
|
|
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr,
|
|
|
|
"usage: xbps-uhelper [options] [action] [args]\n"
|
2009-08-17 22:37:20 +05:30
|
|
|
"\n"
|
|
|
|
" Available actions:\n"
|
2009-11-24 17:29:47 +05:30
|
|
|
" cmpver, digest, fetch, getpkgdepname, getpkgname, getpkgrevision,\n"
|
|
|
|
" getpkgversion, pkgmatch, register, sanitize-plist, unregister,\n"
|
|
|
|
" version\n"
|
2009-08-17 22:37:20 +05:30
|
|
|
"\n"
|
|
|
|
" Action arguments:\n"
|
2009-11-24 17:29:47 +05:30
|
|
|
" cmpver\t\t<instver> <reqver>\n"
|
|
|
|
" digest\t\t<file> <file1+N>\n"
|
2010-01-24 21:55:17 +05:30
|
|
|
" fetch\t\t<URL> <URL1+N>\n"
|
2009-11-07 09:26:20 +05:30
|
|
|
" getpkgdepname\t<string>\n"
|
2011-01-24 23:43:11 +05:30
|
|
|
" getpkgdepversion\t<string>\n"
|
2009-08-17 22:37:20 +05:30
|
|
|
" getpkgname\t\t<string>\n"
|
|
|
|
" getpkgrevision\t<string>\n"
|
|
|
|
" getpkgversion\t<string>\n"
|
2009-11-07 09:26:20 +05:30
|
|
|
" pkgmatch\t\t<pkg-version> <pkg-pattern>\n"
|
2009-08-17 22:37:20 +05:30
|
|
|
" register\t\t<pkgname> <version> <shortdesc>\n"
|
|
|
|
" sanitize-plist\t<plist>\n"
|
|
|
|
" unregister\t\t<pkgname> <version>\n"
|
|
|
|
" version\t\t<pkgname>\n"
|
|
|
|
"\n"
|
|
|
|
" Options shared by all actions:\n"
|
2011-06-04 17:07:53 +05:30
|
|
|
" -C\t\tPath to xbps-conf.plist file.\n"
|
2010-12-18 14:56:12 +05:30
|
|
|
" -d\t\tDebugging messages to stderr.\n"
|
2009-08-17 22:37:20 +05:30
|
|
|
" -r\t\t\t<rootdir>\n"
|
2009-10-18 14:12:04 +05:30
|
|
|
" -V\t\tPrints the xbps release version\n"
|
2009-08-17 22:37:20 +05:30
|
|
|
"\n"
|
|
|
|
" Examples:\n"
|
2009-11-24 17:29:47 +05:30
|
|
|
" $ xbps-uhelper cmpver 'foo-1.0' 'foo-2.1'\n"
|
2010-01-24 21:55:17 +05:30
|
|
|
" $ xbps-uhelper digest /foo/blah.txt ...\n"
|
|
|
|
" $ xbps-uhelper fetch http://www.foo.org/file.blob ...\n"
|
2009-11-24 17:29:47 +05:30
|
|
|
" $ xbps-uhelper getpkgname foo-2.0\n"
|
|
|
|
" $ xbps-uhelper getpkgrevision foo-2.0_1\n"
|
|
|
|
" $ xbps-uhelper getpkgversion foo-2.0\n"
|
|
|
|
" $ xbps-uhelper register pkgname 2.0 \"A short description\"\n"
|
|
|
|
" $ xbps-uhelper sanitize-plist /blah/foo.plist\n"
|
|
|
|
" $ xbps-uhelper unregister pkgname 2.0\n"
|
|
|
|
" $ xbps-uhelper version pkgname\n");
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2011-07-27 20:43:54 +05:30
|
|
|
struct xbps_handle *xhp;
|
2011-07-27 21:34:38 +05:30
|
|
|
struct xferstat xfer;
|
2011-07-15 19:59:55 +05:30
|
|
|
prop_dictionary_t dict;
|
2011-06-04 17:07:53 +05:30
|
|
|
const char *version, *rootdir = NULL, *conffile = NULL;
|
2010-12-16 04:55:53 +05:30
|
|
|
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
|
2011-07-15 19:59:55 +05:30
|
|
|
bool debug = false, in_chroot = false;
|
2010-05-20 02:08:27 +05:30
|
|
|
int i, c, rv = 0;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-06-04 17:07:53 +05:30
|
|
|
while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
|
2009-08-17 22:37:20 +05:30
|
|
|
switch (c) {
|
2011-06-04 17:07:53 +05:30
|
|
|
case 'C':
|
|
|
|
conffile = optarg;
|
|
|
|
break;
|
2009-08-17 22:37:20 +05:30
|
|
|
case 'r':
|
|
|
|
/* To specify the root directory */
|
2011-02-21 22:12:47 +05:30
|
|
|
rootdir = optarg;
|
2009-08-17 22:37:20 +05:30
|
|
|
break;
|
2010-12-18 14:56:12 +05:30
|
|
|
case 'd':
|
|
|
|
debug = true;
|
|
|
|
break;
|
2009-10-18 14:12:04 +05:30
|
|
|
case 'V':
|
|
|
|
printf("%s\n", XBPS_RELVER);
|
|
|
|
exit(EXIT_SUCCESS);
|
2009-08-17 22:37:20 +05:30
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc < 1)
|
|
|
|
usage();
|
|
|
|
|
2011-02-21 18:08:44 +05:30
|
|
|
/*
|
|
|
|
* Initialize the callbacks and debug in libxbps.
|
|
|
|
*/
|
2011-07-27 20:43:54 +05:30
|
|
|
xhp = xbps_handle_alloc();
|
|
|
|
if (xhp == NULL) {
|
|
|
|
xbps_error_printf("xbps-uhelper: failed to allocate resources\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
xhp->debug = debug;
|
|
|
|
xhp->xbps_fetch_cb = fetch_file_progress_cb;
|
2011-07-27 21:34:38 +05:30
|
|
|
xhp->xfcd->cookie = &xfer;
|
2011-07-27 20:43:54 +05:30
|
|
|
xhp->rootdir = rootdir;
|
|
|
|
xhp->conffile = conffile;
|
|
|
|
|
|
|
|
if ((rv = xbps_init(xhp)) != 0) {
|
2011-06-04 17:07:53 +05:30
|
|
|
xbps_error_printf("xbps-uhelper: failed to "
|
|
|
|
"initialize libxbps.\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2010-11-19 18:10:13 +05:30
|
|
|
|
2011-02-21 22:12:47 +05:30
|
|
|
plist = xbps_xasprintf("%s/%s/%s", rootdir,
|
2010-12-16 04:55:53 +05:30
|
|
|
XBPS_META_PATH, XBPS_REGPKGDB);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (plist == NULL) {
|
2011-07-27 20:43:54 +05:30
|
|
|
xbps_end(xhp);
|
2009-08-17 22:37:20 +05:30
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
in_chroot_env = getenv("in_chroot");
|
|
|
|
if (in_chroot_env != NULL)
|
|
|
|
in_chroot = true;
|
|
|
|
|
|
|
|
if (strcasecmp(argv[0], "register") == 0) {
|
|
|
|
/* Registers a package into the database */
|
|
|
|
if (argc != 4)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
dict = prop_dictionary_create();
|
|
|
|
if (dict == NULL)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
prop_dictionary_set_cstring_nocopy(dict, "pkgname", argv[1]);
|
|
|
|
prop_dictionary_set_cstring_nocopy(dict, "version", argv[2]);
|
|
|
|
prop_dictionary_set_cstring_nocopy(dict, "short_desc", argv[3]);
|
2009-11-23 05:58:57 +05:30
|
|
|
pkgver = xbps_xasprintf("%s-%s", argv[1], argv[2]);
|
|
|
|
if (pkgver == NULL)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
prop_dictionary_set_cstring(dict, "pkgver", pkgver);
|
2011-06-25 02:10:00 +05:30
|
|
|
prop_dictionary_set_bool(dict, "automatic-install", false);
|
2009-11-23 05:58:57 +05:30
|
|
|
free(pkgver);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-02-22 15:39:39 +05:30
|
|
|
rv = xbps_set_pkg_state_installed(argv[1], argv[2], pkgver,
|
2009-08-17 22:37:20 +05:30
|
|
|
XBPS_PKG_STATE_INSTALLED);
|
|
|
|
if (rv != 0)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
2011-04-11 18:12:06 +05:30
|
|
|
rv = xbps_register_pkg(dict);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (rv == EEXIST) {
|
2009-10-15 19:47:31 +05:30
|
|
|
printf("%s%s=> %s-%s already registered.%s\n", MSG_WARN,
|
|
|
|
in_chroot ? "[chroot] " : "", argv[1], argv[2],
|
|
|
|
MSG_RESET);
|
2009-08-17 22:37:20 +05:30
|
|
|
} else if (rv != 0) {
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr, "%s%s=> couldn't register %s-%s "
|
2009-10-15 19:47:31 +05:30
|
|
|
"(%s).%s\n", MSG_ERROR,
|
2009-08-17 22:37:20 +05:30
|
|
|
in_chroot ? "[chroot] " : "" , argv[1], argv[2],
|
2009-10-15 19:47:31 +05:30
|
|
|
strerror(rv), MSG_RESET);
|
2009-08-17 22:37:20 +05:30
|
|
|
} else {
|
2009-10-15 19:47:31 +05:30
|
|
|
printf("%s%s=> %s-%s registered successfully.%s\n",
|
|
|
|
MSG_NORMAL, in_chroot ? "[chroot] " : "",
|
|
|
|
argv[1], argv[2], MSG_RESET);
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
2011-02-26 15:45:17 +05:30
|
|
|
prop_object_release(dict);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "unregister") == 0) {
|
|
|
|
/* Unregisters a package from the database */
|
|
|
|
if (argc != 3)
|
|
|
|
usage();
|
|
|
|
|
2011-01-27 22:52:57 +05:30
|
|
|
if (!xbps_remove_pkg_dict_from_plist_by_name(argv[1], plist)) {
|
2010-12-16 04:55:53 +05:30
|
|
|
if (errno == ENOENT)
|
|
|
|
fprintf(stderr, "%s=> ERROR: %s not registered "
|
|
|
|
"in database.%s\n", MSG_WARN, argv[1], MSG_RESET);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s=> ERROR: couldn't unregister %s "
|
|
|
|
"from database (%s)%s\n", MSG_ERROR,
|
|
|
|
argv[1], strerror(errno), MSG_RESET);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2009-10-15 19:47:31 +05:30
|
|
|
printf("%s%s=> %s-%s unregistered successfully.%s\n",
|
|
|
|
MSG_NORMAL, in_chroot ? "[chroot] " : "", argv[1],
|
|
|
|
argv[2], MSG_RESET);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "version") == 0) {
|
|
|
|
/* Prints version of an installed package */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2011-02-05 15:55:04 +05:30
|
|
|
dict = xbps_find_pkg_dict_from_plist_by_name(plist,
|
|
|
|
"packages", argv[1]);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (dict == NULL)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
2010-11-06 11:14:00 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
|
2009-08-17 22:37:20 +05:30
|
|
|
printf("%s\n", version);
|
|
|
|
prop_object_release(dict);
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
|
|
|
|
/* Sanitize a plist file (properly indent the file) */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2010-04-20 17:52:38 +05:30
|
|
|
dict = prop_dictionary_internalize_from_zfile(argv[1]);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (dict == NULL) {
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr,
|
|
|
|
"=> ERROR: couldn't sanitize %s plist file "
|
2009-08-17 22:37:20 +05:30
|
|
|
"(%s)\n", argv[1], strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
write_plist_file(dict, argv[1]);
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "getpkgversion") == 0) {
|
|
|
|
/* Returns the version of a pkg string */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2011-06-01 13:07:32 +05:30
|
|
|
version = xbps_pkg_version(argv[1]);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (version == NULL) {
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr,
|
|
|
|
"Invalid string, expected <string>-<version>\n");
|
2009-08-17 22:37:20 +05:30
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
printf("%s\n", version);
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "getpkgname") == 0) {
|
|
|
|
/* Returns the name of a pkg string */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2011-06-01 13:07:32 +05:30
|
|
|
pkgname = xbps_pkg_name(argv[1]);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (pkgname == NULL) {
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr,
|
|
|
|
"Invalid string, expected <string>-<version>\n");
|
2009-08-17 22:37:20 +05:30
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
printf("%s\n", pkgname);
|
|
|
|
free(pkgname);
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "getpkgrevision") == 0) {
|
|
|
|
/* Returns the revision of a pkg string */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2011-06-01 13:07:32 +05:30
|
|
|
version = xbps_pkg_revision(argv[1]);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (version == NULL)
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
|
printf("%s\n", version);
|
|
|
|
|
2009-11-07 09:26:20 +05:30
|
|
|
} else if (strcasecmp(argv[0], "getpkgdepname") == 0) {
|
|
|
|
/* Returns the pkgname of a dependency */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2011-06-01 13:07:32 +05:30
|
|
|
pkgname = xbps_pkgpattern_name(argv[1]);
|
2009-11-07 09:26:20 +05:30
|
|
|
if (pkgname == NULL)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
printf("%s\n", pkgname);
|
|
|
|
free(pkgname);
|
2011-01-24 23:43:11 +05:30
|
|
|
} else if (strcasecmp(argv[0], "getpkgdepversion") == 0) {
|
|
|
|
/* returns the version of a package pattern dependency */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2011-06-01 13:07:32 +05:30
|
|
|
version = xbps_pkgpattern_version(argv[1]);
|
2011-01-24 23:43:11 +05:30
|
|
|
if (version == NULL)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
printf("%s\n", version);
|
2009-11-07 09:26:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "pkgmatch") == 0) {
|
|
|
|
/* Matches a pkg with a pattern */
|
|
|
|
if (argc != 3)
|
|
|
|
usage();
|
|
|
|
|
2010-01-21 07:40:19 +05:30
|
|
|
exit(xbps_pkgpattern_match(argv[1], argv[2]));
|
2009-11-24 17:29:47 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "cmpver") == 0) {
|
|
|
|
/* Compare two version strings, installed vs required */
|
|
|
|
if (argc != 3)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
exit(xbps_cmpver(argv[1], argv[2]));
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "digest") == 0) {
|
|
|
|
/* Prints SHA256 hashes for specified files */
|
|
|
|
if (argc < 2)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++) {
|
2011-06-01 13:07:32 +05:30
|
|
|
hash = xbps_file_hash(argv[i]);
|
2009-11-24 17:29:47 +05:30
|
|
|
if (hash == NULL) {
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr,
|
|
|
|
"E: couldn't get hash for %s (%s)\n",
|
2009-11-24 17:29:47 +05:30
|
|
|
argv[i], strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
printf("%s\n", hash);
|
|
|
|
free(hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "fetch") == 0) {
|
|
|
|
/* Fetch a file from specified URL */
|
|
|
|
if (argc != 2)
|
|
|
|
usage();
|
|
|
|
|
2010-01-24 21:55:17 +05:30
|
|
|
for (i = 1; i < argc; i++) {
|
2011-02-21 18:08:44 +05:30
|
|
|
rv = xbps_fetch_file(argv[i], ".", false, "v");
|
2010-01-24 21:55:17 +05:30
|
|
|
if (rv == -1) {
|
|
|
|
printf("%s: %s\n", argv[1],
|
|
|
|
xbps_fetch_error_string());
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
} else if (rv == 0) {
|
|
|
|
printf("%s: file is identical than remote.\n",
|
|
|
|
argv[1]);
|
|
|
|
}
|
2009-11-24 17:29:47 +05:30
|
|
|
}
|
2009-11-07 09:26:20 +05:30
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
} else {
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
2011-07-27 20:43:54 +05:30
|
|
|
xbps_end(xhp);
|
2010-11-19 18:10:13 +05:30
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|