xbps-uhelper: new bin that combines xbps-cmpver, xbps-digest,
xbps-fetch and xbps-pkgdb in one utility. Bump XBPS_RELVER to 20091124-1. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091124115947-hb9cp7vp3tyhq64o
This commit is contained in:
parent
ea882fca0b
commit
7ca13ee7df
@ -1,9 +1,6 @@
|
||||
include ../vars.mk
|
||||
|
||||
SUBDIRS = xbps-cmpver
|
||||
SUBDIRS += xbps-digest
|
||||
SUBDIRS += xbps-fetch
|
||||
SUBDIRS += xbps-pkgdb
|
||||
SUBDIRS = xbps-uhelper
|
||||
SUBDIRS += xbps-repo
|
||||
SUBDIRS += xbps-bin
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Compare package and version strings
|
||||
* @ 2008
|
||||
* Author: pancake <youterm.com>
|
||||
*/
|
||||
#include <xbps_api.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
printf("Usage: xbps-cmpver [installed] [required]\n");
|
||||
printf(" xbps-cmpver foo-1.2 foo-2.2 # $? = 1\n");
|
||||
printf(" xbps-cmpver foo-1.2 foo-1.1.0 # $? = 0\n");
|
||||
printf(" xbps-cmpver foo-1.2 foo-1.2 # $? = 0\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return xbps_cmpver(argv[1], argv[2]);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
|
||||
BIN = xbps-digest
|
||||
|
||||
include $(TOPDIR)/prog.mk
|
@ -1,62 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2009 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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: xbps-digest <file> <file1+N> ...\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *hash;
|
||||
int i;
|
||||
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
hash = xbps_get_file_hash(argv[i]);
|
||||
if (hash == NULL) {
|
||||
printf("Couldn't get hash for %s (%s)\n",
|
||||
argv[i], strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("%s\n", hash);
|
||||
free(hash);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
|
||||
BIN = xbps-fetch
|
||||
|
||||
include $(TOPDIR)/prog.mk
|
@ -1,43 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <xbps_api.h>
|
||||
#include "fetch.h"
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("usage: xbps-fetch [-v] URL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char flags[8];
|
||||
int c, rv = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "v")) != -1) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
strcat(flags, "v");
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
rv = xbps_fetch_file(argv[0], ".", false, flags);
|
||||
if (rv == -1) {
|
||||
printf("%s: %s\n", argv[0], xbps_fetch_error_string());
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (rv == 0) {
|
||||
printf("%s: file is identical than remote.\n", argv[0]);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
|
||||
BIN = xbps-pkgdb
|
||||
|
||||
include $(TOPDIR)/prog.mk
|
@ -1,6 +1,6 @@
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/vars.mk
|
||||
|
||||
BIN = xbps-cmpver
|
||||
BIN = xbps-uhelper
|
||||
|
||||
include $(TOPDIR)/prog.mk
|
@ -56,13 +56,17 @@ write_plist_file(prop_dictionary_t dict, const char *file)
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("usage: xbps-pkgdb [options] [action] [args]\n"
|
||||
printf("usage: xbps-uhelper [options] [action] [args]\n"
|
||||
"\n"
|
||||
" Available actions:\n"
|
||||
" getpkgdepname, getpkgname, getpkgrevision, getpkgversion,\n"
|
||||
" pkgmatch, register, sanitize-plist, unregister, version\n"
|
||||
" cmpver, digest, fetch, getpkgdepname, getpkgname, getpkgrevision,\n"
|
||||
" getpkgversion, pkgmatch, register, sanitize-plist, unregister,\n"
|
||||
" version\n"
|
||||
"\n"
|
||||
" Action arguments:\n"
|
||||
" cmpver\t\t<instver> <reqver>\n"
|
||||
" digest\t\t<file> <file1+N>\n"
|
||||
" fetch\t\t<URL>\n"
|
||||
" getpkgdepname\t<string>\n"
|
||||
" getpkgname\t\t<string>\n"
|
||||
" getpkgrevision\t<string>\n"
|
||||
@ -78,13 +82,16 @@ usage(void)
|
||||
" -V\t\tPrints the xbps release version\n"
|
||||
"\n"
|
||||
" Examples:\n"
|
||||
" $ xbps-pkgdb getpkgname foo-2.0\n"
|
||||
" $ xbps-pkgdb getpkgrevision foo-2.0_1\n"
|
||||
" $ xbps-pkgdb getpkgversion foo-2.0\n"
|
||||
" $ xbps-pkgdb register pkgname 2.0 \"A short description\"\n"
|
||||
" $ xbps-pkgdb sanitize-plist /blah/foo.plist\n"
|
||||
" $ xbps-pkgdb unregister pkgname 2.0\n"
|
||||
" $ xbps-pkgdb version pkgname\n");
|
||||
" $ xbps-uhelper cmpver 'foo-1.0' 'foo-2.1'\n"
|
||||
" $ xbps-uhelper digest /foo/blah.txt\n"
|
||||
" $ xbps-uhelper fetch http://www.foo.org/file.blob\n"
|
||||
" $ 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");
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -273,8 +280,46 @@ main(int argc, char **argv)
|
||||
if (argc != 3)
|
||||
usage();
|
||||
|
||||
rv = xbps_pkgdep_match(argv[1], argv[2]);
|
||||
exit(rv);
|
||||
exit(xbps_pkgdep_match(argv[1], argv[2]));
|
||||
|
||||
} 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();
|
||||
|
||||
char *hash;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
hash = xbps_get_file_hash(argv[i]);
|
||||
if (hash == NULL) {
|
||||
printf("Couldn't get hash for %s (%s)\n",
|
||||
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();
|
||||
|
||||
rv = xbps_fetch_file(argv[1], ".", false, "v");
|
||||
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]);
|
||||
}
|
||||
|
||||
} else {
|
||||
usage();
|
@ -38,7 +38,7 @@
|
||||
#include <archive_entry.h>
|
||||
|
||||
/* Current release version */
|
||||
#define XBPS_RELVER "20091124"
|
||||
#define XBPS_RELVER "20091124-1"
|
||||
|
||||
/* Default root PATH for xbps to store metadata info. */
|
||||
#define XBPS_META_PATH "/var/db/xbps"
|
||||
|
Loading…
Reference in New Issue
Block a user