XBPS major changes in June 2011.

- A configuration file "xbps-conf.plist" replaces the (un)register target
  in xbps-repo(8) and (un)set-prop in xbps-bin(8). For now, you can set
  the repositories and prefered virtual packages.

- New package pattern matching code from NetBSD. Supports more ways of
  matching patterns in packages.

- Multiple bugs fixed in virtual packages related matching code.

--HG--
rename : LICENSE => COPYING
This commit is contained in:
Juan RP
2011-06-04 13:37:53 +02:00
parent 2d6140f65b
commit 9673c4bd09
59 changed files with 1183 additions and 1416 deletions

View File

@@ -53,18 +53,15 @@
int
xbps_check_pkg_integrity_all(void)
{
prop_dictionary_t d;
const struct xbps_handle *xhp;
prop_object_t obj;
prop_object_iterator_t iter = NULL;
const char *pkgname, *version;
int rv = 0;
size_t npkgs = 0, nbrokenpkgs = 0;
d = xbps_regpkgdb_dictionary_get();
if (d == NULL)
return ENODEV;
iter = xbps_array_iter_from_dict(d, "packages");
xhp = xbps_handle_get();
iter = xbps_array_iter_from_dict(xhp->regpkgdb_dictionary, "packages");
if (iter == NULL) {
rv = ENOENT;
goto out;
@@ -86,8 +83,6 @@ out:
if (iter)
prop_object_iterator_release(iter);
xbps_regpkgdb_dictionary_release();
return rv;
}

View File

@@ -60,7 +60,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, prop_dictionary_keysym_t ke
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr);
if ((strcmp(filestr, pattern) == 0) ||
(xbps_pkgpattern_match(filestr, __UNCONST(pattern)) == 1))
(xbps_pkgpattern_match(filestr, pattern) == 1))
printf("%s: %s (%s)\n", pkgname, filestr, typestr);
}
prop_object_iterator_release(iter);

View File

@@ -181,13 +181,13 @@ unpack_progress_cb(void *data)
int
main(int argc, char **argv)
{
prop_dictionary_t dict;
const struct xbps_handle *xhp;
struct xbps_handle xh;
struct xbps_unpack_progress_data xupd;
struct xbps_fetch_progress_data xfpd;
struct list_pkgver_cb lpc;
struct sigaction sa;
const char *rootdir, *cachedir;
const char *rootdir, *cachedir, *conffile;
int i , c, flags, rv;
bool yes, purge, with_debug, force_rm_with_deps, recursive_rm;
bool install_auto, install_manual, show_download_pkglist_url;
@@ -197,11 +197,14 @@ main(int argc, char **argv)
yes = purge = force_rm_with_deps = recursive_rm = with_debug = false;
install_auto = install_manual = show_download_pkglist_url = false;
while ((c = getopt(argc, argv, "Ac:dDFfMpRr:Vvy")) != -1) {
while ((c = getopt(argc, argv, "AC:c:dDFfMpRr:Vvy")) != -1) {
switch (c) {
case 'A':
install_auto = true;
break;
case 'C':
conffile = optarg;
break;
case 'c':
cachedir = optarg;
break;
@@ -282,34 +285,23 @@ main(int argc, char **argv)
xh.rootdir = rootdir;
xh.cachedir = cachedir;
xh.flags = flags;
xh.conffile = conffile;
xh.install_reason_manual = install_manual;
xh.install_reason_auto = install_auto;
xbps_init(&xh);
if ((dict = xbps_regpkgdb_dictionary_get()) == NULL) {
if (errno && errno != ENOENT) {
fprintf(stderr,
"E: couldn't initialize regpkgdb dict: %s\n",
strerror(errno));
goto out;
}
}
if ((rv = xbps_repository_pool_init()) != 0) {
if (rv != ENOENT) {
fprintf(stderr,
"E: couldn't initialize repository pool: %s\n",
strerror(rv));
goto out;
}
if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("xbps-bin: couldn't initialize library: %s\n",
strerror(errno));
exit(EXIT_FAILURE);
}
xhp = xbps_handle_get();
if (strcasecmp(argv[0], "list") == 0) {
/* Lists packages currently registered in database. */
if (argc < 1 || argc > 2)
usage();
if (dict == NULL) {
if (xhp->regpkgdb_dictionary == NULL) {
printf("No packages currently installed.\n");
goto out;
}
@@ -335,9 +327,9 @@ main(int argc, char **argv)
/*
* Find the longest pkgver string to pretty print the output.
*/
lpc.pkgver_len = find_longest_pkgver(dict);
rv = xbps_callback_array_iter_in_dict(dict, "packages",
list_pkgs_in_dict, &lpc);
lpc.pkgver_len = find_longest_pkgver(xhp->regpkgdb_dictionary);
rv = xbps_callback_array_iter_in_dict(xhp->regpkgdb_dictionary,
"packages", list_pkgs_in_dict, &lpc);
} else if (strcasecmp(argv[0], "install") == 0) {
/* Installs a binary package and required deps. */
@@ -472,8 +464,8 @@ main(int argc, char **argv)
if (argc != 1)
usage();
rv = xbps_callback_array_iter_in_dict(dict, "packages",
list_manual_packages, NULL);
rv = xbps_callback_array_iter_in_dict(xhp->regpkgdb_dictionary,
"packages", list_manual_packages, NULL);
} else if (strcasecmp(argv[0], "show-revdeps") == 0) {
/*
@@ -494,23 +486,6 @@ main(int argc, char **argv)
rv = find_files_in_packages(argv[1]);
} else if (strcasecmp(argv[0], "set-prop") == 0) {
if (argc < 2 || argc > 3)
usage();
/*
* Sets a property in a package.
*/
rv = xbps_property_set(argv[1], argv[2]);
} else if (strcasecmp(argv[0], "unset-prop") == 0) {
/*
* Unsets a property in a package.
*/
if (argc < 2 || argc > 3)
usage();
rv = xbps_property_unset(argv[1], argv[2]);
} else {
usage();
}

View File

@@ -37,31 +37,14 @@
int
show_pkg_info_from_metadir(const char *pkgname)
{
prop_dictionary_t d, regpkgd, pkgpropsd;
prop_dictionary_t d;
d = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS);
if (d == NULL)
return EINVAL;
regpkgd = xbps_regpkgdb_dictionary_get();
pkgpropsd = xbps_find_pkg_in_dict_by_name(regpkgd,
"properties", pkgname);
if (pkgpropsd == NULL) {
show_pkg_info(d);
prop_object_release(d);
goto out;
}
if (prop_dictionary_get(pkgpropsd, "hold"))
prop_dictionary_set_bool(d, "hold", true);
if (prop_dictionary_get(pkgpropsd, "update-first"))
prop_dictionary_set_bool(d, "update-first", true);
if (prop_dictionary_get(pkgpropsd, "provides"))
prop_dictionary_set_bool(d, "virtual-prefer", true);
show_pkg_info(d);
prop_object_release(d);
out:
xbps_regpkgdb_dictionary_release();
return 0;
}

View File

@@ -187,7 +187,7 @@ show_pkg_files(prop_dictionary_t filesd)
prop_array_t array;
prop_object_iterator_t iter = NULL;
prop_object_t obj;
const char *file, *array_str;
const char *file, *array_str, *target;
int i = 0;
/* This will print links, conf_files and files respectively. */
@@ -209,7 +209,11 @@ show_pkg_files(prop_dictionary_t filesd)
while ((obj = prop_object_iterator_next(iter))) {
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
printf("%s\n", file);
printf("%s", file);
if (prop_dictionary_get_cstring_nocopy(obj,
"target", &target))
printf(" -> %s", target);
printf("\n");
}
prop_object_iterator_release(iter);
}

View File

@@ -1,13 +1,4 @@
'\" t
.\" Title: xbps-bin
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 02/26/2011
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "XBPS\-BIN" "8" "02/26/2011" "\ \&" "\ \&"
.TH "XBPS\-BIN" "8" "06/04/2011" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
@@ -37,6 +28,11 @@ Use of this option takes effect in the \fIautoupdate\fR, \fIinstall\fR and
matched.
.RE
.PP
\fB\-C\fR \fIconffile\fR
.RS 4
Full path to the \fIxbps-conf.plist\fR plist configuration file.
.RE
.PP
\fB\-c\fR \fIcachedir\fR
.RS 4
Sets the cache directory to store downloaded binary packages from remote repositories\&. By default it\(cqs set to
@@ -243,26 +239,6 @@ option is used, package files will be
\fBremoved even if its SHA256 hash don\(cqt match\fR\&.
.RE
.PP
\fBset\-prop \fR\fB\fIproperty\fR\fR\fB \fR\fB\fIpkgname\fR\fR
.RS 4
Sets a
\fIproperty\fR
for a package as specified in
\fIpkgname\fR\&. See the
\fIPROPERTIES\fR
section below for more information\&.
.RE
.PP
\fBunset\-prop \fR\fB\fIproperty\fR\fR\fB \fR\fB\fIpkgname\fR\fR
.RS 4
Unsets a
\fIproperty\fR
for a package as specified in
\fIpkgname\fR\&. See the
\fIPROPERTIES\fR
section below for more information\&.
.RE
.PP
\fBshow \fR\fB\fIpkgname\fR\fR
.RS 4
Shows information for installed package
@@ -318,35 +294,14 @@ The package has been unpacked in destination root directory, but it is not fully
.RS 4
The package has been removed but configuration files and its metadata directory are still available (and it is still registered in the package database)\&. You can purge safely packages that are in this state, modified configuration files will be preserved\&.
.RE
.SH "PROPERTIES"
.sp
Properties can be specified for packages to control behaviour of some aspects in XBPS\&. The following is the list of properties currently implemented:
.PP
\fBhold\fR
.RS 4
When this property is set for a package, it will be put on
\fIhold\fR
i\&.e the package won\(cqt be updated even if there is a newer version in registered repositories\&.
.RE
.PP
\fBupdate\-first\fR
.RS 4
When this property is set, the package will always be updated before all other packages, regardless of its package dependencies\&.
.RE
.PP
\fBvirtual\fR
.RS 4
When this property is set, the virtual packages that target package supports via the
\fBprovides\fR
object will have preference over other packages matching its
\fIpackage name\fR\&. A real example is any package that
\fIprovides\fR
the
\fBsyslog\-daemon\-0\fR
virtual package, if there are two packages supporting this you can choose which one will be installed\&.
.RE
.SH "FILES"
.PP
\fB/etc/xbps-conf.plist\fR
.RS 4
Default XBPS configuration file\&.
.RE
.PP
\fB/var/db/xbps\fR
.RS 4
xbps global metadata directory\&.
@@ -419,18 +374,6 @@ $ xbps\-bin \-yp remove proplib\-devel
$ xbps\-bin \-Rp remove bsdtar
.RE
.PP
\fBSets\fR the \fIvirtual\fR property in the \fBxbps\-devel\fR package:
.RS 4
$ xbps\-bin set\-prop virtual xbps\-devel
.RE
.PP
\fBUnsets\fR the \fIhold\fR property in the \fBcoreutils\fR package:
.RS 4
$ xbps\-bin unset\-prop hold coreutils
.RE
.SH "BUGS"
.sp
Probably, but I try to make this not happen\&. Use it under your own responsability and enjoy your life\&.

View File

@@ -33,8 +33,6 @@
/* From index.c */
int xbps_repo_genindex(const char *);
/* From repository.c */
int register_repository(const char *);
int unregister_repository(const char *);
int show_pkg_info_from_repolist(const char *);
int show_pkg_deps_from_repolist(const char *);
int repository_sync(void);

View File

@@ -60,7 +60,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, prop_dictionary_keysym_t ke
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr);
if ((strcmp(filestr, pattern) == 0) ||
(strstr(filestr, pattern)) ||
(xbps_pkgpattern_match(filestr, __UNCONST(pattern)) == 1))
(xbps_pkgpattern_match(filestr, pattern) == 1))
printf(" %s: %s (%s)\n", pkgver, filestr, typestr);
}
prop_object_iterator_release(iter);

View File

@@ -50,10 +50,16 @@ usage(void)
static int
repo_list_uri_cb(struct repository_pool_index *rpi, void *arg, bool *done)
{
const char *pkgidx;
uint64_t npkgs;
(void)arg;
(void)done;
printf("%s\n", rpi->rpi_uri);
prop_dictionary_get_cstring_nocopy(rpi->rpi_repod,
"pkgindex-version", &pkgidx);
prop_dictionary_get_uint64(rpi->rpi_repod, "total-pkgs", &npkgs);
printf("%s (index %s, %zu packages)\n", rpi->rpi_uri, pkgidx, npkgs);
return 0;
}
@@ -80,19 +86,22 @@ main(int argc, char **argv)
struct xbps_handle xh;
struct xbps_fetch_progress_data xfpd;
prop_dictionary_t pkgd;
const char *rootdir, *cachedir;
const char *rootdir = NULL, *cachedir = NULL, *conffile = NULL;
int c, rv = 0;
bool with_debug = false;
bool debug = false;
rootdir = cachedir = NULL;
while ((c = getopt(argc, argv, "Vc:dr:")) != -1) {
while ((c = getopt(argc, argv, "C:c:dr:V")) != -1) {
switch (c) {
case 'C':
conffile = optarg;
break;
case 'c':
cachedir = optarg;
break;
case 'd':
with_debug = true;
debug = true;
break;
case 'r':
/* To specify the root directory */
@@ -114,46 +123,29 @@ main(int argc, char **argv)
usage();
/*
* Initialize the function callbacks and debug in libxbps.
* Initialize XBPS subsystems.
*/
memset(&xh, 0, sizeof(xh));
xh.with_debug = with_debug;
xh.with_debug = debug;
xh.xbps_fetch_cb = fetch_file_progress_cb;
xh.xfpd = &xfpd;
xh.rootdir = rootdir;
xh.cachedir = cachedir;
xbps_init(&xh);
xh.conffile = conffile;
if ((rv = xbps_repository_pool_init()) != 0) {
if (rv != ENOENT) {
xbps_error_printf("xbps-repo: failed to initialize "
"repository pool: %s\n", strerror(rv));
exit(EXIT_FAILURE);
}
if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",
strerror(errno));
exit(EXIT_FAILURE);
}
if (strcasecmp(argv[0], "add") == 0) {
/* Adds a new repository to the pool. */
if (argc != 2)
usage();
rv = register_repository(argv[1]);
} else if (strcasecmp(argv[0], "list") == 0) {
if (strcasecmp(argv[0], "list") == 0) {
/* Lists all repositories registered in pool. */
if (argc != 1)
usage();
xbps_repository_pool_foreach(repo_list_uri_cb, NULL);
} else if ((strcasecmp(argv[0], "rm") == 0) ||
(strcasecmp(argv[0], "remove") == 0)) {
/* Remove a repository from the pool. */
if (argc != 2)
usage();
rv = unregister_repository(argv[1]);
} else if (strcasecmp(argv[0], "search") == 0) {
/*
* Search for a package by looking at pkgname/short_desc

View File

@@ -42,44 +42,6 @@ struct repoinfo {
uint64_t totalpkgs;
};
static const char *
sanitize_url(const char *path)
{
static char buf[PATH_MAX];
const char *res = NULL;
char *dirnp, *basenp, *dir, *base;
int r = 0;
memset(&buf, 0, sizeof(buf));
if ((dir = strdup(path)) == NULL)
return NULL;
if ((base = strdup(path)) == NULL) {
free(dir);
return NULL;
}
dirnp = dirname(dir);
if (strcmp(dirnp, ".") == 0)
goto out;
basenp = basename(base);
if (strcmp(basenp, base) == 0)
goto out;
r = snprintf(buf, sizeof(buf) - 1, "%s/%s", dirnp, basenp);
if (r < 0 || r >= (int)sizeof(buf) - 1)
goto out;
res = buf;
out:
free(dir);
free(base);
return res;
}
static struct repoinfo *
pkgindex_verify(const char *plist, const char *uri)
{
@@ -137,106 +99,6 @@ out:
return rpi;
}
int
unregister_repository(const char *uri)
{
const char *idxstr = NULL;
int rv = 0;
if ((idxstr = sanitize_url(uri)) == NULL)
return errno;
if ((rv = xbps_repository_unregister(idxstr)) == 0)
return 0;
if (rv == ENOENT) {
xbps_error_printf("Repository '%s' not "
"registered.\n", idxstr);
} else {
xbps_error_printf("xbps-repo: couldn't unregister "
"repository: %s\n", strerror(rv));
}
return rv;
}
int
register_repository(const char *uri)
{
const struct xbps_handle *xhp;
struct repoinfo *rpi = NULL;
const char *idxstr = NULL;
char *metadir, *plist;
int rv = 0;
xhp = xbps_handle_get();
if ((idxstr = sanitize_url(uri)) == NULL)
return errno;
if (xbps_check_is_repository_uri_remote(idxstr)) {
printf("Fetching remote package index at %s...\n", idxstr);
rv = xbps_repository_sync_pkg_index(idxstr);
if (rv == -1) {
xbps_error_printf("xbps-repo: couldn't fetch pkg-index "
"file: %s.\n", xbps_fetch_error_string());
return rv;
} else if (rv == 0) {
printf("Package index file is already "
"up to date.\n");
return 0;
}
plist = xbps_pkg_index_plist(idxstr);
} else {
/*
* Create metadir if necessary.
*/
metadir = xbps_xasprintf("%s/%s", xhp->rootdir,
XBPS_META_PATH);
if (metadir == NULL)
return errno;
if (xbps_mkpath(metadir, 0755) == -1) {
xbps_error_printf("xbps-repo: couldn't create metadata "
"directory: %s.\n", strerror(errno));
free(metadir);
return EXIT_FAILURE;
}
free(metadir);
plist = xbps_pkg_index_plist(idxstr);
}
if (plist == NULL)
return errno;
if ((rpi = pkgindex_verify(plist, idxstr)) == NULL)
goto out;
if ((rv = xbps_repository_register(idxstr)) != 0) {
if (rv == EEXIST) {
xbps_warn_printf("repository already registered.\n");
} else {
xbps_error_printf("xbps-repo: couldn't register "
"repository: %s.\n", strerror(errno));
}
goto out;
}
printf("Added package index at %s (v%s) with %ju packages.\n",
idxstr, rpi->pkgidxver, rpi->totalpkgs);
out:
if (rpi != NULL) {
if (rpi->pkgidxver != NULL)
free(rpi->pkgidxver);
free(rpi);
}
if (plist != NULL)
free(plist);
return rv;
}
int
show_pkg_info_from_repolist(const char *pkgname)
{
@@ -286,7 +148,7 @@ repo_sync_pkg_index_cb(struct repository_pool_index *rpi, void *arg, bool *done)
if (!xbps_check_is_repository_uri_remote(rpi->rpi_uri))
return 0;
printf("Syncing package index from: %s\n", rpi->rpi_uri);
printf("Synchronizing package index for `%s' ...\n", rpi->rpi_uri);
rv = xbps_repository_sync_pkg_index(rpi->rpi_uri);
if (rv == -1) {
xbps_error_printf("xbps-repo: failed to sync `%s': %s\n",

View File

@@ -1,4 +1,4 @@
.TH "XBPS\-REPO" "8" "05/27/2011" "\ \&" "\ \&"
.TH "XBPS\-REPO" "8" "06/04/2011" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
@@ -19,6 +19,11 @@ xbps-repo \- XBPS command for binary package repositories
The xbps\-repo(8) command is used to handle local or remote binary package repositories in the \fBXBPS binary package system\fR\&. You can use it to create a package index for a local repository, add or remove local and remote repositories, search for packages and show information about a binary package in repository pool\&.
.SH "OPTIONS"
.PP
\fB\-C\fR \fIconffile\fR
.RS 4
Full path to the \fIxbps-conf.plist\fR plist configuration file.
.RE
.PP
\fB\-c\fR \fIcachedir\fR
.RS 4
Sets the
@@ -49,21 +54,12 @@ of
.PP
\fB\-V\fR
.RS 4
Shows the current XBPS release version (library and code)\&.
Shows the current XBPS API and INDEX versions\&.
.RE
.SH "TARGETS"
.sp
Please note that all targets are \fBcase insensitive\fR\&.
.PP
\fBadd\fR \fIURI\fR
.RS 4
Adds a repository as specified in
\fIURI\fR
to the repository pool\&. Local (by specifying a
\fBdirectory\fR) and remote (by specifiying an
\fBHTTP/HTTPS/FTP URL\fR) repositories can be specified\&.
.RE
.PP
\fBfind\-files\fR \fIpattern\fR
.RS 4
Prints the name for any package registered in the repository pool, that owns
@@ -86,18 +82,7 @@ will be removed automatically\&.
.PP
\fBlist\fR
.RS 4
Lists all currently registered repositories in repository pool\&.
.RE
.PP
\fBremove\fR \fIURI\fR
.RS 4
Removes a repository from repository pool as specified by the
\fIURI\fR
argument\&. You have to use the same
\fIURI\fR
that was used in the
\fBadd\fR
target\&.
Lists all working repositories in repository pool\&.
.RE
.PP
\fBsearch\fR \fIpattern\fR
@@ -137,6 +122,11 @@ Syncs the package index file for all registered remote repositories\&. The new f
.RE
.SH "FILES"
.PP
\fB/etc/xbps-conf.plist\fR
.RS 4
Default XBPS configuration file\&.
.RE
.PP
\fB/var/db/xbps/repositories\&.plist\fR
.RS 4
Registered repository list\&.

View File

@@ -60,6 +60,8 @@ write_plist_file(prop_dictionary_t dict, const char *file)
static void __attribute__((noreturn))
usage(void)
{
xbps_end();
fprintf(stderr,
"usage: xbps-uhelper [options] [action] [args]\n"
"\n"
@@ -84,6 +86,7 @@ usage(void)
" version\t\t<pkgname>\n"
"\n"
" Options shared by all actions:\n"
" -C\t\tPath to xbps-conf.plist file.\n"
" -d\t\tDebugging messages to stderr.\n"
" -r\t\t\t<rootdir>\n"
" -V\t\tPrints the xbps release version\n"
@@ -110,13 +113,16 @@ main(int argc, char **argv)
struct xbps_fetch_progress_data xfpd;
prop_dictionary_t dict, pkgd;
prop_array_t array;
const char *version, *rootdir = NULL;
const char *version, *rootdir = NULL, *conffile = NULL;
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
bool fromsrc = false, debug = false, in_chroot = false;
int i, c, rv = 0;
while ((c = getopt(argc, argv, "Vdr:")) != -1) {
while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
switch (c) {
case 'C':
conffile = optarg;
break;
case 'r':
/* To specify the root directory */
rootdir = optarg;
@@ -147,14 +153,18 @@ main(int argc, char **argv)
xh.xbps_fetch_cb = fetch_file_progress_cb;
xh.xfpd = &xfpd;
xh.rootdir = rootdir;
xbps_init(&xh);
xh.conffile = conffile;
if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("xbps-uhelper: failed to "
"initialize libxbps.\n");
exit(EXIT_FAILURE);
}
plist = xbps_xasprintf("%s/%s/%s", rootdir,
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL) {
fprintf(stderr,
"%s=> ERROR: couldn't find regpkdb file (%s)%s\n",
MSG_ERROR, strerror(errno), MSG_RESET);
xbps_end();
exit(EXIT_FAILURE);
}