Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-02-26 08:43:02 +0000
committerAaron Griffin <aaron@archlinux.org>2007-02-26 08:43:02 +0000
commit4dd6c9222879198eaff8da464d9eb0ecf6313954 (patch)
tree4599c756911f52b7f61a8714928a6fd122683bca /src
parent8fbdd03cce3c04a8208df30f435bc3e91a84ade3 (diff)
* pacman hidden arguments: removed -Y and -D. -T is the only hidden arg now, to
be used in place of -Y. Also, -D was rather silly, as it does mostly what -S does. * Cleaned up pacman_deptest - removed the goofy faketarget stuff (NEEDS testing still) * libalpm function renames
Diffstat (limited to 'src')
-rw-r--r--src/pacman/deptest.c129
-rw-r--r--src/pacman/pacman.c11
-rw-r--r--src/pacman/query.c8
-rw-r--r--src/pacman/remove.c4
-rw-r--r--src/pacman/sync.c12
-rw-r--r--src/pacman/util.c9
6 files changed, 37 insertions, 136 deletions
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 04faeaa0..f8bf513d 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -36,131 +36,36 @@
extern config_t *config;
-/* TODO this function is fairly messy, with the obscure return codes and the odd
- * 'dummy' packages and all these messy FREELISTs of synctargs
- */
int pacman_deptest(alpm_list_t *targets)
{
- alpm_list_t *data, *i;
- char *str;
int retval = 0;
+ pmdb_t *local;
+ pmpkg_t *pkg;
+ alpm_list_t *i, *provides;
if(targets == NULL) {
return(0);
}
+
+ local = alpm_option_get_localdb();
- /* we create a transaction to hold a dummy package to be able to use
- * deps checkings from alpm_trans_prepare() */
- if(alpm_trans_init(PM_TRANS_TYPE_ADD, 0, NULL, NULL, NULL) == -1) {
- ERR(NL, "%s", alpm_strerror(pm_errno));
- if(pm_errno == PM_ERR_HANDLE_LOCK) {
- MSG(NL, _(" if you're sure a package manager is not already running,\n"
- " you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
- }
- return(1);
- }
-
- /* We use a hidden facility from alpm_trans_addtarget() to add a dummy
- * target to the transaction (see the library code for details).
- * It allows us to use alpm_trans_prepare() to check dependencies of the
- * given target.
- */
- str = (char *)malloc(strlen("name=dummy|version=1.0-1")+1);
- if(str == NULL) {
- ERR(NL, _("memory allocation failure\n"));
- retval = 1;
- goto cleanup;
- }
- strcpy(str, "name=dummy|version=1.0-1");
for(i = targets; i; i = alpm_list_next(i)) {
- const char *targ = alpm_list_getdata(i);
- str = (char *)realloc(str, strlen(str)+8+strlen(targ)+1);
- strcat(str, "|depend=");
- strcat(str, targ);
- }
- vprint(_("add target %s\n"), str);
- if(alpm_trans_addtarget(str) == -1) {
- FREE(str);
- ERR(NL, _("could not add target (%s)\n"), alpm_strerror(pm_errno));
- retval = 1;
- goto cleanup;
- }
- FREE(str);
+ const char *pkgname;
+
+ pkgname = alpm_list_getdata(i);
+ /* find this package in the local DB */
+ pkg = alpm_db_get_pkg(local, pkgname);
- if(alpm_trans_prepare(&data) == -1) {
- alpm_list_t *synctargs = NULL;
- retval = 126;
- /* return 126 = deps were missing, but successfully resolved
- * return 127 = deps were missing, and failed to resolve; OR
- * = deps were missing, but no resolution was attempted; OR
- * = unresolvable conflicts were found
- */
- switch(pm_errno) {
- case PM_ERR_UNSATISFIED_DEPS:
- for(i = data; i; i = alpm_list_next(i)) {
- pmdepmissing_t *miss = alpm_list_getdata(i);
- if(!config->op_d_resolve) {
- MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
- switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_ANY:
- break;
- case PM_DEP_MOD_EQ:
- MSG(CL, "=%s", alpm_dep_get_version(miss));
- break;
- case PM_DEP_MOD_GE:
- MSG(CL, ">=%s", alpm_dep_get_version(miss));
- break;
- case PM_DEP_MOD_LE:
- MSG(CL, "<=%s", alpm_dep_get_version(miss));
- break;
- }
- MSG(CL, "\n");
- }
- synctargs = alpm_list_add(synctargs, strdup(alpm_dep_get_name(miss)));
- }
- alpm_list_free(data);
- break;
- case PM_ERR_CONFLICTING_DEPS:
- /* we can't auto-resolve conflicts */
- for(i = data; i; i = alpm_list_next(i)) {
- pmdepmissing_t *miss = alpm_list_getdata(i);
- MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss));
- }
- retval = 127;
- alpm_list_free(data);
- break;
- default:
- retval = 127;
- break;
- }
-
- /* attempt to resolve missing dependencies */
- /* TODO: handle version comparators (eg, glibc>=2.2.5) */
- if(retval == 126 && synctargs != NULL) {
- if(alpm_trans_release() == -1) {
- ERR(NL, _("could not release transaction (%s)"), alpm_strerror(pm_errno));
- FREELIST(synctargs);
- return(1);
- }
- if(!config->op_d_resolve || pacman_sync(synctargs) != 0) {
- /* error (or -D not used) */
- retval = 127;
+ if(!pkg) {
+ /* not found, can we find anything that provides this in the local DB? */
+ provides = alpm_db_whatprovides(local, pkgname);
+ if(!provides) {
+ /* nope, must be missing */
+ MSG(NL, _("requires: %s"), pkgname);
+ retval = 1;
}
- FREELIST(synctargs);
- return(retval);
}
-
- FREELIST(synctargs);
}
-
-cleanup:
- if(!config->op_d_resolve) {
- if(alpm_trans_release() == -1) {
- ERR(NL, _("could not release transaction (%s)"), alpm_strerror(pm_errno));
- retval = 1;
- }
- }
-
return(retval);
}
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 5212623e..d608a1c6 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -217,7 +217,6 @@ static int parseargs(int argc, char *argv[])
static struct option opts[] =
{
{"add", no_argument, 0, 'A'},
- {"resolve", no_argument, 0, 'D'}, /* used by 'makepkg -s' */
{"freshen", no_argument, 0, 'F'},
{"query", no_argument, 0, 'Q'},
{"remove", no_argument, 0, 'R'},
@@ -264,7 +263,7 @@ static int parseargs(int argc, char *argv[])
struct stat st;
unsigned short logmask;
- while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
+ while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
if(opt < 0) {
break;
}
@@ -316,11 +315,6 @@ static int parseargs(int argc, char *argv[])
alpm_option_set_cachedir(optarg);
break;
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
- case 'D':
- config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
- config->op_d_resolve = 1;
- config->flags |= PM_TRANS_FLAG_ALLDEPS;
- break;
case 'F':
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
config->flags |= PM_TRANS_FLAG_FRESHEN;
@@ -331,9 +325,6 @@ static int parseargs(int argc, char *argv[])
case 'T': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST); break;
case 'U': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE); break;
case 'V': config->version = 1; break;
- case 'Y':
- config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
- break;
case 'b':
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
ERR(NL, _("'%s' is not a valid db path\n"), optarg);
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 160b56e8..2ce36ac4 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -153,7 +153,7 @@ int pacman_query(alpm_list_t *targets)
const char *grpname;
grpname = alpm_grp_get_name(grp);
- pkgnames = alpm_grp_get_packages(grp);
+ pkgnames = alpm_grp_get_pkgs(grp);
for(p = pkgnames; p; p = alpm_list_next(p)) {
MSG(NL, "%s %s\n", grpname, (char *)alpm_list_getdata(p));
@@ -162,7 +162,7 @@ int pacman_query(alpm_list_t *targets)
} else {
pmgrp_t *grp = alpm_db_readgrp(db_local, package);
if(grp) {
- alpm_list_t *p, *pkgnames = alpm_grp_get_packages(grp);
+ alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp);
for(p = pkgnames; p; p = alpm_list_next(p)) {
MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(p));
}
@@ -217,7 +217,7 @@ int pacman_query(alpm_list_t *targets)
pkgver = alpm_pkg_get_version(tmpp);
if(config->op_q_list || config->op_q_orphans || config->op_q_foreign) {
- info = alpm_db_readpkg(db_local, (char *)pkgname);
+ info = alpm_db_get_pkg(db_local, (char *)pkgname);
if(info == NULL) {
/* something weird happened */
ERR(NL, _("package \"%s\" not found\n"), pkgname);
@@ -250,7 +250,7 @@ int pacman_query(alpm_list_t *targets)
}
}
} else {
- info = alpm_db_readpkg(db_local, package);
+ info = alpm_db_get_pkg(db_local, package);
if(info == NULL) {
ERR(NL, _("package \"%s\" not found\n"), package);
continue;
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index dba1d4e3..0b48410c 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -53,7 +53,7 @@ int pacman_remove(alpm_list_t *targets)
pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i));
if(grp) {
int all;
- alpm_list_t *pkgnames = alpm_grp_get_packages(grp);
+ alpm_list_t *pkgnames = alpm_grp_get_pkgs(grp);
MSG(NL, _(":: group %s:\n"), alpm_grp_get_name(grp));
list_display(" ", pkgnames);
@@ -117,7 +117,7 @@ int pacman_remove(alpm_list_t *targets)
if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & PM_TRANS_FLAG_CASCADE) {
/* list transaction targets */
alpm_list_t *lst = NULL;
- for(i = alpm_trans_get_packages(); i; i = alpm_list_next(i)) {
+ for(i = alpm_trans_get_pkgs(); i; i = alpm_list_next(i)) {
pmpkg_t *pkg = alpm_list_getdata(i);
lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 585f3765..8db1d9ac 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -292,7 +292,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
if(grp) {
/* TODO this should be a lot cleaner, why two outputs? */
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
- list_display(" ", alpm_grp_get_packages(grp));
+ list_display(" ", alpm_grp_get_pkgs(grp));
}
}
}
@@ -305,7 +305,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
if(grp && level > 1) {
- list_display(" ", alpm_grp_get_packages(grp));
+ list_display(" ", alpm_grp_get_pkgs(grp));
}
}
}
@@ -510,10 +510,10 @@ int pacman_sync(alpm_list_t *targets)
* this can prevent some of the "syntax error" problems users can have
* when sysupgrade'ing with an older version of pacman.
*/
- data = alpm_trans_get_packages();
+ data = alpm_trans_get_pkgs();
for(i = data; i; i = alpm_list_next(i)) {
pmsyncpkg_t *sync = alpm_list_getdata(i);
- pmpkg_t *spkg = alpm_sync_get_package(sync);
+ pmpkg_t *spkg = alpm_sync_get_pkg(sync);
if(strcmp("pacman", alpm_pkg_get_name(spkg)) == 0 && alpm_list_count(data) > 1) {
MSG(NL, _("\n:: pacman has detected a newer version of the \"pacman\" package.\n"));
MSG(NL, _(":: It is recommended that you allow pacman to upgrade itself\n"));
@@ -567,7 +567,7 @@ int pacman_sync(alpm_list_t *targets)
found++;
MSG(NL, _(":: group %s:\n"), targ);
/* remove dupe entries in case a package exists in multiple repos */
- alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_packages(grp));
+ alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_pkgs(grp));
list_display(" ", pkgs);
if(yesno(_(":: Install whole content? [Y/n] "))) {
for(k = pkgs; k; k = alpm_list_next(k)) {
@@ -659,7 +659,7 @@ int pacman_sync(alpm_list_t *targets)
goto cleanup;
}
- packages = alpm_trans_get_packages();
+ packages = alpm_trans_get_pkgs();
if(packages == NULL) {
/* nothing to do: just exit without complaining */
MSG(NL, _(" local database is up to date\n"));
diff --git a/src/pacman/util.c b/src/pacman/util.c
index b39f51f8..96eb621e 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -274,7 +274,7 @@ void display_targets(alpm_list_t *syncpkgs)
for(i = syncpkgs; i; i = alpm_list_next(i)) {
pmsyncpkg_t *sync = alpm_list_getdata(i);
- pmpkg_t *pkg = alpm_sync_get_package(sync);
+ pmpkg_t *pkg = alpm_sync_get_pkg(sync);
/* If this sync record is a replacement, the data member contains
* a list of packages to be removed due to the package that is being
@@ -381,9 +381,14 @@ void fill_progress(const int percent, const int proglen)
const unsigned short chomp = alpm_option_get_chomp();
const unsigned int hashlen = proglen - 8;
const unsigned int hash = percent * hashlen / 100;
- unsigned int lasthash = 0, mouth = 0;
+ static unsigned int lasthash = 0, mouth = 0;
unsigned int i;
+ if(percent == 0) {
+ lasthash = 0;
+ mouth = 0;
+ }
+
printf(" [");
for(i = hashlen; i > 1; --i) {
/* if special progress bar enabled */