Imported from pacman-2.9.7-TEST3.tar.gz

This commit is contained in:
Judd Vinet 2005-09-11 23:18:42 +00:00
parent 3ba0d67cb1
commit de98f7004e
10 changed files with 115 additions and 29 deletions

View file

@ -1,8 +1,12 @@
VERSION DESCRIPTION VERSION DESCRIPTION
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
2.9.7 - patch from Miklos Vanja fixed md5sums on x86_64 2.9.7 - fixed the dupe listings of packages when dealing w/ groups
- patch from Miklos Vanja adds --sudosync to makepkg - patches from Miklos Vanja:
- patch from Jason Chu adds SHA1 hashes to PKGBUILDs - add regexp search support for -Qs and -Ss
- fixed md5sums on x86_64
- add --sudosync to makepkg
- show syntax help if an invalid option is used
- added makepkg option to disable ccache support
- changed license field to operate as an array, not a string - changed license field to operate as an array, not a string
- added more logic for file conflict checks - if one target - added more logic for file conflict checks - if one target
is a file and the other is a directory, then it's a conflict is a file and the other is a directory, then it's a conflict

View file

@ -331,6 +331,9 @@ $ABSROOT (set in your /etc/makepkg.conf). If it finds them it will
run another copy of makepkg to build and install the missing dependencies. run another copy of makepkg to build and install the missing dependencies.
The child makepkg calls will be made with the \fB-b\fP and \fB-i\fP options. The child makepkg calls will be made with the \fB-b\fP and \fB-i\fP options.
.TP .TP
.B "\-B, \-\-noccache"
Do not use ccache during build.
.TP
.B "\-c, \-\-clean" .B "\-c, \-\-clean"
Clean up leftover work files/directories after a successful build. Clean up leftover work files/directories after a successful build.
.TP .TP

View file

@ -110,9 +110,9 @@ Print out URIs for each package that will be installed, including any
dependencies that have yet to be installed. These can be piped to a dependencies that have yet to be installed. These can be piped to a
file and downloaded at a later time, using a program like wget. file and downloaded at a later time, using a program like wget.
.TP .TP
.B "\-s, \-\-search <string>" .B "\-s, \-\-search <regexp>"
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
that contains <string>. that matches <regexp>.
.TP .TP
.B "\-u, \-\-sysupgrade" .B "\-u, \-\-sysupgrade"
Upgrades all packages that are out of date. pacman will examine every Upgrades all packages that are out of date. pacman will examine every
@ -182,9 +182,9 @@ Tells pacman that the package supplied on the command line is a
file, not an entry in the database. Pacman will decompress the file, not an entry in the database. Pacman will decompress the
file and query it. This is useful with \fB--info\fP and \fB--list\fP. file and query it. This is useful with \fB--info\fP and \fB--list\fP.
.TP .TP
.B "\-s, \-\-search <string>" .B "\-s, \-\-search <regexp>"
This will search each locally-installed package for names or descriptions This will search each locally-installed package for names or descriptions
that contains <string>. that matches <regexp>.
.SH HANDLING CONFIG FILES .SH HANDLING CONFIG FILES
pacman uses the same logic as rpm to determine action against files pacman uses the same logic as rpm to determine action against files
that are designated to be backed up. During an upgrade, it uses 3 that are designated to be backed up. During an upgrade, it uses 3

View file

@ -125,7 +125,17 @@ handledeps() {
elif [ "$DEP_SUDO" = "1" ]; then elif [ "$DEP_SUDO" = "1" ]; then
# install missing deps from binary packages (using pacman -S and sudo) # install missing deps from binary packages (using pacman -S and sudo)
msg "Installing missing dependencies..." msg "Installing missing dependencies..."
if [ "$INFAKEROOT" = "1" ]; then
# kinda hacky, but we need to make pacman think that we're NOT
# in fakeroot so it will go ahead and install the dependencies.
FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY
fi
sudo pacman -D $deplist sudo pacman -D $deplist
if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
fi
if [ "$?" = "127" ]; then if [ "$?" = "127" ]; then
error "Failed to install missing dependencies." error "Failed to install missing dependencies."
exit 1 exit 1
@ -185,6 +195,7 @@ usage() {
echo "usage: $0 [options]" echo "usage: $0 [options]"
echo "options:" echo "options:"
echo " -b, --builddeps Build missing dependencies from source" echo " -b, --builddeps Build missing dependencies from source"
echo " -B, --noccache Do not use ccache during build"
echo " -c, --clean Clean up work files after build" echo " -c, --clean Clean up work files after build"
echo " -C, --cleancache Clean up source files from the cache" echo " -C, --cleancache Clean up source files from the cache"
echo " -d, --nodeps Skip all dependency checks" echo " -d, --nodeps Skip all dependency checks"
@ -210,20 +221,21 @@ usage() {
# Options # Options
BUILDSCRIPT="./PKGBUILD"
CLEANUP=0 CLEANUP=0
CLEANCACHE=0 CLEANCACHE=0
INSTALL=0
GENMD5=0
DEP_BIN=0 DEP_BIN=0
DEP_SUDO=0
DEP_SRC=0 DEP_SRC=0
NODEPS=0 DEP_SUDO=0
FORCE=0 FORCE=0
GENMD5=0
INSTALL=0
NOBUILD=0
NOCCACHE=0
NODEPS=0
NOEXTRACT=0 NOEXTRACT=0
NOSTRIP=0 NOSTRIP=0
NOBUILD=0
RMDEPS=0 RMDEPS=0
BUILDSCRIPT="./PKGBUILD"
ARGLIST=$@ ARGLIST=$@
@ -234,6 +246,7 @@ while [ "$#" -ne "0" ]; do
--syncdeps) DEP_BIN=1 ;; --syncdeps) DEP_BIN=1 ;;
--sudosync) DEP_SUDO=1 ;; --sudosync) DEP_SUDO=1 ;;
--builddeps) DEP_SRC=1 ;; --builddeps) DEP_SRC=1 ;;
--noccache) NOCCACHE=1 ;;
--nodeps) NODEPS=1 ;; --nodeps) NODEPS=1 ;;
--noextract) NOEXTRACT=1 ;; --noextract) NOEXTRACT=1 ;;
--install) INSTALL=1 ;; --install) INSTALL=1 ;;
@ -252,11 +265,12 @@ while [ "$#" -ne "0" ]; do
exit 1 exit 1
;; ;;
-*) -*)
while getopts "cCsSbdehifgj:mnorp:w:-" opt; do while getopts "bBcCdefghij:mnop:rsSw:-" opt; do
case $opt in case $opt in
b) DEP_SRC=1 ;;
B) NOCCACHE=1 ;;
c) CLEANUP=1 ;; c) CLEANUP=1 ;;
C) CLEANCACHE=1 ;; C) CLEANCACHE=1 ;;
b) DEP_SRC=1 ;;
d) NODEPS=1 ;; d) NODEPS=1 ;;
e) NOEXTRACT=1 ;; e) NOEXTRACT=1 ;;
f) FORCE=1 ;; f) FORCE=1 ;;
@ -576,7 +590,9 @@ if [ "$NOBUILD" = "1" ]; then
fi fi
# use ccache if it's available # use ccache if it's available
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH if [ "$NOCCACHE" = "0" ]; then
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
fi
# build # build
msg "Starting build()..." msg "Starting build()..."
@ -711,13 +727,20 @@ if [ "$CLEANUP" = "1" ]; then
rm -rf src pkg filelist rm -rf src pkg filelist
fi fi
if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
msg "Removing installed dependencies..." msg "Removing installed dependencies..."
pacman -R $makedeplist $deplist pacman -R $makedeplist $deplist
elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" ]; then elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" ]; then
msg "Removing installed dependencies..." msg "Removing installed dependencies..."
if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY
fi
sudo pacman -R $makedeplist $deplist sudo pacman -R $makedeplist $deplist
if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
fi
fi fi
msg "Finished making: $pkgname (`date`)" msg "Finished making: $pkgname (`date`)"

View file

@ -659,7 +659,7 @@ void db_search(pacdb_t *db, PMList *cache, const char *treename, PMList *needles
/* check name */ /* check name */
haystack = strdup(pkg->name); haystack = strdup(pkg->name);
strtoupper(haystack); strtoupper(haystack);
if(strstr(haystack, targ)) { if(reg_match(haystack, targ)) {
match = 1; match = 1;
} }
FREE(haystack); FREE(haystack);
@ -668,7 +668,7 @@ void db_search(pacdb_t *db, PMList *cache, const char *treename, PMList *needles
if(!match) { if(!match) {
haystack = strdup(pkg->desc); haystack = strdup(pkg->desc);
strtoupper(haystack); strtoupper(haystack);
if(strstr(haystack, targ)) { if(reg_match(haystack, targ)) {
match = 1; match = 1;
} }
FREE(haystack); FREE(haystack);
@ -682,7 +682,7 @@ void db_search(pacdb_t *db, PMList *cache, const char *treename, PMList *needles
for(m = info->provides; m; m = m->next) { for(m = info->provides; m; m = m->next) {
haystack = strdup(m->data); haystack = strdup(m->data);
strtoupper(haystack); strtoupper(haystack);
if(strstr(haystack, targ)) { if(reg_match(haystack, targ)) {
match = 1; match = 1;
} }
FREE(haystack); FREE(haystack);

View file

@ -238,6 +238,8 @@ int list_strcmp(const void *s1, const void *s2)
return(strcmp(*str1, *str2)); return(strcmp(*str1, *str2));
} }
/* Sort a list of strings.
*/
PMList *list_sort(PMList *list) PMList *list_sort(PMList *list)
{ {
char **arr = NULL; char **arr = NULL;
@ -270,6 +272,24 @@ PMList *list_sort(PMList *list)
return(lp); return(lp);
} }
/* Filter out any duplicate strings in a list.
*
* Not the most efficient way, but simple to implement -- we assemble
* a new list, using is_in() to check for dupes at each iteration.
*
*/
PMList* list_remove_dupes(PMList *list)
{
PMList *i, *newlist = NULL;
for(i = list; i; i = i->next) {
if(!is_in(i->data, newlist)) {
newlist = list_add(newlist, strdup(i->data));
}
}
return newlist;
}
/* Reverse the order of a list /* Reverse the order of a list
* *
* The caller is responsible for freeing the old list * The caller is responsible for freeing the old list

View file

@ -47,6 +47,7 @@ PMList* list_merge(PMList *one, PMList *two);
PMList* list_last(PMList* list); PMList* list_last(PMList* list);
int list_strcmp(const void *s1, const void *s2); int list_strcmp(const void *s1, const void *s2);
PMList *list_sort(PMList *list); PMList *list_sort(PMList *list);
PMList* list_remove_dupes(PMList *list);
PMList *list_reverse(PMList *list); PMList *list_reverse(PMList *list);
void list_display(const char *title, PMList *list); void list_display(const char *title, PMList *list);

View file

@ -160,8 +160,9 @@ int main(int argc, char *argv[])
/* check for permission */ /* check for permission */
pm_access = READ_ONLY; pm_access = READ_ONLY;
if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) { if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) {
if(pmo_op == PM_SYNC && !pmo_s_sync && if((pmo_op == PM_SYNC && !pmo_s_sync &&
(pmo_s_search || pmo_s_printuris || pmo_group || pmo_q_list || pmo_q_info)) { (pmo_s_search || pmo_s_printuris || pmo_group || pmo_q_list ||
pmo_q_info)) || (pmo_op == PM_DEPTEST && !pmo_d_resolve)) {
/* special case: PM_SYNC can be used w/ pmo_s_search by any user */ /* special case: PM_SYNC can be used w/ pmo_s_search by any user */
} else { } else {
if(myuid) { if(myuid) {
@ -238,6 +239,10 @@ int main(int argc, char *argv[])
/* load pm_packages cache */ /* load pm_packages cache */
pm_packages = db_loadpkgs(db_local); pm_packages = db_loadpkgs(db_local);
/* the operation requires at least one target */
if (list_count(pm_targets) == 0 && !(pmo_op == PM_QUERY || (pmo_op == PM_SYNC && (pmo_s_sync || pmo_s_upgrade || pmo_s_clean || pmo_group || pmo_q_list))))
usage(pmo_op, (char*)basename(argv[0]));
/* start the requested operation */ /* start the requested operation */
switch(pmo_op) { switch(pmo_op) {
case PM_ADD: ret = pacman_add(db_local, pm_targets, NULL); break; case PM_ADD: ret = pacman_add(db_local, pm_targets, NULL); break;
@ -509,7 +514,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
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(j->data, allgroups)) {
groups = list_add(groups, strdup((char *)j->data)); groups = list_add(groups, strdup((char *)j->data));
} }
} }
@ -533,6 +538,12 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
pkg = list_sort(i); pkg = list_sort(i);
FREELIST(i); FREELIST(i);
i = pkg;
/* need to remove dupes in the list -- dupes can appear if a package
* belonging to this group exists in more than one repo at the same
* time. */
pkg = list_remove_dupes(i);
FREELIST(i);
list_display(" ", pkg); list_display(" ", pkg);
FREELIST(pkg); FREELIST(pkg);
} }
@ -693,8 +704,8 @@ int pacman_sync(pacdb_t *db, PMList *targets)
cmp = rpmvercmp(local->version, sync->pkg->version); cmp = rpmvercmp(local->version, sync->pkg->version);
if(cmp > 0 && !sync->pkg->force) { if(cmp > 0 && !sync->pkg->force) {
/* local version is newer */ /* local version is newer */
fprintf(stderr, ":: %s: local version (%s) appears to be newer than repo version (%s)\n", fprintf(stderr, ":: %s: local (%s) appears to be newer than repo (%s/%s)\n",
local->name, local->version, sync->pkg->version); local->name, local->version, sync->dbs->sync->treename, sync->pkg->version);
newer = 1; newer = 1;
FREE(sync); FREE(sync);
continue; continue;
@ -811,6 +822,12 @@ int pacman_sync(pacdb_t *db, PMList *targets)
FREELIST(l); FREELIST(l);
} }
if(k != NULL) { if(k != NULL) {
/* remove dupe entries in case a package exists in
* multiple repos */
PMList *tmp = list_remove_dupes(k);
FREELIST(k);
k = tmp;
printf(":: group %s:\n", targ); printf(":: group %s:\n", targ);
list_display(" ", k); list_display(" ", k);
if(yesno(" Install whole content? [Y/n] ")) { if(yesno(" Install whole content? [Y/n] ")) {
@ -3488,7 +3505,7 @@ int parseargs(int op, int argc, char **argv)
case 'v': pmo_verbose = 1; break; case 'v': pmo_verbose = 1; break;
case 'w': pmo_s_downloadonly = 1; break; case 'w': pmo_s_downloadonly = 1; break;
case 'y': pmo_s_sync = 1; break; case 'y': pmo_s_sync = 1; break;
case '?': return(1); case '?': pmo_help = 1; break;
default: return(1); default: return(1);
} }
} }
@ -3507,6 +3524,12 @@ int parseargs(int op, int argc, char **argv)
return(2); return(2);
} }
if (optind == 1) {
fprintf(stderr, "error: you should specify at least one operation\n");
usage(pmo_op, (char*)basename(argv[0]));
return(2);
}
while(optind < argc) { while(optind < argc) {
/* add the target to our target array */ /* add the target to our target array */
char *s = strdup(argv[optind]); char *s = strdup(argv[optind]);
@ -3813,7 +3836,7 @@ void usage(int op, char *myname)
printf(" -o, --owns <file> query the package that owns <file>\n"); printf(" -o, --owns <file> query the package that owns <file>\n");
printf(" -p, --file pacman will query the package file [package] instead of\n"); printf(" -p, --file pacman will query the package file [package] instead of\n");
printf(" looking in the database\n"); printf(" looking in the database\n");
printf(" -s, --search search locally-installed packages for matching strings\n"); printf(" -s, --search search locally-installed packages for matching regexps\n");
} else if(op == PM_SYNC) { } else if(op == PM_SYNC) {
printf("usage: %s {-S --sync} [options] [package]\n", myname); printf("usage: %s {-S --sync} [options] [package]\n", myname);
printf("options:\n"); printf("options:\n");
@ -3824,7 +3847,7 @@ void usage(int op, char *myname)
printf(" -i, --info view package information\n"); printf(" -i, --info view package information\n");
printf(" -l, --list list all packages belonging to the specified repository\n"); printf(" -l, --list list all packages belonging to the specified repository\n");
printf(" -p, --print-uris print out download URIs for each package to be installed\n"); printf(" -p, --print-uris print out download URIs for each package to be installed\n");
printf(" -s, --search search remote repositories for matching strings\n"); printf(" -s, --search search remote repositories for matching regexps\n");
printf(" -u, --sysupgrade upgrade all packages that are out of date\n"); printf(" -u, --sysupgrade upgrade all packages that are out of date\n");
printf(" -w, --downloadonly download packages but do not install/upgrade anything\n"); printf(" -w, --downloadonly download packages but do not install/upgrade anything\n");
printf(" -y, --refresh download fresh package databases from the server\n"); printf(" -y, --refresh download fresh package databases from the server\n");

View file

@ -30,6 +30,7 @@
#include <dirent.h> #include <dirent.h>
#include <zlib.h> #include <zlib.h>
#include <libtar.h> #include <libtar.h>
#include <regex.h>
#include "util.h" #include "util.h"
extern unsigned short pmo_verbose; extern unsigned short pmo_verbose;
@ -427,5 +428,15 @@ int grep(const char *fn, const char *needle)
return(0); return(0);
} }
int reg_match(char *string, char *pattern)
{
int result;
regex_t reg;
regcomp(&reg, pattern, REG_EXTENDED | REG_NOSUB);
result = regexec(&reg, string, 0, 0, 0);
regfree(&reg);
return(!(result));
}
/* vim: set ts=2 sw=2 noet: */ /* vim: set ts=2 sw=2 noet: */

View file

@ -39,6 +39,7 @@ void indentprint(char *str, int indent);
char* trim(char *str); char* trim(char *str);
char* strtoupper(char *str); char* strtoupper(char *str);
int grep(const char *fn, const char *needle); int grep(const char *fn, const char *needle);
int reg_match(char *string, char *pattern);
#endif #endif
/* vim: set ts=2 sw=2 noet: */ /* vim: set ts=2 sw=2 noet: */