From f55545591b80c22e8e3ca4dffe2ac68c59090835 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 3 Sep 2015 16:32:41 +0200 Subject: [PATCH] refuse to upgrade pre-v3 packages --- bin/pharext | Bin 85569 -> 86178 bytes bin/pharext.update | Bin 85583 -> 86192 bytes src/pharext/Updater.php | 33 ++++++++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/bin/pharext b/bin/pharext index 9053bad701183289c6fd998d2f38101d8343603f..11bc13d52faa816ca48a94dc3a75e2673d506c68 100755 GIT binary patch delta 1267 zcmX>&hjr0H)(yR!Ov+J{`#JSM)P7D25cQK&7er}rfdwPD^g+B%F0kMZE)x*%9hWJH zQsp)VQBmArxlV4dhMnA6Ai<~HRv=1|#|T7)La0t2u=f2tU^74Pn1kdrdBLW{@q*>1 z@EU>ykMo*=sQ(Z-6F#tg*?eHb=JSCyT!B!W{9v9PKUjMSgtw9(?3SDSV8eI>zz(z) z09%_Q0G68r5j-uRDbOpxz@QxUA{0c=J6|R?nMF_)WV^N?SVN2;NJDdv;PxIt#)F!Z zS6HS`7m#MGo9tlAG5xO&BiD9U8%A$t*32{o4aMmb>=~skH5ID4I6*+ABqOs}*RDLV zC{IJlIWaFUzeJ(5AiXFtB~_uIC{?%2SfL;>IXf{uwKyhENz;0A-ZY8n`|KIRE%ddt zxHuKG6oOI0t9APEp7#25QV#$j?bp z(15s76J!$9;nO!NF-lBVb70JXdb!VmQN{-9Wqo~xl>9t(oW2AF3)Bf|i8;lo)KOm1xaW@N@7VWR^Nj?3=FB{(xRf& zyb^ebm8BLHXXfWYf}kL=C^1(dxFE+ZGbhzEFD+j|B@M_zlB`z<00pTEIA9?m12+yB z`gtXZnR%Ic=@5MiiNy*jsRgNdDXDqMl~f6331Iqw7*vu`lwV$~;98NKT2PXiKY8I# z$?a2}8KW4XVgKHRQD*Xn3d!lbu8fV7T`%cQmJ{XNz6Ho(ufMjx?DXFQWogO34`#>R ztA5R2y|ikJ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~`9+`UW^?%74N8y7T{4QZK9ui$mEEy#g{HEU0bg|) Q10w^200RSqyOXaI03uFGHvj+t diff --git a/src/pharext/Updater.php b/src/pharext/Updater.php index e3a8b51..af479c9 100644 --- a/src/pharext/Updater.php +++ b/src/pharext/Updater.php @@ -33,7 +33,7 @@ class Updater implements Command ]); } - /** + /** * @inheritdoc * @see \pharext\Command::run() */ @@ -89,7 +89,9 @@ class Updater implements Command } if ($info->isFile()) { - $this->updatePackage($info); + if (!$this->updatePackage($info)) { + $this->warn("Cannot upgrade pre-v3 packages\n"); + } } else { $this->error("File '%s' does not exist\n", $file); exit(self::EARGS); @@ -97,11 +99,19 @@ class Updater implements Command } } + /** + * Replace the pharext core in an .ext.phar package + * @param string $temp path to temp phar + * @return boolean FALSE if the package is too old (pre-v3) to upgrade + */ private function replacePharext($temp) { $phar = new Phar($temp, Phar::CURRENT_AS_SELF); $phar->startBuffering(); - $meta = $phar->getMetadata(); + if (!$meta = $phar->getMetadata()) { + // don't upgrade pre-v3 packages + return false; + } // replace current pharext files $core = (new Task\BundleGenerator)->run($this->verbosity()); @@ -121,13 +131,22 @@ class Updater implements Command $phar->setMetadata([ "version" => Metadata::version(), "header" => Metadata::header(), - ] + (array) $phar->getMetadata()); + ] + $meta); $this->info("Updated pharext version from '%s' to '%s'\n", isset($meta["version"]) ? $meta["version"] : "(unknown)", $phar->getMetadata()["version"]); + + return true; } + /** + * Update an .ext.phar package to the current pharext version + * @param SplFileInfo $file + * @param Phar $phar the parent phar containing $file as dependency + * @return boolean FALSE if the package is too old (pre-v3) to upgrade + * @throws Exception + */ private function updatePackage(SplFileInfo $file, Phar $phar = null) { $this->info("Updating pharext core in '%s'...\n", basename($file)); @@ -140,12 +159,16 @@ class Updater implements Command throw new Exception; } - $this->replacePharext($temp); + if (!$this->replacePharext($temp)) { + return false; + } if ($phar) { $phar->addFile($temp, $file); } elseif (!rename($temp, $file->getPathname())) { throw new Exception; } + + return true; } } -- 2.30.2