public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2007-10-24 16:50 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2007-10-24 16:50 UTC (permalink / raw
  To: gentoo-commits

solar       07/10/24 16:50:31

  Modified:             qmerge.c
  Log:
  - qmerge updates that I needed to commit for a while

Revision  Changes    Path
1.77                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.77&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.77&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.76&r2=1.77

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- qmerge.c	4 Jun 2007 16:53:53 -0000	1.76
+++ qmerge.c	24 Oct 2007 16:50:31 -0000	1.77
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.76 2007/06/04 16:53:53 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.77 2007/10/24 16:50:31 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -24,6 +24,8 @@
 /* #define BUSYBOX "/bin/busybox" */
 #define BUSYBOX ""
 
+int old_repo = 0;
+
 #define QMERGE_FLAGS "fFsKUpuyO5" COMMON_FLAGS
 static struct option const qmerge_long_opts[] = {
 	{"fetch",   no_argument, NULL, 'f'},
@@ -53,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.76 2007/06/04 16:53:53 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.77 2007/10/24 16:50:31 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -238,7 +240,7 @@
 	char *p;
 
 	/* if defined(EBUG) this spits out incorrect versions. */
-	snprintf(buf, sizeof(buf), "qlist -CIev %s%s%s 2>/dev/null | tr '\n' ' '",
+	snprintf(buf, sizeof(buf), "qlist -CIev '%s%s%s' 2>/dev/null | tr '\n' ' '",
 		(CATEGORY != NULL ? CATEGORY : ""), (CATEGORY != NULL ? "/" : ""), PN);
 
 	if ((fp = popen(buf, "r")) == NULL)
@@ -361,10 +363,7 @@
 				case OLDER: c = 'D'; break;
 				default: c = '?'; break;
 			}
-			if (subatom->PR_int)
-				snprintf(buf, sizeof(buf), "%s-r%i", subatom->PV, subatom->PR_int);
-			else
-				snprintf(buf, sizeof(buf), "%s", subatom->PV);
+			strncpy(buf, subatom->P, sizeof(buf));
 			snprintf(install_ver, sizeof(install_ver), "[%s%s%s] ", DKBLUE, buf, NORM);
 			atom_implode(subatom);
 		}
@@ -586,7 +585,7 @@
 						if (strcmp(pkg->SLOT, slot) != 0)
 							u = 0;
 					}
-					if (u) pkg_unmerge(atom->CATEGORY, basename(pf));
+					if (u) pkg_unmerge(atom->CATEGORY, basename(pf)); /* We need to really set this unmerge pending after we look at contents of the new pkg */
 					break;
 				default:
 					warn("no idea how we reached here.");
@@ -765,7 +764,7 @@
 		mkdirhier(buf, 0755);
 	strncat(buf, pkg->PF, sizeof(buf));
 
-	/* FIXME */
+	/* FIXME */ /* move unmerging to around here ? */
 	/* not perfect when a version is already installed */
 	if (access(buf, X_OK) == 0) {
 		char buf2[sizeof(buf)] = "";
@@ -1043,13 +1042,15 @@
 
 		/* fetch the package */
 		/* Check CATEGORY first */
-		snprintf(buf, sizeof(buf), "%s/%s.tbz2", atom->CATEGORY, pkg->PF);
-		fetch(str, buf);
-
+		if (!old_repo) {
+			snprintf(buf, sizeof(buf), "%s/%s.tbz2", atom->CATEGORY, pkg->PF);
+			fetch(str, buf);
+		}
 		snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
 		if (access(buf, R_OK) != 0) {
 			snprintf(buf, sizeof(buf), "%s.tbz2", pkg->PF);
 			fetch(str, buf);
+			old_repo = 1;
 		}
 
 		/* verify the pkg exists now. unlink if zero bytes */
@@ -1455,6 +1456,7 @@
 	queue *world = NULL;
 	char *fname = (char *) "/var/lib/portage/world";
 
+	/* FIXME: Add ROOT= checks here */
 	if ((fp = fopen(fname, "r")) == NULL) {
 		warn("fopen(\"%s\", \"r\"); = -1 (%s)", fname, strerror(errno));
 		return NULL;



-- 
gentoo-commits@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2008-05-10 20:21 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 39+ messages in thread
From: Diego Petteno (flameeyes) @ 2008-05-10 20:21 UTC (permalink / raw
  To: gentoo-commits

flameeyes    08/05/10 20:21:12

  Modified:             qmerge.c
  Log:
  Instead of checking for portroot's address (always valid, as it's an array), check if it's not empty or the default value (/), which seems to be the logic wanted in this case.

Revision  Changes    Path
1.80                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.80&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.80&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.79&r2=1.80

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- qmerge.c	12 Apr 2008 17:25:59 -0000	1.79
+++ qmerge.c	10 May 2008 20:21:12 -0000	1.80
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.79 2008/04/12 17:25:59 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.80 2008/05/10 20:21:12 flameeyes Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.79 2008/04/12 17:25:59 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.80 2008/05/10 20:21:12 flameeyes Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1461,7 +1461,7 @@
 	queue *world = NULL;
 	char fname[_Q_PATH_MAX];
 
-	if (portroot)
+	if (*portroot && strcmp(portroot, "/") != 0)
 		snprintf(fname, sizeof(fname), "%s/var/lib/portage/world", portroot);
 	else
 		strncpy(fname,  "/var/lib/portage/world", sizeof(fname));



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2009-03-21  6:37 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2009-03-21  6:37 UTC (permalink / raw
  To: gentoo-commits

solar       09/03/21 06:37:10

  Modified:             qmerge.c
  Log:
  - display the repo in verbose mode when it is not gentoo

Revision  Changes    Path
1.81                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.81&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.81&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.80&r2=1.81

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- qmerge.c	10 May 2008 20:21:12 -0000	1.80
+++ qmerge.c	21 Mar 2009 06:37:10 -0000	1.81
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.80 2008/05/10 20:21:12 flameeyes Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.81 2009/03/21 06:37:10 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.80 2008/05/10 20:21:12 flameeyes Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.81 2009/03/21 06:37:10 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -84,6 +84,7 @@
 	char SLOT[64];
 	size_t SIZE;
 	char USE[BUFSIZ];
+	char REPO[64];
 } Pkg;
 
 struct llist_char_t {
@@ -1120,6 +1121,9 @@
 		printf(" %sRdepend%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->RDEPEND);
 	if (pkg->USE[0])
 		printf(" %sUse%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->USE);
+	if (pkg->REPO[0])
+		if (strcmp(pkg->REPO, "gentoo") != 0)
+			printf(" %sRepo%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->REPO);
 
 	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
 	atom = atom_explode(buf);
@@ -1245,6 +1249,8 @@
 				strncpy(pkg->PF, value, sizeof(Pkg.PF));
 			if ((strcmp(buf, "CATEGORY:")) == 0)
 				strncpy(pkg->CATEGORY, value, sizeof(Pkg.CATEGORY));
+			if ((strcmp(buf, "REPO:")) == 0)
+				strncpy(pkg->REPO, value, sizeof(Pkg.REPO));
 
 			if ((strcmp(buf, "CPV:")) == 0) {
 				if ((atom = atom_explode(value)) != NULL) {
@@ -1423,6 +1429,7 @@
 				if ((strcmp(buf, "MD5:")) == 0) strncpy(Pkg.MD5, value, sizeof(Pkg.MD5));
 				break;
 			case 'R':
+				if ((strcmp(buf, "REPO:")) == 0) strncpy(Pkg.REPO, value, sizeof(Pkg.REPO));
 				if ((strcmp(buf, "RDEPEND:")) == 0) strncpy(Pkg.RDEPEND, value, sizeof(Pkg.RDEPEND));
 				break;
 			case 'L':






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2009-04-17 14:44 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2009-04-17 14:44 UTC (permalink / raw
  To: gentoo-commits

solar       09/04/17 14:44:55

  Modified:             qmerge.c
  Log:
  - make sure we can fetch foo/pkg:slot

Revision  Changes    Path
1.82                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.82&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.82&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.81&r2=1.82

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- qmerge.c	21 Mar 2009 06:37:10 -0000	1.81
+++ qmerge.c	17 Apr 2009 14:44:55 -0000	1.82
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.81 2009/03/21 06:37:10 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.82 2009/04/17 14:44:55 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.81 2009/03/21 06:37:10 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.82 2009/04/17 14:44:55 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -922,6 +922,7 @@
 	depend_atom *atom;
 	char buf[255], buf2[255];
 	int match = 0;
+	char *ptr;
 
 	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
 	if ((atom = atom_explode(buf)) == NULL)
@@ -942,6 +943,19 @@
 	if ((strcmp(name, atom->PN)) == 0)
 		match = 4;
 
+	if (match)
+		goto match_done;
+
+	if ((ptr = strchr(name, ':')) != NULL) {
+		depend_atom *subatom = atom_explode(name);
+		if (subatom == NULL)
+			goto match_done;
+		if (strcmp(atom->PN, subatom->PN) == 0)
+			match = 1;
+		atom_implode(subatom);
+	}
+
+match_done:
 	atom_implode(atom);
 
 	return match;






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2009-05-03 17:19 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2009-05-03 17:19 UTC (permalink / raw
  To: gentoo-commits

solar       09/05/03 17:19:13

  Modified:             qmerge.c
  Log:
  - Refactor fetching logic (Zdenek Behan <behanz[@]seznam[dot]cz>). bug 266455

Revision  Changes    Path
1.83                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.83&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.83&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.82&r2=1.83

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- qmerge.c	17 Apr 2009 14:44:55 -0000	1.82
+++ qmerge.c	3 May 2009 17:19:13 -0000	1.83
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.82 2009/04/17 14:44:55 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.83 2009/05/03 17:19:13 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.82 2009/04/17 14:44:55 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.83 2009/05/03 17:19:13 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -98,10 +98,11 @@
 void fetch(const char *, const char *);
 void qmerge_initialize(const char *);
 char *best_version(const char *, const char  *);
+void pkg_fetch(int, depend_atom *, struct pkg_t *);
 void pkg_merge(int, depend_atom *, struct pkg_t *);
 int pkg_unmerge(char *, char *);
 int unlink_empty(char *);
-void pkg_fetch(int, char **, struct pkg_t *);
+void pkg_process(int, char **, struct pkg_t *);
 void print_Pkg(int, struct pkg_t *);
 int parse_packages(const char *, int, char **);
 int config_protected(const char *, int, char **);
@@ -509,7 +510,7 @@
 						IF_DEBUG(fprintf(stderr, "+Installed: %s\n", p));
 						if (strlen(p) < 1)
 							if (!((strcmp(pkg->PF, subpkg->PF) == 0) && (strcmp(pkg->CATEGORY, subpkg->CATEGORY) == 0)))
-								pkg_merge(level+1, ratom, subpkg);
+								pkg_fetch(level+1, ratom, subpkg);
 
 						atom_implode(subatom);
 						atom_implode(ratom);
@@ -1004,23 +1005,18 @@
 	return ret;
 }
 
-void pkg_fetch(int argc, char **argv, struct pkg_t *pkg)
+void pkg_process(int argc, char **argv, struct pkg_t *pkg)
 {
 	depend_atom *atom;
-	char savecwd[_POSIX_PATH_MAX];
-	char buf[255], str[255];
+	char buf[255];
 	int i;
 
 	memset(buf, 0, sizeof(buf));
-	memset(str, 0, sizeof(str));
 
 	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
 	if ((atom = atom_explode(buf)) == NULL)
 		errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF);
 
-	snprintf(str, sizeof(str), "%s/%s", pkgdir, pkg->CATEGORY);
-	mkdir(str, 0755);
-
 	for (i = 1; i < argc; i++) {
 		if (argv[i][0] == '-')
 			continue;
@@ -1029,79 +1025,93 @@
 		if (match_pkg(argv[i], pkg) < 1)
 			continue;
 
-		/* qmerge -pv patch */
-		if (pretend) {
-			int level = 0;
-			if (!install) install++;
-			/* qprint_tree_node(level, atom, pkg); */
-			pkg_merge(level, atom, pkg);
-			continue;
-		}
+		pkg_fetch(0, atom, pkg);
+	}
+	/* free the atom */
+	atom_implode(atom);
+}
 
-		/* check to see if file exists and it's checksum matches */
-		snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, pkg->CATEGORY, pkg->PF);
-		unlink_empty(buf);
-
-		if ((force_download) && (access(buf, R_OK) == 0) && ((pkg->SHA1[0]) || (pkg->MD5[0]))) {
-			if ((pkg_verify_checksums(buf, pkg, atom, 0, 0)) != 0)
-				unlink(buf);
-		}
-		if (access(buf, R_OK) == 0) {
-			if ((!pkg->SHA1[0]) && (!pkg->MD5[0])) {
-				warn("No checksum data for %s", buf);
-				continue;
-			} else {
-				if ((pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1)) == 0) {
-					pkg_merge(0, atom, pkg);
-					continue;
-				}
-			}
-		}
-		if (verbose)
-			printf("Fetching %s/%s.tbz2\n", atom->CATEGORY, pkg->PF);
+void pkg_fetch(int level, depend_atom *atom, struct pkg_t *pkg)
+{
+	char savecwd[_POSIX_PATH_MAX];
+	char buf[255], str[255];
+	memset(str, 0, sizeof(str));
 
-		/* fetch the package */
-		/* Check CATEGORY first */
-		if (!old_repo) {
-			snprintf(buf, sizeof(buf), "%s/%s.tbz2", atom->CATEGORY, pkg->PF);
-			fetch(str, buf);
-		}
-		snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
-		if (access(buf, R_OK) != 0) {
-			snprintf(buf, sizeof(buf), "%s.tbz2", pkg->PF);
-			fetch(str, buf);
-			old_repo = 1;
-		}
-
-		/* verify the pkg exists now. unlink if zero bytes */
-		snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
-		unlink_empty(buf);
-
-		if (access(buf, R_OK) != 0) {
-			warn("Failed to fetch %s.tbz2 from %s", pkg->PF, binhost);
-			fflush(stderr);
-			continue;
-		}
-		getcwd(savecwd, sizeof(savecwd));
-		assert(chdir(pkgdir) == 0);
-		if (chdir("All/") == 0) {
-			snprintf(buf, sizeof(buf), "%s.tbz2", pkg->PF);
-			snprintf(str, sizeof(str), "../%s/%s.tbz2", atom->CATEGORY, pkg->PF);
+	/* qmerge -pv patch */
+	if (pretend) {
+		if (!install) install++;
+		/* qprint_tree_node(level, atom, pkg); */
+		pkg_merge(level, atom, pkg);
+		return;
+	}
+
+	/* check to see if file exists and it's checksum matches */
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, pkg->CATEGORY, pkg->PF);
+	unlink_empty(buf);
+
+	snprintf(str, sizeof(str), "%s/%s", pkgdir, pkg->CATEGORY);
+	mkdir(str, 0755);
+
+	if ((force_download) && (access(buf, R_OK) == 0) && ((pkg->SHA1[0]) || (pkg->MD5[0]))) {
+		if ((pkg_verify_checksums(buf, pkg, atom, 0, 0)) != 0)
 			unlink(buf);
-			symlink(str, buf);
+	}
+	if (access(buf, R_OK) == 0) {
+		if ((!pkg->SHA1[0]) && (!pkg->MD5[0])) {
+			warn("No checksum data for %s", buf);
+			return;
+		} else {
+			if ((pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1)) == 0) {
+				pkg_merge(0, atom, pkg);
+				return;
+			}
 		}
-		chdir(savecwd);
+	}
+	if (verbose)
+		printf("Fetching %s/%s.tbz2\n", atom->CATEGORY, pkg->PF);
 
-		snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
-		if ((pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1)) == 0) {
-			pkg_merge(0, atom, pkg);
-			continue;
-		}
+	/* fetch the package */
+	/* Check CATEGORY first */
+	if (!old_repo) {
+		snprintf(buf, sizeof(buf), "%s/%s.tbz2", atom->CATEGORY, pkg->PF);
+		fetch(str, buf);
+	}
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
+	if (access(buf, R_OK) != 0) {
+		snprintf(buf, sizeof(buf), "%s.tbz2", pkg->PF);
+		fetch(str, buf);
+		old_repo = 1;
+	}
+
+	/* verify the pkg exists now. unlink if zero bytes */
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
+	unlink_empty(buf);
+
+	if (access(buf, R_OK) != 0) {
+		warn("Failed to fetch %s.tbz2 from %s", pkg->PF, binhost);
+		fflush(stderr);
+		return;
+	}
+	getcwd(savecwd, sizeof(savecwd));
+	assert(chdir(pkgdir) == 0);
+	if (chdir("All/") == 0) {
+		snprintf(buf, sizeof(buf), "%s.tbz2", pkg->PF);
+		snprintf(str, sizeof(str), "../%s/%s.tbz2", atom->CATEGORY, pkg->PF);
+		unlink(buf);
+		symlink(str, buf);
+	}
+	chdir(savecwd);
+
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
+	if ((pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1)) == 0) {
+		pkg_merge(0, atom, pkg);
+		return;
 	}
-	/* free the atom */
-	atom_implode(atom);
 }
 
+
+
+
 void print_Pkg(int full, struct pkg_t *pkg)
 {
 	char *p = NULL;
@@ -1407,8 +1417,7 @@
 						print_Pkg(verbose, pkg);
 					}
 				} else {
-					/* this name is misleading */
-					pkg_fetch(argc, argv, pkg);
+					pkg_process(argc, argv, pkg);
 				}
 				free(pkg);
 			}






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2010-01-13  6:14 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2010-01-13  6:14 UTC (permalink / raw
  To: gentoo-commits

solar       10/01/13 06:14:40

  Modified:             qmerge.c
  Log:
  - Be less restrictive on allowing merges when rdeps are not used

Revision  Changes    Path
1.85                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.85&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.85&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.84&r2=1.85

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- qmerge.c	8 Sep 2009 03:05:40 -0000	1.84
+++ qmerge.c	13 Jan 2010 06:14:40 -0000	1.85
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.84 2009/09/08 03:05:40 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.85 2010/01/13 06:14:40 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.84 2009/09/08 03:05:40 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.85 2010/01/13 06:14:40 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1556,7 +1556,7 @@
 
 	/* Short circut this. */
 	if ((install || uninstall) && !pretend) {
-		if (getenv("QMERGE") == NULL) {
+		if (follow_rdepends && getenv("QMERGE") == NULL) {
 			uninstall = 0;
 			install = 0;
 			warn("Using these options are likely to break your system at this point. export QMERGE=1; if you think you know what your doing.");






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2010-01-13 19:15 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2010-01-13 19:15 UTC (permalink / raw
  To: gentoo-commits

vapier      10/01/13 19:15:17

  Modified:             qmerge.c
  Log:
  introduce and use xsystem()

Revision  Changes    Path
1.91                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.91&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.91&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.90&r2=1.91

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- qmerge.c	13 Jan 2010 19:11:02 -0000	1.90
+++ qmerge.c	13 Jan 2010 19:15:16 -0000	1.91
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.90 2010/01/13 19:11:02 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.91 2010/01/13 19:15:16 vapier Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.90 2010/01/13 19:11:02 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.91 2010/01/13 19:15:16 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -197,7 +197,7 @@
 		snprintf(buf, sizeof(buf), "%s " BUSYBOX " wget %s -P %s %s/%s", (force_download || install) ? "" : pretend ? "echo " : "",
 			(quiet ? "-q" : ""), destdir, binhost, src);
 	}
-	system(buf);
+	xsystem(buf);
 	fflush(stdout);
 	fflush(stderr);
 }
@@ -294,7 +294,7 @@
 	}
 	qprintf("%s<<<%s %s\n", YELLOW, NORM, buf);
 	snprintf(buf, size, BUSYBOX " rm -rf ./%s", fname);
-	system(buf);
+	xsystem(buf);
 }
 
 void install_mask_pwd(int argc, char **argv, const struct stat st);
@@ -531,7 +531,7 @@
 	/* mkdir(pkg->PF, 0710); */
 	xchdir(pkg->PF);
 
-	system(BUSYBOX " rm -rf ./*"); /* this line does funny things to nano's highlighting. */
+	xsystem(BUSYBOX " rm -rf ./*"); /* this line does funny things to nano's highlighting. */
 
 	/* split the tbz and xpak data */
 	snprintf(tarball, sizeof(tarball), "%s.tbz2", pkg->PF);
@@ -558,11 +558,11 @@
 	/* list and extract vdb files from the xpak */
 	snprintf(buf, sizeof(buf), "qxpak -d %s/%s/vdb -x %s.xpak `qxpak -l %s.xpak`",
 		port_tmpdir, pkg->PF, pkg->PF, pkg->PF);
-	system(buf);
+	xsystem(buf);
 
 	/* extrct the binary package data */
 	snprintf(buf, sizeof(buf), BUSYBOX " tar -jx%sf %s.tar.bz2 -C image/", ((verbose > 1) ? "v" : ""), pkg->PF);
-	system(buf);
+	xsystem(buf);
 	fflush(stdout);
 
 	/* check for an already installed pkg */
@@ -610,9 +610,9 @@
 	makeargv(install_mask, &iargc, &iargv);
 	install_mask_pwd(iargc, iargv, st);
 
-	if ((strstr(features, "noinfo")) != NULL) if (access("./usr/share/info", R_OK) == 0) system(BUSYBOX " rm -rf ./usr/share/info");
-	if ((strstr(features, "noman"))  != NULL) if (access("./usr/share/man",  R_OK) == 0) system(BUSYBOX " rm -rf ./usr/share/man");
-	if ((strstr(features, "nodoc"))  != NULL) if (access("./usr/share/doc",  R_OK) == 0) system(BUSYBOX " rm -rf ./usr/share/doc");
+	if ((strstr(features, "noinfo")) != NULL) if (access("./usr/share/info", R_OK) == 0) xsystem(BUSYBOX " rm -rf ./usr/share/info");
+	if ((strstr(features, "noman"))  != NULL) if (access("./usr/share/man",  R_OK) == 0) xsystem(BUSYBOX " rm -rf ./usr/share/man");
+	if ((strstr(features, "nodoc"))  != NULL) if (access("./usr/share/doc",  R_OK) == 0) xsystem(BUSYBOX " rm -rf ./usr/share/doc");
 
 	/* we dont care about the return code */
 	rmdir("./usr/share");
@@ -688,7 +688,7 @@
 					qprintf("%s***%s %s\n", BRYELLOW, NORM, &buf[1]);
 					if (verbose) {
 						snprintf(newbuf, sizeof(newbuf), "diff -u %s %s", buf, dest);
-						system(newbuf);
+						xsystem(newbuf);
 					}
 					continue;
 				}
@@ -775,7 +775,7 @@
 		char buf2[sizeof(buf)] = "";
 		/* we need to compare CONTENTS in it and remove any file not provided by our CONTENTS */
 		snprintf(buf2, sizeof(buf2), BUSYBOX " rm -rf %s", buf);
-		system(buf2);
+		xsystem(buf2);
 	}
 	if ((fp = fopen("vdb/COUNTER", "w")) != NULL) {
 		fputs("0", fp);
@@ -787,7 +787,7 @@
 	if (which("ebuild") != NULL) {
 		char *tbuf;
 		xasprintf(&tbuf, "ebuild %s/%s.ebuild postinst", buf, basename(buf));
-		system(tbuf);
+		xsystem(tbuf);
 		free(tbuf);
 	}
 
@@ -795,7 +795,7 @@
 	unlink_q(buf);
 	xchdir(port_tmpdir);
 	snprintf(buf, sizeof(buf), "rm -rf %s", pkg->PF);
-	system(buf);
+	xsystem(buf);
 
 	snprintf(buf, sizeof(buf), "%s/%s.tbz2", pkgdir, pkg->PF);
 	unlink(buf);
@@ -902,7 +902,7 @@
 
 	if (!pretend) {
 		snprintf(buf, sizeof(buf), BUSYBOX " rm -rf %s/%s/%s/%s", portroot, portvdb, cat, pkgname);
-		system(buf);
+		xsystem(buf);
 	}
 	return 1;
 }






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2010-01-18  6:30 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2010-01-18  6:30 UTC (permalink / raw
  To: gentoo-commits

solar       10/01/18 06:30:26

  Modified:             qmerge.c
  Log:
  - when DEFINED_PHASES exists no longer run postinst unless it is defined

Revision  Changes    Path
1.93                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.93&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?rev=1.93&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qmerge.c?r1=1.92&r2=1.93

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- qmerge.c	13 Jan 2010 19:16:22 -0000	1.92
+++ qmerge.c	18 Jan 2010 06:30:26 -0000	1.93
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2007 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.92 2010/01/13 19:16:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.93 2010/01/18 06:30:26 solar Exp $
  *
  * Copyright 2005-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2007 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.92 2010/01/13 19:16:22 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.93 2010/01/18 06:30:26 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -402,6 +402,18 @@
 	return c;
 }
 
+int has_postinst(char *vdbroot);
+int has_postinst(char *vdbroot) {
+	FILE *fp;
+	char buf[1024];
+	snprintf(buf, sizeof(buf), "%s/%s", vdbroot, "DEFINED_PHASES");
+	if ((fp = fopen(buf,  "r")) == NULL)
+		return 1;
+	fgets(buf, sizeof(buf), fp);
+	fclose(fp);
+	return ((strstr(buf, "postinst") == NULL) ? 0 : 2);
+}
+
 /* oh shit getting into pkg mgt here. FIXME: write a real dep resolver. */
 void pkg_merge(int level, depend_atom *atom, struct pkg_t *pkg)
 {
@@ -784,7 +796,7 @@
 	interactive_rename("vdb", buf, pkg);
 
 	/* run postinst on non embedded systems */
-	if (which("ebuild") != NULL) {
+	if ((which("ebuild") != NULL) && has_postinst(buf)) {
 		char *tbuf;
 		xasprintf(&tbuf, "ebuild %s/%s.ebuild postinst", buf, basename(buf));
 		xsystem(tbuf);






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2010-06-08  4:52 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2010-06-08  4:52 UTC (permalink / raw
  To: gentoo-commits

vapier      10/06/08 04:52:42

  Modified:             qmerge.c
  Log:
  fix unused fgets() result warning

Revision  Changes    Path
1.95                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.95&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.95&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.94&r2=1.95

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- qmerge.c	7 Apr 2010 05:58:16 -0000	1.94
+++ qmerge.c	8 Jun 2010 04:52:42 -0000	1.95
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.94 2010/04/07 05:58:16 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.95 2010/06/08 04:52:42 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.94 2010/04/07 05:58:16 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.95 2010/06/08 04:52:42 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -402,16 +402,20 @@
 	return c;
 }
 
-int has_postinst(char *vdbroot);
-int has_postinst(char *vdbroot) {
+static int has_postinst(char *vdbroot)
+{
 	FILE *fp;
+	int ret;
 	char buf[1024];
 	snprintf(buf, sizeof(buf), "%s/%s", vdbroot, "DEFINED_PHASES");
 	if ((fp = fopen(buf,  "r")) == NULL)
 		return 1;
-	fgets(buf, sizeof(buf), fp);
+	if (fgets(buf, sizeof(buf), fp))
+		ret = (strstr(buf, "postinst") == NULL) ? 0 : 2;
+	else
+		ret = 0;
 	fclose(fp);
-	return ((strstr(buf, "postinst") == NULL) ? 0 : 2);
+	return ret;
 }
 
 /* oh shit getting into pkg mgt here. FIXME: write a real dep resolver. */






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-02-21  1:52 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-02-21  1:52 UTC (permalink / raw
  To: gentoo-commits

vapier      11/02/21 01:52:46

  Modified:             qmerge.c
  Log:
  clean up style a bit

Revision  Changes    Path
1.98                 portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.98&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.98&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.97&r2=1.98

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- qmerge.c	21 Feb 2011 01:33:47 -0000	1.97
+++ qmerge.c	21 Feb 2011 01:52:46 -0000	1.98
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.97 2011/02/21 01:33:47 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.98 2011/02/21 01:52:46 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.97 2011/02/21 01:33:47 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.98 2011/02/21 01:52:46 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -113,8 +113,8 @@
 
 struct pkg_t *grab_binpkg_info(const char *);
 
-int mkdirhier(char *dname, mode_t mode);
-int mkdirhier(char *dname, mode_t mode) {
+static int mkdirhier(char *dname, mode_t mode)
+{
 	char buf[BUFSIZ];
 	int i;
 	strncpy(buf, dname, sizeof(buf));
@@ -157,7 +157,7 @@
 		snprintf(buf, sizeof(buf), "qfile -Cqev %s 2>/dev/null", dst);
 		if ((fp = popen(buf, "r")) != NULL) {
 			buf[0] = '\0';
-			if ((fgets(buf, sizeof(buf), fp)) != NULL)
+			if (fgets(buf, sizeof(buf), fp) != NULL)
 				if ((p = strchr(buf, '\n')) != NULL) {
 					*p = 0;
 					p = xstrdup(buf);
@@ -218,7 +218,7 @@
 		errf("PORTAGE_BINHOST= does not appear to be valid");
 
 	if (!search_pkgs && !pretend) {
-		if ((access(pkgdir, R_OK|W_OK|X_OK)) != 0)
+		if (access(pkgdir, R_OK|W_OK|X_OK) != 0)
 			errf("Wrong perms on PKGDIR='%s'", pkgdir);
 		mkdir(port_tmpdir, 0755);
 	}
@@ -230,11 +230,11 @@
 		unlink(Packages);
 
 	if ((access(Packages, R_OK) != 0) && (force_download != 2)) {
-			char *tbuf = NULL;
-			xasprintf(&tbuf, "%s/portage/", port_tmpdir);
-		        if ((access(Packages, R_OK) != 0))
-				fetch(tbuf, Packages);
-			free(tbuf);
+		char *tbuf = NULL;
+		xasprintf(&tbuf, "%s/portage/", port_tmpdir);
+		if (access(Packages, R_OK) != 0)
+			fetch(tbuf, Packages);
+		free(tbuf);
 	}
 }
 
@@ -252,7 +252,7 @@
 		return NULL;
 
 	buf[0] = '\0';
-	if ((fgets(buf, sizeof(buf), fp)) != NULL)
+	if (fgets(buf, sizeof(buf), fp) != NULL)
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
 	pclose(fp);
@@ -267,14 +267,14 @@
 	snprintf(dest, sizeof(dest), "%s%s", portroot, buf);
 
 	for (i = 1; i < ARGC; i++)
-		if ((strncmp(ARGV[i], buf, strlen(ARGV[i]))) == 0)
+		if (strncmp(ARGV[i], buf, strlen(ARGV[i])) == 0)
 			if ((access(dest, R_OK)) == 0)
 				return 1;
 
-	if ((strncmp("/etc", buf, 4)) == 0)
-		if ((access(dest, R_OK)) == 0)
+	if (strncmp("/etc", buf, 4) == 0)
+		if (access(dest, R_OK) == 0)
 			return 1;
-	if ((strcmp("/bin/sh", buf)) == 0)
+	if (strcmp("/bin/sh", buf) == 0)
 		return 1;
 	return 0;
 }
@@ -315,7 +315,7 @@
 			glob_t globbuf;
 
 			globbuf.gl_offs = 0;
-			if ((glob(buf, GLOB_DOOFFS|GLOB_BRACE, NULL, &globbuf)) == 0) {
+			if (glob(buf, GLOB_DOOFFS|GLOB_BRACE, NULL, &globbuf) == 0) {
 				for (g = 0; g < globbuf.gl_pathc; g++) {
 					strncpy(buf, globbuf.gl_pathv[g], sizeof(buf));
 					/* qprintf("globbed: %s\n", globbuf.gl_pathv[g]); */
@@ -374,11 +374,11 @@
 		}
 		if (update_only && c != 'U')
 			return c;
-		if (((c == 'R') || (c == 'D')) && update_only && level)
+		if ((c == 'R' || c == 'D') && update_only && level)
 			return c;
 		if (c == 'R')
 			snprintf(buf, sizeof(buf), "%s%c%s", YELLOW, c, NORM);
-		if ((c == 'U') || (c == 'D'))
+		if (c == 'U' || c == 'D')
 			snprintf(buf, sizeof(buf), "%s%c%s", BLUE, c, NORM);
 #if 0
 		if (level) {
@@ -393,7 +393,8 @@
 #endif
 	}
 	printf("[%s] ", buf);
-	for (i = 0; i < level; i++) putchar(' ');
+	for (i = 0; i < level; ++i)
+		putchar(' ');
 	if (verbose)
 		printf("%s%s/%s%s %s%s%s%s%s%s\n", DKGREEN, pkg->CATEGORY, pkg->PF, NORM,
 			install_ver, strlen(pkg->USE) > 0 ? "(" : "", RED, pkg->USE, NORM, strlen(pkg->USE) > 0 ? ")" : "");
@@ -493,7 +494,7 @@
 							if (virtuals == NULL)
 								virtuals = resolve_virtuals();
 							resolved = find_binpkg(virtual(name, virtuals));
-							if ((resolved == NULL) || (!strlen(resolved)))
+							if (resolved == NULL || !strlen(resolved))
 								resolved = find_binpkg(name);
 						} else
 							resolved = NULL;
@@ -643,7 +644,7 @@
 
 	makeargv(config_protect, &ARGC, &ARGV);
 
-	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		char line[BUFSIZ];
 		int protected = 0;
 		char matched = 0;
@@ -655,7 +656,7 @@
 		if (buf[0] != '.')
 			continue;
 
-		if (((strcmp(buf, ".")) == 0) || ((strcmp(buf, "..")) == 0))
+		if ((strcmp(buf, ".") == 0) || (strcmp(buf, "..") == 0))
 			continue;
 
 		for (i = 1; i < iargc; i++) {
@@ -676,8 +677,8 @@
 
 		/* portage has code that handes fifo's but it looks unused */
 
-		if ((S_ISCHR(st.st_mode)) || \
-			(S_ISBLK(st.st_mode))); /* block or character device */
+		if (S_ISCHR(st.st_mode) ||
+			S_ISBLK(st.st_mode)); /* block or character device */
 		if (S_ISFIFO(st.st_mode));	/* FIFO (named pipe) */
 		if (S_ISSOCK(st.st_mode));	/* socket? (Not in POSIX.1-1996.) */
 
@@ -711,7 +712,7 @@
 					continue;
 				}
 			}
-			if ((lstat(dest, &lst)) != (-1)) {
+			if (lstat(dest, &lst) != -1) {
 				if (S_ISLNK(lst.st_mode)) {
 					warn("%s exists and is a symlink and we are going to overwrite it with a file", dest);
 					unlink_q(dest);
@@ -844,7 +845,7 @@
 	argv = NULL;
 	makeargv(config_protect, &argc, &argv);
 
-	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		contents_entry *e;
 		char zing[20];
 		int protected = 0;
@@ -928,10 +929,10 @@
 int unlink_empty(char *buf)
 {
 	struct stat st;
-	if ((stat(buf, &st)) != (-1))
+	if (stat(buf, &st) != -1)
 		if (st.st_size == 0)
 			return unlink(buf);
-	return (-1);
+	return -1;
 }
 
 int match_pkg(const char *name, struct pkg_t *pkg)
@@ -946,18 +947,18 @@
 		errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF);
 
 	/* verify this is the requested package */
-	if ((strcmp(name, buf)) == 0)
+	if (strcmp(name, buf) == 0)
 		match = 1;
 
-	if ((strcmp(name, pkg->PF)) == 0)
+	if (strcmp(name, pkg->PF) == 0)
 		match = 2;
 
 	snprintf(buf2, sizeof(buf2), "%s/%s", pkg->CATEGORY, atom->PN);
 
-	if ((strcmp(name, buf2)) == 0)
+	if (strcmp(name, buf2) == 0)
 		match = 3;
 
-	if ((strcmp(name, atom->PN)) == 0)
+	if (strcmp(name, atom->PN) == 0)
 		match = 4;
 
 	if (match)
@@ -1068,16 +1069,16 @@
 	snprintf(str, sizeof(str), "%s/%s", pkgdir, pkg->CATEGORY);
 	mkdir(str, 0755);
 
-	if ((force_download) && (access(buf, R_OK) == 0) && ((pkg->SHA1[0]) || (pkg->MD5[0]))) {
-		if ((pkg_verify_checksums(buf, pkg, atom, 0, 0)) != 0)
+	if (force_download && (access(buf, R_OK) == 0) && (pkg->SHA1[0] || pkg->MD5[0])) {
+		if (pkg_verify_checksums(buf, pkg, atom, 0, 0) != 0)
 			unlink(buf);
 	}
 	if (access(buf, R_OK) == 0) {
-		if ((!pkg->SHA1[0]) && (!pkg->MD5[0])) {
+		if (!pkg->SHA1[0] && !pkg->MD5[0]) {
 			warn("No checksum data for %s", buf);
 			return;
 		} else {
-			if ((pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1)) == 0) {
+			if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1) == 0) {
 				pkg_merge(0, atom, pkg);
 				return;
 			}
@@ -1120,7 +1121,7 @@
 	xchdir(savecwd);
 
 	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
-	if ((pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1)) == 0) {
+	if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, 1) == 0) {
 		pkg_merge(0, atom, pkg);
 		return;
 	}
@@ -1231,7 +1232,7 @@
 	if ((fp = fopen(buf, "r")) == NULL)
 		errp("Unable to open package file %s", buf);
 
-	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		if (*buf == '\n') {
 			if (pkg->PF[0] && pkg->CATEGORY[0]) {
 				int ret;
@@ -1281,16 +1282,16 @@
 
 		if (*buf) {
 			/* we dont need all the info */
-			if ((strcmp(buf, "RDEPEND:")) == 0)
+			if (strcmp(buf, "RDEPEND:") == 0)
 				strncpy(pkg->RDEPEND, value, sizeof(Pkg.RDEPEND));
-			if ((strcmp(buf, "PF:")) == 0)
+			if (strcmp(buf, "PF:") == 0)
 				strncpy(pkg->PF, value, sizeof(Pkg.PF));
-			if ((strcmp(buf, "CATEGORY:")) == 0)
+			if (strcmp(buf, "CATEGORY:") == 0)
 				strncpy(pkg->CATEGORY, value, sizeof(Pkg.CATEGORY));
-			if ((strcmp(buf, "REPO:")) == 0)
+			if (strcmp(buf, "REPO:") == 0)
 				strncpy(pkg->REPO, value, sizeof(Pkg.REPO));
 
-			if ((strcmp(buf, "CPV:")) == 0) {
+			if (strcmp(buf, "CPV:") == 0) {
 				if ((atom = atom_explode(value)) != NULL) {
 					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
 					if (atom->PR_int)
@@ -1300,15 +1301,15 @@
 					atom_implode(atom);
 				}
 			}
-			if ((strcmp(buf, "SLOT:")) == 0)
+			if (strcmp(buf, "SLOT:") == 0)
 				strncpy(pkg->SLOT, value, sizeof(Pkg.SLOT));
-			if ((strcmp(buf, "USE:")) == 0)
+			if (strcmp(buf, "USE:") == 0)
 				strncpy(pkg->USE, value, sizeof(Pkg.USE));
 
 			/* checksums. We must have 1 or the other unless --*/
-			if ((strcmp(buf, "MD5:")) == 0)
+			if (strcmp(buf, "MD5:") == 0)
 				strncpy(pkg->MD5, value, sizeof(Pkg.MD5));
-			if ((strcmp(buf, "SHA1:")) == 0)
+			if (strcmp(buf, "SHA1:") == 0)
 				strncpy(pkg->SHA1, value, sizeof(Pkg.SHA1));
 		}
 	}
@@ -1337,7 +1338,7 @@
 	if ((fp = fopen(buf, "r")) == NULL)
 		errp("Unable to open package file %s", buf);
 
-	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		if (*buf == '\n') {
 			if (PF[0] && CATEGORY[0]) {
 				int ret;
@@ -1381,7 +1382,7 @@
 		strncpy(value, p, sizeof(value));
 
 		if (*buf) {
-			if ((strcmp(buf, "CPV:")) == 0) {
+			if (strcmp(buf, "CPV:") == 0) {
 				depend_atom *atom;
 				if ((atom = atom_explode(value)) != NULL) {
 					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
@@ -1392,9 +1393,9 @@
 					atom_implode(atom);
 				}
 			}
-			if ((strcmp(buf, "PF:")) == 0)
+			if (strcmp(buf, "PF:") == 0)
 				strncpy(PF, value, sizeof(PF));
-			if ((strcmp(buf, "CATEGORY:")) == 0)
+			if (strcmp(buf, "CATEGORY:") == 0)
 				strncpy(CATEGORY, value, sizeof(CATEGORY));
 		}
 	}
@@ -1416,7 +1417,7 @@
 
 	memset(&Pkg, 0, sizeof(Pkg));
 
-	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		lineno++;
 		if (*buf == '\n') {
 			if ((strlen(Pkg.PF) > 0) && (strlen(Pkg.CATEGORY) > 0)) {
@@ -1452,29 +1453,29 @@
 
 		switch (*buf) {
 			case 'U':
-				if ((strcmp(buf, "USE:")) == 0) strncpy(Pkg.USE, value, sizeof(Pkg.USE));
+				if (strcmp(buf, "USE:") == 0) strncpy(Pkg.USE, value, sizeof(Pkg.USE));
 				break;
 			case 'P':
-				if ((strcmp(buf, "PF:")) == 0) strncpy(Pkg.PF, value, sizeof(Pkg.PF));
+				if (strcmp(buf, "PF:") == 0) strncpy(Pkg.PF, value, sizeof(Pkg.PF));
 				break;
 			case 'S':
-				if ((strcmp(buf, "SIZE:")) == 0) Pkg.SIZE = atol(value);
-				if ((strcmp(buf, "SLOT:")) == 0) strncpy(Pkg.SLOT, value, sizeof(Pkg.SLOT));
-				if ((strcmp(buf, "SHA1:")) == 0) strncpy(Pkg.SHA1, value, sizeof(Pkg.SHA1));
+				if (strcmp(buf, "SIZE:") == 0) Pkg.SIZE = atol(value);
+				if (strcmp(buf, "SLOT:") == 0) strncpy(Pkg.SLOT, value, sizeof(Pkg.SLOT));
+				if (strcmp(buf, "SHA1:") == 0) strncpy(Pkg.SHA1, value, sizeof(Pkg.SHA1));
 				break;
 			case 'M':
-				if ((strcmp(buf, "MD5:")) == 0) strncpy(Pkg.MD5, value, sizeof(Pkg.MD5));
+				if (strcmp(buf, "MD5:") == 0) strncpy(Pkg.MD5, value, sizeof(Pkg.MD5));
 				break;
 			case 'R':
-				if ((strcmp(buf, "REPO:")) == 0) strncpy(Pkg.REPO, value, sizeof(Pkg.REPO));
-				if ((strcmp(buf, "RDEPEND:")) == 0) strncpy(Pkg.RDEPEND, value, sizeof(Pkg.RDEPEND));
+				if (strcmp(buf, "REPO:") == 0) strncpy(Pkg.REPO, value, sizeof(Pkg.REPO));
+				if (strcmp(buf, "RDEPEND:") == 0) strncpy(Pkg.RDEPEND, value, sizeof(Pkg.RDEPEND));
 				break;
 			case 'L':
-				if ((strcmp(buf, "LICENSE:")) == 0) strncpy(Pkg.LICENSE, value, sizeof(Pkg.LICENSE));
+				if (strcmp(buf, "LICENSE:") == 0) strncpy(Pkg.LICENSE, value, sizeof(Pkg.LICENSE));
 				break;
 			case 'C':
-				if ((strcmp(buf, "CATEGORY:")) == 0) strncpy(Pkg.CATEGORY, value, sizeof(Pkg.CATEGORY));
-				if ((strcmp(buf, "CPV:")) == 0) {
+				if (strcmp(buf, "CATEGORY:") == 0) strncpy(Pkg.CATEGORY, value, sizeof(Pkg.CATEGORY));
+				if (strcmp(buf, "CPV:") == 0) {
 					depend_atom *atom;
 					if ((atom = atom_explode(value)) != NULL) {
 						snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
@@ -1487,7 +1488,7 @@
 				}
 				break;
 			case 'D':
-				if ((strcmp(buf, "DESC:")) == 0) strncpy(Pkg.DESC, value, sizeof(Pkg.DESC));
+				if (strcmp(buf, "DESC:") == 0) strncpy(Pkg.DESC, value, sizeof(Pkg.DESC));
 				break;
 			default:
 				break;
@@ -1499,7 +1500,8 @@
 }
 
 queue *get_world(void);
-queue *get_world(void) {
+queue *get_world(void)
+{
 	FILE *fp;
 	char buf[BUFSIZ];
 	queue *world = NULL;
@@ -1515,7 +1517,7 @@
 		return NULL;
 	}
 
-	while ((fgets(buf, sizeof(buf), fp)) != NULL) {
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		char *p;
 		char *slot = (char *) "0";
 
@@ -1532,12 +1534,13 @@
 }
 
 queue *qmerge_load_set(char *, queue *);
-queue *qmerge_load_set(char *buf, queue *set) {
+queue *qmerge_load_set(char *buf, queue *set)
+{
 	if (set != NULL)
 		return set;
-	if ((strcmp(buf, "world") == 0))
+	if (strcmp(buf, "world") == 0)
 		return get_world();
-	if ((strcmp(buf, "all") == 0))
+	if (strcmp(buf, "all") == 0)
 		return get_vdb_atoms(0);
 	return NULL;
 }
@@ -1545,7 +1548,7 @@
 int qmerge_main(int argc, char **argv)
 {
 	int i;
-	const char *Packages = "Packages";
+	const char Packages[] = "Packages";
 	int ARGC = argc;
 	char **ARGV = argv;
 






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-02-21 22:02 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-02-21 22:02 UTC (permalink / raw
  To: gentoo-commits

vapier      11/02/21 22:02:59

  Modified:             qmerge.c
  Log:
  add support for CONFIG_PROTECT_MASK when unmerging, as well as running the pkg_{pre,post}rm funcs

Revision  Changes    Path
1.100                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.100&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.100&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.99&r2=1.100

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- qmerge.c	21 Feb 2011 06:20:24 -0000	1.99
+++ qmerge.c	21 Feb 2011 22:02:59 -0000	1.100
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.99 2011/02/21 06:20:24 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.100 2011/02/21 22:02:59 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.99 2011/02/21 06:20:24 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.100 2011/02/21 22:02:59 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -105,7 +105,6 @@
 void pkg_process(int, char **, struct pkg_t *);
 void print_Pkg(int, struct pkg_t *);
 int parse_packages(const char *, int, char **);
-int config_protected(const char *, int, char **);
 int match_pkg(const char *, struct pkg_t *);
 int pkg_verify_checksums(char *, struct pkg_t *, depend_atom *, int strict, int display);
 int unmerge_packages(int, char **);
@@ -129,8 +128,7 @@
 	return mkdir(dname, mode);
 }
 
-int q_unlink_q(char *, const char *, int);
-int q_unlink_q(char *path, const char *func, int line)
+static int q_unlink_q(char *path, const char *func, int line)
 {
 	if ((strcmp(path, "/bin/sh") == 0) || (strcmp(path, BUSYBOX) == 0)) {
 		warn("Oh hell no: unlink(%s) from %s line %d", path, func, line);
@@ -153,7 +151,7 @@
 	struct stat st;
 	char check_interactive = interactive;
 
-	if (check_interactive && (stat(dst, &st) != (-1))) {
+	if (check_interactive && (stat(dst, &st) != -1)) {
 		snprintf(buf, sizeof(buf), "qfile -Cqev %s 2>/dev/null", dst);
 		if ((fp = popen(buf, "r")) != NULL) {
 			buf[0] = '\0';
@@ -260,22 +258,29 @@
 	return (char *) buf;
 }
 
-int config_protected(const char *buf, int ARGC, char **ARGV)
+static int
+config_protected(const char *buf, int cp_argc, char **cp_argv,
+                 int cpm_argc, char **cpm_argv)
 {
 	int i;
 	char dest[_Q_PATH_MAX];
 	snprintf(dest, sizeof(dest), "%s%s", portroot, buf);
 
-	for (i = 1; i < ARGC; i++)
-		if (strncmp(ARGV[i], buf, strlen(ARGV[i])) == 0)
-			if ((access(dest, R_OK)) == 0)
+	/* Check CONFIG_PROTECT_MASK */
+	for (i = 1; i < cpm_argc; ++i)
+		if (strncmp(cpm_argv[i], buf, strlen(cpm_argv[i])) == 0)
+			return 0;
+
+	/* Check CONFIG_PROTECT */
+	for (i = 1; i < cp_argc; ++i)
+		if (strncmp(cp_argv[i], buf, strlen(cp_argv[i])) == 0)
+			if (access(dest, R_OK) == 0)
 				return 1;
 
-	if (strncmp("/etc", buf, 4) == 0)
-		if (access(dest, R_OK) == 0)
-			return 1;
+	/* this would probably be bad */
 	if (strcmp("/bin/sh", buf) == 0)
 		return 1;
+
 	return 0;
 }
 
@@ -286,7 +291,7 @@
 
 	assert(pretend == 0);
 
-	if (lstat(buf, &lst) == (-1))
+	if (lstat(buf, &lst) == -1)
 		return;
 	if (lst.st_dev != st.st_dev) {
 		warn("skipping crossmount install masking: %s", buf);
@@ -623,7 +628,7 @@
 	}
 	xchdir("image");
 
-	if (stat("./", &st) == (-1))
+	if (stat("./", &st) == -1)
 		err("Cant stat pwd");
 
 	makeargv(install_mask, &iargc, &iargv);
@@ -699,7 +704,7 @@
 			snprintf(line, sizeof(line), "obj %s %s %lu", &buf[1], hash, st.st_mtime);
 			/* /etc /usr/kde/2/share/config /usr/kde/3/share/config	/var/qmail/control */
 
-			protected = config_protected(&buf[1], ARGC, ARGV);
+			protected = config_protected(&buf[1], ARGC, ARGV, 0, NULL);
 			if (protected) {
 				unsigned char *target_hash = hash_file(dest, HASH_MD5);
 				if (memcmp(target_hash, hash, 16) != 0) {
@@ -757,7 +762,7 @@
 
 			xgetcwd(pwd, sizeof(pwd));
 			xchdir(dirname(tmp)); /* tmp gets eatten up now by the dirname call */
-			if (lstat(path, &lst) != (-1))
+			if (lstat(path, &lst) != -1)
 				unlink_q(dest);
 			/* if (path[0] != '/')
 				puts("path does not start with /");
@@ -822,12 +827,19 @@
 
 int pkg_unmerge(const char *cat, const char *pkgname)
 {
-	char buf[BUFSIZ];
+	size_t buflen;
+	char *buf, *vdb_path;
 	FILE *fp;
-	int argc;
-	char **argv;
+	int ret, fd, vdb_fd;
+	int cp_argc, cpm_argc;
+	char **cp_argv, **cpm_argv;
 	llist_char *dirs = NULL;
 
+	ret = 1;
+	buf = NULL;
+	vdb_path = NULL;
+	vdb_fd = fd = -1;
+
 	if ((strchr(pkgname, ' ') != NULL) || (strchr(cat, ' ') != NULL)) {
 		qfprintf(stderr, "%s!!!%s '%s' '%s' (ambiguous name) specify fully-qualified pkgs\n", RED, NORM, cat, pkgname);
 		qfprintf(stderr, "%s!!!%s %s/%s (ambiguous name) specify fully-qualified pkgs\n", RED, NORM, cat, pkgname);
@@ -839,16 +851,44 @@
 	if (pretend == 100)
 		return 0;
 
-	snprintf(buf, sizeof(buf), "%s/%s/%s/%s/CONTENTS", portroot, portvdb, cat, pkgname);
-
-	if ((fp = fopen(buf, "r")) == NULL)
-		return 1;
+	/* Get a handle on the vdb path which we'll use everywhere else */
+	xasprintf(&vdb_path, "%s/%s/%s/%s/", portroot, portvdb, cat, pkgname);
+	vdb_fd = open(vdb_path, O_RDONLY | O_CLOEXEC);
+	if (vdb_fd == -1) {
+		warnp("unable to read %s", vdb_path);
+		goto done;
+	}
 
-	argc = 0;
-	argv = NULL;
-	makeargv(config_protect, &argc, &argv);
+	/* First execute the pkg_prerm step */
+	if (!pretend) {
+		qprintf(">>> pkg_prerm\n");
+		xchdir(vdb_path);
+		xsystembash(
+			"bzip2 -dc environment.bz2 > environment && "
+			"pkg_prerm() { :; } && "
+			". ./environment && "
+			"pkg_prerm"
+		);
+	}
+
+	/* Now start removing all the installed files */
+	fd = openat(vdb_fd, "CONTENTS", O_RDONLY | O_CLOEXEC);
+	if (fd == -1) {
+		warnp("unable to read %s", "CONTENTS");
+		goto done;
+	}
+	fp = fdopen(fd, "r");
+	if (fp == NULL)
+		goto done;
+
+	/* XXX: be nice to pull this out of the current func
+	 *      so we don't keep reparsing the same env var
+	 *      when unmerging multiple packages.
+	 */
+	makeargv(config_protect, &cp_argc, &cp_argv);
+	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
+	while (getline(&buf, &buflen, fp) != -1) {
 		contents_entry *e;
 		char zing[20];
 		int protected = 0;
@@ -858,8 +898,9 @@
 		e = contents_parse_line(buf);
 		if (!e) continue;
 		snprintf(dst, sizeof(dst), "%s%s", portroot, e->name);
-		protected = config_protected(e->name, argc, argv);
+		protected = config_protected(e->name, cp_argc, cp_argv, cpm_argc, cpm_argv);
 		snprintf(zing, sizeof(zing), "%s%s%s", protected ? YELLOW : GREEN, protected ? "***" : "<<<" , NORM);
+
 		/* Should we remove in order symlinks,objects,dirs ? */
 		switch (e->type) {
 			case CONTENTS_DIR:
@@ -870,17 +911,19 @@
 					list->next = dirs;
 					dirs = list;
 				}
-				qprintf("%s %s%s%s/\n", zing, DKBLUE, dst, NORM);
 				break;
 			case CONTENTS_OBJ:
-				if (!protected)	unlink_q(dst);
+				if (!protected)
+					unlink_q(dst);
 				qprintf("%s %s\n", zing, dst);
 				break;
 			case CONTENTS_SYM:
-				if (protected) break;
-				if (e->name[0] != '/') break;
+				if (protected)
+					break;
+				if (e->name[0] != '/')
+					break;
 				if (e->sym_target[0] != '/') {
-					if (lstat(dst, &lst) != (-1)) {
+					if (lstat(dst, &lst) != -1) {
 						if (S_ISLNK(lst.st_mode)) {
 							qprintf("%s %s%s -> %s%s\n", zing, CYAN, dst, e->sym_target, NORM);
 							unlink_q(dst);
@@ -892,7 +935,7 @@
 					warn("!!! %s -> %s", e->name, e->sym_target);
 					break;
 				}
-				if (lstat(dst, &lst) != (-1)) {
+				if (lstat(dst, &lst) != -1) {
 					if (S_ISLNK(lst.st_mode)) {
 						qprintf("%s %s%s -> %s%s\n", zing, CYAN, dst, e->sym_target, NORM);
 						unlink_q(dst);
@@ -910,23 +953,68 @@
 	}
 
 	fclose(fp);
+	fd = -1;
 
-	/* remove all dirs in reverse order */
+	/* Then remove all dirs in reverse order */
 	while (dirs != NULL) {
 		llist_char *list = dirs;
-		dirs = dirs->next;
-		rmdir(list->data);
+		char *dir = list->data;
+		int rm;
+
+		rm = pretend ? -1 : rmdir(dir);
+		qprintf("%s%s%s %s%s%s/\n", rm ? YELLOW : GREEN, rm ? "---" : "<<<",
+			NORM, DKBLUE, dir, NORM);
+
 		free(list->data);
 		free(list);
+		dirs = dirs->next;
 	}
 
-	freeargv(argc, argv);
+	freeargv(cp_argc, cp_argv);
+	freeargv(cpm_argc, cpm_argv);
 
+	/* Then execute the pkg_postrm step */
 	if (!pretend) {
-		snprintf(buf, sizeof(buf), BUSYBOX " rm -rf %s/%s/%s/%s", portroot, portvdb, cat, pkgname);
-		xsystem(buf);
+		qprintf(">>> pkg_postrm\n");
+		xsystembash(
+			/* "bzip2 -dc environment.bz2 > environment && " */
+			"pkg_postrm() { :; } && "
+			". ./environment && "
+			"pkg_postrm"
+		);
 	}
-	return 1;
+
+	if (!pretend) {
+		/* Finally delete the vdb entry */
+		DIR *dir;
+		struct dirent *de;
+
+		dir = fdopendir(vdb_fd);
+		if (!dir)
+			goto done;
+
+		while ((de = readdir(dir)) != NULL)
+			unlinkat(vdb_fd, de->d_name, 0);
+
+		closedir(dir);
+		vdb_fd = -1;
+
+		rmdir(vdb_path);
+
+		/* XXX: Really only needed because we shell out to qlist and such ... */
+		xchdir("/");
+	}
+
+	ret = 0;
+ done:
+	if (fd != -1)
+		close(fd);
+	if (vdb_fd != -1)
+		close(vdb_fd);
+	free(buf);
+	free(vdb_path);
+
+	return ret;
 }
 
 int unlink_empty(char *buf)






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-02-22  6:10 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-02-22  6:10 UTC (permalink / raw
  To: gentoo-commits

vapier      11/02/22 06:10:16

  Modified:             qmerge.c
  Log:
  unify the pkg_{pre,post}rm steps a bit, and seed the env with stub debug-print funcs like the pm does

Revision  Changes    Path
1.101                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.101&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.101&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.100&r2=1.101

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- qmerge.c	21 Feb 2011 22:02:59 -0000	1.100
+++ qmerge.c	22 Feb 2011 06:10:16 -0000	1.101
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.100 2011/02/21 22:02:59 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.101 2011/02/22 06:10:16 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.100 2011/02/21 22:02:59 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.101 2011/02/22 06:10:16 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -424,6 +424,20 @@
 	return ret;
 }
 
+#define pkg_run_func(func, setup) \
+	do { \
+		qprintf(">>> %s\n", func); \
+		xsystembash( \
+			"debug-print() { :; }; " \
+			"debug-print-function() { :; }; " \
+			"debug-print-section() { :; }; " \
+			func "() { :; }; " \
+			setup \
+			". ./environment && " \
+			func \
+		); \
+	} while (0)
+
 /* oh shit getting into pkg mgt here. FIXME: write a real dep resolver. */
 void pkg_merge(int level, depend_atom *atom, struct pkg_t *pkg)
 {
@@ -861,14 +875,8 @@
 
 	/* First execute the pkg_prerm step */
 	if (!pretend) {
-		qprintf(">>> pkg_prerm\n");
 		xchdir(vdb_path);
-		xsystembash(
-			"bzip2 -dc environment.bz2 > environment && "
-			"pkg_prerm() { :; } && "
-			". ./environment && "
-			"pkg_prerm"
-		);
+		pkg_run_func("pkg_prerm", "bzip2 -dc environment.bz2 > environment && ");
 	}
 
 	/* Now start removing all the installed files */
@@ -974,15 +982,8 @@
 	freeargv(cpm_argc, cpm_argv);
 
 	/* Then execute the pkg_postrm step */
-	if (!pretend) {
-		qprintf(">>> pkg_postrm\n");
-		xsystembash(
-			/* "bzip2 -dc environment.bz2 > environment && " */
-			"pkg_postrm() { :; } && "
-			". ./environment && "
-			"pkg_postrm"
-		);
-	}
+	if (!pretend)
+		pkg_run_func("pkg_postrm", "");
 
 	if (!pretend) {
 		/* Finally delete the vdb entry */






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-02-24  1:29 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-02-24  1:29 UTC (permalink / raw
  To: gentoo-commits

vapier      11/02/24 01:29:27

  Modified:             qmerge.c
  Log:
  use a proper linked list structure for the package todo rather than building up and breaking down strings all the time

Revision  Changes    Path
1.104                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.104&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.104&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.103&r2=1.104

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- qmerge.c	23 Feb 2011 22:58:51 -0000	1.103
+++ qmerge.c	24 Feb 2011 01:29:27 -0000	1.104
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.103 2011/02/23 22:58:51 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.104 2011/02/24 01:29:27 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.103 2011/02/23 22:58:51 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.104 2011/02/24 01:29:27 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -67,6 +67,7 @@
 char nomd5 = 0;
 char qmerge_strict = 0;
 char update_only = 0;
+const char Packages[] = "Packages";
 
 /*
 	"CHOST", "DEPEND", "DESCRIPTION", "EAPI",
@@ -96,18 +97,13 @@
 
 int interactive_rename(const char *, const char *, struct pkg_t *);
 void fetch(const char *, const char *);
-void qmerge_initialize(const char *);
 char *best_version(const char *, const char  *);
 void pkg_fetch(int, depend_atom *, struct pkg_t *);
 void pkg_merge(int, depend_atom *, struct pkg_t *);
 int pkg_unmerge(const char *, const char *);
 int unlink_empty(char *);
-void pkg_process(int, char **, struct pkg_t *);
 void print_Pkg(int, struct pkg_t *);
-int parse_packages(const char *, int, char **);
-int match_pkg(const char *, struct pkg_t *);
 int pkg_verify_checksums(char *, struct pkg_t *, depend_atom *, int strict, int display);
-int unmerge_packages(int, char **);
 char *find_binpkg(const char *);
 
 struct pkg_t *grab_binpkg_info(const char *);
@@ -184,7 +180,7 @@
 	fflush(stderr);
 }
 
-void qmerge_initialize(const char *Packages)
+static void qmerge_initialize(void)
 {
 	if (strlen(BUSYBOX))
 		if (access(BUSYBOX, X_OK) != 0)
@@ -930,6 +926,8 @@
 
 	snprintf(buf, sizeof(buf), "%s/%s.tbz2", pkgdir, pkg->PF);
 	unlink(buf);
+
+	printf("%s>>>%s %s%s%s/%s%s%s\n", YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, atom->PN, NORM);
 }
 
 int pkg_unmerge(const char *cat, const char *pkgname)
@@ -1113,37 +1111,36 @@
 	return -1;
 }
 
-int match_pkg(const char *name, struct pkg_t *pkg)
+static int match_pkg(queue *ll, struct pkg_t *pkg)
 {
 	depend_atom *atom;
 	char buf[255], buf2[255];
 	int match = 0;
-	char *ptr;
 
 	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
 	if ((atom = atom_explode(buf)) == NULL)
 		errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF);
 
 	/* verify this is the requested package */
-	if (strcmp(name, buf) == 0)
+	if (strcmp(ll->name, buf) == 0)
 		match = 1;
 
-	if (strcmp(name, pkg->PF) == 0)
+	if (strcmp(ll->name, pkg->PF) == 0)
 		match = 2;
 
 	snprintf(buf2, sizeof(buf2), "%s/%s", pkg->CATEGORY, atom->PN);
 
-	if (strcmp(name, buf2) == 0)
+	if (strcmp(ll->name, buf2) == 0)
 		match = 3;
 
-	if (strcmp(name, atom->PN) == 0)
+	if (strcmp(ll->name, atom->PN) == 0)
 		match = 4;
 
 	if (match)
 		goto match_done;
 
-	if ((ptr = strchr(name, ':')) != NULL) {
-		depend_atom *subatom = atom_explode(name);
+	if (ll->item) {
+		depend_atom *subatom = atom_explode(ll->name);
 		if (subatom == NULL)
 			goto match_done;
 		if (strcmp(atom->PN, subatom->PN) == 0)
@@ -1200,28 +1197,26 @@
 	return ret;
 }
 
-void pkg_process(int argc, char **argv, struct pkg_t *pkg)
+static void pkg_process(queue *todo, struct pkg_t *pkg)
 {
+	queue *ll;
 	depend_atom *atom;
 	char buf[255];
-	int i;
-
-	memset(buf, 0, sizeof(buf));
 
 	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
 	if ((atom = atom_explode(buf)) == NULL)
 		errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF);
 
-	for (i = 1; i < argc; i++) {
-		if (argv[i][0] == '-')
-			continue;
-
-		/* verify this is the requested package */
-		if (match_pkg(argv[i], pkg) < 1)
-			continue;
+	ll = todo;
+	while (ll) {
+		if (ll->name[0] != '-' && match_pkg(ll, pkg)) {
+			/* fetch all requested packages */
+			pkg_fetch(0, atom, pkg);
+		}
 
-		pkg_fetch(0, atom, pkg);
+		ll = ll->next;
 	}
+
 	/* free the atom */
 	atom_implode(atom);
 }
@@ -1349,13 +1344,13 @@
 	if ((p = best_version(pkg->CATEGORY, atom->PN)) != NULL) {
 		if (*p) {
 			int ret;
-			char *icolor = (char *) RED;
+			const char *icolor = RED;
 			ret = atom_compare_str(buf, p);
 			switch (ret) {
-				case EQUAL: icolor = (char *) RED; break;
-				case NEWER: icolor = (char *) YELLOW; break;
-				case OLDER: icolor = (char *) BLUE; break;
-				default: icolor = (char *) NORM; break;
+				case EQUAL: icolor = RED;    break;
+				case NEWER: icolor = YELLOW; break;
+				case OLDER: icolor = BLUE;   break;
+				default:    icolor = NORM;   break;
 			}
 			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
 		}
@@ -1363,28 +1358,30 @@
 	atom_implode(atom);
 }
 
-int unmerge_packages(int argc, char **argv)
+static int unmerge_packages(queue *todo)
 {
 	depend_atom *atom;
 	char *p;
-	int i;
 
-	if (argc == optind)
-		return 1;
-
-	for (i = 1; i < argc; i++) {
+	while (todo) {
 		char buf[512];
 
-		if (argv[i][0] == '-')
-			continue;
+		if (todo->name[0] == '-')
+			goto next;
 
-		p = best_version(NULL, argv[i]);
-		if (!*p) continue;
-		if ((atom = atom_explode(p)) == NULL) continue;
+		p = best_version(NULL, todo->name);
+		if (!*p)
+			goto next;
+		if ((atom = atom_explode(p)) == NULL)
+			goto next;
 		atom2str(atom, buf, sizeof(buf));
 		pkg_unmerge(atom->CATEGORY, buf);
 		atom_implode(atom);
+
+ next:
+		todo = todo->next;
 	}
+
 	return 0;
 }
 
@@ -1392,7 +1389,6 @@
 {
 	FILE *fp;
 	char buf[BUFSIZ];
-	char value[BUFSIZ];
 	char *p;
 	depend_atom *atom;
 
@@ -1449,28 +1445,26 @@
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
 
-		memset(value, 0, sizeof(value));
 		if ((p = strchr(buf, ':')) == NULL)
 			continue;
 		if ((p = strchr(buf, ' ')) == NULL)
 			continue;
 		*p = 0;
 		++p;
-		strncpy(value, p, sizeof(value));
 
 		if (*buf) {
 			/* we dont need all the info */
 			if (strcmp(buf, "RDEPEND:") == 0)
-				strncpy(pkg->RDEPEND, value, sizeof(Pkg.RDEPEND));
+				strncpy(pkg->RDEPEND, p, sizeof(Pkg.RDEPEND));
 			if (strcmp(buf, "PF:") == 0)
-				strncpy(pkg->PF, value, sizeof(Pkg.PF));
+				strncpy(pkg->PF, p, sizeof(Pkg.PF));
 			if (strcmp(buf, "CATEGORY:") == 0)
-				strncpy(pkg->CATEGORY, value, sizeof(Pkg.CATEGORY));
+				strncpy(pkg->CATEGORY, p, sizeof(Pkg.CATEGORY));
 			if (strcmp(buf, "REPO:") == 0)
-				strncpy(pkg->REPO, value, sizeof(Pkg.REPO));
+				strncpy(pkg->REPO, p, sizeof(Pkg.REPO));
 
 			if (strcmp(buf, "CPV:") == 0) {
-				if ((atom = atom_explode(value)) != NULL) {
+				if ((atom = atom_explode(p)) != NULL) {
 					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
 					if (atom->PR_int)
 						snprintf(buf, sizeof(buf), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
@@ -1480,15 +1474,15 @@
 				}
 			}
 			if (strcmp(buf, "SLOT:") == 0)
-				strncpy(pkg->SLOT, value, sizeof(Pkg.SLOT));
+				strncpy(pkg->SLOT, p, sizeof(Pkg.SLOT));
 			if (strcmp(buf, "USE:") == 0)
-				strncpy(pkg->USE, value, sizeof(Pkg.USE));
+				strncpy(pkg->USE, p, sizeof(Pkg.USE));
 
 			/* checksums. We must have 1 or the other unless --*/
 			if (strcmp(buf, "MD5:") == 0)
-				strncpy(pkg->MD5, value, sizeof(Pkg.MD5));
+				strncpy(pkg->MD5, p, sizeof(Pkg.MD5));
 			if (strcmp(buf, "SHA1:") == 0)
-				strncpy(pkg->SHA1, value, sizeof(Pkg.SHA1));
+				strncpy(pkg->SHA1, p, sizeof(Pkg.SHA1));
 		}
 	}
 	fclose(fp);
@@ -1500,7 +1494,6 @@
 {
 	FILE *fp;
 	char buf[BUFSIZ];
-	char value[BUFSIZ];
 	char *p;
 	char PF[sizeof(Pkg.PF)];
 	char CATEGORY[sizeof(Pkg.CATEGORY)];
@@ -1550,19 +1543,17 @@
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
 
-		memset(&value, 0, sizeof(value));
 		if ((p = strchr(buf, ':')) == NULL)
 			continue;
 		if ((p = strchr(buf, ' ')) == NULL)
 			continue;
 		*p = 0;
 		++p;
-		strncpy(value, p, sizeof(value));
 
 		if (*buf) {
 			if (strcmp(buf, "CPV:") == 0) {
 				depend_atom *atom;
-				if ((atom = atom_explode(value)) != NULL) {
+				if ((atom = atom_explode(p)) != NULL) {
 					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
 					if (atom->PR_int)
 						snprintf(buf, sizeof(buf), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
@@ -1572,22 +1563,20 @@
 				}
 			}
 			if (strcmp(buf, "PF:") == 0)
-				strncpy(PF, value, sizeof(PF));
+				strncpy(PF, p, sizeof(PF));
 			if (strcmp(buf, "CATEGORY:") == 0)
-				strncpy(CATEGORY, value, sizeof(CATEGORY));
+				strncpy(CATEGORY, p, sizeof(CATEGORY));
 		}
 	}
 	fclose(fp);
 	return best_match;
 }
 
-int parse_packages(const char *Packages, int argc, char **argv)
+static int parse_packages(queue *todo)
 {
 	FILE *fp;
-	char buf[BUFSIZ];
-	char value[BUFSIZ];
-	char *p;
-	int i;
+	size_t buflen;
+	char *buf, *p;
 	long lineno = 0;
 
 	if ((fp = fopen(Packages, "r")) == NULL)
@@ -1595,23 +1584,27 @@
 
 	memset(&Pkg, 0, sizeof(Pkg));
 
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
+	buf = NULL;
+	while (getline(&buf, &buflen, fp) != -1) {
 		lineno++;
 		if (*buf == '\n') {
 			if ((strlen(Pkg.PF) > 0) && (strlen(Pkg.CATEGORY) > 0)) {
-				struct pkg_t *pkg = xmalloc(sizeof(struct pkg_t));
-				memcpy(pkg, &Pkg, sizeof(struct pkg_t));
+				struct pkg_t *pkg = xmalloc(sizeof(*pkg));
+				*pkg = Pkg;
+
 				if (search_pkgs) {
-					if (argc != optind) {
-						for (i = 0; i < argc; i++)
-							if ((match_pkg(argv[i], pkg) > 0) || (strcmp(argv[i], pkg->CATEGORY) == 0))
+					if (todo) {
+						queue *ll = todo;
+						while (ll) {
+							if ((match_pkg(ll, pkg) > 0) || (strcmp(ll->name, pkg->CATEGORY) == 0))
 								print_Pkg(verbose, pkg);
-					} else {
+							ll = ll->next;
+						}
+					} else
 						print_Pkg(verbose, pkg);
-					}
-				} else {
-					pkg_process(argc, argv, pkg);
-				}
+				} else
+					pkg_process(todo, pkg);
+
 				free(pkg);
 			}
 			memset(&Pkg, 0, sizeof(Pkg));
@@ -1620,115 +1613,137 @@
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
 
-		memset(&value, 0, sizeof(value));
 		if ((p = strchr(buf, ':')) == NULL)
 			continue;
 		if ((p = strchr(buf, ' ')) == NULL)
 			continue;
 		*p = 0;
 		++p;
-		strncpy(value, p, sizeof(value));
 
 		switch (*buf) {
 			case 'U':
-				if (strcmp(buf, "USE:") == 0) strncpy(Pkg.USE, value, sizeof(Pkg.USE));
+				if (strcmp(buf, "USE:") == 0) strncpy(Pkg.USE, p, sizeof(Pkg.USE));
 				break;
 			case 'P':
-				if (strcmp(buf, "PF:") == 0) strncpy(Pkg.PF, value, sizeof(Pkg.PF));
+				if (strcmp(buf, "PF:") == 0) strncpy(Pkg.PF, p, sizeof(Pkg.PF));
 				break;
 			case 'S':
-				if (strcmp(buf, "SIZE:") == 0) Pkg.SIZE = atol(value);
-				if (strcmp(buf, "SLOT:") == 0) strncpy(Pkg.SLOT, value, sizeof(Pkg.SLOT));
-				if (strcmp(buf, "SHA1:") == 0) strncpy(Pkg.SHA1, value, sizeof(Pkg.SHA1));
+				if (strcmp(buf, "SIZE:") == 0) Pkg.SIZE = atol(p);
+				if (strcmp(buf, "SLOT:") == 0) strncpy(Pkg.SLOT, p, sizeof(Pkg.SLOT));
+				if (strcmp(buf, "SHA1:") == 0) strncpy(Pkg.SHA1, p, sizeof(Pkg.SHA1));
 				break;
 			case 'M':
-				if (strcmp(buf, "MD5:") == 0) strncpy(Pkg.MD5, value, sizeof(Pkg.MD5));
+				if (strcmp(buf, "MD5:") == 0) strncpy(Pkg.MD5, p, sizeof(Pkg.MD5));
 				break;
 			case 'R':
-				if (strcmp(buf, "REPO:") == 0) strncpy(Pkg.REPO, value, sizeof(Pkg.REPO));
-				if (strcmp(buf, "RDEPEND:") == 0) strncpy(Pkg.RDEPEND, value, sizeof(Pkg.RDEPEND));
+				if (strcmp(buf, "REPO:") == 0) strncpy(Pkg.REPO, p, sizeof(Pkg.REPO));
+				if (strcmp(buf, "RDEPEND:") == 0) strncpy(Pkg.RDEPEND, p, sizeof(Pkg.RDEPEND));
 				break;
 			case 'L':
-				if (strcmp(buf, "LICENSE:") == 0) strncpy(Pkg.LICENSE, value, sizeof(Pkg.LICENSE));
+				if (strcmp(buf, "LICENSE:") == 0) strncpy(Pkg.LICENSE, p, sizeof(Pkg.LICENSE));
 				break;
 			case 'C':
-				if (strcmp(buf, "CATEGORY:") == 0) strncpy(Pkg.CATEGORY, value, sizeof(Pkg.CATEGORY));
+				if (strcmp(buf, "CATEGORY:") == 0) strncpy(Pkg.CATEGORY, p, sizeof(Pkg.CATEGORY));
 				if (strcmp(buf, "CPV:") == 0) {
 					depend_atom *atom;
-					if ((atom = atom_explode(value)) != NULL) {
-						snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
+					if ((atom = atom_explode(p)) != NULL) {
 						if (atom->PR_int)
-							snprintf(buf, sizeof(buf), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
-						strncpy(Pkg.PF, buf, sizeof(Pkg.PF));
+							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
+						else
+							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s", atom->PN, atom->PV);
 						strncpy(Pkg.CATEGORY, atom->CATEGORY, sizeof(Pkg.CATEGORY));
 						atom_implode(atom);
 					}
 				}
 				break;
 			case 'D':
-				if (strcmp(buf, "DESC:") == 0) strncpy(Pkg.DESC, value, sizeof(Pkg.DESC));
+				if (strcmp(buf, "DESC:") == 0) strncpy(Pkg.DESC, p, sizeof(Pkg.DESC));
 				break;
 			default:
 				break;
 		}
-		memset(&buf, 0, sizeof(buf));
 	}
+
+	free(buf);
 	fclose(fp);
+
 	return 0;
 }
 
-queue *get_world(void);
-queue *get_world(void)
+static queue *qmerge_add_set_atom(char *satom, queue *set)
+{
+	char *p;
+	const char *slot;
+
+	if ((p = strchr(satom, ':')) != NULL) {
+		*p = 0;
+		slot = p + 1;
+	} else
+		slot = "0";
+
+	return add_set(satom, slot, set);
+}
+
+static queue *qmerge_add_set_file(const char *file, queue *set)
 {
 	FILE *fp;
-	char buf[BUFSIZ];
-	queue *world = NULL;
-	char fname[_Q_PATH_MAX];
+	size_t buflen;
+	char *buf;
+	const char *fname;
 
-	if (*portroot && strcmp(portroot, "/") != 0)
-		snprintf(fname, sizeof(fname), "%s/var/lib/portage/world", portroot);
-	else
-		strncpy(fname,  "/var/lib/portage/world", sizeof(fname));
+	/* Find the file to read */
+	if (*portroot && strcmp(portroot, "/") != 0) {
+		size_t len, flen;
+		char *f;
+
+		len = strlen(portroot);
+		flen = strlen(file) + 1;
+		fname = f = alloca(len + flen);
+		memcpy(f, portroot, len);
+		memcpy(f + len, file, flen);
+	} else
+		fname = file;
 
 	if ((fp = fopen(fname, "r")) == NULL) {
-		warnp("fopen(\"%s\", \"r\"); = -1", fname);
+		warnp("unable to read set file %s", fname);
 		return NULL;
 	}
 
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
-		char *p;
-		char *slot = (char *) "0";
-
+	/* Load each entry */
+	buf = NULL;
+	while (getline(&buf, &buflen, fp) != -1) {
 		rmspace(buf);
-
-		if ((p = strchr(buf, ':')) != NULL) {
-			*p = 0;
-			slot = p + 1;
-		}
-		world = add_set(buf, slot, world);
+		set = qmerge_add_set_atom(buf, set);
 	}
+	free(buf);
+
 	fclose(fp);
-	return world;
+
+	return set;
 }
 
-queue *qmerge_load_set(char *, queue *);
-queue *qmerge_load_set(char *buf, queue *set)
+static queue *qmerge_add_set(char *buf, queue *set)
 {
-	if (set != NULL)
-		return set;
 	if (strcmp(buf, "world") == 0)
-		return get_world();
+		return qmerge_add_set_file("/var/lib/portage/world", set);
 	if (strcmp(buf, "all") == 0)
 		return get_vdb_atoms(0);
-	return NULL;
+	/* XXX: Should load custom sets here */
+	return qmerge_add_set_atom(buf, set);
+}
+
+static int qmerge_run(queue *todo)
+{
+	if (uninstall)
+		return unmerge_packages(todo);
+	else
+		return parse_packages(todo);
 }
 
 int qmerge_main(int argc, char **argv)
 {
 	int i, ret;
-	const char Packages[] = "Packages";
-	int ARGC = argc;
-	char **ARGV = argv;
+	queue *todo;
 
 	if (argc < 2)
 		qmerge_usage(EXIT_FAILURE);
@@ -1761,78 +1776,43 @@
 		}
 	}
 
-	if (uninstall) {
-		if (interactive) {
-			int save_pretend = pretend;
-			int save_verbose = verbose;
-			int save_quiet = quiet;
-
-			pretend = 100;
-			verbose = 0;
-			quiet = 1;
-			ret = unmerge_packages(argc, argv);
-			if (ret || save_pretend)
-				return ret;
+	/* Expand any portage sets on the command line */
+	todo = NULL;
+	for (i = optind; i < argc; ++i)
+		todo = qmerge_add_set(argv[i], todo);
+
+	if (!uninstall)
+		qmerge_initialize();
+
+	/* Make sure the user wants to do it */
+	if (interactive) {
+		int save_pretend = pretend;
+		int save_verbose = verbose;
+		int save_quiet = quiet;
+
+		pretend = 100;
+		verbose = 0;
+		quiet = 1;
+		ret = qmerge_run(todo);
+		if (ret || save_pretend)
+			return ret;
 
+		if (uninstall) {
 			if (!prompt("OK to unmerge these packages"))
 				return 0;
-
-			pretend = save_pretend;
-			verbose = save_verbose;
-			quiet = save_quiet;
+		} else {
+			if (!prompt("OK to merge these packages"))
+				return 0;
 		}
 
-		return unmerge_packages(argc, argv);
+		pretend = save_pretend;
+		verbose = save_verbose;
+		quiet = save_quiet;
 	}
 
-	ARGC = argc;
-	ARGV = argv;
-
-	qmerge_initialize(Packages);
-
-	if (optind < argc) {
-		queue *world = NULL;
-		int ind = optind;
-		while (ind < argc) {
-			size_t size = 0;
-			i = ind;
-			ind++;
-
-			if ((world = qmerge_load_set(argv[i], world)) == NULL)
-				continue;
-
-			if (world != NULL) {
-				queue *ll;
-				char *ptr;
-
-				for (ll = world; ll != NULL; ll = ll->next)
-					size += (strlen(ll->name) + 1);
-				if (size < 1)
-					continue;
-
-				size += (strlen(argv[0]) + 1);
-				ptr = xmalloc(size);
-				sprintf(ptr, "%s ", argv[0]);
-
-				for (ll = world; ll != NULL; ll = ll->next) {
-					char *p = NULL;
-					xasprintf(&p, "%s ", ll->name);
-					strcat(ptr, p);
-					free(p);
-				}
-				ARGC = 0;
-				ARGV = NULL;
-				/* this will leak mem */
-				/* follow_rdepends = 0; */
-				makeargv(ptr, &ARGC, &ARGV);
-
-				free(ptr);
-				free_sets(world);
-				world = NULL;
-			}
-		}
-	}
-	return parse_packages(Packages, ARGC, ARGV);
+	ret = qmerge_run(todo);
+	free_sets(todo);
+	return ret;
 }
 
 #else






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-03-02  3:51 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2011-03-02  3:51 UTC (permalink / raw
  To: gentoo-commits

solar       11/03/02 03:51:01

  Modified:             qmerge.c
  Log:
  fix unlink behavior

Revision  Changes    Path
1.105                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.105&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.105&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.104&r2=1.105

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- qmerge.c	24 Feb 2011 01:29:27 -0000	1.104
+++ qmerge.c	2 Mar 2011 03:51:01 -0000	1.105
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.104 2011/02/24 01:29:27 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.105 2011/03/02 03:51:01 solar Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.104 2011/02/24 01:29:27 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.105 2011/03/02 03:51:01 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -919,7 +919,7 @@
 	/* move the local vdb copy to the final place */
 	interactive_rename("vdb", buf, pkg);
 
-	snprintf(buf, sizeof(buf), BUSYBOX " %s.tar.bz2", pkg->PF);
+	snprintf(buf, sizeof(buf), "%s.tar.bz2", pkg->PF);
 	unlink_q(buf);
 	xchdir(port_tmpdir);
 	rm_rf(pkg->PF);






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-03-02  9:22 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-02  9:22 UTC (permalink / raw
  To: gentoo-commits

vapier      11/03/02 09:22:15

  Modified:             qmerge.c
  Log:
  scrub now unused code

Revision  Changes    Path
1.107                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.107&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.107&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.106&r2=1.107

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- qmerge.c	2 Mar 2011 09:16:22 -0000	1.106
+++ qmerge.c	2 Mar 2011 09:22:14 -0000	1.107
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.106 2011/03/02 09:16:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.107 2011/03/02 09:22:14 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.106 2011/03/02 09:16:22 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.107 2011/03/02 09:22:14 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -101,29 +101,6 @@
 _q_static struct pkg_t *grab_binpkg_info(const char *);
 _q_static char *find_binpkg(const char *);
 
-_q_static int q_unlink_q(const char *path, const char *func, int line)
-{
-	int ret;
-	char *d;
-
-	if (pretend)
-		return 0;
-
-	ret = unlink(path);
-	if (ret)
-		return ret;
-
-	d = strrchr(path, '/');
-	if (d) {
-		*d = '\0';
-		rmdir_r(path);
-	}
-
-	return ret;
-}
-
-#define unlink_q(path) q_unlink_q(path, __FUNCTION__, __LINE__)
-
 _q_static void fetch(const char *destdir, const char *src)
 {
 	char buf[BUFSIZ];
@@ -1167,8 +1144,6 @@
 	freeargv(cpm_argc, cpm_argv);
 
 	if (!pretend) {
-		char *dir;
-
 		/* Then execute the pkg_postrm step */
 		pkg_run_func(vdb_path, phases, "pkg_postrm");
 






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-03-05 19:28 Ned Ludd (solar)
  0 siblings, 0 replies; 39+ messages in thread
From: Ned Ludd (solar) @ 2011-03-05 19:28 UTC (permalink / raw
  To: gentoo-commits

solar       11/03/05 19:28:21

  Modified:             qmerge.c
  Log:
  - names should match

Revision  Changes    Path
1.108                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.108&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.108&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.107&r2=1.108

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- qmerge.c	2 Mar 2011 09:22:14 -0000	1.107
+++ qmerge.c	5 Mar 2011 19:28:21 -0000	1.108
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.107 2011/03/02 09:22:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.108 2011/03/05 19:28:21 solar Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.107 2011/03/02 09:22:14 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.108 2011/03/05 19:28:21 solar Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -290,7 +290,7 @@
 	rm_rf(fname);
 }
 
-void install_mask_pwd(int argc, char **argv, const struct stat st);
+void install_mask_pwd(int iargc, char **iargv, const struct stat st);
 void install_mask_pwd(int iargc, char **iargv, const struct stat st)
 {
 	char buf[1024];






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-03-17  2:02 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-17  2:02 UTC (permalink / raw
  To: gentoo-commits

vapier      11/03/17 02:02:39

  Modified:             qmerge.c
  Log:
  qmerge: delay PORTAGE_BINHOST checking to point where it is needed

Revision  Changes    Path
1.109                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.109&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.109&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.108&r2=1.109

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- qmerge.c	5 Mar 2011 19:28:21 -0000	1.108
+++ qmerge.c	17 Mar 2011 02:02:39 -0000	1.109
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.108 2011/03/05 19:28:21 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.109 2011/03/17 02:02:39 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.108 2011/03/05 19:28:21 solar Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.109 2011/03/17 02:02:39 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -105,6 +105,9 @@
 {
 	char buf[BUFSIZ];
 
+	if (!binhost[0])
+		errf("PORTAGE_BINHOST= does not appear to be valid");
+
 	fflush(stdout);
 	fflush(stderr);
 
@@ -164,9 +167,6 @@
 	if (pkgdir[0] != '/')
 		errf("PKGDIR='%s' does not appear to be valid", pkgdir);
 
-	if (!binhost[0])
-		errf("PORTAGE_BINHOST= does not appear to be valid");
-
 	if (!search_pkgs && !pretend) {
 		if (mkdir_p(pkgdir, 0755))
 			errp("could not setup PKGDIR: %s", pkgdir);






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-10-02 22:09 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-10-02 22:09 UTC (permalink / raw
  To: gentoo-commits

vapier      11/10/02 22:09:48

  Modified:             qmerge.c
  Log:
  fix warning with gcc-4.6+ about set-but-unused variable c

Revision  Changes    Path
1.110                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.110&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.110&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.109&r2=1.110

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -r1.109 -r1.110
--- qmerge.c	17 Mar 2011 02:02:39 -0000	1.109
+++ qmerge.c	2 Oct 2011 22:09:47 -0000	1.110
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.109 2011/03/17 02:02:39 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.110 2011/10/02 22:09:47 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.109 2011/03/17 02:02:39 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.110 2011/10/02 22:09:47 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -716,8 +716,8 @@
 	char **ARGV;
 	int ARGC;
 	struct stat st;
-	char c;
 	char **iargv;
+	char c;
 	int iargc;
 
 	if (!install || !pkg || !atom)
@@ -730,9 +730,9 @@
 
 	c = qprint_tree_node(level, atom, pkg);
 
-	/* if (((c == 'R') || (c == 'D')) && update_only)
-		return;
-	*/
+	if (0)
+		if (((c == 'R') || (c == 'D')) && update_only)
+			return;
 
 	if (pkg->RDEPEND[0] && follow_rdepends) {
 		const char *rdepend;






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-12-12 20:47 Fabian Groffen (grobian)
  0 siblings, 0 replies; 39+ messages in thread
From: Fabian Groffen (grobian) @ 2011-12-12 20:47 UTC (permalink / raw
  To: gentoo-commits

grobian     11/12/12 20:47:00

  Modified:             qmerge.c
  Log:
  Fixed compilation on Darwin by solving GNUlib st_mtim problem
  
  Use GNUlib's wrappers to get st_mtim, define a workaround macro for when
  we don't use GNUlib.  (Tested on plain Gentoo Linux.)

Revision  Changes    Path
1.111                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.111&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.111&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.110&r2=1.111

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- qmerge.c	2 Oct 2011 22:09:47 -0000	1.110
+++ qmerge.c	12 Dec 2011 20:47:00 -0000	1.111
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.110 2011/10/02 22:09:47 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.111 2011/12/12 20:47:00 grobian Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -11,6 +11,16 @@
 
 #include <fnmatch.h>
 #include <glob.h>
+#include <sys/stat.h>
+/* This is a GNUlib hack, because GNUlib doesn't provide st_mtim members
+ * of struct stat, but instead provides wrappers to retrieve the time
+ * fields (stat-time module). We just define a macro in case people are
+ * building without autoconf. */
+#ifdef _GL_SYS_STAT_H
+# include "stat-time.h"
+#else
+# define get_stat_mtime(X) ((X)->st_mtim)
+#endif
 
 #ifndef GLOB_BRACE
 # define GLOB_BRACE     (1 << 10)	/* Expand "{a,b}" to "a" "b".  */
@@ -55,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.110 2011/10/02 22:09:47 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.111 2011/12/12 20:47:00 grobian Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -612,8 +622,8 @@
 			}
 
 			/* Preserve the file times */
-			times[0] = st.st_mtim;
-			times[1] = st.st_mtim;
+			times[0] = get_stat_mtime(&st);
+			times[1] = get_stat_mtime(&st);
 			futimens(fd_dstf, times);
 
 			close(fd_srcf);
@@ -655,8 +665,8 @@
 			}
 
 			struct timespec times[2];
-			times[0] = st.st_mtim;
-			times[1] = st.st_mtim;
+			times[0] = get_stat_mtime(&st);
+			times[1] = get_stat_mtime(&st);
 			utimensat(subfd_dst, name, times, AT_SYMLINK_NOFOLLOW);
 		}
 






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-12-18 20:41 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-18 20:41 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/18 20:41:54

  Modified:             qmerge.c
  Log:
  drop unused fp argument in q_profile_walk callback

Revision  Changes    Path
1.113                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.113&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.113&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.112&r2=1.113

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- qmerge.c	18 Dec 2011 20:23:34 -0000	1.112
+++ qmerge.c	18 Dec 2011 20:41:54 -0000	1.113
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.112 2011/12/18 20:23:34 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.113 2011/12/18 20:41:54 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.112 2011/12/18 20:23:34 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.113 2011/12/18 20:41:54 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1777,7 +1777,7 @@
 }
 
 _q_static void *
-qmerge_add_set_system(void *data, char *buf, FILE *fp)
+qmerge_add_set_system(void *data, char *buf)
 {
 	queue *set = data;
 	char *s;






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2011-12-19  4:58 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-19  4:58 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/19 04:58:09

  Modified:             qmerge.c
  Log:
  avoid xstrdup when qmerge fetching when possible

Revision  Changes    Path
1.115                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.115&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.115&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.114&r2=1.115

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- qmerge.c	19 Dec 2011 04:23:18 -0000	1.114
+++ qmerge.c	19 Dec 2011 04:58:09 -0000	1.115
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.114 2011/12/19 04:23:18 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.115 2011/12/19 04:58:09 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.114 2011/12/19 04:23:18 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.115 2011/12/19 04:58:09 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -132,27 +132,29 @@
 		pid_t p;
 		int status;
 
-		const char *prog = (force_download || install) ? "wget" : pretend ? "echo" : "wget";
+		char prog[] = "wget";
+		char argv_c[] = "-c";
+		char argv_P[] = "-P";
+		char argv_q[] = "-q";
+		char *argv_dir = xstrdup(destdir);
 		char *argv[] = {
-			xstrdup(prog),
-			xstrdup("-c"),
-			xstrdup("-P"),
-			xstrdup(destdir),
+			prog,
+			argv_c,
+			argv_P,
+			argv_dir,
 			buf,
-			quiet ? xstrdup("-q") : NULL,
+			quiet ? argv_q : NULL,
 			NULL,
 		};
+		if (!(force_download || install) && pretend)
+			strcpy(prog, "echo");
 		snprintf(buf, sizeof(buf), "%s/%s", binhost, src);
 
 		p = vfork();
 		if (p == 0)
 			_exit(execvp(prog, argv));
 
-		free(argv[0]);
-		free(argv[1]);
-		free(argv[2]);
-		free(argv[3]);
-		free(argv[5]);
+		free(argv_dir);
 
 		waitpid(p, &status, 0);
 #if 0






^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-20  7:32 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-20  7:32 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/20 07:32:07

  Modified:             qmerge.c
  Log:
  qmerge: fix -U for the most part

Revision  Changes    Path
1.117                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.117&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.117&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.116&r2=1.117

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -r1.116 -r1.117
--- qmerge.c	13 Aug 2012 22:23:35 -0000	1.116
+++ qmerge.c	20 Apr 2013 07:32:07 -0000	1.117
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.116 2012/08/13 22:23:35 robbat2 Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.117 2013/04/20 07:32:07 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.116 2012/08/13 22:23:35 robbat2 Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.117 2013/04/20 07:32:07 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -210,14 +210,15 @@
 _q_static int qmerge_filter_cat(q_vdb_cat_ctx *cat_ctx, void *priv)
 {
 	struct qmerge_bv_state *state = priv;
-	return strcmp(cat_ctx->name, state->catname) == 0;
+	return !state->catname || strcmp(cat_ctx->name, state->catname) == 0;
 }
 
 _q_static int qmerge_best_version_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qmerge_bv_state *state = priv;
 	if (qlist_match(pkg_ctx, state->buf, true))
-		strcpy(state->retbuf, state->buf);
+		snprintf(state->retbuf, sizeof(state->buf), "%s/%s",
+			pkg_ctx->cat_ctx->name, pkg_ctx->name);
 	return 0;
 }
 
@@ -230,8 +231,9 @@
 		.retbuf = retbuf,
 	};
 
-	snprintf(state.buf, sizeof(state.buf), "%s/%s", catname, pkgname);
 	retbuf[0] = '\0';
+	snprintf(state.buf, sizeof(state.buf), "%s%s%s",
+		catname ? : "", catname ? "/" : "", pkgname);
 	q_vdb_foreach_pkg(qmerge_best_version_cb, &state, qmerge_filter_cat);
 
 	return retbuf;





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-22  3:55 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-22  3:55 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/22 03:55:18

  Modified:             qmerge.c
  Log:
  qmerge: create tmpdirs before trying to use them

Revision  Changes    Path
1.119                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.119&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.119&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.118&r2=1.119

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- qmerge.c	21 Apr 2013 04:28:10 -0000	1.118
+++ qmerge.c	22 Apr 2013 03:55:18 -0000	1.119
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.118 2013/04/21 04:28:10 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.119 2013/04/22 03:55:18 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.118 2013/04/21 04:28:10 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.119 2013/04/22 03:55:18 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -182,10 +182,11 @@
 	if (!search_pkgs && !pretend) {
 		if (mkdir_p(pkgdir, 0755))
 			errp("could not setup PKGDIR: %s", pkgdir);
-		mkdir_p(port_tmpdir, 0755);
 	}
 
+	mkdir_p(port_tmpdir, 0755);
 	xchdir(port_tmpdir);
+	mkdir_p("portage", 0755);
 	xchdir("portage");
 
 	if (force_download && force_download != 2)





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-29  6:26 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-29  6:26 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/29 06:26:57

  Modified:             qmerge.c
  Log:
  qmerge: check if the vdb exists before running best_version to avoid warnings when doing the first merge

Revision  Changes    Path
1.121                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.121&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.121&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.120&r2=1.121

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- qmerge.c	29 Apr 2013 05:10:35 -0000	1.120
+++ qmerge.c	29 Apr 2013 06:26:57 -0000	1.121
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.120 2013/04/29 05:10:35 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.121 2013/04/29 06:26:57 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.120 2013/04/29 05:10:35 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.121 2013/04/29 06:26:57 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -225,6 +225,7 @@
 
 _q_static char *best_version(const char *catname, const char *pkgname)
 {
+	static int vdb_check = 1;
 	static char retbuf[4096];
 	struct qmerge_bv_state state = {
 		.catname = catname,
@@ -232,11 +233,28 @@
 		.retbuf = retbuf,
 	};
 
+	/* Make sure these dirs exist before we try walking them */
+	switch (vdb_check) {
+	case 1: {
+		int fd = open(portroot, O_RDONLY|O_CLOEXEC);
+		if (fd >= 0) {
+			/* skip leading slash */
+			vdb_check = faccessat(fd, portvdb + 1, X_OK, 0);
+			close(fd);
+		} else
+			vdb_check = -1;
+	}
+		if (vdb_check)
+	case -1:
+			goto done;
+	}
+
 	retbuf[0] = '\0';
 	snprintf(state.buf, sizeof(state.buf), "%s%s%s",
 		catname ? : "", catname ? "/" : "", pkgname);
 	q_vdb_foreach_pkg(qmerge_best_version_cb, &state, qmerge_filter_cat);
 
+ done:
 	return retbuf;
 }
 





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-29  6:28 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-29  6:28 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/29 06:28:22

  Modified:             qmerge.c
  Log:
  qmerge: fall back to loading the Packages file from the binpkg store when the temp one does not exist (in case we want to avoid fetching all the damn time)

Revision  Changes    Path
1.122                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.122&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.122&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.121&r2=1.122

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- qmerge.c	29 Apr 2013 06:26:57 -0000	1.121
+++ qmerge.c	29 Apr 2013 06:28:21 -0000	1.122
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.121 2013/04/29 06:26:57 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.122 2013/04/29 06:28:21 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.121 2013/04/29 06:26:57 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.122 2013/04/29 06:28:21 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1467,6 +1467,26 @@
 	return 0;
 }
 
+_q_static FILE *
+open_binpkg_index(void)
+{
+	FILE *fp;
+	char buf[BUFSIZ];
+
+	snprintf(buf, sizeof(buf), "%s/portage/%s", port_tmpdir, Packages);
+	fp = fopen(buf, "r");
+	if (fp)
+		return fp;
+
+	snprintf(buf, sizeof(buf), "%s/%s", pkgdir, Packages);
+	fp = fopen(buf, "r");
+	if (fp)
+		return fp;
+
+	errp("Unable to open package file %s in %s/portage or %s",
+		Packages, port_tmpdir, pkgdir);
+}
+
 _q_static struct pkg_t *
 grab_binpkg_info(const char *name)
 {
@@ -1475,19 +1495,14 @@
 	char *p;
 	depend_atom *atom;
 
-	struct pkg_t *pkg = xmalloc(sizeof(struct pkg_t));
-	struct pkg_t *rpkg = xmalloc(sizeof(struct pkg_t));
+	struct pkg_t *pkg = xzalloc(sizeof(struct pkg_t));
+	struct pkg_t *rpkg = xzalloc(sizeof(struct pkg_t));
 
 	static char best_match[sizeof(Pkg.PF)+2+sizeof(Pkg.CATEGORY)];
 
 	best_match[0] = 0;
 
-	memset(pkg, 0, sizeof(struct pkg_t));
-	memset(rpkg, 0, sizeof(struct pkg_t));
-	snprintf(buf, sizeof(buf), "%s/portage/Packages", port_tmpdir);
-
-	if ((fp = fopen(buf, "r")) == NULL)
-		errp("Unable to open package file %s", buf);
+	fp = open_binpkg_index();
 
 	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		if (*buf == '\n') {
@@ -1588,10 +1603,7 @@
 	if (NULL == name)
 		return best_match;
 
-	snprintf(buf, sizeof(buf), "%s/portage/Packages", port_tmpdir);
-
-	if ((fp = fopen(buf, "r")) == NULL)
-		errp("Unable to open package file %s", buf);
+	fp = open_binpkg_index();
 
 	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		if (*buf == '\n') {
@@ -1664,8 +1676,7 @@
 	char *buf, *p;
 	long lineno = 0;
 
-	if ((fp = fopen(Packages, "r")) == NULL)
-		errp("Unable to open package file %s", Packages);
+	fp = open_binpkg_index();
 
 	memset(&Pkg, 0, sizeof(Pkg));
 





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-29  6:29 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-29  6:29 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/29 06:29:55

  Modified:             qmerge.c
  Log:
  qmerge: clean up init logic slightly -- only run mkdir/chdir once, and avoicd access() when we know we wont be downloading anything

Revision  Changes    Path
1.123                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.123&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.123&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.122&r2=1.123

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- qmerge.c	29 Apr 2013 06:28:21 -0000	1.122
+++ qmerge.c	29 Apr 2013 06:29:55 -0000	1.123
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.122 2013/04/29 06:28:21 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.123 2013/04/29 06:29:55 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.122 2013/04/29 06:28:21 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.123 2013/04/29 06:29:55 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -184,20 +184,21 @@
 			errp("could not setup PKGDIR: %s", pkgdir);
 	}
 
-	mkdir_p(port_tmpdir, 0755);
-	xchdir(port_tmpdir);
-	mkdir_p("portage", 0755);
-	xchdir("portage");
-
-	if (force_download && force_download != 2)
-		unlink(Packages);
-
-	if ((access(Packages, R_OK) != 0) && (force_download != 2)) {
-		char *tbuf = NULL;
-		xasprintf(&tbuf, "%s/portage/", port_tmpdir);
-		if (access(Packages, R_OK) != 0)
-			fetch(tbuf, Packages);
-		free(tbuf);
+	char *buf;
+	xasprintf(&buf, "%s/portage", port_tmpdir);
+	mkdir_p(buf, 0755);
+	xchdir(buf);
+
+	if (force_download != 2) {
+		if (force_download)
+			unlink(Packages);
+
+		if (access(Packages, R_OK) != 0) {
+			xasprintf(&buf, "%s/portage/", port_tmpdir);
+			if (access(Packages, R_OK) != 0)
+				fetch(buf, Packages);
+			free(buf);
+		}
 	}
 }
 





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-29 16:18 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-29 16:18 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/29 16:18:34

  Modified:             qmerge.c
  Log:
  qmerge: run pkg_setup too

Revision  Changes    Path
1.125                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.125&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.125&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.124&r2=1.125

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- qmerge.c	29 Apr 2013 06:51:33 -0000	1.124
+++ qmerge.c	29 Apr 2013 16:18:34 -0000	1.125
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.124 2013/04/29 06:51:33 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.125 2013/04/29 16:18:34 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.124 2013/04/29 06:51:33 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.125 2013/04/29 16:18:34 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -881,6 +881,7 @@
 	fflush(stdout);
 
 	eat_file("vdb/DEFINED_PHASES", phases, sizeof(phases));
+	pkg_run_func("vdb", phases, "pkg_setup", D, T);
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 
 	/* XXX: kill this off */





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-29 16:30 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-29 16:30 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/29 16:30:22

  Modified:             qmerge.c
  Log:
  qmerge: run pkg_pretend, set MERGE_TYPE var, and add a few more helper funcs

Revision  Changes    Path
1.126                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.126&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.126&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.125&r2=1.126

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- qmerge.c	29 Apr 2013 16:18:34 -0000	1.125
+++ qmerge.c	29 Apr 2013 16:30:22 -0000	1.126
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.125 2013/04/29 16:18:34 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.126 2013/04/29 16:30:22 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.125 2013/04/29 16:18:34 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.126 2013/04/29 16:30:22 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -432,13 +432,17 @@
 		"debug-print-section() { :; }\n"
 		/* Not quite right */
 		"has_version() { qlist -ICq -e '$1' >/dev/null; }\n"
+		/* best_version() */
 		"use() { useq \"$@\"; }\n"
-		"useq() { hasq $1 $USE; }\n"
+		"usex() { useq \"$1\" && echo \"${2-yes}$4\" || echo \"${3-no}$5\"; }\n"
+		"useq() { hasq \"$1\" $USE; }\n"
 		"has() { hasq \"$@\"; }\n"
 		"hasq() { local h=$1; shift; case \" $* \" in *\" $h \"*) return 0;; *) return 1;; esac; }\n"
+		"hasv() { hasq \"$@\" && echo \"$1\"; }\n"
 		"elog() { printf ' * %%b\\n' \"$*\"; }\n"
 		"einfo() { elog \"$@\"; }\n"
 		"ewarn() { elog \"$@\"; }\n"
+		"eqawarn() { elog \"QA: \"\"$@\"; }\n"
 		"eerror() { elog \"$@\"; }\n"
 		"die() { eerror \"$@\"; exit 1; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
@@ -448,6 +452,7 @@
 		/* Load the main env */
 		". '%1$s/environment'\n"
 		/* Reload env vars that matter to us */
+		"MERGE_TYPE=binary\n"
 		"ROOT='%4$s'\n"
 		"EROOT=\"${EPREFIX%%/}/${ROOT#/}\"\n"
 		"D='%5$s'\n"
@@ -881,6 +886,7 @@
 	fflush(stdout);
 
 	eat_file("vdb/DEFINED_PHASES", phases, sizeof(phases));
+	pkg_run_func("vdb", phases, "pkg_pretend", D, T);
 	pkg_run_func("vdb", phases, "pkg_setup", D, T);
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-29 23:03 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-29 23:03 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/29 23:03:31

  Modified:             qmerge.c
  Log:
  qmerge: create $ROOT when merging if it does not yet exist, and check the return value of merge_tree()

Revision  Changes    Path
1.127                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.127&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.127&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.126&r2=1.127

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -r1.126 -r1.127
--- qmerge.c	29 Apr 2013 16:30:22 -0000	1.126
+++ qmerge.c	29 Apr 2013 23:03:31 -0000	1.127
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.126 2013/04/29 16:30:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.127 2013/04/29 23:03:31 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.126 2013/04/29 16:30:22 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.127 2013/04/29 23:03:31 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -854,17 +854,18 @@
 		return;
 
 	/* Set up our temp dir to unpack this stuff */
-	xasprintf(&p, "%s/qmerge/%s", port_tmpdir, pkg->PF);
+	xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir, pkg->CATEGORY, pkg->PF);
 	mkdir_p(p, 0755);
 	xchdir(p);
+	xasprintf(&D, "%s/image", p);
+	xasprintf(&T, "%s/temp", p);
 	free(p);
 
 	/* Doesn't actually remove $PWD, just everything under it */
 	rm_rf(".");
 
-	xasprintf(&D, "%s/qmerge/%s/image", port_tmpdir, pkg->PF);
-	xasprintf(&T, "%s/qmerge/%s/temp", port_tmpdir, pkg->PF);
 	mkdir("temp", 0755);
+	mkdir_p(portroot, 0755);
 
 	/* XXX: maybe some day we should have this step operate on the
 	 *      tarball directly rather than unpacking it first. */
@@ -915,7 +916,8 @@
 	if ((contents = fopen("vdb/CONTENTS", "w")) == NULL)
 		errf("come on wtf?");
 	objs = NULL;
-	merge_tree("image", portroot, contents, &objs, iargc, iargv);
+	if (merge_tree("image", portroot, contents, &objs, iargc, iargv))
+		errp("failed to merge to %s", portroot);
 	fclose(contents);
 
 	freeargv(iargc, iargv);





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-04-30  1:50 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-30  1:50 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/30 01:50:20

  Modified:             qmerge.c
  Log:
  qmerge: add support for FEATURES=config-protect-if-modified when unmerging

Revision  Changes    Path
1.128                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.128&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.128&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.127&r2=1.128

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- qmerge.c	29 Apr 2013 23:03:31 -0000	1.127
+++ qmerge.c	30 Apr 2013 01:50:20 -0000	1.128
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.127 2013/04/29 23:03:31 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.128 2013/04/30 01:50:20 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.127 2013/04/29 23:03:31 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.128 2013/04/30 01:50:20 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1078,6 +1078,8 @@
 	makeargv(config_protect, &cp_argc, &cp_argv);
 	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
+	bool unmerge_config_protected = !!strstr(features, "config-protect-if-modified");
+
 	while (getline(&buf, &buflen, fp) != -1) {
 		queue *q;
 		contents_entry *e;
@@ -1097,17 +1099,21 @@
 
 		/* Should we remove in order symlinks,objects,dirs ? */
 		switch (e->type) {
-			case CONTENTS_DIR:
-				if (!protected) {
-					/* since the dir contains files, we remove it later */
-					llist_char *list = xmalloc(sizeof(llist_char));
-					list->data = xstrdup(e->name);
-					list->next = dirs;
-					dirs = list;
-				}
+			case CONTENTS_DIR: {
+				/* since the dir contains files, we remove it later */
+				llist_char *list = xmalloc(sizeof(llist_char));
+				list->data = xstrdup(e->name);
+				list->next = dirs;
+				dirs = list;
 				continue;
+			}
 
 			case CONTENTS_OBJ:
+				if (protected && unmerge_config_protected) {
+					/* If the file wasn't modified, unmerge it */
+					unsigned char *hash = hash_file_at(portroot_fd, e->name + 1, HASH_MD5);
+					protected = strcmp(e->digest, (const char *)hash);
+				}
 				break;
 
 			case CONTENTS_SYM:





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-05-03 22:28 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-05-03 22:28 UTC (permalink / raw
  To: gentoo-commits

vapier      13/05/03 22:28:48

  Modified:             qmerge.c
  Log:
  qmerge: drop QMERGE check when unmerging as it should be stable now

Revision  Changes    Path
1.129                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.129&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.129&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.128&r2=1.129

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -r1.128 -r1.129
--- qmerge.c	30 Apr 2013 01:50:20 -0000	1.128
+++ qmerge.c	3 May 2013 22:28:48 -0000	1.129
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.128 2013/04/30 01:50:20 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.129 2013/05/03 22:28:48 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.128 2013/04/30 01:50:20 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.129 2013/05/03 22:28:48 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1923,9 +1923,8 @@
 	qmerge_strict = (strstr("strict", features) == 0) ? 1 : 0;
 
 	/* Short circut this. */
-	if ((install || uninstall) && !pretend) {
+	if (install && !pretend) {
 		if (follow_rdepends && getenv("QMERGE") == NULL) {
-			uninstall = 0;
 			install = 0;
 			warn("Using these options are likely to break your system at this point. export QMERGE=1; if you think you know what your doing.");
 		}





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2013-05-09  5:28 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2013-05-09  5:28 UTC (permalink / raw
  To: gentoo-commits

vapier      13/05/09 05:28:11

  Modified:             qmerge.c
  Log:
  qmerge: change output when removing unmodified config files to <<< rather than ***
  
  also abort if unlinking failed such as trying to remove a file but lack perms (e.g. non-root when ROOT=/)

Revision  Changes    Path
1.130                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.130&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.130&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.129&r2=1.130

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -r1.129 -r1.130
--- qmerge.c	3 May 2013 22:28:48 -0000	1.129
+++ qmerge.c	9 May 2013 05:28:11 -0000	1.130
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.129 2013/05/03 22:28:48 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.130 2013/05/09 05:28:11 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.129 2013/05/03 22:28:48 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.130 2013/05/09 05:28:11 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1092,7 +1092,6 @@
 			continue;
 
 		protected = config_protected(e->name, cp_argc, cp_argv, cpm_argc, cpm_argv);
-		snprintf(zing, sizeof(zing), "%s%s%s", protected ? YELLOW : GREEN, protected ? "***" : "<<<" , NORM);
 
 		/* This should never happen ... */
 		assert(e->name[0] == '/' && e->name[1] != '/');
@@ -1133,6 +1132,8 @@
 				continue;
 		}
 
+		snprintf(zing, sizeof(zing), "%s%s%s", protected ? YELLOW : GREEN, protected ? "***" : "<<<" , NORM);
+
 		if (protected) {
 			qprintf("%s %s\n", zing, e->name);
 			continue;
@@ -1156,7 +1157,8 @@
 		if (!keep || q) {
 			char *p;
 
-			unlinkat(portroot_fd, e->name + 1, 0);
+			if (unlinkat(portroot_fd, e->name + 1, 0))
+				errp("could not unlink: %s%s", portroot, e->name + 1);
 
 			p = strrchr(e->name, '/');
 			if (p) {





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-01-07 19:17 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-01-07 19:17 UTC (permalink / raw
  To: gentoo-commits

vapier      14/01/07 19:17:25

  Modified:             qmerge.c
  Log:
  qmerge: ignore unmerge errors due to missing files in case someone already did `rm` on it

Revision  Changes    Path
1.131                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.131&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.131&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.130&r2=1.131

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -r1.130 -r1.131
--- qmerge.c	9 May 2013 05:28:11 -0000	1.130
+++ qmerge.c	7 Jan 2014 19:17:25 -0000	1.131
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.130 2013/05/09 05:28:11 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.131 2014/01/07 19:17:25 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.130 2013/05/09 05:28:11 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.131 2014/01/07 19:17:25 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1157,8 +1157,11 @@
 		if (!keep || q) {
 			char *p;
 
-			if (unlinkat(portroot_fd, e->name + 1, 0))
-				errp("could not unlink: %s%s", portroot, e->name + 1);
+			if (unlinkat(portroot_fd, e->name + 1, 0)) {
+				/* If a file was already deleted, ignore the error */
+				if (errno != ENOENT)
+					errp("could not unlink: %s%s", portroot, e->name + 1);
+			}
 
 			p = strrchr(e->name, '/');
 			if (p) {





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-02-17  6:32 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-17  6:32 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/17 06:32:33

  Modified:             qmerge.c
  Log:
  qmerge: do not require PORTAGE_BINHOST all the time
  
  perfectly reasonable to only install local binpkgs

Revision  Changes    Path
1.133                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.133&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.133&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.132&r2=1.133

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- qmerge.c	16 Feb 2014 21:14:24 -0000	1.132
+++ qmerge.c	17 Feb 2014 06:32:33 -0000	1.133
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.132 2014/02/16 21:14:24 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.132 2014/02/16 21:14:24 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -113,16 +113,15 @@
 
 _q_static void fetch(const char *destdir, const char *src)
 {
-	char buf[BUFSIZ];
-
 	if (!binhost[0])
-		errf("PORTAGE_BINHOST= does not appear to be valid");
+		return;
 
 	fflush(stdout);
 	fflush(stderr);
 
 #if 0
 	if (getenv("FETCHCOMMAND") != NULL) {
+		char buf[BUFSIZ];
 		snprintf(buf, sizeof(buf), "(export DISTDIR='%s' URI='%s/%s'; %s)",
 			destdir, binhost, src, getenv("FETCHCOMMAND"));
 		xsystem(buf);
@@ -131,6 +130,7 @@
 	{
 		pid_t p;
 		int status;
+		char *path;
 
 		char prog[] = "wget";
 		char argv_c[] = "-c";
@@ -142,18 +142,23 @@
 			argv_c,
 			argv_P,
 			argv_dir,
-			buf,
+			path,
 			quiet ? argv_q : NULL,
 			NULL,
 		};
 		if (!(force_download || install) && pretend)
 			strcpy(prog, "echo");
-		snprintf(buf, sizeof(buf), "%s/%s", binhost, src);
+		xasprintf(&path, "%s/%s", binhost, src);
 
 		p = vfork();
-		if (p == 0)
+		switch (p) {
+		case 0:
 			_exit(execvp(prog, argv));
+		case -1:
+			errp("vfork failed");
+		}
 
+		free(path);
 		free(argv_dir);
 
 		waitpid(p, &status, 0);





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-02-18  4:32 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-18  4:32 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/18 04:32:52

  Modified:             qmerge.c
  Log:
  qmerge: fix path use -- assign it to argv after we init it

Revision  Changes    Path
1.134                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.134&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.134&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.133&r2=1.134

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -r1.133 -r1.134
--- qmerge.c	17 Feb 2014 06:32:33 -0000	1.133
+++ qmerge.c	18 Feb 2014 04:32:52 -0000	1.134
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -132,6 +132,8 @@
 		int status;
 		char *path;
 
+		xasprintf(&path, "%s/%s", binhost, src);
+
 		char prog[] = "wget";
 		char argv_c[] = "-c";
 		char argv_P[] = "-P";
@@ -148,7 +150,6 @@
 		};
 		if (!(force_download || install) && pretend)
 			strcpy(prog, "echo");
-		xasprintf(&path, "%s/%s", binhost, src);
 
 		p = vfork();
 		switch (p) {





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-02-18  6:57 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-18  6:57 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/18 06:57:41

  Modified:             qmerge.c
  Log:
  qmerge: fix has_version definition -- qlist always exits 0, but writes updates to stdout

Revision  Changes    Path
1.135                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.135&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.135&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.134&r2=1.135

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -r1.134 -r1.135
--- qmerge.c	18 Feb 2014 04:32:52 -0000	1.134
+++ qmerge.c	18 Feb 2014 06:57:41 -0000	1.135
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -437,7 +437,7 @@
 		"debug-print-function() { :; }\n"
 		"debug-print-section() { :; }\n"
 		/* Not quite right */
-		"has_version() { qlist -ICq -e '$1' >/dev/null; }\n"
+		"has_version() { [ -n \"$(qlist -ICqe \"$1\")\" ]; }\n"
 		/* best_version() */
 		"use() { useq \"$@\"; }\n"
 		"usex() { useq \"$1\" && echo \"${2-yes}$4\" || echo \"${3-no}$5\"; }\n"





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-02-18  6:58 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-18  6:58 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/18 06:58:13

  Modified:             qmerge.c
  Log:
  qmerge: add emake/FILESDIR definitions
  
  for now, we disable FILESDIR on the assumption there is no PORTDIR anywhere

Revision  Changes    Path
1.136                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.136&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.136&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.135&r2=1.136

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -r1.135 -r1.136
--- qmerge.c	18 Feb 2014 06:57:41 -0000	1.135
+++ qmerge.c	18 Feb 2014 06:58:13 -0000	1.136
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -453,11 +453,13 @@
 		"die() { eerror \"$@\"; exit 1; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
 		"eend() { local r=${1:-$?}; [ $# -gt 0 ] && shift; [ $r -eq 0 ] && echo ' [ ok ]' || echo \" $* \"'[ !! ]'; return $r; }\n"
+		"emake() { ${MAKE:-make} ${MAKEOPTS} \"$@\"; }\n"
 		/* Unpack the env if need be */
 		"[ -e '%1$s/environment' ] || { bzip2 -dc '%1$s/environment.bz2' > '%1$s/environment' || exit 1; }\n"
 		/* Load the main env */
 		". '%1$s/environment'\n"
 		/* Reload env vars that matter to us */
+		"FILESDIR=/.does/not/exist/anywhere\n"
 		"MERGE_TYPE=binary\n"
 		"ROOT='%4$s'\n"
 		"EROOT=\"${EPREFIX%%/}/${ROOT#/}\"\n"





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-02-18  6:58 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-18  6:58 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/18 06:58:45

  Modified:             qmerge.c
  Log:
  qmerge: auto fix local Packages files via `emaint binhost --fix`

Revision  Changes    Path
1.137                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.137&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.137&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.136&r2=1.137

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- qmerge.c	18 Feb 2014 06:58:13 -0000	1.136
+++ qmerge.c	18 Feb 2014 06:58:45 -0000	1.137
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1378,7 +1378,7 @@
 	}
 	if (access(buf, R_OK) == 0) {
 		if (!pkg->SHA1[0] && !pkg->MD5[0]) {
-			warn("No checksum data for %s", buf);
+			warn("No checksum data for %s (try `emaint binhost --fix`)", buf);
 			return;
 		} else {
 			if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, !quiet) == 0) {
@@ -1520,20 +1520,51 @@
 open_binpkg_index(void)
 {
 	FILE *fp;
-	char buf[BUFSIZ];
+	char *path;
 
-	snprintf(buf, sizeof(buf), "%s/portage/%s", port_tmpdir, Packages);
-	fp = fopen(buf, "r");
+	xasprintf(&path, "%s/portage/%s", port_tmpdir, Packages);
+	fp = fopen(path, "r");
 	if (fp)
-		return fp;
+		goto done;
+	free(path);
 
-	snprintf(buf, sizeof(buf), "%s/%s", pkgdir, Packages);
-	fp = fopen(buf, "r");
+	xasprintf(&path, "%s/%s", pkgdir, Packages);
+	fp = fopen(path, "r");
 	if (fp)
-		return fp;
+		goto done;
 
-	errp("Unable to open package file %s in %s/portage or %s",
+	/* This is normal when installing from local repo only. */
+	warnp("Unable to open package file %s in %s/portage or %s",
 		Packages, port_tmpdir, pkgdir);
+	warn("Attempting to manually regen via `emaint binhost`");
+
+	pid_t p;
+	int status;
+
+	char argv_emaint[] = "emaint";
+	char argv_binhost[] = "binhost";
+	char argv_fix[] = "--fix";
+	char *argv[] = {
+		argv_emaint,
+		argv_binhost,
+		argv_fix,
+		NULL,
+	};
+
+	p = vfork();
+	switch (p) {
+	case 0:
+		_exit(execvp(argv[0], argv));
+	case -1:
+		errp("vfork failed");
+	}
+	waitpid(p, &status, 0);
+
+	fp = fopen(path, "r");
+
+ done:
+	free(path);
+	return fp;
 }
 
 _q_static struct pkg_t *
@@ -1812,7 +1843,7 @@
 	free(buf);
 	fclose(fp);
 
-	return 0;
+	return EXIT_SUCCESS;
 }
 
 _q_static queue *





^ permalink raw reply	[flat|nested] 39+ messages in thread

* [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
@ 2014-02-18  6:59 Mike Frysinger (vapier)
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Frysinger (vapier) @ 2014-02-18  6:59 UTC (permalink / raw
  To: gentoo-commits

vapier      14/02/18 06:59:05

  Modified:             qmerge.c
  Log:
  qmerge: add --debug option for auto running shell through `set -x`

Revision  Changes    Path
1.138                portage-utils/qmerge.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.138&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.138&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.137&r2=1.138

Index: qmerge.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- qmerge.c	18 Feb 2014 06:58:45 -0000	1.137
+++ qmerge.c	18 Feb 2014 06:59:05 -0000	1.138
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.138 2014/02/18 06:59:05 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -48,6 +48,7 @@
 	{"yes",     no_argument, NULL, 'y'},
 	{"nodeps",  no_argument, NULL, 'O'},
 	{"nomd5",   no_argument, NULL, '5'},
+	{"debug",   no_argument, NULL, 128},
 	COMMON_LONG_OPTS
 };
 
@@ -62,10 +63,11 @@
 	"Don't prompt before overwriting",
 	"Don't merge dependencies",
 	"Don't verify MD5 digest of files",
+	"Run shell funcs with `set -x`",
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.138 2014/02/18 06:59:05 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -77,6 +79,7 @@
 char nomd5 = 0;
 char qmerge_strict = 0;
 char update_only = 0;
+bool debug = false;
 const char Packages[] = "Packages";
 
 /*
@@ -467,10 +470,16 @@
 		"ED=\"${EPREFIX%%/}/${D#/}\"\n"
 		"T='%6$s'\n"
 		/* Finally run the func */
-		"%2$s\n"
+		"%7$s%2$s\n"
 		/* Ignore func return values (not exit values) */
 		":",
-		vdb_path, func, phase, portroot, D, T);
+		/*1*/ vdb_path,
+		/*2*/ func,
+		/*3*/ phase,
+		/*4*/ portroot,
+		/*5*/ D,
+		/*6*/ T,
+		/*7*/ debug ? "set -x;" : "");
 	xsystembash(script);
 	free(script);
 }
@@ -1961,6 +1970,7 @@
 			case 'y': interactive = 0; break;
 			case 'O': follow_rdepends = 0; break;
 			case '5': nomd5 = 1; break;
+			case 128: debug = true; break;
 			COMMON_GETOPTS_CASES(qmerge)
 		}
 	}





^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2014-02-18  6:59 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-18 20:41 [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c Mike Frysinger (vapier)
  -- strict thread matches above, loose matches on Subject: below --
2014-02-18  6:59 Mike Frysinger (vapier)
2014-02-18  6:58 Mike Frysinger (vapier)
2014-02-18  6:58 Mike Frysinger (vapier)
2014-02-18  6:57 Mike Frysinger (vapier)
2014-02-18  4:32 Mike Frysinger (vapier)
2014-02-17  6:32 Mike Frysinger (vapier)
2014-01-07 19:17 Mike Frysinger (vapier)
2013-05-09  5:28 Mike Frysinger (vapier)
2013-05-03 22:28 Mike Frysinger (vapier)
2013-04-30  1:50 Mike Frysinger (vapier)
2013-04-29 23:03 Mike Frysinger (vapier)
2013-04-29 16:30 Mike Frysinger (vapier)
2013-04-29 16:18 Mike Frysinger (vapier)
2013-04-29  6:29 Mike Frysinger (vapier)
2013-04-29  6:28 Mike Frysinger (vapier)
2013-04-29  6:26 Mike Frysinger (vapier)
2013-04-22  3:55 Mike Frysinger (vapier)
2013-04-20  7:32 Mike Frysinger (vapier)
2011-12-19  4:58 Mike Frysinger (vapier)
2011-12-12 20:47 Fabian Groffen (grobian)
2011-10-02 22:09 Mike Frysinger (vapier)
2011-03-17  2:02 Mike Frysinger (vapier)
2011-03-05 19:28 Ned Ludd (solar)
2011-03-02  9:22 Mike Frysinger (vapier)
2011-03-02  3:51 Ned Ludd (solar)
2011-02-24  1:29 Mike Frysinger (vapier)
2011-02-22  6:10 Mike Frysinger (vapier)
2011-02-21 22:02 Mike Frysinger (vapier)
2011-02-21  1:52 Mike Frysinger (vapier)
2010-06-08  4:52 Mike Frysinger (vapier)
2010-01-18  6:30 Ned Ludd (solar)
2010-01-13 19:15 Mike Frysinger (vapier)
2010-01-13  6:14 Ned Ludd (solar)
2009-05-03 17:19 Ned Ludd (solar)
2009-04-17 14:44 Ned Ludd (solar)
2009-03-21  6:37 Ned Ludd (solar)
2008-05-10 20:21 Diego Petteno (flameeyes)
2007-10-24 16:50 Ned Ludd (solar)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox