Suppress chpathtool's warnings with -q
authorFabian Groffen <grobian@gentoo.org>
Sat, 13 Oct 2007 12:58:04 +0000 (12:58 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 13 Oct 2007 12:58:04 +0000 (12:58 -0000)
svn path=/main/branches/prefix/; revision=8109

pym/portage/__init__.py
src/chpathtool.c

index 73a2bfdb45d7fe51a12ab169db3ed10f4e3b3489..07bb72d3b2a742d23a5bab741825a737a9e62ba7 100644 (file)
@@ -5416,7 +5416,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, vartree=None, prev_mtimes
                        portage.util.ensure_dirs(i)
                        os.rmdir(i)
                        retval = portage.process.spawn_bash(
-                               "chpathtool '%s' '%s' '%s' '%s'" % (b, i, buildprefix, EPREFIX),
+                               "chpathtool -q '%s' '%s' '%s' '%s'" % (b, i, buildprefix, EPREFIX),
                                env=mysettings.environ())
                        if retval != os.EX_OK:
                                writemsg("!!! Adjusing to Prefix failed!\n", noiselevel=-1)
index 2388fa93bdd12c07dd7acc5e7f61c4e83028e5ba..995af13d4750786efa609af13a37e383dacc930a 100644 (file)
@@ -35,6 +35,7 @@ static char *magic;
 static char *value;
 static size_t magiclen;
 static size_t valuelen;
+static char quiet;
 
 /**
  * Writes padding zero-bytes after the first encountered zero-byte.
@@ -149,9 +150,9 @@ static int chpath(const char *fi, const char *fo) {
        fclose(fout);
        fclose(fin);
 
-       if (padding != 0) {
+       if (padding != 0 && quiet == 0) {
                fprintf(stdout, "warning: couldn't find a location to write "
-                               "%zd padding bytes for %s\n", padding, fi);
+                               "%zd padding bytes in %s\n", padding, fo);
        }
 
        return(0);
@@ -338,16 +339,24 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
 
 int main(int argc, char **argv) {
        struct stat file;
+       int o = 0;
+
+       quiet = 0;
+       if (argc >= 2 && strcmp(argv[1], "-q") == 0) {
+               argc--;
+               o++;
+               quiet = 1;
+       }
 
        if (argc != 5) {
-               fprintf(stderr, "usage: in-file out-file magic value\n");
+               fprintf(stderr, "usage: [-q] in-file out-file magic value\n");
                fprintf(stderr, "       if in-file is a directory, out-file is "
                                "treated as one too\n");
                return(-1);
        }
 
-       magic    = argv[3];
-       value    = argv[4];
+       magic    = argv[o + 3];
+       value    = argv[o + 4];
        magiclen = strlen(magic);
        valuelen = strlen(value);
 
@@ -362,20 +371,22 @@ int main(int argc, char **argv) {
                return(-1);
        }
 
-       if (stat(argv[1], &file) != 0) {
-               fprintf(stderr, "unable to stat %s: %s\n", argv[1], strerror(errno));
+       if (stat(argv[o + 1], &file) != 0) {
+               fprintf(stderr, "unable to stat %s: %s\n",
+                               argv[o + 1], strerror(errno));
                return(-1);
        }
        if (S_ISDIR(file.st_mode)) {
                char *src = alloca(sizeof(char) * MAX_PATH);
                char *trg = alloca(sizeof(char) * MAX_PATH);
-               strcpy(src, argv[1]);
-               strcpy(trg, argv[2]);
+               strcpy(src, argv[o + 1]);
+               strcpy(trg, argv[o + 2]);
                /* walk this directory and process recursively */
-               return(dirwalk(src, src + strlen(argv[1]), trg, trg + strlen(argv[2])));
+               return(dirwalk(src, src + strlen(argv[o + 1]),
+                                       trg, trg + strlen(argv[o + 2])));
        } else {
                /* process as normal file */
-               return(chpath(argv[1], argv[2]));
+               return(chpath(argv[o + 1], argv[o + 2]));
        }
 }