]> granicus.if.org Git - php/commitdiff
* regenerate package.xml with file checksums
authorStig Bakken <ssb@php.net>
Thu, 28 Mar 2002 23:49:34 +0000 (23:49 +0000)
committerStig Bakken <ssb@php.net>
Thu, 28 Mar 2002 23:49:34 +0000 (23:49 +0000)
pear/PEAR/Packager.php

index 8ef95bf78d333821668ced0ae851941f5a70229b..c314e55f8d953f39f3c634cccb8262bf86dcfb49 100644 (file)
@@ -99,24 +99,41 @@ class PEAR_Packager extends PEAR_Common
                 return $this->raiseError("File $fname does not exist");
             } else {
                 $filelist[$i++] = $fname;
+                if (empty($pkginfo['filelist'][$fname]['md5sum'])) {
+                    $md5sum = md5_file($fname);
+                    $pkginfo['filelist'][$fname]['md5sum'] = $md5sum;
+                }
                 $this->log(2, "Adding file $fname");
             }
         }
-        // XXX TODO: Rebuild the package file as the old method did?
+        $new_xml = $this->xmlFromInfo($pkginfo);
+        if (PEAR::isError($new_xml)) {
+            return $new_xml;
+        }
+        $tmpdir = $this->mkTempDir(getcwd());
+        $newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgfile;
+        $np = @fopen($newpkgfile, "w");
+        if (!$np) {
+            return $this->raiseError("PEAR_Packager: unable to rewrite $pkgfile");
+        }
+        fwrite($np, $new_xml);
+        fclose($np);
 
         // TAR the Package -------------------------------------------
         $dest_package = $this->orig_pwd . DIRECTORY_SEPARATOR . "{$pkgver}.tgz";
         $tar =& new Archive_Tar($dest_package, true);
-        $tar->setErrorHandling(PEAR_ERROR_PRINT); // XXX Don't print errors
+        $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
         // ----- Creates with the package.xml file
-        if (!$tar->create($pkgfile)) {
-            return $this->raiseError('an error ocurred during package creation');
+        $ok = $tar->createModify($newpkgfile, '', $tmpdir);
+        if (PEAR::isError($ok)) {
+            return $ok;
+        } elseif (!$ok) {
+            return $this->raiseError('PEAR_Packager: tarball creation failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver)) {
-            return $this->raiseError('an error ocurred during package creation');
+            return $this->raiseError('PEAR_Packager: tarball creation failed');
         }
-
         $this->log(1, "Package $dest_package done");
         $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkgversion);
         $cvstag = "RELEASE_$cvsversion";