Imported from pacman-2.6.2.tar.gz

This commit is contained in:
Judd Vinet 2003-09-29 00:58:58 +00:00
parent 9d9ffa6cec
commit 16f42002ec
14 changed files with 171 additions and 144 deletions

View file

@ -1,5 +1,15 @@
VERSION DESCRIPTION VERSION DESCRIPTION
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
2.6.2 - Fixed a memory cleanup bug
- Aurelien's patch:
- bug #159 implemented (for -S and -R)
- fixed a bug with pacman -Sg (pacman was browsing only one
db to get groups)
- fixed a bug with list_merge()
- fixed some MLK (in dumppkg() and with "-Qi --orphans")
- now "pacman -Sg" only displays groups (without content)
whereas "pacman -Sg target1 target2" displays groups
target1 and target2 with content
2.6.1 - Added http download support (Aurelien Foret) 2.6.1 - Added http download support (Aurelien Foret)
- Improved makepkg's --builddeps behaviour when called via - Improved makepkg's --builddeps behaviour when called via
makeworld makeworld

View file

@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
PACVER = 2.6.1 PACVER = 2.6.2
TOPDIR = @srcdir@ TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src/ SRCDIR = $(TOPDIR)/src/

View file

@ -1,4 +1,4 @@
.TH pacman 8 "September 01, 2003" "pacman #VERSION#" "" .TH pacman 8 "September 28, 2003" "pacman #VERSION#" ""
.SH NAME .SH NAME
pacman \- package manager utility pacman \- package manager utility
.SH SYNOPSIS .SH SYNOPSIS
@ -98,7 +98,7 @@ diskspace, you can remove these packages by using the --clean option.
.TP .TP
.B "\-g, \-\-groups" .B "\-g, \-\-groups"
Display all the members for each package group specified. If no group Display all the members for each package group specified. If no group
names are provided, all groups and members will be listed. names are provided, all groups will be listed.
.TP .TP
.B "\-s, \-\-search <string>" .B "\-s, \-\-search <string>"
This will search each package in the package list for names or descriptions This will search each package in the package list for names or descriptions

View file

@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.6.1' myver='2.6.2'
usage() { usage() {
echo "gensync $myver" echo "gensync $myver"
@ -36,7 +36,7 @@ usage() {
echo " generated database must reside in the same directory as your" echo " generated database must reside in the same directory as your"
echo " custom packages (also configured in /etc/pacman.conf)" echo " custom packages (also configured in /etc/pacman.conf)"
echo echo
echo "example: gensync /usr/abs/local /home/mypkgs/custom.db.tar.gz" echo "example: gensync /var/abs/local /home/mypkgs/custom.db.tar.gz"
echo echo
echo echo
exit 0 exit 0

View file

@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.6.1' myver='2.6.2'
startdir=`pwd` startdir=`pwd`
# source Arch's abs.conf if it's present # source Arch's abs.conf if it's present

View file

@ -21,7 +21,7 @@
# #
toplevel=`pwd` toplevel=`pwd`
version="2.6.1" version="2.6.2"
usage() { usage() {
echo "makeworld version $version" echo "makeworld version $version"
@ -38,7 +38,7 @@ usage() {
echo " where <category> is one or more directory names under the ABS root" echo " where <category> is one or more directory names under the ABS root"
echo " eg: makeworld -c /packages base lib editors" echo " eg: makeworld -c /packages base lib editors"
echo echo
echo " this should be run from the toplevel directory of ABS (usually /usr/abs)" echo " this should be run from the toplevel directory of ABS (usually /var/abs)"
} }
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then

View file

@ -73,10 +73,7 @@ PMList* db_loadpkgs(pacdb_t *db, PMList *pkgcache)
/* if pm_packages already contains data, free it first */ /* if pm_packages already contains data, free it first */
for(lp = pkgcache; lp; lp = lp->next) { for(lp = pkgcache; lp; lp = lp->next) {
if(lp->data) { FREEPKG(lp->data);
freepkg(lp->data);
lp->data = NULL;
}
} }
list_free(pkgcache); list_free(pkgcache);
@ -522,8 +519,7 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
} }
} }
} }
freepkg(dbpkg); FREEPKG(dbpkg);
dbpkg = NULL;
} }
return(conflicts); return(conflicts);
@ -540,10 +536,10 @@ PMList *whatprovides(pacdb_t *db, char* package)
if(is_in(package, info->provides)) { if(is_in(package, info->provides)) {
i = list_add(i, strdup(info->name)); i = list_add(i, strdup(info->name));
} }
freepkg(info); FREEPKG(info);
} }
pkgs = list_sort(i); pkgs = list_sort(i);
list_free(i); FREELIST(i);
return(pkgs); return(pkgs);
} }
@ -565,10 +561,10 @@ PMList *find_groups(pacdb_t *db)
i = list_add(i, strdup((char*)lp->data)); i = list_add(i, strdup((char*)lp->data));
} }
} }
freepkg(info); FREEPKG(info);
} }
groups = list_sort(i); groups = list_sort(i);
list_free(i); FREELIST(i);
return(groups); return(groups);
} }
@ -590,10 +586,10 @@ PMList *pkg_ingroup(pacdb_t *db, char *group)
i = list_add(i, strdup(info->name)); i = list_add(i, strdup(info->name));
} }
} }
freepkg(info); FREEPKG(info);
} }
pkg = list_sort(i); pkg = list_sort(i);
list_free(i); FREELIST(i);
return(pkg); return(pkg);
} }

View file

@ -115,21 +115,28 @@ int is_in(char *needle, PMList *haystack)
} }
/* List one is extended and returned /* List one is extended and returned
* List two is freed (but not its data)
*/ */
PMList* list_merge(PMList *one, PMList *two) PMList* list_merge(PMList *one, PMList *two)
{ {
PMList *lp; PMList *lp, *ptr;
if(two == NULL) {
return one;
}
ptr = one;
if(ptr == NULL) {
ptr = list_new();
}
for(lp = two; lp; lp = lp->next) { for(lp = two; lp; lp = lp->next) {
if(lp->data) { if(lp->data) {
list_add(one, lp->data); ptr = list_add(ptr, lp->data);
lp->data = NULL; lp->data = NULL;
} }
} }
list_free(two);
return(one); return(ptr);
} }
PMList* list_last(PMList *list) PMList* list_last(PMList *list)
@ -193,7 +200,7 @@ void list_display(const char *title, PMList *list)
} }
len = strlen(title); len = strlen(title);
printf("%s", title); printf("%s ", title);
if(list) { if(list) {
for(lp = list, cols = len; lp; lp = lp->next) { for(lp = list, cols = len; lp; lp = lp->next) {
@ -202,7 +209,7 @@ void list_display(const char *title, PMList *list)
int i; int i;
cols = len; cols = len;
printf("\n"); printf("\n");
for (i = 0; i < len; i++) { for (i = 0; i < len+1; i++) {
printf(" "); printf(" ");
} }
} }

View file

@ -21,6 +21,8 @@
#ifndef _PAC_LIST_H #ifndef _PAC_LIST_H
#define _PAC_LIST_H #define _PAC_LIST_H
#define FREELIST(p) { list_free(p); p = NULL; }
/* your average linked list */ /* your average linked list */
typedef struct __pmlist_t { typedef struct __pmlist_t {
void* data; void* data;

View file

@ -251,14 +251,14 @@ void freepkg(pkginfo_t *pkg)
return; return;
} }
list_free(pkg->files); FREELIST(pkg->files);
list_free(pkg->backup); FREELIST(pkg->backup);
list_free(pkg->depends); FREELIST(pkg->depends);
list_free(pkg->conflicts); FREELIST(pkg->conflicts);
list_free(pkg->requiredby); FREELIST(pkg->requiredby);
list_free(pkg->groups); FREELIST(pkg->groups);
list_free(pkg->provides); FREELIST(pkg->provides);
list_free(pkg->replaces); FREELIST(pkg->replaces);
FREE(pkg); FREE(pkg);
return; return;
} }
@ -310,8 +310,8 @@ void dump_pkg(pkginfo_t *info)
printf("Name : %s\n", info->name); printf("Name : %s\n", info->name);
printf("Version : %s\n", info->version); printf("Version : %s\n", info->version);
pm = list_sort(info->groups); pm = list_sort(info->groups);
list_display("Groups : ", pm); list_display("Groups :", pm);
FREE(pm); FREELIST(pm);
printf("Packager : %s\n", info->packager); printf("Packager : %s\n", info->packager);
printf("URL : %s\n", (info->url ? info->url : "None")); printf("URL : %s\n", (info->url ? info->url : "None"));
printf("Size : %ld\n", info->size); printf("Size : %ld\n", info->size);
@ -319,17 +319,17 @@ void dump_pkg(pkginfo_t *info)
printf("Install Date : %s %s\n", info->installdate, strlen(info->installdate) ? "UTC" : ""); printf("Install Date : %s %s\n", info->installdate, strlen(info->installdate) ? "UTC" : "");
printf("Install Script : %s\n", (info->scriptlet ? "Yes" : "No")); printf("Install Script : %s\n", (info->scriptlet ? "Yes" : "No"));
pm = list_sort(info->provides); pm = list_sort(info->provides);
list_display("Provides : ", pm); list_display("Provides :", pm);
FREE(pm); FREELIST(pm);
pm = list_sort(info->depends); pm = list_sort(info->depends);
list_display("Depends On : ", pm); list_display("Depends On :", pm);
FREE(pm); FREELIST(pm);
pm = list_sort(info->requiredby); pm = list_sort(info->requiredby);
list_display("Required By : ", pm); list_display("Required By :", pm);
FREE(pm); FREELIST(pm);
pm = list_sort(info->conflicts); pm = list_sort(info->conflicts);
list_display("Conflicts With : ", pm); list_display("Conflicts With :", pm);
FREE(pm); FREELIST(pm);
printf("Description : %s\n", info->desc); printf("Description : %s\n", info->desc);
} }

View file

@ -23,6 +23,8 @@
#include "list.h" #include "list.h"
#define FREEPKG(p) { freepkg(p); p = NULL; }
/* mods for depend_t.mod */ /* mods for depend_t.mod */
#define DEP_ANY 0 #define DEP_ANY 0
#define DEP_EQ 1 #define DEP_EQ 1

View file

@ -175,7 +175,7 @@ int main(int argc, char *argv[])
/* db location */ /* db location */
vprint("Top-level DB Path: %s%s\n", pmo_root, pmo_dbpath); vprint("Top-level DB Path: %s%s\n", pmo_root, pmo_dbpath);
if(pmo_verbose) { if(pmo_verbose) {
list_display("Targets: ", pm_targets); list_display("Targets:", pm_targets);
} }
db_local = db_open(pmo_root, pmo_dbpath, "local"); db_local = db_open(pmo_root, pmo_dbpath, "local");
@ -213,6 +213,7 @@ int main(int argc, char *argv[])
ret = 1; ret = 1;
} }
db_close(db_local); db_close(db_local);
FREELIST(pm_packages);
FREE(pmo_root); FREE(pmo_root);
FREE(pmo_dbpath); FREE(pmo_dbpath);
cleanup(ret); cleanup(ret);
@ -244,9 +245,8 @@ int pacman_deptest(pacdb_t *db, PMList *targets)
} }
list = list_add(list, dummy); list = list_add(list, dummy);
deps = checkdeps(db, PM_ADD, list); deps = checkdeps(db, PM_ADD, list);
freepkg(dummy); FREELIST(list);
list->data = NULL; FREEPKG(dummy);
list_free(list);
if(deps) { if(deps) {
/* return 126 = deps were missing, but successfully resolved /* return 126 = deps were missing, but successfully resolved
@ -286,8 +286,7 @@ int pacman_deptest(pacdb_t *db, PMList *targets)
ret = 127; ret = 127;
} }
} }
list_free(synctargs); FREELIST(synctargs);
synctargs = NULL;
return(ret); return(ret);
} }
return(0); return(0);
@ -417,18 +416,18 @@ int pacman_sync(pacdb_t *db, PMList *targets)
i = list_add(i, strdup((char *)pm->data)); i = list_add(i, strdup((char *)pm->data));
} }
} }
list_free(k); FREELIST(k);
} }
allgroups = list_sort(i); allgroups = list_sort(i);
list_free(i); FREELIST(i);
if(targets) { if(targets) {
groups = NULL; groups = NULL;
for(j = targets; j; j = j->next) { for(j = targets; j; j = j->next) {
if(is_in((char *)j->data, allgroups)) { if(is_in((char *)j->data, allgroups)) {
groups = list_add(groups, (char *)j->data); groups = list_add(groups, strdup((char *)j->data));
} }
} }
list_free(allgroups); FREELIST(allgroups);
} else { } else {
groups = allgroups; groups = allgroups;
} }
@ -436,24 +435,22 @@ int pacman_sync(pacdb_t *db, PMList *targets)
for(pm = groups; pm; pm = pm->next) { for(pm = groups; pm; pm = pm->next) {
PMList *pkg; PMList *pkg;
printf("%s\n", (char *)pm->data); printf("%s\n", (char *)pm->data);
if(targets == NULL) {
continue;
}
i = NULL; i = NULL;
for(j = databases; j; j = j->next) { for(j = databases; j; j = j->next) {
PMList *lp;
dbsync_t *dbs = (dbsync_t*)j->data; dbsync_t *dbs = (dbsync_t*)j->data;
k = pkg_ingroup(dbs->db, (char *)pm->data); PMList *l = pkg_ingroup(dbs->db, (char *)pm->data);
for(lp = k; lp; lp = lp->next) { i = list_merge(i, l);
if(!is_in((char *)lp->data, i)) { FREELIST(l);
i = list_add(i, strdup((char *)lp->data));
}
}
list_free(k);
} }
pkg = list_sort(i); pkg = list_sort(i);
list_free(i); FREELIST(i);
list_display(" ", pkg); list_display(" ", pkg);
list_free(pkg); FREELIST(pkg);
} }
list_free(groups); FREELIST(groups);
} else if(pmo_s_upgrade) { } else if(pmo_s_upgrade) {
int newer = 0; int newer = 0;
int ignore = 0; int ignore = 0;
@ -573,24 +570,17 @@ int pacman_sync(pacdb_t *db, PMList *targets)
/* process targets */ /* process targets */
for(i = targets; i && allgood; i = i->next) { for(i = targets; i && allgood; i = i->next) {
if(i->data) { if(i->data) {
int cmp, found = 0, group = 0; int cmp, found = 0;
pkginfo_t *local; pkginfo_t *local;
syncpkg_t *sync = NULL; syncpkg_t *sync = NULL;
MALLOC(sync, sizeof(syncpkg_t)); MALLOC(sync, sizeof(syncpkg_t));
sync->replaces = NULL; sync->replaces = NULL;
local = db_scan(db, (char*)i->data, INFRQ_DESC);
for(j = databases; !found && j; j = j->next) { for(j = databases; !found && j; j = j->next) {
dbsync_t *dbs = (dbsync_t*)j->data; dbsync_t *dbs = (dbsync_t*)j->data;
for(k = dbs->pkgcache; !found && k; k = k->next) { for(k = dbs->pkgcache; !found && k; k = k->next) {
pkginfo_t *pkg = (pkginfo_t*)k->data; pkginfo_t *pkg = (pkginfo_t*)k->data;
if(is_in((char*)i->data, pkg->groups)) { if(!strcmp((char*)i->data, pkg->name)) {
group = 1;
if(!yesno(":: install %s from group %s? [Y/n] ", pkg->name, (char*)i->data)) {
continue;
}
targets = list_add(targets, strdup(pkg->name));
} else if(!strcmp((char*)i->data, pkg->name)) {
found = 1; found = 1;
sync->dbs = dbs; sync->dbs = dbs;
/* re-fetch the package record with dependency info */ /* re-fetch the package record with dependency info */
@ -601,37 +591,60 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
} }
} }
if(!found || group) { if(!found) {
if(!group) { /* target not found: check if it's a group */
k = NULL;
for(j = databases; j; j = j->next) {
dbsync_t *dbs = (dbsync_t*)j->data;
PMList *l = pkg_ingroup(dbs->db, (char *)i->data);
k = list_merge(k, l);
FREELIST(l);
}
if(k != NULL) {
printf(":: group %s:\n", (char*)i->data);
list_display(" ", k);
if(yesno(" Install whole content? [Y/n] ")) {
targets = list_merge(targets, k);
FREELIST(k);
} else {
PMList *l;
for(l = k; l; l = l->next) {
if(yesno(":: install %s from group %s? [Y/n] ", (char*)l->data, (char*)i->data)) {
targets = list_add(targets, strdup((char*)l->data));
}
}
}
FREELIST(k);
} else {
fprintf(stderr, "%s: not found in sync db\n", (char*)i->data); fprintf(stderr, "%s: not found in sync db\n", (char*)i->data);
allgood = 0; allgood = 0;
} }
freepkg(local);
FREE(sync); FREE(sync);
continue; continue;
} }
local = db_scan(db, (char*)i->data, INFRQ_DESC);
if(local && !pmo_s_downloadonly) { if(local && !pmo_s_downloadonly) {
/* this is an upgrade, compare versions and determine if it is necessary */ /* this is an upgrade, compare versions and determine if it is necessary */
cmp = rpmvercmp(local->version, sync->pkg->version); cmp = rpmvercmp(local->version, sync->pkg->version);
if(cmp > 0) { if(cmp > 0) {
/* local version is newer - get confirmation first */ /* local version is newer - get confirmation first */
if(!yesno(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", local->name, local->version)) { if(!yesno(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", local->name, local->version)) {
freepkg(local); FREEPKG(local);
freepkg(sync->pkg); FREEPKG(sync->pkg);
FREE(sync); FREE(sync);
continue; continue;
} }
} else if(cmp == 0) { } else if(cmp == 0) {
/* versions are identical */ /* versions are identical */
if(!yesno(":: %s-%s: is up to date. Upgrade anyway? [Y/n] ", local->name, local->version)) { if(!yesno(":: %s-%s: is up to date. Upgrade anyway? [Y/n] ", local->name, local->version)) {
freepkg(local); FREEPKG(local);
freepkg(sync->pkg); FREEPKG(sync->pkg);
FREE(sync); FREE(sync);
continue; continue;
} }
} }
} }
freepkg(local); FREEPKG(local);
found = (find_pkginsync(sync->pkg->name, final) != NULL); found = (find_pkginsync(sync->pkg->name, final) != NULL);
if(!found && !pmo_nodeps) { if(!found && !pmo_nodeps) {
@ -739,8 +752,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
for(i = list; i; i = i->next) { for(i = list; i; i = i->next) {
i->data = NULL; i->data = NULL;
} }
list_free(list); FREELIST(list);
list = NULL;
} }
/* any packages in rmtargs need to be removed from final. */ /* any packages in rmtargs need to be removed from final. */
@ -761,7 +773,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
i->data = NULL; i->data = NULL;
} }
list_free(final); FREELIST(final);
final = k; final = k;
/* list targets */ /* list targets */
@ -781,8 +793,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
printf("\nRemove: "); printf("\nRemove: ");
indentprint(buildstring(list), 9); indentprint(buildstring(list), 9);
printf("\n"); printf("\n");
list_free(list); FREELIST(list);
list = NULL;
} }
for(i = final; i; i = i->next) { for(i = final; i; i = i->next) {
syncpkg_t *s = (syncpkg_t*)i->data; syncpkg_t *s = (syncpkg_t*)i->data;
@ -796,8 +807,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
printf("\nTargets: "); printf("\nTargets: ");
indentprint(buildstring(list), 9); indentprint(buildstring(list), 9);
printf("\n"); printf("\n");
list_free(list); FREELIST(list);
list = NULL;
} }
/* get confirmation */ /* get confirmation */
@ -886,8 +896,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
allgood = 0; allgood = 0;
} }
count += list_count(files); count += list_count(files);
list_free(files); FREELIST(files);
files = NULL;
} }
if(count == list_count(final)) { if(count == list_count(final)) {
done = 1; done = 1;
@ -896,18 +905,14 @@ int pacman_sync(pacdb_t *db, PMList *targets)
printf("\n"); printf("\n");
/* double-check */ /* double-check */
if(files) { FREELIST(files);
list_free(files);
files = NULL;
}
if(!pmo_s_downloadonly) { if(!pmo_s_downloadonly) {
/* remove any conflicting packages (WITH dep checks) */ /* remove any conflicting packages (WITH dep checks) */
if(rmtargs) { if(rmtargs) {
int retcode; int retcode;
retcode = pacman_remove(db, rmtargs); retcode = pacman_remove(db, rmtargs);
list_free(rmtargs); FREELIST(rmtargs);
rmtargs = NULL;
if(retcode == 1) { if(retcode == 1) {
fprintf(stderr, "\nupgrade aborted.\n"); fprintf(stderr, "\nupgrade aborted.\n");
allgood = 0; allgood = 0;
@ -915,8 +920,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
/* reload package cache */ /* reload package cache */
pm_packages = db_loadpkgs(db, pm_packages); pm_packages = db_loadpkgs(db, pm_packages);
} }
list_free(rmtargs); FREELIST(rmtargs);
rmtargs = NULL;
for(i = final; allgood && i; i = i->next) { for(i = final; allgood && i; i = i->next) {
char *str; char *str;
syncpkg_t *sync = (syncpkg_t*)i->data; syncpkg_t *sync = (syncpkg_t*)i->data;
@ -927,7 +931,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
for(j = sync->replaces; j; j = j->next) { for(j = sync->replaces; j; j = j->next) {
pkginfo_t *pkg = (pkginfo_t*)j->data; pkginfo_t *pkg = (pkginfo_t*)j->data;
rmtargs = list_add(rmtargs, pkg->name); rmtargs = list_add(rmtargs, strdup(pkg->name));
} }
} }
/* remove to-be-replaced packages */ /* remove to-be-replaced packages */
@ -973,7 +977,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
} }
db_write(db, new); db_write(db, new);
freepkg(new); FREEPKG(new);
} }
} }
} }
@ -991,12 +995,11 @@ int pacman_sync(pacdb_t *db, PMList *targets)
for(i = final; i; i = i->next) { for(i = final; i; i = i->next) {
syncpkg_t *sync = (syncpkg_t*)i->data; syncpkg_t *sync = (syncpkg_t*)i->data;
if(sync) { if(sync) {
freepkg(sync->pkg); FREEPKG(sync->pkg);
for(j = sync->replaces; j; j = j->next) { for(j = sync->replaces; j; j = j->next) {
freepkg(j->data); FREEPKG(j->data);
j->data = NULL;
} }
list_free(sync->replaces); FREELIST(sync->replaces);
} }
FREE(sync); FREE(sync);
i->data = NULL; i->data = NULL;
@ -1016,14 +1019,14 @@ int pacman_sync(pacdb_t *db, PMList *targets)
j->data = NULL; j->data = NULL;
} }
} }
list_free(dbs->pkgcache); FREELIST(dbs->pkgcache);
FREE(dbs); FREE(dbs);
i->data = NULL; i->data = NULL;
} }
list_free(databases); FREELIST(databases);
list_free(final); FREELIST(final);
list_free(trail); FREELIST(trail);
list_free(rmtargs); FREELIST(rmtargs);
return(!allgood); return(!allgood);
} }
@ -1063,11 +1066,10 @@ int pacman_add(pacdb_t *db, PMList *targets)
/* only upgrade/install this package if it is already installed and at a lesser version */ /* only upgrade/install this package if it is already installed and at a lesser version */
pkginfo_t *dummy = db_scan(db, info->name, INFRQ_DESC); pkginfo_t *dummy = db_scan(db, info->name, INFRQ_DESC);
if(dummy == NULL || rpmvercmp(dummy->version, info->version) >= 0) { if(dummy == NULL || rpmvercmp(dummy->version, info->version) >= 0) {
freepkg(info); FREEPKG(info);
info = NULL;
continue; continue;
} }
freepkg(dummy); FREEPKG(dummy);
} }
alltargs = list_add(alltargs, info); alltargs = list_add(alltargs, info);
filenames = list_add(filenames, strdup(targ->data)); filenames = list_add(filenames, strdup(targ->data));
@ -1151,7 +1153,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
} }
lp->data = NULL; lp->data = NULL;
} }
list_free(alltargs); FREELIST(alltargs);
alltargs = k; alltargs = k;
/* make sure pacman_remove does it's own dependency check */ /* make sure pacman_remove does it's own dependency check */
pmo_upgrade = 0; pmo_upgrade = 0;
@ -1167,7 +1169,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
} }
} }
if(errorout) { if(errorout) {
list_free(lp); FREELIST(lp);
return(1); return(1);
} }
list_free(lp); list_free(lp);
@ -1180,7 +1182,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
for(j = alltargs; j; j = j->next) { for(j = alltargs; j; j = j->next) {
j->data = NULL; j->data = NULL;
} }
list_free(alltargs); FREELIST(alltargs);
alltargs = lp; alltargs = lp;
} }
@ -1194,11 +1196,11 @@ int pacman_add(pacdb_t *db, PMList *targets)
printf(" %s\n", (char*)j->data); printf(" %s\n", (char*)j->data);
} }
printf("\n"); printf("\n");
list_free(lp); FREELIST(lp);
return(1); return(1);
} }
printf("done.\n"); printf("done.\n");
list_free(lp); FREELIST(lp);
} }
/* this can get modified in the next for loop, so we reset it on each iteration */ /* this can get modified in the next for loop, so we reset it on each iteration */
@ -1317,7 +1319,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
/* 32 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */ /* 32 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */
MALLOC(fn, strlen(lp->data)+34); MALLOC(fn, strlen(lp->data)+34);
sprintf(fn, "%s\t%s", (char*)lp->data, md5_pkg); sprintf(fn, "%s\t%s", (char*)lp->data, md5_pkg);
free(lp->data); FREE(lp->data);
lp->data = fn; lp->data = fn;
} }
} }
@ -1519,11 +1521,10 @@ int pacman_add(pacdb_t *db, PMList *targets)
/* clean up */ /* clean up */
for(lp = alltargs; lp; lp = lp->next) { for(lp = alltargs; lp; lp = lp->next) {
freepkg((pkginfo_t*)lp->data); FREEPKG(lp->data);
lp->data = NULL;
} }
list_free(alltargs); FREELIST(alltargs);
list_free(filenames); FREELIST(filenames);
/* run ldconfig if it exists */ /* run ldconfig if it exists */
snprintf(expath, PATH_MAX, "%setc/ld.so.conf", pmo_root); snprintf(expath, PATH_MAX, "%setc/ld.so.conf", pmo_root);
@ -1564,19 +1565,27 @@ int pacman_remove(pacdb_t *db, PMList *targets)
/* if the target is a group, ask if its packages should be removed */ /* if the target is a group, ask if its packages should be removed */
groups = find_groups(db); groups = find_groups(db);
if(is_in((char *)lp->data, groups)) { if(is_in((char *)lp->data, groups)) {
PMList *pkg; PMList *pkgs = pkg_ingroup(db, (char *)lp->data);
pkg = pkg_ingroup(db, (char *)lp->data); printf(":: group %s:\n", (char*)lp->data);
for(j = pkg; j; j = j->next) { list_display(" ", pkgs);
if(yesno(":: Remove %s from group %s? [Y/n] ", (char *)j->data, (char *)lp->data)) { if(yesno(" Remove whole content? [Y/n] ")) {
for(j = pkgs; j; j = j->next) {
info = db_scan(db, (char *)j->data, INFRQ_ALL); info = db_scan(db, (char *)j->data, INFRQ_ALL);
alltargs = list_add(alltargs, info); alltargs = list_add(alltargs, info);
} }
} else {
for(j = pkgs; j; j = j->next) {
if(yesno(":: remove %s from group %s? [Y/n] ", (char*)j->data, (char*)lp->data)) {
info = db_scan(db, (char *)j->data, INFRQ_ALL);
alltargs = list_add(alltargs, info);
}
}
} }
list_free(pkg); FREELIST(pkgs);
list_free(groups); FREELIST(groups);
continue; continue;
} }
list_free(groups); FREELIST(groups);
fprintf(stderr, "error: could not find %s in database\n", (char*)lp->data); fprintf(stderr, "error: could not find %s in database\n", (char*)lp->data);
return(1); return(1);
} }
@ -1599,7 +1608,7 @@ int pacman_remove(pacdb_t *db, PMList *targets)
lp = checkdeps(db, PM_REMOVE, alltargs); lp = checkdeps(db, PM_REMOVE, alltargs);
} }
/* list targets */ /* list targets */
list_display("\nTargets: ", alltargs); list_display("\nTargets:", alltargs);
/* get confirmation */ /* get confirmation */
if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) { if(yesno("\nDo you want to remove these packages? [Y/n] ") == 0) {
list_free(alltargs); list_free(alltargs);
@ -1758,7 +1767,7 @@ int pacman_remove(pacdb_t *db, PMList *targets)
} }
} }
list_free(alltargs); FREELIST(alltargs);
/* run ldconfig if it exists */ /* run ldconfig if it exists */
snprintf(line, PATH_MAX, "%setc/ld.so.conf", pmo_root); snprintf(line, PATH_MAX, "%setc/ld.so.conf", pmo_root);
@ -1803,20 +1812,21 @@ int pacman_query(pacdb_t *db, PMList *targets)
for(q = pkg; q; q = q->next) { for(q = pkg; q; q = q->next) {
printf("%s %s\n", (char *)lp->data, (char *)q->data); printf("%s %s\n", (char *)lp->data, (char *)q->data);
} }
list_free(pkg); FREELIST(pkg);
} }
} else { } else {
if(!is_in(package, groups)) { if(!is_in(package, groups)) {
fprintf(stderr, "Group \"%s\" was not found.\n", package); fprintf(stderr, "Group \"%s\" was not found.\n", package);
FREELIST(groups);
return(2); return(2);
} }
pkg = pkg_ingroup(db, package); pkg = pkg_ingroup(db, package);
for(q = pkg; q; q = q->next) { for(q = pkg; q; q = q->next) {
printf("%s %s\n", package, (char *)q->data); printf("%s %s\n", package, (char *)q->data);
} }
list_free(pkg); FREELIST(pkg);
} }
list_free(groups); FREELIST(groups);
continue; continue;
} }
@ -1840,7 +1850,7 @@ int pacman_query(pacdb_t *db, PMList *targets)
} else { } else {
printf("%s %s\n", info->name, info->version); printf("%s %s\n", info->name, info->version);
} }
freepkg(info); FREEPKG(info);
continue; continue;
} }
@ -1862,7 +1872,7 @@ int pacman_query(pacdb_t *db, PMList *targets)
gotcha = 1; gotcha = 1;
} }
} }
freepkg(info); FREEPKG(info);
} }
if(!gotcha) { if(!gotcha) {
fprintf(stderr, "No package owns %s\n", package); fprintf(stderr, "No package owns %s\n", package);
@ -1888,7 +1898,7 @@ int pacman_query(pacdb_t *db, PMList *targets)
for(q = info->files; q; q = q->next) { for(q = info->files; q; q = q->next) {
printf("%s %s%s\n", info->name, pmo_root, (char*)q->data); printf("%s %s%s\n", info->name, pmo_root, (char*)q->data);
} }
freepkg(info); FREEPKG(info);
} else if(pmo_q_orphans) { } else if(pmo_q_orphans) {
info = db_scan(db, tmpp->name, INFRQ_DESC | INFRQ_DEPENDS); info = db_scan(db, tmpp->name, INFRQ_DESC | INFRQ_DEPENDS);
if(info == NULL) { if(info == NULL) {
@ -1897,6 +1907,7 @@ int pacman_query(pacdb_t *db, PMList *targets)
if(info->requiredby == NULL) { if(info->requiredby == NULL) {
printf("%s %s\n", tmpp->name, tmpp->version); printf("%s %s\n", tmpp->name, tmpp->version);
} }
FREEPKG(info);
} else { } else {
printf("%s %s\n", tmpp->name, tmpp->version); printf("%s %s\n", tmpp->name, tmpp->version);
} }
@ -1937,7 +1948,7 @@ int pacman_query(pacdb_t *db, PMList *targets)
} }
printf("%s %s\n", info->name, info->version); printf("%s %s\n", info->name, info->version);
} }
freepkg(info); FREEPKG(info);
} }
} }

View file

@ -22,7 +22,7 @@
#define _PAC_PACMAN_H #define _PAC_PACMAN_H
#ifndef PACVER #ifndef PACVER
#define PACVER "2.6.1" #define PACVER "2.6.2"
#endif #endif
#ifndef PKGDIR #ifndef PKGDIR

View file

@ -69,8 +69,7 @@ int sync_synctree()
fprintf(stderr, "failed to synchronize %s\n", sync->treename); fprintf(stderr, "failed to synchronize %s\n", sync->treename);
success = 0; success = 0;
} }
list_free(files); FREELIST(files);
files = NULL;
snprintf(path, PATH_MAX, "%s/%s.db.tar.gz", ldir, sync->treename); snprintf(path, PATH_MAX, "%s/%s.db.tar.gz", ldir, sync->treename);
if(success) { if(success) {