Compare commits

...

25 commits

Author SHA1 Message Date
Jan-Hendrik Frintrop 22b2fcf742 Change default deb package name (#19)
* Change default deb package name

Changed default deb package name to `"{$name}_{$version}_{$arch}.deb"` since this is what normally would be generated.

* Fix tests for default deb name

The tests with default package name still expected the old version of the name.

* Fixed tests

Tests tried to get the Control via `$this->getControl()` which obviously failed.
2017-07-18 12:07:15 +02:00
Walter Dal Mut fe2ad18bb3 Merge pull request #18 from jhfrintrop/patch-6
Fix spacing in method names
2017-07-18 12:07:01 +02:00
Jan-Hendrik Frintrop c2fa2ffd7f Fix setMaintainer (#14)
* Fix brackets of maintainer email

The email address of the maintainer must use angle brackes as per https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Maintainer
Also there should be a space between name and email.

* Use variable interpolation for maintainer name

Since you already use interpolation for maintainer email you can use it for name too.

* Fix default value for maintainer

The default value for the maintainer still had the square brackets.

* Fix tests for StandardFile

The tests still used square brackets.
2017-07-18 12:06:01 +02:00
Walter Dal Mut eb7402f531 Merge pull request #17 from jhfrintrop/patch-5
Fix setReplaces
2017-07-18 12:05:32 +02:00
Walter Dal Mut e5eac39aeb Merge pull request #16 from jhfrintrop/patch-4
Fix setProvides
2017-07-18 12:05:05 +02:00
Walter Dal Mut 0a7965ca27 Merge pull request #13 from jhfrintrop/patch-1
Fix setRecommends
2017-07-18 12:04:24 +02:00
Walter Dal Mut c1db405718 Merge pull request #15 from jhfrintrop/patch-3
Fix setPriority
2017-07-18 12:03:53 +02:00
Jan-Hendrik Frintrop 9f73b61e7e Fix spacing in method names
Some method names were followed by spaces.
2017-07-18 09:14:45 +02:00
Jan-Hendrik Frintrop f02de6e4f0 Fix setReplaces
`setReplaces` used `"Conflicts"` as key which should be `"Replaces"`.
2017-07-18 09:07:36 +02:00
Jan-Hendrik Frintrop c31de5be5f Fix setProvides
Provided packages can also be a list of packages.
2017-07-18 09:05:56 +02:00
Jan-Hendrik Frintrop 26deac007c Fix setPriority
`setPriority` used `$this["Priority"]` as key which should be just `"Priority"`.
2017-07-18 09:03:50 +02:00
Jan-Hendrik Frintrop 9f0e89de59 Recommended packages can be a list
The field "Recommends" needs to accept a list of recommended packages.
2017-07-18 08:50:11 +02:00
Jan-Hendrik Frintrop 72f6bf643d Fix spelling mistake in property name
Property "Reccommends" does not exist.
It is "Recommends"
2017-07-18 08:46:05 +02:00
Walter Dal Mut c5db10bb90 Merge pull request #12 from Tony133/master
Fix identation method
2017-06-27 19:30:58 +02:00
Tony133 5616cfaedd Fix identation 2017-06-27 15:10:25 +02:00
Walter Dal Mut 4733e927cb Merge pull request #11 from Tony133/master
Fix spaces
2017-06-27 11:00:36 +02:00
Tony133 7f65a0aa86 Fix indentation 2017-04-19 12:12:32 +02:00
Walter Dal Mut ecc361aad0 Merge pull request #10 from DavidGoodwin/master
improve symlink copying
2016-06-21 14:50:09 +02:00
David Goodwin d04b3e44fa don't continue and try to set permissions on a symlink - that'll be covered by something else in this package, or is outside our scope and part of the O/S or another package 2016-06-21 13:33:34 +01:00
David Goodwin e5be8eac40 check retval from copy(src,dest) 2016-06-21 13:22:27 +01:00
David Goodwin eafedc1c8f Fix indentation 2016-06-21 13:19:46 +01:00
Walter Dal Mut 56493c7991 Merge pull request #9 from ashleyfraser/symlinks
Added support for copying symbolic links
2016-06-14 19:17:30 +02:00
Ashley Fraser 84d9e7f8d7 Added support for copying symbolic links 2016-06-14 14:36:06 +02:00
Walter Dal Mut 25e3350670 Merge pull request #8 from utkuaydin/master
Minor correction in readme file
2015-07-06 15:40:03 +02:00
Utku Aydın 4d5ec6074e Minor correction in readme file 2015-07-06 16:23:39 +03:00
5 changed files with 49 additions and 20 deletions

View file

@ -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

View file

@ -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}";

View file

@ -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;
}
}

View file

@ -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()

View file

@ -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