Improvements

This commit is contained in:
Christopher Vagnetoft
2016-04-19 22:55:09 +02:00
parent fceb4c4966
commit b63260533f
12 changed files with 101 additions and 13 deletions

View File

@ -9,6 +9,8 @@ class Hotfix
protected $signer;
protected $keyId;
protected $header;
protected $body;
@ -16,7 +18,8 @@ class Hotfix
public function __construct($hotfix, $signer)
{
$this->load($hotfix);
$this->signer = $signer;
$this->signer = $signer[0];
$this->keyId = $signer[1];
}
protected function load($hotfix)
@ -31,6 +34,11 @@ class Hotfix
$this->body = $body;
}
public function getBody()
{
return $this->body;
}
public function apply()
{
if (!array_key_exists('lang', $this->header)) {
@ -40,9 +48,12 @@ class Hotfix
}
$script = null;
$head = null;
$foot = null;
switch ($lang) {
case 'bash':
$exec = "/bin/bash";
$head = file_get_contents(__DIR__."/../stubs/bash.stub");
break;
case 'php':
$exec = "/usr/bin/env php";
@ -53,7 +64,7 @@ class Hotfix
}
$tmpfile = sys_get_temp_dir()."/hotfix_".sha1($this->header['hotfix']);
file_put_contents($tmpfile, $this->body);
file_put_contents($tmpfile, $head."\n".$this->body."\n".$foot);
passthru($exec." ".$tmpfile);
unlink($tmpfile);
}
@ -68,6 +79,11 @@ class Hotfix
$this->signer['uids'][0]['email']
);
}
public function getKeyId()
{
return $this->keyId;
}
public function getName()
{