summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2005-09-12 01:18:42 +0200
committerJudd Vinet <judd@archlinux.org>2005-09-12 01:18:42 +0200
commitde98f7004e712ae422af4a567c7df26c4579b0d6 (patch)
tree7ec6634ec2894457f11df40c8c44777063feccfe
parent3ba0d67cb14ba5d608df16eb447fe441956dbf8f (diff)
downloadpacman-de98f7004e712ae422af4a567c7df26c4579b0d6.tar.gz
pacman-de98f7004e712ae422af4a567c7df26c4579b0d6.tar.xz
Imported from pacman-2.9.7-TEST3.tar.gz
-rw-r--r--ChangeLog10
-rw-r--r--doc/makepkg.8.in3
-rw-r--r--doc/pacman.8.in8
-rwxr-xr-xscripts/makepkg45
-rw-r--r--src/db.c6
-rw-r--r--src/list.c20
-rw-r--r--src/list.h1
-rw-r--r--src/pacman.c39
-rw-r--r--src/util.c11
-rw-r--r--src/util.h1
10 files changed, 115 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index eaab95f9..ea8162dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,12 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
-2.9.7 - patch from Miklos Vanja fixed md5sums on x86_64
- - patch from Miklos Vanja adds --sudosync to makepkg
- - patch from Jason Chu adds SHA1 hashes to PKGBUILDs
+2.9.7 - fixed the dupe listings of packages when dealing w/ groups
+ - patches from Miklos Vanja:
+ - 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
- added more logic for file conflict checks - if one target
is a file and the other is a directory, then it's a conflict
diff --git a/doc/makepkg.8.in b/doc/makepkg.8.in
index 0de31bf1..ea0c44f8 100644
--- a/doc/makepkg.8.in
+++ b/doc/makepkg.8.in
@@ -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.
The child makepkg calls will be made with the \fB-b\fP and \fB-i\fP options.
.TP
+.B "\-B, \-\-noccache"
+Do not use ccache during build.
+.TP
.B "\-c, \-\-clean"
Clean up leftover work files/directories after a successful build.
.TP
diff --git a/doc/pacman.8.in b/doc/pacman.8.in
index 32e04e3a..a09c1de5 100644
--- a/doc/pacman.8.in
+++ b/doc/pacman.8.in
@@ -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
file and downloaded at a later time, using a program like wget.
.TP
-.B "\-s, \-\-search <string>"
+.B "\-s, \-\-search <regexp>"
This will search each package in the package list for names or descriptions
-that contains <string>.
+that matches <regexp>.
.TP
.B "\-u, \-\-sysupgrade"
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 and query it. This is useful with \fB--info\fP and \fB--list\fP.
.TP
-.B "\-s, \-\-search <string>"
+.B "\-s, \-\-search <regexp>"
This will search each locally-installed package for names or descriptions
-that contains <string>.
+that matches <regexp>.
.SH HANDLING CONFIG 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
diff --git a/scripts/makepkg b/scripts/makepkg
index e9c764c1..6b578524 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -125,7 +125,17 @@ handledeps() {
elif [ "$DEP_SUDO" = "1" ]; then
# install missing deps from binary packages (using pacman -S and sudo)
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
+ if [ "$INFAKEROOT" = "1" ]; then
+ FAKEROOTKEY=$FAKEROOTKEY2
+ unset FAKEROOTKEY2
+ fi
if [ "$?" = "127" ]; then
error "Failed to install missing dependencies."
exit 1
@@ -185,6 +195,7 @@ usage() {
echo "usage: $0 [options]"
echo "options:"
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, --cleancache Clean up source files from the cache"
echo " -d, --nodeps Skip all dependency checks"
@@ -210,20 +221,21 @@ usage() {
# Options
+BUILDSCRIPT="./PKGBUILD"
CLEANUP=0
CLEANCACHE=0
-INSTALL=0
-GENMD5=0
DEP_BIN=0
-DEP_SUDO=0
DEP_SRC=0
-NODEPS=0
+DEP_SUDO=0
FORCE=0
+GENMD5=0
+INSTALL=0
+NOBUILD=0
+NOCCACHE=0
+NODEPS=0
NOEXTRACT=0
NOSTRIP=0
-NOBUILD=0
RMDEPS=0
-BUILDSCRIPT="./PKGBUILD"
ARGLIST=$@
@@ -234,6 +246,7 @@ while [ "$#" -ne "0" ]; do
--syncdeps) DEP_BIN=1 ;;
--sudosync) DEP_SUDO=1 ;;
--builddeps) DEP_SRC=1 ;;
+ --noccache) NOCCACHE=1 ;;
--nodeps) NODEPS=1 ;;
--noextract) NOEXTRACT=1 ;;
--install) INSTALL=1 ;;
@@ -252,11 +265,12 @@ while [ "$#" -ne "0" ]; do
exit 1
;;
-*)
- while getopts "cCsSbdehifgj:mnorp:w:-" opt; do
+ while getopts "bBcCdefghij:mnop:rsSw:-" opt; do
case $opt in
+ b) DEP_SRC=1 ;;
+ B) NOCCACHE=1 ;;
c) CLEANUP=1 ;;
C) CLEANCACHE=1 ;;
- b) DEP_SRC=1 ;;
d) NODEPS=1 ;;
e) NOEXTRACT=1 ;;
f) FORCE=1 ;;
@@ -576,7 +590,9 @@ if [ "$NOBUILD" = "1" ]; then
fi
# 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
msg "Starting build()..."
@@ -711,13 +727,20 @@ if [ "$CLEANUP" = "1" ]; then
rm -rf src pkg filelist
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..."
pacman -R $makedeplist $deplist
-
elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" ]; then
msg "Removing installed dependencies..."
+ if [ "$INFAKEROOT" = "1" ]; then
+ FAKEROOTKEY2=$FAKEROOTKEY
+ unset FAKEROOTKEY
+ fi
sudo pacman -R $makedeplist $deplist
+ if [ "$INFAKEROOT" = "1" ]; then
+ FAKEROOTKEY=$FAKEROOTKEY2
+ unset FAKEROOTKEY2
+ fi
fi
msg "Finished making: $pkgname (`date`)"
diff --git a/src/db.c b/src/db.c
index 4d5c4e22..6bcd0530 100644
--- a/src/db.c
+++ b/src/db.c
@@ -659,7 +659,7 @@ void db_search(pacdb_t *db, PMList *cache, const char *treename, PMList *needles
/* check name */
haystack = strdup(pkg->name);
strtoupper(haystack);
- if(strstr(haystack, targ)) {
+ if(reg_match(haystack, targ)) {
match = 1;
}
FREE(haystack);
@@ -668,7 +668,7 @@ void db_search(pacdb_t *db, PMList *cache, const char *treename, PMList *needles
if(!match) {
haystack = strdup(pkg->desc);
strtoupper(haystack);
- if(strstr(haystack, targ)) {
+ if(reg_match(haystack, targ)) {
match = 1;
}
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) {
haystack = strdup(m->data);
strtoupper(haystack);
- if(strstr(haystack, targ)) {
+ if(reg_match(haystack, targ)) {
match = 1;
}
FREE(haystack);
diff --git a/src/list.c b/src/list.c
index 49c07f51..1394f321 100644
--- a/src/list.c
+++ b/src/list.c
@@ -238,6 +238,8 @@ int list_strcmp(const void *s1, const void *s2)
return(strcmp(*str1, *str2));
}
+/* Sort a list of strings.
+ */
PMList *list_sort(PMList *list)
{
char **arr = NULL;
@@ -270,6 +272,24 @@ PMList *list_sort(PMList *list)
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
*
* The caller is responsible for freeing the old list
diff --git a/src/list.h b/src/list.h
index 28ef2a6c..fec2fcde 100644
--- a/src/list.h
+++ b/src/list.h
@@ -47,6 +47,7 @@ PMList* list_merge(PMList *one, PMList *two);
PMList* list_last(PMList* list);
int list_strcmp(const void *s1, const void *s2);
PMList *list_sort(PMList *list);
+PMList* list_remove_dupes(PMList *list);
PMList *list_reverse(PMList *list);
void list_display(const char *title, PMList *list);
diff --git a/src/pacman.c b/src/pacman.c
index 6ab8d3cf..acd70566 100644
--- a/src/pacman.c
+++ b/src/pacman.c
@@ -160,8 +160,9 @@ int main(int argc, char *argv[])
/* check for permission */
pm_access = READ_ONLY;
if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) {
- if(pmo_op == PM_SYNC && !pmo_s_sync &&
- (pmo_s_search || pmo_s_printuris || pmo_group || pmo_q_list || pmo_q_info)) {
+ if((pmo_op == PM_SYNC && !pmo_s_sync &&
+ (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 */
} else {
if(myuid) {
@@ -238,6 +239,10 @@ int main(int argc, char *argv[])
/* load pm_packages cache */
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 */
switch(pmo_op) {
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) {
groups = NULL;
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));
}
}
@@ -533,6 +538,12 @@ int pacman_sync(pacdb_t *db, PMList *targets)
}
pkg = list_sort(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);
FREELIST(pkg);
}
@@ -693,8 +704,8 @@ int pacman_sync(pacdb_t *db, PMList *targets)
cmp = rpmvercmp(local->version, sync->pkg->version);
if(cmp > 0 && !sync->pkg->force) {
/* local version is newer */
- fprintf(stderr, ":: %s: local version (%s) appears to be newer than repo version (%s)\n",
- local->name, local->version, sync->pkg->version);
+ fprintf(stderr, ":: %s: local (%s) appears to be newer than repo (%s/%s)\n",
+ local->name, local->version, sync->dbs->sync->treename, sync->pkg->version);
newer = 1;
FREE(sync);
continue;
@@ -811,6 +822,12 @@ int pacman_sync(pacdb_t *db, PMList *targets)
FREELIST(l);
}
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);
list_display(" ", k);
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 'w': pmo_s_downloadonly = 1; break;
case 'y': pmo_s_sync = 1; break;
- case '?': return(1);
+ case '?': pmo_help = 1; break;
default: return(1);
}
}
@@ -3507,6 +3524,12 @@ int parseargs(int op, int argc, char **argv)
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) {
/* add the target to our target array */
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(" -p, --file pacman will query the package file [package] instead of\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) {
printf("usage: %s {-S --sync} [options] [package]\n", myname);
printf("options:\n");
@@ -3824,7 +3847,7 @@ void usage(int op, char *myname)
printf(" -i, --info view package information\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(" -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(" -w, --downloadonly download packages but do not install/upgrade anything\n");
printf(" -y, --refresh download fresh package databases from the server\n");
diff --git a/src/util.c b/src/util.c
index b68b71f2..528cc91f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -30,6 +30,7 @@
#include <dirent.h>
#include <zlib.h>
#include <libtar.h>
+#include <regex.h>
#include "util.h"
extern unsigned short pmo_verbose;
@@ -427,5 +428,15 @@ int grep(const char *fn, const char *needle)
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: */
diff --git a/src/util.h b/src/util.h
index a536c2e1..2098277d 100644
--- a/src/util.h
+++ b/src/util.h
@@ -39,6 +39,7 @@ void indentprint(char *str, int indent);
char* trim(char *str);
char* strtoupper(char *str);
int grep(const char *fn, const char *needle);
+int reg_match(char *string, char *pattern);
#endif
/* vim: set ts=2 sw=2 noet: */