diff --git a/RoboFile.php b/RoboFile.php index 3a577cc..b48353e 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -1,5 +1,6 @@ changelogDebian($this->changelogParse(file_get_contents($dir."CHANGELOG"), $version), $version); - // save commit description to VERSION file for use by packaging + // save commit description to VERSION file for reference $t->addTask($this->taskWriteToFile($dir."VERSION")->text($version)); - // save the Debian changelog - $t->addTask($this->taskWriteToFile($dir."dist/debian/changelog")->text($debianChangelog)); // patch the Arch PKGBUILD file with the correct version string $t->addTask($this->taskReplaceInFile($dir."dist/arch/PKGBUILD")->regex('/^pkgver=.*$/m')->to("pkgver=$archVersion")); // patch the Arch PKGBUILD file with the correct source file $t->addTask($this->taskReplaceInFile($dir."dist/arch/PKGBUILD")->regex('/^source=\("arsse-[^"]+"\)$/m')->to('source=("'.basename($tarball).'")')); + // Prepare Debian-related files + $this->prepDebian($t, $dir, $version); // perform Composer installation in the temp location with dev dependencies $t->addTask($this->taskComposerInstall()->arg("-q")->dir($dir)); // generate manpages @@ -196,6 +195,7 @@ class RoboFile extends \Robo\Tasks { $dir.".git", $dir.".gitignore", $dir.".gitattributes", + $dir."dist/debian/.gitignore", $dir."composer.json", $dir."composer.lock", $dir.".php_cs.dist", @@ -462,4 +462,21 @@ class RoboFile extends \Robo\Tasks { } return $out; } + + protected function prepDebian(CollectionBuilder $t, string $dir, string $version): void { + // generate the Debian changelog; this also validates our original changelog + $debianChangelog = $this->changelogDebian($this->changelogParse(file_get_contents($dir."CHANGELOG"), $version), $version); + // save the Debian changelog + $t->addTask($this->taskWriteToFile($dir."dist/debian/changelog")->text($debianChangelog)); + // adapt the systemd unit for Debian: this involves using only the "arsse-fetch" unit (renamed to "arsse"), removing the "PartOf" directive, and changing the user and group to "www-data" + $t->addTask($this->taskFilesystemStack()->copy($dir."dist/systemd/arsse-fetch.service", $dir."dist/debian/arsse.service")); + $t->addTask($this->taskReplaceInFile($dir."/dist/debian/arsse.service")->regex('/^PartOf=.*$/m')->to("")); + $t->addTask($this->taskReplaceInFile($dir."/dist/debian/arsse.service")->regex('/^(User|Group)=.*$/m')->to("$1=www-data")); + // change the user and group references in tmpfiles + $t->addTask($this->taskFilesystemStack()->copy($dir."dist/tmpfiles.conf", $dir."dist/debian/arsse.tmpfiles")); + $t->addTask($this->taskReplaceInFile($dir."dist/debian/arsse.tmpfiles")->regex('/(?<= )arsse(?= )/')->to("www-data")); + // change the user reference in the executable file + $t->addTask($this->taskFilesystemStack()->copy($dir."dist/arsse", $dir."dist/debian/arsse")); + $t->addTask($this->taskReplaceInFile($dir."dist/debian/arsse")->from('posix_getpwnam("arsse"')->to('posix_getpwnam("www-data"')); + } } diff --git a/dist/debian/.gitignore b/dist/debian/.gitignore new file mode 100644 index 0000000..d8b7e4f --- /dev/null +++ b/dist/debian/.gitignore @@ -0,0 +1,13 @@ +* +!.gitignore +!arsse.install +!compat +!control +!copyright +!lintian-overrides +!rules + +!source/ +source/* +!source/lintian-overrides +!source/format diff --git a/dist/debian/arsse.install b/dist/debian/arsse.install index 852ddb0..c9f0f14 100644 --- a/dist/debian/arsse.install +++ b/dist/debian/arsse.install @@ -8,7 +8,7 @@ UPGRADING usr/share/arsse/ README.md usr/share/arsse/ arsse.php usr/share/arsse/ -dist/arsse usr/bin/ +dist/debian/arsse usr/bin/ manual usr/share/doc/arsse/ dist/man/* usr/share/man/ dist/nginx etc/arsse/ diff --git a/dist/systemd/arsse-fetch.service b/dist/systemd/arsse-fetch.service index 76b16e0..3ae3553 100644 --- a/dist/systemd/arsse-fetch.service +++ b/dist/systemd/arsse-fetch.service @@ -33,4 +33,4 @@ RestartPreventStatus= #ReadOnlyPaths=/ #ReadWriePaths=/var/lib/arsse #NoExecPaths=/ -#ExecPaths=/usr/bin/php /usr/bin/php7 +#ExecPaths=/usr/bin/php