diff --git a/README.md b/README.md index b76f7ba..f73d343 100644 --- a/README.md +++ b/README.md @@ -5,29 +5,16 @@ HotFix; Quickly patch and fix system ## Usage - $ hotfix pastebin:1234abcd - Downloading hotfix... - Checking signature... - Good signature from - - Info: - This hotfix will install this driver for you - - Do you want to proceed? - Yes, No or Inspect [noi]: y - + $ hotfix apply pastebin:1234abcd + $ hotfix apply gist:user/hash + $ hotfix apply http://some.site/url.to.fix ### Applying local patches - $ hotfix apply --unsigned test.hotfix - Skipping signature check of test.hotfix - - Info: - ... + $ hotfix apply --insecure test.hotfix ### Signing - $ hotfix sign -o test-signed.hotfix test.hotfix - ... + $ hotfix sign test.hotfix diff --git a/src/Command/ApplyCommand.php b/src/Command/ApplyCommand.php index 15813e0..d519a65 100644 --- a/src/Command/ApplyCommand.php +++ b/src/Command/ApplyCommand.php @@ -40,6 +40,10 @@ class ApplyCommand extends Command $output->writeln("Error: ".$e->getMessage().""); return; } + if (!$hotfix) { + $output->writeln("Could not load hotfix"); + return; + } $output->writeln(""); if (($signer = $hotfix->getSignedBy())) { diff --git a/src/Hotfix/Hotfix.php b/src/Hotfix/Hotfix.php index 49697ca..1fd5ed6 100644 --- a/src/Hotfix/Hotfix.php +++ b/src/Hotfix/Hotfix.php @@ -21,7 +21,9 @@ class Hotfix protected function load($hotfix) { - // echo $hotfix."\n\n"; + if (strpos($hotfix, "\n---\n")===false) { + throw new \Exception("Hotfix is missing a proper header, is line endings wrong?"); + } list ($header, $body) = explode("\n---\n", $hotfix, 2); $header = Yaml::parse($header); diff --git a/src/Hotfix/Loader.php b/src/Hotfix/Loader.php index 182d551..be1ea47 100644 --- a/src/Hotfix/Loader.php +++ b/src/Hotfix/Loader.php @@ -43,7 +43,7 @@ class Loader } return new Hotfix($body, $signer); } - fprintf(STDERR, "Error: Couldn't load '%s'", $fix); + fprintf(STDERR, "Error: Couldn't load '%s'\n", $fix); } protected function verifySignature($body, $signature) diff --git a/src/Hotfix/Loader/HttpLoader.php b/src/Hotfix/Loader/HttpLoader.php index 623a035..a78dee3 100644 --- a/src/Hotfix/Loader/HttpLoader.php +++ b/src/Hotfix/Loader/HttpLoader.php @@ -6,6 +6,10 @@ class HttpLoader implements LoaderInterface { public function load($fix) { + if (preg_match("/^http[s]?:/", $fix)) { + $body = file_get_contents($fix); + return $body; + } return false; } }