Simplify url retrieval in rpmInstall()
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 11 Apr 2008 08:45:35 +0000 (11:45 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 11 Apr 2008 08:45:35 +0000 (11:45 +0300)
- use rpmMkTemp() instead of manual kludgery to static buffer

lib/rpminstall.c

index 8c4d3d0..908448f 100644 (file)
@@ -301,28 +301,20 @@ restart:
        case URL_IS_HTTP:
        case URL_IS_FTP:
        {   char *tfn;
+           FD_t tfd;
 
            if (rpmIsVerbose())
                fprintf(stdout, _("Retrieving %s\n"), fileURL);
 
-           {   char tfnbuf[64];
-               const char * rootDir = rpmtsRootDir(ts);
-               if (!(rootDir && * rootDir))
-                   rootDir = "";
-               strcpy(tfnbuf, "rpm-xfer.XXXXXX");
-#if defined(HAVE_MKSTEMP)
-               (void) close(mkstemp(tfnbuf));
-#else
-               (void) mktemp(tfnbuf);
-#endif
-               tfn = rpmGenPath(rootDir, "%{_tmppath}/", tfnbuf);
+           tfd = rpmMkTemp(rpmtsRootDir(ts), &tfn);
+           if (tfd && tfn) {
+               Fclose(tfd);
+               rc = urlGetFile(fileURL, tfn);
+           } else {
+               rc = -1;
            }
 
-           /* XXX undefined %{name}/%{version}/%{release} here */
-           /* XXX %{_tmpdir} does not exist */
-           rpmlog(RPMLOG_DEBUG, " ... as %s\n", tfn);
-           rc = urlGetFile(fileURL, tfn);
-           if (rc < 0) {
+           if (rc != 0) {
                rpmlog(RPMLOG_ERR,
                        _("skipping %s - transfer failed - %s\n"),
                        fileURL, ftpStrerror(rc));