* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2007-10-28 21:22 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2007-10-28 21:22 UTC (permalink / raw
To: gentoo-commits
solar 07/10/28 21:22:18
Modified: main.c
Log:
- fix up slotting support a little. raised default warn time about slow file systems so fanboys shutup
Revision Changes Path
1.148 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.148&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.148&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.147&r2=1.148
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- main.c 30 May 2007 23:17:24 -0000 1.147
+++ main.c 28 Oct 2007 21:22:17 -0000 1.148
@@ -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/main.c,v 1.147 2007/05/30 23:17:24 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.148 2007/10/28 21:22:17 solar Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -685,7 +685,7 @@
if (frac < 0) frac = 0;
warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
- if (secs > 100)
+ if (secs > 120)
#ifdef __linux__
warn("You should consider a faster file system such as reiserfs for PORTDIR='%s'", portdir);
#else
@@ -908,6 +908,7 @@
int dfd, i;
char buf[_Q_PATH_MAX];
+ char slot[_Q_PATH_MAX];
static char savecwd[_POSIX_PATH_MAX];
struct dirent **cat;
@@ -947,11 +948,14 @@
if ((atom = atom_explode(buf)) == NULL)
continue;
+ slot[0] = '0';
+ slot[1] = 0;
strncat(buf, "/SLOT", sizeof(buf));
if (access(buf, R_OK) == 0) {
eat_file(buf, buf, sizeof(buf));
rmspace(buf);
- if (strcmp(buf, "0") != 0);
+ if (strcmp(buf, "0") != 0)
+ strncpy(slot, buf, sizeof(slot));
}
if (fullcpv) {
@@ -962,9 +966,8 @@
} else {
snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
}
-
atom_implode(atom);
- cpf = add_set(buf, "0", cpf);
+ cpf = add_set(buf, slot, cpf);
}
chdir("..");
while (dfd--) free(pf[dfd]);
--
gentoo-commits@gentoo.org mailing list
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2008-01-15 8:03 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2008-01-15 8:03 UTC (permalink / raw
To: gentoo-commits
vapier 08/01/15 08:03:35
Modified: main.c
Log:
define and use xrealloc()
Revision Changes Path
1.151 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.151&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.151&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.150&r2=1.151
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- main.c 24 Nov 2007 08:53:35 -0000 1.150
+++ main.c 15 Jan 2008 08:03:35 -0000 1.151
@@ -1,10 +1,10 @@
/*
- * Copyright 2005-2007 Gentoo Foundation
+ * Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.150 2007/11/24 08:53:35 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.151 2008/01/15 08:03:35 vapier Exp $
*
- * Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
- * Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
+ * Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
+ * Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
*/
#define _GNU_SOURCE
@@ -303,7 +303,7 @@
if (*argc == curc) {
curc *= 2;
- (*argv) = (char **) realloc(*argv, sizeof(char **) * curc);
+ (*argv) = xrealloc(*argv, sizeof(char **) * curc);
}
(*argv)[*argc] = xstrdup(str);
(*argc)++;
--
gentoo-commits@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2008-01-16 7:09 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2008-01-16 7:09 UTC (permalink / raw
To: gentoo-commits
vapier 08/01/16 07:09:07
Modified: main.c
Log:
fix edge case when exploding an atom without a version
Revision Changes Path
1.152 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.152&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.152&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.151&r2=1.152
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -r1.151 -r1.152
--- main.c 15 Jan 2008 08:03:35 -0000 1.151
+++ main.c 16 Jan 2008 07:09:06 -0000 1.152
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.151 2008/01/15 08:03:35 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.152 2008/01/16 07:09:06 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
--
gentoo-commits@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2008-05-11 17:25 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2008-05-11 17:25 UTC (permalink / raw
To: gentoo-commits
solar 08/05/11 17:25:01
Modified: main.c
Log:
- fix-uninitialised-value. Bug 221307 - thanks Arvid Norlander
Revision Changes Path
1.155 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.155&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.155&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.154&r2=1.155
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -r1.154 -r1.155
--- main.c 15 Mar 2008 16:28:06 -0000 1.154
+++ main.c 11 May 2008 17:25:00 -0000 1.155
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.154 2008/03/15 16:28:06 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.155 2008/05/11 17:25:00 solar Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -449,6 +449,7 @@
{
char nocolor = 0;
int i, f;
+ ssize_t profilelen;
struct stat st;
FILE *fp;
char buf[BUFSIZE], *s, *p;
@@ -481,10 +482,14 @@
strncat(portroot, "/", sizeof(portroot));
f = 0;
- if (readlink("/etc/make.profile", profile, sizeof(profile)) == -1)
+ profilelen = readlink("/etc/make.profile", profile, sizeof(profile));
+ if (profilelen == -1)
strcpy(profile, "/etc/make.profile");
+ else
+ profile[profilelen]='\0';
+
if (profile[0] != '/') {
- memmove(profile+5, profile, strlen(profile));
+ memmove(profile+5, profile, strnlen(profile, (size_t)profilelen)+1);
memcpy(profile, "/etc/", 5);
}
do {
@@ -709,11 +714,7 @@
warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
if (secs > 120)
-#ifdef __linux__
- warn("You should consider a faster file system such as reiserfs for PORTDIR='%s'", portdir);
-#else
warn("You should consider using the noatime mount option for PORTDIR='%s' if it's not already enabled", portdir);
-#endif
ret:
return cache_file;
}
--
gentoo-commits@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2008-09-13 18:58 Fabian Groffen (grobian)
0 siblings, 0 replies; 49+ messages in thread
From: Fabian Groffen (grobian) @ 2008-09-13 18:58 UTC (permalink / raw
To: gentoo-commits
grobian 08/09/13 18:58:28
Modified: main.c
Log:
strnlen is a GNU extension, use strlen instead.
Revision Changes Path
1.156 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.156&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.156&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.155&r2=1.156
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -r1.155 -r1.156
--- main.c 11 May 2008 17:25:00 -0000 1.155
+++ main.c 13 Sep 2008 18:58:28 -0000 1.156
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.155 2008/05/11 17:25:00 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.156 2008/09/13 18:58:28 grobian Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -482,14 +482,14 @@
strncat(portroot, "/", sizeof(portroot));
f = 0;
- profilelen = readlink("/etc/make.profile", profile, sizeof(profile));
+ profilelen = readlink("/etc/make.profile", profile, sizeof(profile) - 1);
if (profilelen == -1)
strcpy(profile, "/etc/make.profile");
else
profile[profilelen]='\0';
if (profile[0] != '/') {
- memmove(profile+5, profile, strnlen(profile, (size_t)profilelen)+1);
+ memmove(profile+5, profile, strlen(profile)+1);
memcpy(profile, "/etc/", 5);
}
do {
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2008-09-26 16:42 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2008-09-26 16:42 UTC (permalink / raw
To: gentoo-commits
solar 08/09/26 16:42:02
Modified: main.c
Log:
- add new PROPERTIES field for the metadata cache handler
Revision Changes Path
1.157 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.157&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.157&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.156&r2=1.157
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -r1.156 -r1.157
--- main.c 13 Sep 2008 18:58:28 -0000 1.156
+++ main.c 26 Sep 2008 16:42:01 -0000 1.157
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.156 2008/09/13 18:58:28 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.157 2008/09/26 16:42:01 solar Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -756,6 +756,7 @@
char *PDEPEND;
char *PROVIDE; /* line 14 */
char *EAPI;
+ char *PROPERTIES;
depend_atom *atom;
} portage_cache;
@@ -857,6 +858,7 @@
next_line(CDEPEND, PDEPEND)
next_line(PDEPEND, PROVIDE)
next_line(PROVIDE, EAPI)
+ next_line(EAPI, PROPERTIES)
#undef next_line
ptr = strchr(ptr+1, '\n');
*ptr = '\0';
@@ -891,6 +893,7 @@
printf("PDEPEND : %s\n", cache->PDEPEND);
printf("PROVIDE : %s\n", cache->PROVIDE);
printf("EAPI : %s\n", cache->EAPI);
+ printf("PROPERTIES : %s\n", cache->PROPERTIES);
if (!cache->atom) return;
printf("CATEGORY : %s\n", cache->atom->CATEGORY);
printf("PN : %s\n", cache->atom->PN);
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2008-12-07 3:43 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2008-12-07 3:43 UTC (permalink / raw
To: gentoo-commits
solar 08/12/07 03:43:07
Modified: main.c
Log:
- append trailing slash to ${ROOT}
Revision Changes Path
1.159 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.159&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.159&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.158&r2=1.159
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -r1.158 -r1.159
--- main.c 4 Nov 2008 07:23:22 -0000 1.158
+++ main.c 7 Dec 2008 03:43:07 -0000 1.159
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.158 2008/11/04 07:23:22 pva Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.159 2008/12/07 03:43:07 solar Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -588,6 +588,10 @@
}
}
}
+ if ((p = strchr(portroot, '/')) != NULL)
+ if (strlen(p) != 1)
+ strncat(portroot, "/", sizeof(portroot));
+
if (getenv("PORTAGE_QUIET") != NULL)
quiet = 1;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2009-03-15 10:03 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2009-03-15 10:03 UTC (permalink / raw
To: gentoo-commits
vapier 09/03/15 10:03:42
Modified: main.c
Log:
allow people to override default vdb path with Q_VDB env var #257251
Revision Changes Path
1.160 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.160&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.160&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.159&r2=1.160
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -r1.159 -r1.160
--- main.c 7 Dec 2008 03:43:07 -0000 1.159
+++ main.c 15 Mar 2009 10:03:42 -0000 1.160
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.159 2008/12/07 03:43:07 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.160 2009/03/15 10:03:42 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -55,7 +55,7 @@
char reinitialize_metacache = 0;
char portdir[_Q_PATH_MAX] = "/usr/portage";
char portarch[20] = "";
-char portvdb[] = "var/db/pkg";
+char portvdb[_Q_PATH_MAX] = "var/db/pkg";
char portcachedir[] = "metadata/cache";
char portroot[_Q_PATH_MAX] = "/";
char config_protect[_Q_PATH_MAX] = "/etc/";
@@ -496,6 +496,12 @@
{"ROOT", 4, _Q_STR, portroot, sizeof(portroot)}
};
+ s = getenv("Q_VDB"); /* #257251 */
+ if (s) {
+ strncpy(portvdb, s, sizeof(portvdb));
+ portvdb[sizeof(portvdb) - 1] = '\0';
+ }
+
if ((p = strchr(portroot, '/')) != NULL)
if (strlen(p) != 1)
strncat(portroot, "/", sizeof(portroot));
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2009-08-23 6:07 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2009-08-23 6:07 UTC (permalink / raw
To: gentoo-commits
solar 09/08/23 06:07:08
Modified: main.c
Log:
- old patch that needs pushing. I think it fixed the -rX problem with qpkg
Revision Changes Path
1.163 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.163&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.163&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.162&r2=1.163
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -r1.162 -r1.163
--- main.c 24 Mar 2009 20:53:24 -0000 1.162
+++ main.c 23 Aug 2009 06:07:07 -0000 1.163
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.162 2009/03/24 20:53:24 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.163 2009/08/23 06:07:07 solar Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -946,6 +946,11 @@
free(cache);
}
+char *atom_to_pvr(depend_atom *atom);
+char *atom_to_pvr(depend_atom *atom) {
+ return (atom->PR_int == 0 ? atom->P : atom->PVR );
+}
+
char *grab_vdb_item(const char *, const char *, const char *);
char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF)
{
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2009-09-08 16:49 Fabian Groffen (grobian)
0 siblings, 0 replies; 49+ messages in thread
From: Fabian Groffen (grobian) @ 2009-09-08 16:49 UTC (permalink / raw
To: gentoo-commits
grobian 09/09/08 16:49:56
Modified: main.c
Log:
Fix compilation on FreeMiNT by dropping some conflicting but unused code, thanks Alan Hourihane, bug #283497
Revision Changes Path
1.165 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.165&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.165&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.164&r2=1.165
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.164
retrieving revision 1.165
diff -u -r1.164 -r1.165
--- main.c 8 Sep 2009 03:05:40 -0000 1.164
+++ main.c 8 Sep 2009 16:49:56 -0000 1.165
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.164 2009/09/08 03:05:40 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.165 2009/09/08 16:49:56 grobian Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -29,7 +29,6 @@
#include <libgen.h>
#include <limits.h>
#include <assert.h>
-#include <dlfcn.h>
#include "main.h"
/* prototypes and such */
@@ -46,7 +45,6 @@
int lookup_applet_idx(const char *);
/* variables to control runtime behavior */
-void *dlhandle = NULL;
char *module_name = NULL;
char *modpath = NULL;
char exact = 0;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-01-13 6:12 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2010-01-13 6:12 UTC (permalink / raw
To: gentoo-commits
solar 10/01/13 06:12:38
Modified: main.c
Log:
- noop dead code
Revision Changes Path
1.166 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.166&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.166&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.165&r2=1.166
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -r1.165 -r1.166
--- main.c 8 Sep 2009 16:49:56 -0000 1.165
+++ main.c 13 Jan 2010 06:12:38 -0000 1.166
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.165 2009/09/08 16:49:56 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.166 2010/01/13 06:12:38 solar Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -812,59 +812,6 @@
goto err;
len = sizeof(*ret) + s.st_size + 1;
ret = xzalloc(len);
-#if 0
-{ /* This is the expected format of portage-2.0 cache code NAME=var */
- /* at any time ferringb might decide to add new entries. CDEPEND= will be no more */
- char buf[BUFSIZ];
- while ((fgets(buf, sizeof(buf), f)) != NULL) {
- if ((ptr = strrchr(buf, '\n')) != NULL)
- *ptr = 0;
-
- if ((strncmp(buf, "DEPEND=", 7)) == 0)
- ret->DEPEND = xstrdup(buf + 7);
-
- if ((strncmp(buf, "DESCRIPTION=", 12)) == 0)
- ret->DESCRIPTION = xstrdup(buf + 12);
-#if 0
- if ((strncmp(buf, "EAPI=", 5)) == 0)
- warnf("EAPI=%s", buf + 5);
-#endif
- if ((strncmp(buf, "HOMEPAGE=", 9)) == 0)
- ret->HOMEPAGE = xstrdup(buf + 9);
-
- if ((strncmp(buf, "INHERITED=", 10)) == 0)
- ret->INHERITED = xstrdup(buf + 10);
-
- if ((strncmp(buf, "IUSE=", 4)) == 0)
- ret->IUSE = xstrdup(buf + 4);
-
- if ((strncmp(buf, "KEYWORDS=", 9)) == 0)
- ret->KEYWORDS = xstrdup(buf + 9);
-
- if ((strncmp(buf, "LICENSE=", 8)) == 0)
- ret->LICENSE = xstrdup(buf + 8);
-
- if ((strncmp(buf, "PDEPEND=", 8)) == 0)
- ret->PDEPEND = xstrdup(buf + 8);
-
- if ((strncmp(buf, "PROVIDE=", 8)) == 0)
- ret->PROVIDE = xstrdup(buf + 8);
-
- if ((strncmp(buf, "RDEPEND=", 8)) == 0)
- ret->RDEPEND = xstrdup(buf + 8);
-
- if ((strncmp(buf, "RESTRICT=", 9)) == 0)
- ret->RESTRICT = xstrdup(buf + 9);
-
- if ((strncmp(buf, "SLOT=", 5)) == 0)
- ret->SLOT = xstrdup(buf + 5);
-
- if ((strncmp(buf, "SRC_URI=", 8)) == 0)
- ret->SRC_URI = xstrdup(buf + 8);
- }
- rewind(f);
-}
-#endif
ptr = (char*)ret;
ret->_data = ptr + sizeof(*ret);
if ((off_t)fread(ret->_data, 1, s.st_size, f) != s.st_size)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-01-13 18:23 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-01-13 18:23 UTC (permalink / raw
To: gentoo-commits
vapier 10/01/13 18:23:48
Modified: main.c
Log:
shut up freopen() on stderr warnings
Revision Changes Path
1.168 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.168&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.168&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.167&r2=1.168
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -r1.167 -r1.168
--- main.c 13 Jan 2010 18:17:23 -0000 1.167
+++ main.c 13 Jan 2010 18:23:48 -0000 1.168
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.167 2010/01/13 18:17:23 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.168 2010/01/13 18:23:48 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -118,7 +118,7 @@
NULL
#define COMMON_GETOPTS_CASES(applet) \
case 'v': ++verbose; break; \
- case 'q': ++quiet; freopen("/dev/null", "w", stderr); break; \
+ case 'q': ++quiet; stderr = freopen("/dev/null", "w", stderr); break; \
case 'V': version_barf( applet ## _rcsid ); break; \
case 'h': applet ## _usage(EXIT_SUCCESS); break; \
case 'C': no_colors(); break; \
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-01-17 0:24 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-01-17 0:24 UTC (permalink / raw
To: gentoo-commits
vapier 10/01/17 00:24:32
Modified: main.c
Log:
didnt mean to commit that previous change to eat_file, but fix the intended changes rather than revert
Revision Changes Path
1.172 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.172&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.172&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.171&r2=1.172
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -r1.171 -r1.172
--- main.c 16 Jan 2010 23:45:02 -0000 1.171
+++ main.c 17 Jan 2010 00:24:32 -0000 1.172
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.171 2010/01/16 23:45:02 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.172 2010/01/17 00:24:32 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -185,7 +185,6 @@
if ((fd = open(file, O_RDONLY)) == -1)
return ret;
- buf[0] = '\0';
if (fstat(fd, &s) != 0)
goto close_and_ret;
if (s.st_size) {
@@ -193,9 +192,11 @@
goto close_and_ret;
if (read(fd, buf, s.st_size) != (ssize_t)s.st_size)
goto close_and_ret;
+ buf[s.st_size] = '\0';
} else {
if (read(fd, buf, bufsize) == 0)
goto close_and_ret;
+ buf[bufsize] = '\0';
}
ret = 1;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-01-17 0:25 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-01-17 0:25 UTC (permalink / raw
To: gentoo-commits
vapier 10/01/17 00:25:35
Modified: main.c
Log:
make sure eat_file always returns a string with a NUL
Revision Changes Path
1.173 portage-utils/main.c
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.173&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?rev=1.173&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/main.c?r1=1.172&r2=1.173
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -r1.172 -r1.173
--- main.c 17 Jan 2010 00:24:32 -0000 1.172
+++ main.c 17 Jan 2010 00:25:35 -0000 1.173
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.172 2010/01/17 00:24:32 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.173 2010/01/17 00:25:35 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -185,6 +185,7 @@
if ((fd = open(file, O_RDONLY)) == -1)
return ret;
+ buf[0] = '\0';
if (fstat(fd, &s) != 0)
goto close_and_ret;
if (s.st_size) {
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-06-08 4:54 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-06-08 4:54 UTC (permalink / raw
To: gentoo-commits
vapier 10/06/08 04:54:42
Modified: main.c
Log:
fix by Benjamin Franzke for small buffer overflow in eat_file() #311443
Revision Changes Path
1.174 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.174&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.174&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.173&r2=1.174
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -r1.173 -r1.174
--- main.c 17 Jan 2010 00:25:35 -0000 1.173
+++ main.c 8 Jun 2010 04:54:42 -0000 1.174
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.173 2010/01/17 00:25:35 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.174 2010/06/08 04:54:42 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -197,7 +197,7 @@
} else {
if (read(fd, buf, bufsize) == 0)
goto close_and_ret;
- buf[bufsize] = '\0';
+ buf[bufsize - 1] = '\0';
}
ret = 1;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-12-04 11:15 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-12-04 11:15 UTC (permalink / raw
To: gentoo-commits
vapier 10/12/04 11:15:56
Modified: main.c
Log:
check /etc/portage/make.conf too #346569 by Daniel Pielmeier
Revision Changes Path
1.175 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.175&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.175&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.174&r2=1.175
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -r1.174 -r1.175
--- main.c 8 Jun 2010 04:54:42 -0000 1.174
+++ main.c 4 Dec 2010 11:15:56 -0000 1.175
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.174 2010/06/08 04:54:42 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.175 2010/12/04 11:15:56 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -478,7 +478,12 @@
char *e = (char *) EPREFIX;
char profile[_Q_PATH_MAX], portage_file[_Q_PATH_MAX];
- const char *files[] = {portage_file, EPREFIX "/etc/make.globals", EPREFIX "/etc/make.conf"};
+ const char *files[] = {
+ portage_file,
+ EPREFIX "/etc/make.globals",
+ EPREFIX "/etc/make.conf",
+ EPREFIX "/etc/portage/make.conf",
+ };
typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
struct {
const char *name;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-12-04 12:20 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-12-04 12:20 UTC (permalink / raw
To: gentoo-commits
vapier 10/12/04 12:20:43
Modified: main.c
Log:
refactor portage env parsing code so we support "source" keyword in files and we handle multiple stacked parents
Revision Changes Path
1.176 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.176&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.176&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.175&r2=1.176
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -r1.175 -r1.176
--- main.c 4 Dec 2010 11:15:56 -0000 1.175
+++ main.c 4 Dec 2010 12:20:43 -0000 1.176
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.175 2010/12/04 11:15:56 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.176 2010/12/04 12:20:43 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -425,8 +425,7 @@
return &e;
}
-char *strincr_var(const char *, char *, char *, const size_t);
-char *strincr_var(const char *name, char *s, char *value, const size_t value_len)
+static char *strincr_var(const char *name, const char *s, char *value, const size_t value_len)
{
char buf[BUFSIZ];
char *p;
@@ -464,34 +463,122 @@
remove_extra_space(value);
/* we should sort here */
- return (char *) value;
+ return value;
}
-void initialize_portage_env(void)
+typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
+typedef struct {
+ const char *name;
+ const size_t name_len;
+ const var_types type;
+ char *value;
+ const size_t value_len;
+} env_vars;
+
+static void set_portage_env_var(const env_vars var, const char *value)
{
- char nocolor = 0;
- int i, f;
- ssize_t profilelen;
- struct stat st;
+ switch (var.type) {
+ case _Q_BOOL: *var.value = 1; break;
+ case _Q_STR: strncpy(var.value, value, var.value_len); break;
+ case _Q_ISTR: strincr_var(var.name, value, var.value, var.value_len); break;
+ }
+}
+
+/* Helper to read a portage env file (e.g. make.conf) */
+static void read_portage_env_file(const char *file, const env_vars vars[])
+{
+ size_t i;
FILE *fp;
char buf[BUFSIZE], *s, *p;
- char *e = (char *) EPREFIX;
- char profile[_Q_PATH_MAX], portage_file[_Q_PATH_MAX];
- const char *files[] = {
- portage_file,
+ IF_DEBUG(fprintf(stderr, "profile %s\n", file));
+
+ fp = fopen(file, "r");
+ if (fp == NULL)
+ return;
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ rmspace(buf);
+ if (*buf == '#' || *buf == '\0')
+ continue;
+
+ /* Handle "source" keyword */
+ if (!strncmp(buf, "source ", 7))
+ read_portage_env_file(buf + 7, vars);
+
+ /* look for our desired variables and grab their value */
+ for (i = 0; vars[i].name; ++i) {
+ if (buf[vars[i].name_len] != '=' && buf[vars[i].name_len] != ' ')
+ continue;
+ if (strncmp(buf, vars[i].name, vars[i].name_len))
+ continue;
+
+ /* make sure we handle spaces between the varname, the =, and the value:
+ * VAR=val VAR = val VAR="val"
+ */
+ s = buf + vars[i].name_len;
+ if ((p = strchr(s, '=')) != NULL)
+ s = p + 1;
+ while (isspace(*s))
+ ++s;
+ if (*s == '"' || *s == '\'') {
+ ++s;
+ s[strlen(s)-1] = '\0';
+ }
+
+ set_portage_env_var(vars[i], s);
+ }
+ }
+
+ fclose(fp);
+}
+
+/* Helper to recursively read stacked make.defaults in profiles */
+static void read_portage_profile(const char *profile, const env_vars vars[])
+{
+ size_t profile_len, sub_len;
+ char profile_file[_Q_PATH_MAX], *sub_file;
+ char buf[BUFSIZE], *s;
+
+ /* initialize the base profile path */
+ profile_len = strlen(profile);
+ if (profile_len > sizeof(profile_file) - 20)
+ return;
+ strncpy(profile_file, profile, sizeof(profile_file));
+ profile_file[profile_len] = '/';
+ sub_file = profile_file + profile_len + 1;
+ sub_len = sizeof(profile_file) - profile_len - 1;
+
+ /* first consume the profile's make.defaults */
+ strncpy(sub_file, "make.defaults", sub_len);
+ read_portage_env_file(profile_file, vars);
+
+ /* now walk all the parents */
+ strncpy(sub_file, "parent", sub_len);
+ if (eat_file(profile_file, buf, sizeof(buf)) == 0)
+ return;
+ rmspace(buf);
+
+ s = strtok(buf, "\n");
+ while (s) {
+ strncpy(sub_file, s, sub_len);
+ read_portage_profile(profile_file, vars);
+ s = strtok(NULL, "\n");
+ }
+}
+
+void initialize_portage_env(void)
+{
+ size_t i;
+ char *s;
+
+ static const char * const files[] = {
EPREFIX "/etc/make.globals",
EPREFIX "/etc/make.conf",
EPREFIX "/etc/portage/make.conf",
};
- typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
- struct {
- const char *name;
- const size_t name_len;
- const var_types type;
- char *value;
- const size_t value_len;
- } vars_to_read[] = {
+ char nocolor = 0;
+ const env_vars vars_to_read[] = {
{"ACCEPT_LICENSE", 14, _Q_STR, accept_license, sizeof(accept_license)},
{"INSTALL_MASK", 12, _Q_ISTR, install_mask, sizeof(install_mask)},
{"ARCH", 4, _Q_STR, portarch, sizeof(portarch)},
@@ -502,102 +589,36 @@
{"PORTAGE_BINHOST", 15, _Q_STR, binhost, sizeof(binhost)},
{"PORTAGE_TMPDIR", 14, _Q_STR, port_tmpdir, sizeof(port_tmpdir)},
{"PKGDIR", 6, _Q_STR, pkgdir, sizeof(pkgdir)},
- {"ROOT", 4, _Q_STR, portroot, sizeof(portroot)}
+ {"ROOT", 4, _Q_STR, portroot, sizeof(portroot)},
+ { },
};
s = getenv("Q_VDB"); /* #257251 */
if (s) {
strncpy(portvdb, s, sizeof(portvdb));
portvdb[sizeof(portvdb) - 1] = '\0';
- } else if ((i = strlen(e)) > 1) {
+ } else if ((i = strlen(EPREFIX)) > 1) {
memmove(portvdb + i, portvdb, strlen(portvdb));
- memcpy(portvdb, e + 1, i - 1);
+ memcpy(portvdb, EPREFIX + 1, i - 1);
portvdb[i - 1] = '/';
}
- if ((p = strchr(portroot, '/')) != NULL)
- if (strlen(p) != 1)
+ if ((s = strchr(portroot, '/')) != NULL)
+ if (strlen(s) != 1)
strncat(portroot, "/", sizeof(portroot));
- f = 0;
- profilelen = readlink(EPREFIX "/etc/make.profile", profile, sizeof(profile) - 1);
- if (profilelen == -1)
- strcpy(profile, EPREFIX "/etc/make.profile");
- else
- profile[profilelen]='\0';
-
- if (profile[0] != '/') {
- memmove(profile+5+strlen(EPREFIX), profile, strlen(profile)+1);
- memcpy(profile, EPREFIX "/etc/", strlen(EPREFIX) + 5);
- }
- do {
- if (f == 0)
- snprintf(portage_file, sizeof(portage_file), "%s/make.defaults", profile);
- IF_DEBUG(fprintf(stderr, "profile %s\n", files[f]));
+ /* walk all the stacked profiles */
+ read_portage_profile(EPREFIX "/etc/make.profile", vars_to_read);
- if ((fp=fopen(files[f], "r")) != NULL) {
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- rmspace(buf);
- if (*buf == '#' || *buf == '\0')
- continue;
- for (i=0; i < ARR_SIZE(vars_to_read); ++i) {
- if (buf[vars_to_read[i].name_len] != '=' && buf[vars_to_read[i].name_len] != ' ')
- continue;
- if (strncmp(buf, vars_to_read[i].name, vars_to_read[i].name_len))
- continue;
-
- /* make sure we handle spaces between the varname, the =, and the value:
- * VAR=val VAR = val VAR="val"
- */
- s = buf + vars_to_read[i].name_len;
- if ((p = strchr(s, '=')) != NULL)
- s = p + 1;
- while (isspace(*s))
- ++s;
- if (*s == '"' || *s == '\'') {
- ++s;
- s[strlen(s)-1] = '\0';
- }
-
- switch (vars_to_read[i].type) {
- case _Q_BOOL: *vars_to_read[i].value = 1; break;
- case _Q_STR: strncpy(vars_to_read[i].value, s, vars_to_read[i].value_len); break;
- case _Q_ISTR: strincr_var(vars_to_read[i].name, s, vars_to_read[i].value, vars_to_read[i].value_len); break;
- }
- }
- }
- fclose(fp);
- }
-
- if (f > 0) {
- if (++f < ARR_SIZE(files))
- continue;
- else
- break;
- }
-
- /* everything below here is to figure out what the next parent is */
- snprintf(portage_file, sizeof(portage_file), "%s/parent", profile);
- if (stat(portage_file, &st) == 0) {
- eat_file(portage_file, buf, sizeof(buf));
- rmspace(buf);
- portage_file[strlen(portage_file)-7] = '\0';
- snprintf(profile, sizeof(profile), "%s/%s", portage_file, buf);
- } else {
- f = 1;
- }
- } while (1);
+ /* now read all the config files */
+ for (i = 0; i < ARR_SIZE(files); ++i)
+ read_portage_env_file(files[i], vars_to_read);
/* finally, check the env */
- for (i=0; i < ARR_SIZE(vars_to_read); ++i) {
+ for (i = 0; vars_to_read[i].name; ++i) {
s = getenv(vars_to_read[i].name);
- if (s != NULL) {
- switch (vars_to_read[i].type) {
- case _Q_BOOL: *vars_to_read[i].value = 1; break;
- case _Q_STR: strncpy(vars_to_read[i].value, s, vars_to_read[i].value_len); break;
- case _Q_ISTR: strincr_var(vars_to_read[i].name, s, vars_to_read[i].value, vars_to_read[i].value_len); break;
- }
- }
+ if (s != NULL)
+ set_portage_env_var(vars_to_read[i], s);
if (getenv("DEBUG") IF_DEBUG(|| 1)) {
fprintf(stderr, "%s = ", vars_to_read[i].name);
switch (vars_to_read[i].type) {
@@ -607,8 +628,8 @@
}
}
}
- if ((p = strchr(portroot, '/')) != NULL)
- if (strlen(p) != 1)
+ if ((s = strchr(portroot, '/')) != NULL)
+ if (strlen(s) != 1)
strncat(portroot, "/", sizeof(portroot));
if (getenv("PORTAGE_QUIET") != NULL)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-12-04 12:37 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-12-04 12:37 UTC (permalink / raw
To: gentoo-commits
vapier 10/12/04 12:37:28
Modified: main.c
Log:
handle multiline quoted variables in config files #315261 by Michał Górny
Revision Changes Path
1.177 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.177&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.177&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.176&r2=1.177
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -r1.176 -r1.177
--- main.c 4 Dec 2010 12:20:43 -0000 1.176
+++ main.c 4 Dec 2010 12:37:28 -0000 1.177
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.176 2010/12/04 12:20:43 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.177 2010/12/04 12:37:28 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -522,8 +522,26 @@
while (isspace(*s))
++s;
if (*s == '"' || *s == '\'') {
- ++s;
- s[strlen(s)-1] = '\0';
+ size_t l = strlen(s);
+ if (*s != s[l - 1]) {
+ /* If the last char is not a quote, then we span lines */
+ char *q = s + l + 1, *qq = NULL;
+ q[-1] = ' ';
+ while (fgets(q, sizeof(buf) - (s - buf), fp) != NULL) {
+ l = strlen(q);
+ qq = strchr(q, *s);
+ if (qq) {
+ *qq = '\0';
+ break;
+ }
+ }
+ if (!qq)
+ warn("%s: %s: quote mismatch", file, vars[i].name);
+ ++s;
+ } else {
+ s[l - 1] = '\0';
+ ++s;
+ }
}
set_portage_env_var(vars[i], s);
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-12-07 1:13 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2010-12-07 1:13 UTC (permalink / raw
To: gentoo-commits
vapier 10/12/07 01:13:04
Modified: main.c
Log:
also read /usr/share/portage/config/make.globals and /etc/portage/make.profile #346569
Revision Changes Path
1.178 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.178&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.178&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.177&r2=1.178
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -r1.177 -r1.178
--- main.c 4 Dec 2010 12:37:28 -0000 1.177
+++ main.c 7 Dec 2010 01:13:04 -0000 1.178
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.177 2010/12/04 12:37:28 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.178 2010/12/07 01:13:04 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -592,6 +592,7 @@
static const char * const files[] = {
EPREFIX "/etc/make.globals",
+ EPREFIX "/usr/share/portage/config/make.globals",
EPREFIX "/etc/make.conf",
EPREFIX "/etc/portage/make.conf",
};
@@ -627,6 +628,7 @@
/* walk all the stacked profiles */
read_portage_profile(EPREFIX "/etc/make.profile", vars_to_read);
+ read_portage_profile(EPREFIX "/etc/portage/make.profile", vars_to_read);
/* now read all the config files */
for (i = 0; i < ARR_SIZE(files); ++i)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2010-12-19 13:15 Fabian Groffen (grobian)
0 siblings, 0 replies; 49+ messages in thread
From: Fabian Groffen (grobian) @ 2010-12-19 13:15 UTC (permalink / raw
To: gentoo-commits
grobian 10/12/19 13:15:31
Modified: main.c
Log:
assign freopen output to a dummy, to fix compilation on platforms where stderr is not something that can be assigned to
Revision Changes Path
1.179 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.179&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.179&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.178&r2=1.179
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -r1.178 -r1.179
--- main.c 7 Dec 2010 01:13:04 -0000 1.178
+++ main.c 19 Dec 2010 13:15:31 -0000 1.179
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.178 2010/12/07 01:13:04 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.179 2010/12/19 13:15:31 grobian Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -118,7 +118,7 @@
NULL
#define COMMON_GETOPTS_CASES(applet) \
case 'v': ++verbose; break; \
- case 'q': ++quiet; stderr = freopen("/dev/null", "w", stderr); break; \
+ case 'q': { FILE *dummy; ++quiet; dummy = freopen("/dev/null", "w", stderr); break; } \
case 'V': version_barf( applet ## _rcsid ); break; \
case 'h': applet ## _usage(EXIT_SUCCESS); break; \
case 'C': no_colors(); break; \
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-02-28 18:16 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-02-28 18:16 UTC (permalink / raw
To: gentoo-commits
vapier 11/02/28 18:16:11
Modified: main.c
Log:
need stdarg for new helper
Revision Changes Path
1.186 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.186&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.186&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.185&r2=1.186
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -r1.185 -r1.186
--- main.c 23 Feb 2011 22:58:51 -0000 1.185
+++ main.c 28 Feb 2011 18:16:11 -0000 1.186
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.185 2011/02/23 22:58:51 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.186 2011/02/28 18:16:11 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -12,6 +12,7 @@
#define _LINUX_SOURCE_COMPAT
#endif
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-03-02 2:40 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-02 2:40 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/02 02:40:19
Modified: main.c
Log:
convert grab_vdb_item to eat_file, and drop the leading slash on vdb path for now
Revision Changes Path
1.187 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.187&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.187&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.186&r2=1.187
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -r1.186 -r1.187
--- main.c 28 Feb 2011 18:16:11 -0000 1.186
+++ main.c 2 Mar 2011 02:40:19 -0000 1.187
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.186 2011/02/28 18:16:11 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.187 2011/03/02 02:40:19 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -688,7 +688,10 @@
_Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "/var/tmp/portage/")
_Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "/usr/portage/packages/")
_Q_EVS(STR, ROOT, portroot, "/")
- _Q_EVS(STR, Q_VDB, portvdb, EPREFIX "/var/db/pkg")
+ /* XXX: This needs to not have a leading slash since some of the q
+ * utils use chdir(root) && chdir(portvdb). Once those are
+ * fixed, we can add a proper leading slash here. */
+ _Q_EVS(STR, Q_VDB, portvdb, EPREFIX "var/db/pkg")
{ }
#undef _Q_EV
@@ -1022,21 +1025,12 @@
return (atom->PR_int == 0 ? atom->P : atom->PVR );
}
-char *grab_vdb_item(const char *, const char *, const char *);
-char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF)
+static char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF)
{
static char buf[_Q_PATH_MAX];
- char *p;
- FILE *fp;
snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
- if ((fp = fopen(buf, "r")) == NULL)
- return NULL;
- if (fgets(buf, sizeof(buf), fp) == NULL)
- buf[0] = '\0';
- if ((p = strchr(buf, '\n')) != NULL)
- *p = 0;
- fclose(fp);
+ eat_file(buf, buf, sizeof(buf));
rmspace(buf);
return buf;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-03-02 5:31 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-02 5:31 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/02 05:31:46
Modified: main.c
Log:
fix up extended line reading to avoid buffer overflows
Revision Changes Path
1.188 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.188&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.188&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.187&r2=1.188
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -r1.187 -r1.188
--- main.c 2 Mar 2011 02:40:19 -0000 1.187
+++ main.c 2 Mar 2011 05:31:46 -0000 1.188
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.187 2011/03/02 02:40:19 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.188 2011/03/02 05:31:46 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -11,6 +11,9 @@
#ifdef _AIX
#define _LINUX_SOURCE_COMPAT
#endif
+#ifndef _q_static
+# define _q_static static
+#endif
#include <stdarg.h>
#include <stdio.h>
@@ -529,7 +532,7 @@
const char *default_value;
} env_vars;
-static void set_portage_env_var(env_vars *var, const char *value)
+_q_static void set_portage_env_var(env_vars *var, const char *value)
{
switch (var->type) {
case _Q_BOOL:
@@ -546,7 +549,7 @@
}
/* Helper to read a portage env file (e.g. make.conf) */
-static void read_portage_env_file(const char *file, env_vars vars[])
+_q_static void read_portage_env_file(const char *file, env_vars vars[])
{
size_t i, buflen, line;
FILE *fp;
@@ -586,22 +589,32 @@
while (isspace(*s))
++s;
if (*s == '"' || *s == '\'') {
+ char q = *s;
size_t l = strlen(s);
- if (*s != s[l - 1]) {
+
+ if (q != s[l - 1]) {
/* If the last char is not a quote, then we span lines */
- char *q = s + l + 1, *qq = NULL;
- q[-1] = ' ';
- while (fgets(q, buflen - (s - buf), fp) != NULL) {
- l = strlen(q);
- qq = strchr(q, *s);
+ size_t abuflen;
+ char *abuf, *qq;
+
+ qq = abuf = NULL;
+ while (getline(&abuf, &abuflen, fp) != -1) {
+ buf = xrealloc(buf, buflen + abuflen);
+ strcat(buf, abuf);
+ buflen += abuflen;
+
+ qq = strchr(abuf, q);
if (qq) {
*qq = '\0';
break;
}
}
+ free(abuf);
+
if (!qq)
warn("%s:%zu: %s: quote mismatch", file, line, vars[i].name);
- ++s;
+
+ s = buf + vars[i].name_len + 1;
} else {
s[l - 1] = '\0';
++s;
@@ -702,10 +715,6 @@
if (vars_to_read[i].type != _Q_BOOL)
*vars_to_read[i].value.s = xstrdup(vars_to_read[i].default_value);
- if ((s = strchr(portroot, '/')) != NULL)
- if (strlen(s) != 1)
- strncat(portroot, "/", sizeof(portroot));
-
/* walk all the stacked profiles */
read_portage_profile(EPREFIX "/etc/make.profile", vars_to_read);
read_portage_profile(EPREFIX "/etc/portage/make.profile", vars_to_read);
@@ -729,10 +738,6 @@
}
}
- if ((s = strchr(portroot, '/')) != NULL)
- if (strlen(s) != 1)
- strncat(portroot, "/", sizeof(portroot));
-
if (getenv("PORTAGE_QUIET") != NULL)
quiet = 1;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-03-02 7:55 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-02 7:55 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/02 07:55:57
Modified: main.c
Log:
make sure new eat_file_at helper always sets up buf
Revision Changes Path
1.189 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.189&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.189&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.188&r2=1.189
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -r1.188 -r1.189
--- main.c 2 Mar 2011 05:31:46 -0000 1.188
+++ main.c 2 Mar 2011 07:55:57 -0000 1.189
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.188 2011/03/02 05:31:46 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.189 2011/03/02 07:55:57 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -204,8 +204,10 @@
int fd;
char ret;
- if ((fd = openat(dfd, file, O_RDONLY)) == -1)
+ if ((fd = openat(dfd, file, O_RDONLY)) == -1) {
+ buf[0] = '\0';
return 0;
+ }
ret = eat_file_fd(fd, buf, bufsize);
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-03-02 8:10 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-02 8:10 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/02 08:10:39
Modified: main.c
Log:
restore & simplify the ROOT slash append check
Revision Changes Path
1.190 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.190&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.190&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.189&r2=1.190
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -r1.189 -r1.190
--- main.c 2 Mar 2011 07:55:57 -0000 1.189
+++ main.c 2 Mar 2011 08:10:39 -0000 1.190
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.189 2011/03/02 07:55:57 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.190 2011/03/02 08:10:39 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -542,7 +542,7 @@
break;
case _Q_STR:
free(*var->value.s);
- *var->value.s = xstrdup(value);
+ *var->value.s = xstrdup_len(value, &var->value_len);
break;
case _Q_ISTR:
strincr_var(var->name, value, var->value.s, &var->value_len);
@@ -678,6 +678,7 @@
};
bool nocolor = 0;
+ env_vars *var;
env_vars vars_to_read[] = {
#define _Q_EV(t, V, set, lset, d) \
{ \
@@ -691,6 +692,7 @@
#define _Q_EVS(t, V, v, d) _Q_EV(t, V, .value.s = &v, .value_len = strlen(d), d)
#define _Q_EVB(t, V, v, d) _Q_EV(t, V, .value.b = &v, .value_len = 0, d)
+ _Q_EVS(STR, ROOT, portroot, "/")
_Q_EVS(STR, ACCEPT_LICENSE, accept_license, "")
_Q_EVS(ISTR, INSTALL_MASK, install_mask, "")
_Q_EVS(STR, ARCH, portarch, "")
@@ -702,7 +704,6 @@
_Q_EVS(STR, PORTAGE_BINHOST, binhost, DEFAULT_PORTAGE_BINHOST)
_Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "/var/tmp/portage/")
_Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "/usr/portage/packages/")
- _Q_EVS(STR, ROOT, portroot, "/")
/* XXX: This needs to not have a leading slash since some of the q
* utils use chdir(root) && chdir(portvdb). Once those are
* fixed, we can add a proper leading slash here. */
@@ -713,9 +714,11 @@
};
/* initialize all the strings with their default value */
- for (i = 0; vars_to_read[i].name; ++i)
- if (vars_to_read[i].type != _Q_BOOL)
- *vars_to_read[i].value.s = xstrdup(vars_to_read[i].default_value);
+ for (i = 0; vars_to_read[i].name; ++i) {
+ var = &vars_to_read[i];
+ if (var->type != _Q_BOOL)
+ *var->value.s = xstrdup(var->default_value);
+ }
/* walk all the stacked profiles */
read_portage_profile(EPREFIX "/etc/make.profile", vars_to_read);
@@ -727,19 +730,28 @@
/* finally, check the env */
for (i = 0; vars_to_read[i].name; ++i) {
- s = getenv(vars_to_read[i].name);
+ var = &vars_to_read[i];
+ s = getenv(var->name);
if (s != NULL)
- set_portage_env_var(&vars_to_read[i], s);
+ set_portage_env_var(var, s);
if (getenv("DEBUG") IF_DEBUG(|| 1)) {
- fprintf(stderr, "%s = ", vars_to_read[i].name);
+ fprintf(stderr, "%s = ", var->name);
switch (vars_to_read[i].type) {
- case _Q_BOOL: fprintf(stderr, "%i\n", *vars_to_read[i].value.b); break;
+ case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
case _Q_STR:
- case _Q_ISTR: fprintf(stderr, "%s\n", *vars_to_read[i].value.s); break;
+ case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
}
}
}
+ /* Make sure ROOT always ends in a slash */
+ var = &vars_to_read[0];
+ if ((*var->value.s)[var->value_len - 1] != '/') {
+ portroot = xrealloc(portroot, var->value_len + 2);
+ portroot[var->value_len] = '/';
+ portroot[var->value_len + 1] = '\0';
+ }
+
if (getenv("PORTAGE_QUIET") != NULL)
quiet = 1;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-03-17 3:04 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-03-17 3:04 UTC (permalink / raw
To: gentoo-commits
vapier 11/03/17 03:04:03
Modified: main.c
Log:
add support for PORTAGE_CONFIGROOT
Revision Changes Path
1.191 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.191&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.191&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.190&r2=1.191
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -r1.190 -r1.191
--- main.c 2 Mar 2011 08:10:39 -0000 1.190
+++ main.c 17 Mar 2011 03:04:03 -0000 1.191
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.190 2011/03/02 08:10:39 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.191 2011/03/17 03:04:03 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -35,6 +35,10 @@
#include <assert.h>
#include "main.h"
+#ifndef EPREFIX
+# define EPREFIX "/"
+#endif
+
/* prototypes and such */
static char eat_file(const char *file, char *buf, const size_t bufsize);
int charmatch(const char *str1, const char *str2);
@@ -632,27 +636,31 @@
}
/* Helper to recursively read stacked make.defaults in profiles */
-static void read_portage_profile(const char *profile, env_vars vars[])
+static void read_portage_profile(const char *configroot, const char *profile, env_vars vars[])
{
- size_t profile_len, sub_len;
- char profile_file[_Q_PATH_MAX], *sub_file;
+ size_t configroot_len, profile_len, sub_len;
+ char *profile_file, *sub_file;
char buf[BUFSIZE], *s;
/* initialize the base profile path */
+ if (!configroot)
+ configroot = "";
+ configroot_len = strlen(configroot);
profile_len = strlen(profile);
- if (profile_len > sizeof(profile_file) - 20)
- return;
- strncpy(profile_file, profile, sizeof(profile_file));
- profile_file[profile_len] = '/';
- sub_file = profile_file + profile_len + 1;
- sub_len = sizeof(profile_file) - profile_len - 1;
+ sub_len = 1024; /* should be big enough for longest line in "parent" */
+ profile_file = xmalloc(configroot_len + profile_len + sub_len + 2);
+
+ memcpy(profile_file, configroot, configroot_len);
+ memcpy(profile_file + configroot_len, profile, profile_len);
+ sub_file = profile_file + configroot_len + profile_len + 1;
+ sub_file[-1] = '/';
/* first consume the profile's make.defaults */
- strncpy(sub_file, "make.defaults", sub_len);
+ strcpy(sub_file, "make.defaults");
read_portage_env_file(profile_file, vars);
/* now walk all the parents */
- strncpy(sub_file, "parent", sub_len);
+ strcpy(sub_file, "parent");
if (eat_file(profile_file, buf, sizeof(buf)) == 0)
return;
rmspace(buf);
@@ -660,21 +668,23 @@
s = strtok(buf, "\n");
while (s) {
strncpy(sub_file, s, sub_len);
- read_portage_profile(profile_file, vars);
+ read_portage_profile(NULL, profile_file, vars);
s = strtok(NULL, "\n");
}
+
+ free(profile_file);
}
void initialize_portage_env(void)
{
size_t i;
- char *s;
+ const char *s;
static const char * const files[] = {
- EPREFIX "/etc/make.globals",
- EPREFIX "/usr/share/portage/config/make.globals",
- EPREFIX "/etc/make.conf",
- EPREFIX "/etc/portage/make.conf",
+ EPREFIX "etc/make.globals",
+ EPREFIX "usr/share/portage/config/make.globals",
+ EPREFIX "etc/make.conf",
+ EPREFIX "etc/portage/make.conf",
};
bool nocolor = 0;
@@ -696,17 +706,14 @@
_Q_EVS(STR, ACCEPT_LICENSE, accept_license, "")
_Q_EVS(ISTR, INSTALL_MASK, install_mask, "")
_Q_EVS(STR, ARCH, portarch, "")
- _Q_EVS(ISTR, CONFIG_PROTECT, config_protect, EPREFIX "/etc")
+ _Q_EVS(ISTR, CONFIG_PROTECT, config_protect, EPREFIX "etc")
_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
_Q_EVB(BOOL, NOCOLOR, nocolor, 0)
_Q_EVS(ISTR, FEATURES, features, "noman noinfo nodoc")
- _Q_EVS(STR, PORTDIR, portdir, EPREFIX "/usr/portage")
+ _Q_EVS(STR, PORTDIR, portdir, EPREFIX "usr/portage")
_Q_EVS(STR, PORTAGE_BINHOST, binhost, DEFAULT_PORTAGE_BINHOST)
- _Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "/var/tmp/portage/")
- _Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "/usr/portage/packages/")
- /* XXX: This needs to not have a leading slash since some of the q
- * utils use chdir(root) && chdir(portvdb). Once those are
- * fixed, we can add a proper leading slash here. */
+ _Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "var/tmp/portage/")
+ _Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "usr/portage/packages/")
_Q_EVS(STR, Q_VDB, portvdb, EPREFIX "var/db/pkg")
{ }
@@ -721,8 +728,11 @@
}
/* walk all the stacked profiles */
- read_portage_profile(EPREFIX "/etc/make.profile", vars_to_read);
- read_portage_profile(EPREFIX "/etc/portage/make.profile", vars_to_read);
+ s = getenv("PORTAGE_CONFIGROOT");
+ if (!s)
+ s = "/";
+ read_portage_profile(s, EPREFIX "etc/make.profile", vars_to_read);
+ read_portage_profile(s, EPREFIX "etc/portage/make.profile", vars_to_read);
/* now read all the config files */
for (i = 0; i < ARRAY_SIZE(files); ++i)
@@ -1152,7 +1162,7 @@
#ifdef ENABLE_NLS /* never tested */
setlocale(LC_ALL, "");
- bindtextdomain(argv0, EPREFIX "/usr/share/locale");
+ bindtextdomain(argv0, EPREFIX "usr/share/locale");
textdomain(argv0);
#endif
#if 1
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-10-02 22:08 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-10-02 22:08 UTC (permalink / raw
To: gentoo-commits
vapier 11/10/02 22:08:11
Modified: main.c
Log:
tweak how we ignore the return of freopen() to work with gcc-4.6+
Revision Changes Path
1.194 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.194&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.194&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.193&r2=1.194
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -r1.193 -r1.194
--- main.c 30 Mar 2011 05:33:19 -0000 1.193
+++ main.c 2 Oct 2011 22:08:11 -0000 1.194
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.193 2011/03/30 05:33:19 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.194 2011/10/02 22:08:11 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -119,7 +119,7 @@
NULL
#define COMMON_GETOPTS_CASES(applet) \
case 'v': ++verbose; break; \
- case 'q': { FILE *dummy; ++quiet; dummy = freopen("/dev/null", "w", stderr); break; } \
+ case 'q': ++quiet; if (freopen("/dev/null", "w", stderr)); break; \
case 'V': version_barf( applet ## _rcsid ); break; \
case 'h': applet ## _usage(EXIT_SUCCESS); break; \
case 'C': no_colors(); break; \
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-09 16:50 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-09 16:50 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/09 16:50:29
Modified: main.c
Log:
use getline() from the C library #394139 by Naohiro Aota
Revision Changes Path
1.196 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.196&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.196&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.195&r2=1.196
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -r1.195 -r1.196
--- main.c 3 Oct 2011 01:25:54 -0000 1.195
+++ main.c 9 Dec 2011 16:50:29 -0000 1.196
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.195 2011/10/03 01:25:54 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.196 2011/12/09 16:50:29 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -217,34 +217,6 @@
return eat_file_at(AT_FDCWD, file, buf, bufsize);
}
-#if !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
-static ssize_t getline(char **line, size_t *len, FILE *fp)
-{
- char *s;
- size_t off;
-
- if (!*line) {
- *len = BUFSIZE;
- *line = xmalloc(*len);
- }
-
- off = 0;
- while (1) {
- s = fgets(*line + off, *len - off, fp);
- if (s == NULL)
- return -1;
-
- s = strchr(s, '\n');
- if (s)
- break;
-
- off = *len;
- *len += BUFSIZE;
- *line = xrealloc(*line, *len);
- }
-}
-#endif
-
static bool prompt(const char *p)
{
printf("%s? [Y/n] ", p);
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-12 21:42 Fabian Groffen (grobian)
0 siblings, 0 replies; 49+ messages in thread
From: Fabian Groffen (grobian) @ 2011-12-12 21:42 UTC (permalink / raw
To: gentoo-commits
grobian 11/12/12 21:42:23
Modified: main.c
Log:
include config.h for EPREFIX from configure
Revision Changes Path
1.199 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.199&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.199&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.198&r2=1.199
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -r1.198 -r1.199
--- main.c 12 Dec 2011 21:29:22 -0000 1.198
+++ main.c 12 Dec 2011 21:42:23 -0000 1.199
@@ -1,12 +1,16 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.198 2011/12/12 21:29:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.199 2011/12/12 21:42:23 grobian Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h" /* make sure we have EPREFIX, if set */
+#endif
+
#define _GNU_SOURCE
#ifdef _AIX
#define _LINUX_SOURCE_COMPAT
@@ -30,7 +34,6 @@
#include <libgen.h>
#include <limits.h>
#include <assert.h>
-
#include "main.h"
/* prototypes and such */
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-18 3:04 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-18 3:04 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/18 03:04:07
Modified: main.c
Log:
expand nested variables when using known important ones #307625 by Wilke Schwiedop
Revision Changes Path
1.201 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.201&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.201&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.200&r2=1.201
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -r1.200 -r1.201
--- main.c 18 Dec 2011 01:17:14 -0000 1.200
+++ main.c 18 Dec 2011 03:04:07 -0000 1.201
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.200 2011/12/18 01:17:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.201 2011/12/18 03:04:07 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -64,6 +64,7 @@
static char *portvdb;
const char portcachedir[] = "metadata/cache";
static char *portroot;
+static char *eprefix;
static char *config_protect, *config_protect_mask;
static char *pkgdir;
@@ -501,6 +502,17 @@
const char *default_value;
} env_vars;
+_q_static env_vars *get_portage_env_var(env_vars *vars, const char *name)
+{
+ size_t i;
+
+ for (i = 0; vars[i].name; ++i)
+ if (!strcmp(vars[i].name, name))
+ return &vars[i];
+
+ return NULL;
+}
+
_q_static void set_portage_env_var(env_vars *var, const char *value)
{
switch (var->type) {
@@ -673,6 +685,7 @@
_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
_Q_EVB(BOOL, NOCOLOR, nocolor, 0)
_Q_EVS(ISTR, FEATURES, features, "noman noinfo nodoc")
+ _Q_EVS(STR, EPREFIX, eprefix, EPREFIX)
_Q_EVS(STR, PORTDIR, portdir, EPREFIX "usr/portage")
_Q_EVS(STR, PORTAGE_BINHOST, binhost, DEFAULT_PORTAGE_BINHOST)
_Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "var/tmp/portage/")
@@ -709,7 +722,7 @@
set_portage_env_var(var, s);
if (getenv("DEBUG") IF_DEBUG(|| 1)) {
fprintf(stderr, "%s = ", var->name);
- switch (vars_to_read[i].type) {
+ switch (var->type) {
case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
case _Q_STR:
case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
@@ -717,6 +730,70 @@
}
}
+ /* expand any nested variables e.g. PORTDIR=${EPREFIX}/usr/portage */
+ for (i = 0; vars_to_read[i].name; ++i) {
+ char *svar;
+
+ var = &vars_to_read[i];
+ if (var->type == _Q_BOOL)
+ continue;
+
+ while ((svar = strchr(*var->value.s, '$'))) {
+ env_vars *evar;
+ bool brace;
+ const char *sval;
+ size_t slen, pre_len, var_len, post_len;
+ char byte;
+
+ pre_len = svar - *var->value.s;
+
+ /* First skip the leading "${" */
+ s = ++svar;
+ brace = (*svar == '{');
+ if (brace)
+ s = ++svar;
+
+ /* Now skip the variable name itself */
+ while (isalnum(*svar) || *svar == '_')
+ ++svar;
+
+ /* Finally skip the trailing "}" */
+ if (brace && *svar != '}') {
+ warn("invalid variable setting: %s\n", *var->value.s);
+ break;
+ }
+
+ var_len = svar - *var->value.s + 1;
+
+ byte = *svar;
+ *svar = '\0';
+ evar = get_portage_env_var(vars_to_read, s);
+ if (evar) {
+ sval = *evar->value.s;
+ } else {
+ sval = getenv(s);
+ if (!sval)
+ sval = "";
+ }
+ *svar = byte;
+ slen = strlen(sval);
+ post_len = strlen(svar + 1);
+ *var->value.s = xrealloc(*var->value.s, pre_len + MAX(var_len, slen) + post_len + 1);
+
+ /*
+ * VAR=XxXxX (slen = 5)
+ * FOO${VAR}BAR
+ * pre_len = 3
+ * var_len = 6
+ * post_len = 3
+ */
+ memmove(*var->value.s + pre_len + slen,
+ *var->value.s + pre_len + var_len,
+ post_len + 1);
+ memcpy(*var->value.s + pre_len, sval, slen);
+ }
+ }
+
/* Make sure ROOT always ends in a slash */
var = &vars_to_read[0];
if ((*var->value.s)[var->value_len - 1] != '/') {
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-18 20:21 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-18 20:21 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/18 20:21:45
Modified: main.c
Log:
drop "exact" global since each util does it itself now
Revision Changes Path
1.203 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.203&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.203&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.202&r2=1.203
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -r1.202 -r1.203
--- main.c 18 Dec 2011 06:31:29 -0000 1.202
+++ main.c 18 Dec 2011 20:21:45 -0000 1.203
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.202 2011/12/18 06:31:29 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.203 2011/12/18 20:21:45 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -52,7 +52,6 @@
/* variables to control runtime behavior */
char *module_name = NULL;
char *modpath = NULL;
-char exact = 0;
int found = 0;
int verbose = 0;
int quiet = 0;
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-18 20:35 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-18 20:35 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/18 20:35:25
Modified: main.c
Log:
do not redefine _GNU_SOURCE if it is on the command line
Revision Changes Path
1.204 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.204&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.204&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.203&r2=1.204
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -r1.203 -r1.204
--- main.c 18 Dec 2011 20:21:45 -0000 1.203
+++ main.c 18 Dec 2011 20:35:25 -0000 1.204
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.203 2011/12/18 20:21:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.204 2011/12/18 20:35:25 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -11,7 +11,9 @@
# include "config.h" /* make sure we have EPREFIX, if set */
#endif
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#ifdef _AIX
#define _LINUX_SOURCE_COMPAT
#endif
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-19 4:37 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-19 4:37 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/19 04:37:23
Modified: main.c
Log:
add some NULL fields to fix -Wmissing-field-initializers gcc warnings
Revision Changes Path
1.206 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.206&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.206&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.205&r2=1.206
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -r1.205 -r1.206
--- main.c 19 Dec 2011 04:28:35 -0000 1.205
+++ main.c 19 Dec 2011 04:37:23 -0000 1.206
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.205 2011/12/19 04:28:35 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.206 2011/12/19 04:37:23 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -692,7 +692,7 @@
_Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "var/tmp/portage/")
_Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "usr/portage/packages/")
_Q_EVS(STR, Q_VDB, portvdb, EPREFIX "var/db/pkg")
- { }
+ { NULL, 0, _Q_BOOL, NULL, 0, NULL, }
#undef _Q_EV
};
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-19 4:39 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-19 4:39 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/19 04:39:24
Modified: main.c
Log:
refine previous fix to make it work with -Wmissing-braces too
Revision Changes Path
1.207 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.207&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.207&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.206&r2=1.207
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.206
retrieving revision 1.207
diff -u -r1.206 -r1.207
--- main.c 19 Dec 2011 04:37:23 -0000 1.206
+++ main.c 19 Dec 2011 04:39:24 -0000 1.207
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.206 2011/12/19 04:37:23 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.207 2011/12/19 04:39:24 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -692,7 +692,7 @@
_Q_EVS(STR, PORTAGE_TMPDIR, port_tmpdir, EPREFIX "var/tmp/portage/")
_Q_EVS(STR, PKGDIR, pkgdir, EPREFIX "usr/portage/packages/")
_Q_EVS(STR, Q_VDB, portvdb, EPREFIX "var/db/pkg")
- { NULL, 0, _Q_BOOL, NULL, 0, NULL, }
+ { NULL, 0, _Q_BOOL, { NULL }, 0, NULL, }
#undef _Q_EV
};
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-19 20:09 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-19 20:09 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/19 20:09:48
Modified: main.c
Log:
dump variable values after we have expanded inline variables
Revision Changes Path
1.209 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.209&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.209&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.208&r2=1.209
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -r1.208 -r1.209
--- main.c 19 Dec 2011 19:43:36 -0000 1.208
+++ main.c 19 Dec 2011 20:09:48 -0000 1.209
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.208 2011/12/19 19:43:36 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.209 2011/12/19 20:09:48 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -722,14 +722,6 @@
s = getenv(var->name);
if (s != NULL)
set_portage_env_var(var, s);
- if (getenv("DEBUG") IF_DEBUG(|| 1)) {
- fprintf(stderr, "%s = ", var->name);
- switch (var->type) {
- case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
- case _Q_STR:
- case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
- }
- }
}
/* expand any nested variables e.g. PORTDIR=${EPREFIX}/usr/portage */
@@ -796,6 +788,18 @@
}
}
+ if (getenv("DEBUG") IF_DEBUG(|| 1)) {
+ for (i = 0; vars_to_read[i].name; ++i) {
+ var = &vars_to_read[i];
+ fprintf(stderr, "%s = ", var->name);
+ switch (var->type) {
+ case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
+ case _Q_STR:
+ case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
+ }
+ }
+ }
+
/* Make sure ROOT always ends in a slash */
var = &vars_to_read[0];
if ((*var->value.s)[var->value_len - 1] != '/') {
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-21 4:35 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-21 4:35 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/21 04:35:09
Modified: main.c
Log:
use O_CLOEXEC when eating files
Revision Changes Path
1.211 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.211&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.211&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.210&r2=1.211
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -r1.210 -r1.211
--- main.c 19 Dec 2011 20:27:36 -0000 1.210
+++ main.c 21 Dec 2011 04:35:09 -0000 1.211
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.210 2011/12/19 20:27:36 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.211 2011/12/21 04:35:09 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -207,7 +207,7 @@
int fd;
char ret;
- if ((fd = openat(dfd, file, O_RDONLY)) == -1) {
+ if ((fd = openat(dfd, file, O_CLOEXEC|O_RDONLY)) == -1) {
buf[0] = '\0';
return 0;
}
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-22 17:11 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-22 17:11 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/22 17:11:11
Modified: main.c
Log:
make sure to clear out -* symbol too
Revision Changes Path
1.212 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.212&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.212&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.211&r2=1.212
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -r1.211 -r1.212
--- main.c 21 Dec 2011 04:35:09 -0000 1.211
+++ main.c 22 Dec 2011 17:11:11 -0000 1.212
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.211 2011/12/21 04:35:09 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.212 2011/12/22 17:11:11 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -458,7 +458,7 @@
memcpy(nv, s, len + 1);
while ((p = strstr(nv, "-*")) != NULL)
- memset(*value, ' ', p - *value);
+ memset(*value, ' ', p - *value + 2);
/* This function is mainly used by the startup code for parsing
make.conf and stacking variables remove.
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-22 17:49 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-22 17:49 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/22 17:49:19
Modified: main.c
Log:
have the one user pass in an empty string rather than always checking the param
Revision Changes Path
1.213 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.213&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.213&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.212&r2=1.213
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -r1.212 -r1.213
--- main.c 22 Dec 2011 17:11:11 -0000 1.212
+++ main.c 22 Dec 2011 17:49:19 -0000 1.213
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.212 2011/12/22 17:11:11 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.213 2011/12/22 17:49:19 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -619,8 +619,6 @@
char buf[BUFSIZE], *s;
/* initialize the base profile path */
- if (!configroot)
- configroot = "";
configroot_len = strlen(configroot);
profile_len = strlen(profile);
sub_len = 1024; /* should be big enough for longest line in "parent" */
@@ -644,7 +642,7 @@
s = strtok(buf, "\n");
while (s) {
strncpy(sub_file, s, sub_len);
- read_portage_profile(NULL, profile_file, vars);
+ read_portage_profile("", profile_file, vars);
s = strtok(NULL, "\n");
}
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2011-12-22 20:26 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-22 20:26 UTC (permalink / raw
To: gentoo-commits
vapier 11/12/22 20:26:20
Modified: main.c
Log:
support PORTAGE_CONFIGROOT with make.conf files, stop reading /etc/make.globals (since portage has too), and support sourcing files in make.conf via relative paths
Revision Changes Path
1.214 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.214&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.214&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.213&r2=1.214
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -r1.213 -r1.214
--- main.c 22 Dec 2011 17:49:19 -0000 1.213
+++ main.c 22 Dec 2011 20:26:20 -0000 1.214
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.213 2011/12/22 17:49:19 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.214 2011/12/22 20:26:20 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -531,20 +531,28 @@
}
/* Helper to read a portage env file (e.g. make.conf) */
-_q_static void read_portage_env_file(const char *file, env_vars vars[])
+_q_static void read_portage_env_file(const char *configroot, const char *file, env_vars vars[])
{
- size_t i, buflen, line;
+ size_t i, buflen, line, configroot_len, file_len;
FILE *fp;
char *buf, *s, *p;
IF_DEBUG(fprintf(stderr, "profile %s\n", file));
- fp = fopen(file, "r");
+ configroot_len = strlen(configroot);
+ file_len = strlen(file);
+ buflen = configroot_len + file_len + 1;
+ buf = xmalloc(buflen);
+
+ memcpy(buf, configroot, configroot_len);
+ memcpy(buf + configroot_len, file, file_len);
+ buf[buflen - 1] = '\0';
+
+ fp = fopen(buf, "r");
if (fp == NULL)
- return;
+ goto done;
line = 0;
- buf = NULL;
while (getline(&buf, &buflen, fp) != -1) {
++line;
rmspace(buf);
@@ -552,8 +560,27 @@
continue;
/* Handle "source" keyword */
- if (!strncmp(buf, "source ", 7))
- read_portage_env_file(buf + 7, vars);
+ if (!strncmp(buf, "source ", 7)) {
+ const char *sfile = buf + 7;
+
+ if (sfile[0] != '/') {
+ /* handle relative paths */
+ size_t file_path_len, source_len;
+
+ s = strrchr(file, '/');
+ file_path_len = s - file + 1;
+ source_len = strlen(sfile);
+
+ if (buflen <= source_len + file_path_len)
+ buf = xrealloc(buf, buflen = source_len + file_path_len + 1);
+ memmove(buf + file_path_len, buf + 7, source_len + 1);
+ memcpy(buf, file, file_path_len);
+ sfile = buf;
+ }
+
+ read_portage_env_file(configroot, sfile, vars);
+ continue;
+ }
/* look for our desired variables and grab their value */
for (i = 0; vars[i].name; ++i) {
@@ -607,8 +634,9 @@
}
}
- free(buf);
fclose(fp);
+ done:
+ free(buf);
}
/* Helper to recursively read stacked make.defaults in profiles */
@@ -631,12 +659,12 @@
/* first consume the profile's make.defaults */
strcpy(sub_file, "make.defaults");
- read_portage_env_file(profile_file, vars);
+ read_portage_env_file("", profile_file, vars);
/* now walk all the parents */
strcpy(sub_file, "parent");
if (eat_file(profile_file, buf, sizeof(buf)) == 0)
- return;
+ goto done;
rmspace(buf);
s = strtok(buf, "\n");
@@ -646,6 +674,7 @@
s = strtok(NULL, "\n");
}
+ done:
free(profile_file);
}
@@ -654,12 +683,6 @@
size_t i;
const char *s;
- static const char * const files[] = {
- CONFIG_EPREFIX "etc/make.globals",
- CONFIG_EPREFIX "usr/share/portage/config/make.globals",
- CONFIG_EPREFIX "etc/make.conf",
- CONFIG_EPREFIX "etc/portage/make.conf",
- };
bool nocolor = 0;
env_vars *var;
@@ -702,17 +725,19 @@
*var->value.s = xstrdup(var->default_value);
}
- /* walk all the stacked profiles */
+ /* figure out where to find our config files */
s = getenv("PORTAGE_CONFIGROOT");
if (!s)
s = "/";
+ /* walk all the stacked profiles */
read_portage_profile(s, CONFIG_EPREFIX "etc/make.profile", vars_to_read);
read_portage_profile(s, CONFIG_EPREFIX "etc/portage/make.profile", vars_to_read);
/* now read all the config files */
- for (i = 0; i < ARRAY_SIZE(files); ++i)
- read_portage_env_file(files[i], vars_to_read);
+ read_portage_env_file("", CONFIG_EPREFIX "usr/share/portage/config/make.globals", vars_to_read);
+ read_portage_env_file(s, CONFIG_EPREFIX "etc/make.conf", vars_to_read);
+ read_portage_env_file(s, CONFIG_EPREFIX "etc/portage/make.conf", vars_to_read);
/* finally, check the env */
for (i = 0; vars_to_read[i].name; ++i) {
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-01-08 17:41 Ned Ludd (solar)
0 siblings, 0 replies; 49+ messages in thread
From: Ned Ludd (solar) @ 2012-01-08 17:41 UTC (permalink / raw
To: gentoo-commits
solar 12/01/08 17:41:07
Modified: main.c
Log:
Need the env vars pushed to cvs as well
Revision Changes Path
1.215 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.215&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.215&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.214&r2=1.215
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.214
retrieving revision 1.215
diff -u -r1.214 -r1.215
--- main.c 22 Dec 2011 20:26:20 -0000 1.214
+++ main.c 8 Jan 2012 17:41:07 -0000 1.215
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.214 2011/12/22 20:26:20 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.215 2012/01/08 17:41:07 solar Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -75,6 +75,7 @@
static char *features;
static char *accept_license;
static char *install_mask;
+static char *pkg_install_mask;
const char err_noapplet[] = "Sorry this applet was disabled at compile time";
@@ -702,6 +703,7 @@
_Q_EVS(STR, ROOT, portroot, "/")
_Q_EVS(STR, ACCEPT_LICENSE, accept_license, "")
_Q_EVS(ISTR, INSTALL_MASK, install_mask, "")
+ _Q_EVS(ISTR, PKG_INSTALL_MASK, pkg_install_mask, "")
_Q_EVS(STR, ARCH, portarch, "")
_Q_EVS(ISTR, CONFIG_PROTECT, config_protect, CONFIG_EPREFIX "etc")
_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-05-19 13:20 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2012-05-19 13:20 UTC (permalink / raw
To: gentoo-commits
vapier 12/05/19 13:20:20
Modified: main.c
Log:
fix handling of quoted lines that do not end in a quote because they have trailing comments/whitespace #416585 by Nikoli
Revision Changes Path
1.216 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.216&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.216&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.215&r2=1.216
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -r1.215 -r1.216
--- main.c 8 Jan 2012 17:41:07 -0000 1.215
+++ main.c 19 May 2012 13:20:20 -0000 1.216
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.215 2012/01/08 17:41:07 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.216 2012/05/19 13:20:20 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -599,34 +599,36 @@
while (isspace(*s))
++s;
if (*s == '"' || *s == '\'') {
+ char *endq;
char q = *s;
- size_t l = strlen(s);
- if (q != s[l - 1]) {
+ /* make sure we handle spacing/comments after the quote */
+ endq = strchr(s + 1, q);
+ if (!endq) {
/* If the last char is not a quote, then we span lines */
size_t abuflen;
- char *abuf, *qq;
+ char *abuf;
- qq = abuf = NULL;
+ abuf = NULL;
while (getline(&abuf, &abuflen, fp) != -1) {
buf = xrealloc(buf, buflen + abuflen);
strcat(buf, abuf);
buflen += abuflen;
- qq = strchr(abuf, q);
- if (qq) {
- *qq = '\0';
+ endq = strchr(abuf, q);
+ if (endq) {
+ *endq = '\0';
break;
}
}
free(abuf);
- if (!qq)
+ if (!endq)
warn("%s:%zu: %s: quote mismatch", file, line, vars[i].name);
s = buf + vars[i].name_len + 1;
} else {
- s[l - 1] = '\0';
+ *endq = '\0';
++s;
}
}
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-06-04 23:13 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2012-06-04 23:13 UTC (permalink / raw
To: gentoo-commits
vapier 12/06/04 23:13:23
Modified: main.c
Log:
do not try to expand a variable into itself #419581 by Nathan Caldwell
Revision Changes Path
1.217 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.217&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.217&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.216&r2=1.217
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -r1.216 -r1.217
--- main.c 19 May 2012 13:20:20 -0000 1.216
+++ main.c 4 Jun 2012 23:13:23 -0000 1.217
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.216 2012/05/19 13:20:20 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.217 2012/06/04 23:13:23 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -788,13 +788,19 @@
byte = *svar;
*svar = '\0';
- evar = get_portage_env_var(vars_to_read, s);
- if (evar) {
- sval = *evar->value.s;
+
+ /* Don't try to expand ourselves */
+ if (strcmp(var->name, s)) {
+ evar = get_portage_env_var(vars_to_read, s);
+ if (evar) {
+ sval = *evar->value.s;
+ } else {
+ sval = getenv(s);
+ if (!sval)
+ sval = "";
+ }
} else {
- sval = getenv(s);
- if (!sval)
- sval = "";
+ sval = "";
}
*svar = byte;
slen = strlen(sval);
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-08-04 20:24 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2012-08-04 20:24 UTC (permalink / raw
To: gentoo-commits
vapier 12/08/04 20:24:56
Modified: main.c
Log:
support options that do not have short flags
Revision Changes Path
1.218 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.218&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.218&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.217&r2=1.218
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -r1.217 -r1.218
--- main.c 4 Jun 2012 23:13:23 -0000 1.217
+++ main.c 4 Aug 2012 20:24:56 -0000 1.218
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.217 2012/06/04 23:13:23 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.218 2012/08/04 20:24:56 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -159,13 +159,22 @@
printf("\n%sOptions:%s -[%s]\n", GREEN, NORM, flags);
for (i = 0; opts[i].name; ++i) {
- assert(help[i] != NULL); /* this assert is a life saver when adding new applets. */
+ /* this assert is a life saver when adding new applets. */
+ assert(help[i] != NULL);
+
+ /* first output the short flag if it has one */
+ if (opts[i].val > '~')
+ printf(" ");
+ else
+ printf(" -%c, ", opts[i].val);
+
+ /* then the long flag + help text */
if (opts[i].has_arg == no_argument)
- printf(" -%c, --%-15s%s*%s %s\n", opts[i].val,
- opts[i].name, RED, NORM, _(help[i]));
+ printf("--%-15s%s*%s %s\n", opts[i].name,
+ RED, NORM, _(help[i]));
else
- printf(" -%c, --%-8s %s<arg>%s %s*%s %s\n", opts[i].val,
- opts[i].name, DKBLUE, NORM, RED, NORM, _(help[i]));
+ printf("--%-8s %s<arg>%s %s*%s %s\n", opts[i].name,
+ DKBLUE, NORM, RED, NORM, _(help[i]));
}
exit(status);
}
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-08-13 21:16 Robin H. Johnson (robbat2)
0 siblings, 0 replies; 49+ messages in thread
From: Robin H. Johnson (robbat2) @ 2012-08-13 21:16 UTC (permalink / raw
To: gentoo-commits
robbat2 12/08/13 21:16:57
Modified: main.c
Log:
Implement md5-cache support.
Revision Changes Path
1.219 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.219&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.219&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.218&r2=1.219
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -p -w -b -B -u -u -r1.218 -r1.219
--- main.c 4 Aug 2012 20:24:56 -0000 1.218
+++ main.c 13 Aug 2012 21:16:57 -0000 1.219
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.218 2012/08/04 20:24:56 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.219 2012/08/13 21:16:57 robbat2 Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -57,13 +57,15 @@ char *modpath = NULL;
int found = 0;
int verbose = 0;
int quiet = 0;
+int portcachedir_type = 0;
char pretend = 0;
char reinitialize = 0;
char reinitialize_metacache = 0;
static char *portdir;
static char *portarch;
static char *portvdb;
-const char portcachedir[] = "metadata/cache";
+const char portcachedir_pms[] = "metadata/cache";
+const char portcachedir_md5[] = "metadata/md5-cache";
static char *portroot;
static char *eprefix;
static char *config_protect, *config_protect_mask;
@@ -861,7 +863,9 @@ void initialize_portage_env(void)
enum {
CACHE_EBUILD = 1,
- CACHE_METADATA = 2
+ CACHE_METADATA = 2,
+ CACHE_METADATA_PMS = 10,
+ CACHE_METADATA_MD5 = 11,
};
int filter_hidden(const struct dirent *dentry);
@@ -881,6 +885,7 @@ const char *initialize_flat(int cache_ty
struct stat st;
struct timeval start, finish;
static const char *cache_file;
+ const char *portcachedir_actual;
char *p;
int a, b, c, d, e, i;
int frac, secs, count;
@@ -896,10 +901,18 @@ const char *initialize_flat(int cache_ty
goto ret;
}
- if (cache_type == CACHE_METADATA && chdir(portcachedir) != 0) {
- warnp("chdir to portage cache '%s/%s' failed", portdir, portcachedir);
+ if (cache_type == CACHE_METADATA) {
+ if(chdir(portcachedir_md5) == 0) {
+ portcachedir_type = CACHE_METADATA_MD5;
+ portcachedir_actual = portcachedir_md5;
+ } else if(chdir(portcachedir_pms) == 0) {
+ portcachedir_type = CACHE_METADATA_PMS;
+ portcachedir_actual = portcachedir_pms;
+ } else {
+ warnp("chdir to portage cache '%s/%s' or '%s/%s' failed", portdir, portcachedir_md5, portdir, portcachedir_pms);
goto ret;
}
+ }
if (stat(cache_file, &st) != -1)
if (st.st_size == 0)
@@ -921,7 +934,7 @@ const char *initialize_flat(int cache_ty
if (cache_type == CACHE_EBUILD)
warnfp("opening '%s/%s' failed", portdir, cache_file);
else
- warnfp("opening '%s/%s/%s' failed", portdir, portcachedir, cache_file);
+ warnfp("opening '%s/%s/%s' failed", portdir, portcachedir_actual, cache_file);
if (errno == EACCES)
warnf("You should run this command as root: q -%c",
cache_type == CACHE_EBUILD ? 'r' : 'm');
@@ -1037,12 +1050,28 @@ typedef struct {
char *EAPI;
char *PROPERTIES;
depend_atom *atom;
+ /* These are MD5-Cache only */
+ char *DEFINED_PHASES;
+ char *REQUIRED_USE;
+ char *_eclasses_;
+ char *_md5_;
} portage_cache;
void cache_free(portage_cache *cache);
+portage_cache *cache_read_file_pms(const char *file);
+portage_cache *cache_read_file_md5(const char *file);
portage_cache *cache_read_file(const char *file);
+
portage_cache *cache_read_file(const char *file)
{
+ if(portcachedir_type == CACHE_METADATA_MD5)
+ return(cache_read_file_md5(file));
+ else if(portcachedir_type == CACHE_METADATA_PMS)
+ return(cache_read_file_pms(file));
+}
+
+portage_cache *cache_read_file_pms(const char *file)
+{
struct stat s;
char *ptr;
FILE *f;
@@ -1098,6 +1127,105 @@ err:
return NULL;
}
+portage_cache *cache_read_file_md5(const char *file)
+{
+ struct stat s;
+ char *ptr, *endptr;
+ //const char *cmpkey;
+ FILE *f;
+ portage_cache *ret = NULL;
+ size_t len;
+
+ if ((f = fopen(file, "r")) == NULL)
+ goto err;
+
+ if (fstat(fileno(f), &s) != 0)
+ goto err;
+ len = sizeof(*ret) + s.st_size + 1;
+ ret = xzalloc(len);
+ ptr = (char*)ret;
+ ret->_data = ptr + sizeof(*ret);
+ if ((off_t)fread(ret->_data, 1, s.st_size, f) != s.st_size)
+ goto err;
+
+ ret->atom = atom_explode(file);
+
+ /* We have a block of key=value\n data.
+ * KEY=VALUE\n
+ * Where KEY does NOT contain:
+ * \0 \n =
+ * And VALUE does NOT contain:
+ * \0 \n
+ * */
+#define assign_var_cmp(keyname, cmpkey) \
+ if (strncmp(keyptr, cmpkey, strlen(cmpkey)) == 0) { \
+ ret->keyname = valptr; \
+ continue; \
+ }
+#define assign_var(keyname) \
+ assign_var_cmp(keyname, #keyname);
+
+ ptr = ret->_data;
+ endptr = strchr(ptr, '\0');
+ if(endptr == NULL) {
+ warn("Invalid cache file '%s' - could not find end of cache data", file);
+ goto err;
+ }
+
+ while(ptr != NULL && ptr != endptr) {
+ char *keyptr;
+ char *valptr;
+ keyptr = ptr;
+ valptr = strchr(ptr, '=');
+ if(valptr == NULL) {
+ warn("Invalid cache file '%s' val", file);
+ goto err;
+ }
+ *valptr = '\0';
+ valptr++;
+ ptr = strchr(valptr, '\n');
+ if(ptr == NULL) {
+ warn("Invalid cache file '%s' key", file);
+ goto err;
+ }
+ *ptr = '\0';
+ ptr++;
+
+ assign_var(CDEPEND);
+ assign_var(DEPEND);
+ assign_var(DESCRIPTION);
+ assign_var(EAPI);
+ assign_var(HOMEPAGE);
+ assign_var(INHERITED);
+ assign_var(IUSE);
+ assign_var(KEYWORDS);
+ assign_var(LICENSE);
+ assign_var(PDEPEND);
+ assign_var(PROPERTIES);
+ assign_var(PROVIDE);
+ assign_var(RDEPEND);
+ assign_var(RESTRICT);
+ assign_var(SLOT);
+ assign_var(SRC_URI);
+ assign_var(DEFINED_PHASES);
+ assign_var(REQUIRED_USE);
+ assign_var(_eclasses_);
+ assign_var(_md5_);
+ warn("Cache file '%s' with unknown key %s", file, keyptr);
+ }
+#undef assign_var
+#undef assign_var_cmp
+
+ fclose(f);
+
+ return ret;
+
+err:
+ fclose(f);
+ if (ret) cache_free(ret);
+ return NULL;
+}
+
void cache_dump(portage_cache *cache);
void cache_dump(portage_cache *cache)
{
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-10-28 10:11 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2012-10-28 10:11 UTC (permalink / raw
To: gentoo-commits
vapier 12/10/28 10:11:47
Modified: main.c
Log:
fix variable name length calculation when expanding later vars #417457 by stephen thomas
Revision Changes Path
1.224 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.224&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.224&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.223&r2=1.224
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -r1.223 -r1.224
--- main.c 28 Oct 2012 07:56:51 -0000 1.223
+++ main.c 28 Oct 2012 10:11:47 -0000 1.224
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.223 2012/10/28 07:56:51 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.224 2012/10/28 10:11:47 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -753,7 +753,7 @@
break;
}
- var_len = svar - *var->value.s + 1;
+ var_len = svar - s + 1 + (brace ? 2 : 0);
byte = *svar;
*svar = '\0';
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2012-10-28 10:29 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2012-10-28 10:29 UTC (permalink / raw
To: gentoo-commits
vapier 12/10/28 10:29:38
Modified: main.c
Log:
improve trimming of quotes/whitespace when loading env files
Revision Changes Path
1.225 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.225&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.225&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.224&r2=1.225
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- main.c 28 Oct 2012 10:11:47 -0000 1.224
+++ main.c 28 Oct 2012 10:29:38 -0000 1.225
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.224 2012/10/28 10:11:47 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.225 2012/10/28 10:29:38 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -581,25 +581,30 @@
abuf = NULL;
while (getline(&abuf, &abuflen, fp) != -1) {
buf = xrealloc(buf, buflen + abuflen);
+ endq = strchr(abuf, q);
+ if (endq)
+ *endq = '\0';
+
strcat(buf, abuf);
buflen += abuflen;
- endq = strchr(abuf, q);
- if (endq) {
- *endq = '\0';
+ if (endq)
break;
- }
}
free(abuf);
if (!endq)
warn("%s:%zu: %s: quote mismatch", file, line, vars[i].name);
- s = buf + vars[i].name_len + 1;
+ s = buf + vars[i].name_len + 2;
} else {
*endq = '\0';
++s;
}
+ } else {
+ /* no quotes, so chop the spacing/comments ourselves */
+ size_t off = strcspn(s, "# \t\n");
+ s[off] = '\0';
}
set_portage_env_var(&vars[i], s);
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2013-04-03 18:39 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-03 18:39 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/03 18:39:22
Modified: main.c
Log:
dump usage to stderr when an error has happened to avoid things like foo=`qlist $emptyvar` from inserting content into $foo
Revision Changes Path
1.226 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.226&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.226&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.225&r2=1.226
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -r1.225 -r1.226
--- main.c 28 Oct 2012 10:29:38 -0000 1.225
+++ main.c 3 Apr 2013 18:39:22 -0000 1.226
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.225 2012/10/28 10:29:38 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.226 2013/04/03 18:39:22 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -137,6 +137,8 @@
const char * const help[], int blabber)
{
unsigned long i;
+ if (status != EXIT_SUCCESS)
+ dup2(STDERR_FILENO, STDOUT_FILENO);
if (blabber == 0) {
printf("%sUsage:%s %sq%s %s<applet> <args>%s : %s"
"invoke a portage utility applet\n\n", GREEN,
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2013-05-23 3:19 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2013-05-23 3:19 UTC (permalink / raw
To: gentoo-commits
vapier 13/05/23 03:19:00
Modified: main.c
Log:
use 64bit file interfaces even with 32bit processes #471024
Revision Changes Path
1.227 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.227&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.227&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.226&r2=1.227
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- main.c 3 Apr 2013 18:39:22 -0000 1.226
+++ main.c 23 May 2013 03:19:00 -0000 1.227
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2008 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.226 2013/04/03 18:39:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.227 2013/05/23 03:19:00 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
@@ -14,6 +14,9 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
+#ifndef _FILE_OFFSET_BITS
+#define _FILE_OFFSET_BITS 64 /* #471024 */
+#endif
#ifdef _AIX
#define _LINUX_SOURCE_COMPAT
#endif
^ permalink raw reply [flat|nested] 49+ messages in thread
* [gentoo-commits] gentoo-projects commit in portage-utils: main.c
@ 2013-10-31 2:40 Mike Frysinger (vapier)
0 siblings, 0 replies; 49+ messages in thread
From: Mike Frysinger (vapier) @ 2013-10-31 2:40 UTC (permalink / raw
To: gentoo-commits
vapier 13/10/31 02:40:24
Modified: main.c
Log:
fix bug related to var parsing w/out braces
Revision Changes Path
1.229 portage-utils/main.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.229&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?rev=1.229&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/main.c?r1=1.228&r2=1.229
Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -r1.228 -r1.229
--- main.c 29 Sep 2013 22:42:36 -0000 1.228
+++ main.c 31 Oct 2013 02:40:23 -0000 1.229
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2013 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.228 2013/09/29 22:42:36 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.229 2013/10/31 02:40:23 vapier Exp $
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2013 Mike Frysinger - <vapier@gentoo.org>
@@ -752,7 +752,7 @@
}
*svar = byte;
slen = strlen(sval);
- post_len = strlen(svar + 1);
+ post_len = strlen(svar + !!brace);
*var->value.s = xrealloc(*var->value.s, pre_len + MAX(var_len, slen) + post_len + 1);
/*
^ permalink raw reply [flat|nested] 49+ messages in thread
end of thread, other threads:[~2013-10-31 2:40 UTC | newest]
Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-19 13:20 [gentoo-commits] gentoo-projects commit in portage-utils: main.c Mike Frysinger (vapier)
-- strict thread matches above, loose matches on Subject: below --
2013-10-31 2:40 Mike Frysinger (vapier)
2013-05-23 3:19 Mike Frysinger (vapier)
2013-04-03 18:39 Mike Frysinger (vapier)
2012-10-28 10:29 Mike Frysinger (vapier)
2012-10-28 10:11 Mike Frysinger (vapier)
2012-08-13 21:16 Robin H. Johnson (robbat2)
2012-08-04 20:24 Mike Frysinger (vapier)
2012-06-04 23:13 Mike Frysinger (vapier)
2012-01-08 17:41 Ned Ludd (solar)
2011-12-22 20:26 Mike Frysinger (vapier)
2011-12-22 17:49 Mike Frysinger (vapier)
2011-12-22 17:11 Mike Frysinger (vapier)
2011-12-21 4:35 Mike Frysinger (vapier)
2011-12-19 20:09 Mike Frysinger (vapier)
2011-12-19 4:39 Mike Frysinger (vapier)
2011-12-19 4:37 Mike Frysinger (vapier)
2011-12-18 20:35 Mike Frysinger (vapier)
2011-12-18 20:21 Mike Frysinger (vapier)
2011-12-18 3:04 Mike Frysinger (vapier)
2011-12-12 21:42 Fabian Groffen (grobian)
2011-12-09 16:50 Mike Frysinger (vapier)
2011-10-02 22:08 Mike Frysinger (vapier)
2011-03-17 3:04 Mike Frysinger (vapier)
2011-03-02 8:10 Mike Frysinger (vapier)
2011-03-02 7:55 Mike Frysinger (vapier)
2011-03-02 5:31 Mike Frysinger (vapier)
2011-03-02 2:40 Mike Frysinger (vapier)
2011-02-28 18:16 Mike Frysinger (vapier)
2010-12-19 13:15 Fabian Groffen (grobian)
2010-12-07 1:13 Mike Frysinger (vapier)
2010-12-04 12:37 Mike Frysinger (vapier)
2010-12-04 12:20 Mike Frysinger (vapier)
2010-12-04 11:15 Mike Frysinger (vapier)
2010-06-08 4:54 Mike Frysinger (vapier)
2010-01-17 0:25 Mike Frysinger (vapier)
2010-01-17 0:24 Mike Frysinger (vapier)
2010-01-13 18:23 Mike Frysinger (vapier)
2010-01-13 6:12 Ned Ludd (solar)
2009-09-08 16:49 Fabian Groffen (grobian)
2009-08-23 6:07 Ned Ludd (solar)
2009-03-15 10:03 Mike Frysinger (vapier)
2008-12-07 3:43 Ned Ludd (solar)
2008-09-26 16:42 Ned Ludd (solar)
2008-09-13 18:58 Fabian Groffen (grobian)
2008-05-11 17:25 Ned Ludd (solar)
2008-01-16 7:09 Mike Frysinger (vapier)
2008-01-15 8:03 Mike Frysinger (vapier)
2007-10-28 21:22 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