diff --git a/RoboFile.php b/RoboFile.php index 8bb5991..4ad7e3c 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -158,7 +158,7 @@ class RoboFile extends \Robo\Tasks { public function package(string $version = null): Result { // establish which commit to package $version = $version ?? $this->askDefault("Commit to package:", "HEAD"); - $archive = BASE."arsse-$version.tar.gz"; + $archive = "arsse-$version.tar.gz"; // start a collection $t = $this->collectionBuilder(); // create a temporary directory @@ -215,30 +215,20 @@ class RoboFile extends \Robo\Tasks { return $t->run(); } - /** Packages a given commit of the software into an Arch package - * - * The version to package may be any Git tree-ish identifier: a tag, a branch, - * or any commit hash. If none is provided on the command line, Robo will prompt - * for a commit to package; the default is "HEAD". - */ - public function packageArch(string $version = null): Result { - // establish which commit to package - $version = $version ?? $this->askDefault("Commit to package:", "HEAD"); - $archive = BASE."arsse-$version.tar.gz"; + /** Packages a release tarball into an Arch package */ + public function packageArch(string $tarball): Result { + $dir = dirname($tarball); // start a collection $t = $this->collectionBuilder(); - // create a tarball - $t->addCode(function() use ($version) { - return $this->package($version); - }); - // extract the PKGBUILD from the just-created archive and build it - $t->addCode(function() use ($archive) { + // extract the PKGBUILD from the tarball + $t->addCode(function() use ($tarball, $dir) { // because Robo doesn't support extracting a single file we have to do it ourselves - (new \Archive_Tar($archive))->extractList("arsse/dist/arch/PKGBUILD", BASE, "arsse/dist/arch/", false); + (new \Archive_Tar($tarball))->extractList("arsse/dist/arch/PKGBUILD", $dir,"arsse/dist/arch/", false); // perform a do-nothing filesystem operation since we need a Robo task result - return $this->taskFilesystemStack()->chmod(BASE."PKGBUILD", 0644)->run(); - })->completion($this->taskFilesystemStack()->remove(BASE."PKGBUILD")); - $t->taskExec("makepkg -Ccf")->dir(BASE); + return $this->taskFilesystemStack()->chmod("PKGBUILD", 0644)->dir($dir)->run(); + })->completion($this->taskFilesystemStack()->remove("PKGBUILD")->dir($dir)); + // build the package + $t->taskExec("makepkg -Ccf")->dir($dir); return $t->run(); } @@ -285,4 +275,36 @@ class RoboFile extends \Robo\Tasks { // execute the collection return $t->run(); } + + protected function parseChangelog(string $text, string $targetVersion): array { + $baseVersion = preg_replace('/^(\d+(?:\.\d+)*).*/', "$1", $targetVersion); + $lines = preg_split('/[\r\n]+/', trim($text)); + $version = ""; + $section = ""; + $out = []; + $l = 0; + $expected = "version"; + for ($a = 0; $a < sizeof($lines);) { + $l = rtrim($lines[$a++]); + Process: + if (in_array($expected, ["version", "section"]) && preg_match('/^Version (\d+(?:\.\d+)*) \(([\d\?]{4}-[\d\?]{2}-[\d\?]{2})\)\s*$/', $l, $m)) { + $version = $m[1]; + if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $m[2])) { + // uncertain dates are allowed only for the top version, and only if it does not match the target version (otherwise we have forgot to set the correct date before tagging) + if (!$out && $targetVersion !== $version) { + // use today's date; local time is fine + $date = date("Y-m-d"); + } else { + throw new \Exception("CHANGELOG: Date at line $a is incomplete"); + } + } else { + $date = $m[2]; + } + $out[$version] = ['date' => $date, 'features' => [], 'fixes' => [], 'changes' => []]; + $expected = "separator"; + } elseif ($expected === "separator" && $length = strlen($lines[$a - 2]) && preg_match('/^={'.$length.'}$/', $l)) { + // verify that the next line is blank + } + } + } } diff --git a/dist/arch/PKGBUILD b/dist/arch/PKGBUILD index 259158f..5f7154b 100644 --- a/dist/arch/PKGBUILD +++ b/dist/arch/PKGBUILD @@ -2,7 +2,7 @@ pkgname="arsse" pkgver=0.9.1 pkgrel=1 epoch= -pkgdesc="RSS/Atom newsfeed synchronization server" +pkgdesc="Multi-protocol RSS/Atom newsfeed synchronization server" arch=("any") url="https://thearsse.com/" license=("MIT") @@ -57,4 +57,5 @@ package() { sed -ise 's/\/\(etc\|usr\/share\)\/arsse\//\/\1\/webapps\/arsse\//' "$pkgdir/etc/webapps/arsse/nginx/"* "$pkgdir/etc/webapps/arsse/apache/"* "$pkgdir/usr/lib/tmpfiles.d/arsse.conf" "$pkgdir/usr/lib/systemd/system/"* "$pkgdir/usr/bin/"* sed -ise 's/\/var\/run\/php\//\/run\/php-fpm\//' "$pkgdir/etc/webapps/arsse/nginx/"* "$pkgdir/etc/webapps/arsse/apache/"* "$pkgdir/etc/php/php-fpm.d/arsse.conf" sed -ise 's/www-data/http/' "$pkgdir/etc/php/php-fpm.d/arsse.conf" + sed -ie 's/^WorkingDirectory=.*$/WorkingDirectory=\/usr\/share\/webapps\/arsse/' -e 's/^ConfigurationDirectory=.*$/ConfigurationDirectory=webapps\/arsse/' "$pkgdir/usr/lib/systemd/system/arsse-fetch.service" } diff --git a/dist/debian/control b/dist/debian/control new file mode 100644 index 0000000..99221dd --- /dev/null +++ b/dist/debian/control @@ -0,0 +1,32 @@ +Source: arsse +Maintainer: J. King +Section: contrib/net +Priority: optional +Standards-Version: 4.5.1 +Homepage: https://thearsse.com/ +Vcs-Browser: https://code.mensbeam.com/MensBeam/arsse/ +Vcs-Git: https://code.mensbeam.com/MensBeam/arsse/ + +Package: arsse +Architecture: all +Section: contrib/net +Priority: optional +Essential: no +Homepage: https://thearsse.com/ +Description: Multi-protocol RSS/Atom newsfeed synchronization server + The Arsse bridges the gap between multiple existing newsfeed aggregator + client protocols such as Tiny Tiny RSS, Nextcloud News and Miniflux, + allowing you to use compatible clients for many protocols with a single + server. +Depends: ${misc:Depends}, + dbconfig-mysql | dbconfig-pgsql | dbconfig-sqlite3 | dbconfig-no-thanks, + php (>= 7.1.0), + php-cli, + php-intl, + php-json, + php-xml, + php-sqlite3 | php-mysql | php-pgsql +Recommends: apache2 | nginx, + php-fpm, + php-curl, + ca-certificates