Compare commits
25 commits
Author | SHA1 | Date | |
---|---|---|---|
22b2fcf742 | |||
fe2ad18bb3 | |||
c2fa2ffd7f | |||
eb7402f531 | |||
e5eac39aeb | |||
0a7965ca27 | |||
c1db405718 | |||
9f73b61e7e | |||
f02de6e4f0 | |||
c31de5be5f | |||
26deac007c | |||
9f0e89de59 | |||
72f6bf643d | |||
c5db10bb90 | |||
5616cfaedd | |||
4733e927cb | |||
7f65a0aa86 | |||
ecc361aad0 | |||
d04b3e44fa | |||
e5be8eac40 | |||
eafedc1c8f | |||
56493c7991 | |||
84d9e7f8d7 | |||
25e3350670 | |||
4d5ec6074e |
|
@ -76,7 +76,7 @@ Adding scripts
|
|||
$packager->setPreInstallScript(__DIR__ . '/my-pre-install-script.sh');
|
||||
$packager->setPostInstallScript(__DIR__ . '/my-post-install-script.sh');
|
||||
$packager->setPreRemoveScript(__DIR__ . '/my-pre-remove-script.sh');
|
||||
$packager->setPreRemoveScript(__DIR__ . '/my-post-remove-script.sh');
|
||||
$packager->setPostRemoveScript(__DIR__ . '/my-post-remove-script.sh');
|
||||
```
|
||||
|
||||
See a script example
|
||||
|
|
|
@ -179,15 +179,28 @@ class Packager
|
|||
if (!file_exists($destFolder)) {
|
||||
mkdir($destFolder, 0777, true);
|
||||
}
|
||||
copy($source, $dest);
|
||||
if (fileperms($source) != fileperms($dest))
|
||||
if (is_link($source)) {
|
||||
symlink(readlink($source), $dest);
|
||||
return; // don't set perms on symlink targets
|
||||
} else {
|
||||
if (!copy($source, $dest)) {
|
||||
echo "Error: failed to copy: $source -> $dest \m";
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fileperms($source) != fileperms($dest)) {
|
||||
chmod($dest, fileperms($source));
|
||||
}
|
||||
}
|
||||
|
||||
public function build($debPackageName = false)
|
||||
{
|
||||
if (!$debPackageName) {
|
||||
$debPackageName = basename($this->getOutputPath() . ".deb");
|
||||
$control = $this->getControl();
|
||||
$name = $control['Package'];
|
||||
$version = $control['Version'];
|
||||
$arch = $control['Architecture'];
|
||||
$debPackageName = "{$name}_{$version}_{$arch}.deb";
|
||||
}
|
||||
|
||||
$command = "dpkg -b {$this->getOutputPath()} {$debPackageName}";
|
||||
|
|
|
@ -44,7 +44,7 @@ class StandardFile
|
|||
"Recommends" => false,
|
||||
"Suggests" => false,
|
||||
"Installed-Size" => 1024,
|
||||
"Maintainer" => "name [email]",
|
||||
"Maintainer" => "name <email>",
|
||||
"Conflicts" => false,
|
||||
"Replaces" => false,
|
||||
"Provides" => "your-company",
|
||||
|
@ -68,7 +68,7 @@ class StandardFile
|
|||
|
||||
public function setPriority($priority)
|
||||
{
|
||||
return $this->_setProperty($this["Priority"], $priority);
|
||||
return $this->_setProperty("Priority", $priority);
|
||||
}
|
||||
|
||||
public function setArchitecture($arch)
|
||||
|
@ -93,7 +93,7 @@ class StandardFile
|
|||
|
||||
public function setRecommends($depends)
|
||||
{
|
||||
return $this->_setProperty("Reccommends", $depends);
|
||||
return $this->_setProperty("Recommends", $this->_transformList($depends));
|
||||
}
|
||||
|
||||
public function setSuggests($depends)
|
||||
|
@ -109,7 +109,7 @@ class StandardFile
|
|||
public function setMaintainer($maintainer, $email = false)
|
||||
{
|
||||
$email = ($email) ? $email : "---";
|
||||
return $this->_setProperty("Maintainer", $maintainer . "[{$email}]");
|
||||
return $this->_setProperty("Maintainer", "{$maintainer} <{$email}>");
|
||||
}
|
||||
|
||||
public function setConflicts($conflicts)
|
||||
|
@ -119,12 +119,12 @@ class StandardFile
|
|||
|
||||
public function setReplaces($replaces)
|
||||
{
|
||||
return $this->_setProperty("Conflicts", $this->_transformList($replaces));
|
||||
return $this->_setProperty("Replaces", $this->_transformList($replaces));
|
||||
}
|
||||
|
||||
public function setProvides($provides)
|
||||
{
|
||||
return $this->_setProperty("Provides", $provides);
|
||||
return $this->_setProperty("Provides", $this->_transformList($provides));
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
|
@ -149,11 +149,13 @@ class StandardFile
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function offsetExists ($offset) {
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->_keys);
|
||||
}
|
||||
|
||||
public function offsetGet ($offset) {
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if ($this->offsetExists($offset)) {
|
||||
return $this->_keys[$offset];
|
||||
} else {
|
||||
|
@ -161,14 +163,16 @@ class StandardFile
|
|||
}
|
||||
}
|
||||
|
||||
public function offsetSet ($offset, $value) {
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (!$this->offsetExists($offset)) {
|
||||
throw new \InvalidArgumentException("Invalid property '{$offset}' for this control file.");
|
||||
}
|
||||
$this->_keys[$offset] = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset ($offset) {
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
if ($this->offsetExists($offset)) {
|
||||
unset($this->_keys[$offset]);
|
||||
}
|
||||
|
@ -183,7 +187,7 @@ class StandardFile
|
|||
{
|
||||
$control = '';
|
||||
foreach ($this->_keys as $key => $value) {
|
||||
if($value){
|
||||
if ($value) {
|
||||
$control .= "{$key}: {$value}" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,14 @@ class PackagerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->object->run();
|
||||
$command = $this->object->build();
|
||||
|
||||
$control = $this->object->getControl();
|
||||
$name = $control['Package'];
|
||||
$version = $control['Version'];
|
||||
$arch = $control['Architecture'];
|
||||
$debPackageName = "{$name}_{$version}_{$arch}.deb";
|
||||
|
||||
$this->assertEquals("dpkg -b vfs://root/tmp tmp.deb", $command);
|
||||
$this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $command);
|
||||
}
|
||||
|
||||
public function testCreateDebWhenOutputFolderIsMissing()
|
||||
|
@ -72,8 +78,14 @@ class PackagerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->object->run();
|
||||
$command = $this->object->build();
|
||||
|
||||
$control = $this->object->getControl();
|
||||
$name = $control['Package'];
|
||||
$version = $control['Version'];
|
||||
$arch = $control['Architecture'];
|
||||
$debPackageName = "{$name}_{$version}_{$arch}.deb";
|
||||
|
||||
$this->assertEquals("dpkg -b vfs://root/tmp tmp.deb", $command);
|
||||
$this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $command);
|
||||
}
|
||||
|
||||
public function testCreateDebPackageWithAnotherName()
|
||||
|
|
|
@ -21,7 +21,7 @@ Priority: optional
|
|||
Architecture: all
|
||||
Essential: no
|
||||
Installed-Size: 1024
|
||||
Maintainer: name [email]
|
||||
Maintainer: name <email>
|
||||
Provides: your-company
|
||||
Description: Your description
|
||||
|
||||
|
@ -46,7 +46,7 @@ OEF;
|
|||
$this->object["Architecture"] = "x86";
|
||||
$this->object["Essential"] = "yes";
|
||||
$this->object["Installed-Size"] = "2048";
|
||||
$this->object["Maintainer"] = "Walter Dal Mut [walter.dalmut at gmail dot com]";
|
||||
$this->object["Maintainer"] = "Walter Dal Mut <walter.dalmut at gmail dot com>";
|
||||
$this->object["Provides"] = "Corley SRL";
|
||||
$this->object["Description"] = "My Desc";
|
||||
$this->object["Depends"] = "php5-cli";
|
||||
|
@ -63,7 +63,7 @@ Essential: yes
|
|||
Depends: php5-cli
|
||||
Recommends: php5-curl
|
||||
Installed-Size: 2048
|
||||
Maintainer: Walter Dal Mut [walter.dalmut at gmail dot com]
|
||||
Maintainer: Walter Dal Mut <walter.dalmut at gmail dot com>
|
||||
Provides: Corley SRL
|
||||
Description: My Desc
|
||||
|
||||
|
|
Loading…
Reference in a new issue