[4.0] Use strip (instead of eu-strip) to support --strip-debug of *.so at build time
[platform/upstream/rpm.git] / rpm2cpio.c
index 92de0fa..89ebdfa 100644 (file)
@@ -17,10 +17,12 @@ int main(int argc, char *argv[])
     FD_t fdi, fdo;
     Header h;
     char * rpmio_flags = NULL;
-    rpmRC rc;
+    int rc;
+    off_t payload_size;
     FD_t gzdi;
     
     setprogname(argv[0]);      /* Retrofit glibc __progname */
+    rpmReadConfigFiles(NULL, NULL);
     if (argc == 1)
        fdi = fdDup(STDIN_FILENO);
     else {
@@ -37,7 +39,6 @@ int main(int argc, char *argv[])
        exit(EXIT_FAILURE);
     }
     fdo = fdDup(STDOUT_FILENO);
-    rpmReadConfigFiles(NULL, NULL);
 
     {  rpmts ts = rpmtsCreate();
        rpmVSFlags vsflags = 0;
@@ -69,14 +70,10 @@ int main(int argc, char *argv[])
        break;
     }
 
-    /* Retrieve type of payload compression. */
-    {  const char *compr = NULL;
-       struct rpmtd_s pc;
-
-       headerGet(h, RPMTAG_PAYLOADCOMPRESSOR, &pc, HEADERGET_DEFAULT);
-       compr = rpmtdGetString(&pc);
+    /* Retrieve payload size and compression type. */
+    {  const char *compr = headerGetString(h, RPMTAG_PAYLOADCOMPRESSOR);
        rpmio_flags = rstrscat(NULL, "r.", compr ? compr : "gzip", NULL);
-       rpmtdFreeData(&pc);
+       payload_size = headerGetNumber(h, RPMTAG_LONGARCHIVESIZE);
     }
 
     gzdi = Fdopen(fdi, rpmio_flags);   /* XXX gzdi == fdi */
@@ -87,8 +84,8 @@ int main(int argc, char *argv[])
        exit(EXIT_FAILURE);
     }
 
-    rc = ufdCopy(gzdi, fdo);
-    rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
+    rc = (ufdCopy(gzdi, fdo) == payload_size) ? EXIT_SUCCESS : EXIT_FAILURE;
+
     Fclose(fdo);
 
     Fclose(gzdi);      /* XXX gzdi == fdi */