Просмотр исходного кода

* Reverted the new tmpfile stuff in dpkg-deb. For some reason it's
completely corrupting the new package

Ben Collins лет назад: 27
Родитель
Сommit
3593fd4559
3 измененных файлов с 11 добавлено и 21 удалено
  1. 5 0
      ChangeLog
  2. 4 17
      dpkg-deb/build.c
  3. 2 4
      dpkg-deb/info.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Tue Oct 19 09:59:22 EDT 1999 Ben Collins <bcollins.debian.org>
+
+  * Reverted the new tmpfile stuff in dpkg-deb. For some reason it's
+    completely corrupting the new package
+
 Mon Oct 18 18:40:35 EDT 1999 Ben Collins <bcollins.debian.org>
 
   * Reimplemented a better *stat cache for the removal checking code,

+ 4 - 17
dpkg-deb/build.c

@@ -57,13 +57,13 @@ void do_build(const char *const *argv) {
     PREINSTFILE, POSTINSTFILE, PRERMFILE, POSTRMFILE, 0
   };
   
-  char *m, *tmpd, *tmpf;
+  char *m;
   const char *debar, *directory, *const *mscriptp, *versionstring, *arch;
   char *controlfile;
   struct pkginfo *checkedinfo;
   struct arbitraryfield *field;
   FILE *ar, *gz, *cf;
-  int p1[2],p2[2], warns, errs, n, c, subdir, gzfd;
+  int p1[2],p2[2], warns, errs, n, c, subdir;
   pid_t c1,c2,c3,c4,c5;
   struct stat controlstab, datastab, mscriptstab, debarstab;
   char conffilename[MAXCONFFILENAME+1];
@@ -209,16 +209,7 @@ void do_build(const char *const *argv) {
     execlp(TAR,"tar","-cf","-",".",(char*)0); ohshite(_("failed to exec tar -cf"));
   }
   close(p1[1]);
-
-  if (!(tmpd = getenv("TMPDIR")))
-    tmpd= "/tmp";
-  tmpf= malloc(strlen(tmpd) + strlen("/dpkg.XXXXXX"));
-  strcpy(tmpf, tmpd);
-  strcat(tmpf, "/dpkg.XXXXXX");
-  if (!(gzfd= mkstemp(tmpf)) || !(gz= fdopen(gzfd, "r+")))
-    ohshite(_("failed to make tmpfile (control)"));
-
-
+  if (!(gz= tmpfile())) ohshite(_("failed to make tmpfile (control)"));
   if (!(c2= m_fork())) {
     m_dup2(p1[0],0); m_dup2(fileno(gz),1); close(p1[0]);
     execlp(GZIP,"gzip","-9c",(char*)0); ohshite(_("failed to exec gzip -9c"));
@@ -255,12 +246,8 @@ void do_build(const char *const *argv) {
   
   if (!oldformatflag) {
     fclose(gz);
-    strcpy(tmpf, tmpd);
-    strcat(tmpf, "/dpkg.XXXXXX");
-    if (!(gzfd= mkstemp(tmpf)) || !(gz= fdopen(gzfd, "r+")))
-      ohshite(_("failed to make tmpfile (data)"));
+    if (!(gz= tmpfile())) ohshite(_("failed to make tmpfile (data)"));
   }
-  free(tmpf);
   m_pipe(p2);
   if (!(c4= m_fork())) {
     m_dup2(p2[1],1); close(p2[0]); close(p2[1]);

+ 2 - 4
dpkg-deb/info.c

@@ -59,13 +59,12 @@ static void info_prepare(const char *const **argvp,
                          const char **debarp,
                          const char **directoryp,
                          int admininfo) {
-  char *dbuf;
+  static char dbuf[L_tmpnam];
   pid_t c1;
   
   *debarp= *(*argvp)++;
   if (!*debarp) badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
-  dbuf = tempnam(NULL, "dpkg");
-  if (!dbuf) ohshite(_("failed to make temporary filename"));
+  if (!tmpnam(dbuf)) ohshite(_("failed to make temporary filename"));
   *directoryp= dbuf;
 
   if (!(c1= m_fork())) {
@@ -74,7 +73,6 @@ static void info_prepare(const char *const **argvp,
   waitsubproc(c1,"rm -rf",0);
   push_cleanup(cu_info_prepare,-1, 0,0, 1, (void*)dbuf);
   extracthalf(*debarp, dbuf, "mx", admininfo);
-  free(dbuf);
 }
 
 static int ilist_select(const struct dirent *de) {