From e653fb3f737723d40a3905d136d2d18e67b27e50 Mon Sep 17 00:00:00 2001 From: "J. KIng" Date: Fri, 21 May 2021 21:11:22 -0400 Subject: [PATCH] Enhancements to Debian files --- RoboFile.php | 42 +++++++++++++++++++++++++-------------- dist/debian/copyright | 33 ++++++++++++++++++++++++++++++ dist/debian/rules | 3 ++- dist/debian/source/format | 1 + 4 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 dist/debian/copyright create mode 100644 dist/debian/source/format diff --git a/RoboFile.php b/RoboFile.php index f869c33..dbffa4c 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -248,20 +248,28 @@ class RoboFile extends \Robo\Tasks { /** Packages a release tarball into a Debian package */ public function packageDeb(string $tarball): Result { + // determine the "upstream" (tagged) version + if (preg_match('/^arsse-(\d+(?:\.\d+)*)/', basename($tarball, $m))) { + $version = $m[1]; + $base = $dir."arsse-$version"; + } else { + throw new \Exception("Tarball is not named correctly"); + } $t = $this->collectionBuilder(); - $dir = $t->tmpDir().\DIRECTORY_SEPARATOR; - // name the "orig" tarball - $orig = $dir.str_replace(".tar.gz", ".orig.tar.gz", str_replace("arsse-", "arsse_", basename($tarball))); + $dir = $t->workDir("~/temp2").\DIRECTORY_SEPARATOR; // copy the tarball $t->addTask($this->taskFilesystemStack()->copy($tarball, $orig)); - // extract the tarball and keep all "dist files" + // extract the tarball $t->addCode(function() use ($tarball, $dir) { - // because Robo doesn't support extracting a single file we have to do it ourselves + // Robo's extract task is broken, so we do it manually (new \Archive_Tar($tarball))->extract($dir, false); - // perform a do-nothing filesystem operation since we need a Robo task result - return $this->taskFilesystemStack()->rename($dir."arsse", $dir."src")->run(); + // "temp.orig" is a special directory name to Debian's "quilt" format + return $this->taskFilesystemStack()->rename($dir."arsse", $dir."temp.orig")->run(); }); - $t->addTask($this->taskFilesystemStack()->mirror($dir."src/dist", $dir)); + // create a directory with the package name and "upstream" version; this is also special to Debian + $t->addTask($this->taskFilesystemStack()->mkdir($base)); + // copy relevant files to the directory + $t->addTask($this->taskFilesystemStack()->mirror($dir."temp.orig/dist", $base)); $t->addTask($this->taskExec("deber")->dir($dir)); return $t->run(); } @@ -334,7 +342,7 @@ class RoboFile extends \Robo\Tasks { } if ($entry) { $out[] = $entry; - } + } $entry = ['version' => $version, 'date' => $date, 'features' => [], 'fixes' => [], 'changes' => []]; $expected = ["separator"]; } elseif (in_array("separator", $expected) && preg_match('/^=+/', $l)) { @@ -398,27 +406,31 @@ class RoboFile extends \Robo\Tasks { } $out = ""; foreach ($log as $entry) { - $out .= "arsse (".$entry['version']."-1) unstable; urgency=low\n"; + // normalize the version string + preg_match('/^(\d+(?:\.\d+)*)(?:-(\d+)-.+)?$/', $entry['version'], $m); + $version = $m[1]."-".($m[2] ?: "1"); + // output the entry + $out .= "arsse ($version) UNRELEASED; urgency=low\n"; if ($entry['features']) { - $out .= "\n [ New features ]\n"; + $out .= "\n"; foreach ($entry['features'] as $item) { $out .= " * ".trim(preg_replace("/^/m", " ", $item))."\n"; } } if ($entry['fixes']) { - $out .= "\n [ Bug fixes ]\n"; + $out .= "\n"; foreach ($entry['fixes'] as $item) { $out .= " * ".trim(preg_replace("/^/m", " ", $item))."\n"; } } if ($entry['changes']) { - $out .= "\n [ Other changes ]\n"; + $out .= "\n"; foreach ($entry['changes'] as $item) { $out .= " * ".trim(preg_replace("/^/m", " ", $item))."\n"; } } - $out .= "\n -- The Arsse team ".\DateTimeImmutable::createFromFormat("Y-m-d", $entry['date'], new \DateTimeZone("UTC"))->format("D, d M Y")." 00:00:00 +0000\n\n"; + $out .= "\n -- The Arsse team ".\DateTimeImmutable::createFromFormat("Y-m-d", $entry['date'], new \DateTimeZone("UTC"))->format("D, d M Y")." 00:00:00 +0000\n\n"; } return $out; } -} \ No newline at end of file +} diff --git a/dist/debian/copyright b/dist/debian/copyright new file mode 100644 index 0000000..29222cd --- /dev/null +++ b/dist/debian/copyright @@ -0,0 +1,33 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: arsse +Upstream-Contact: J. King +Source: https://code.mensbeam.com/MensBeam/arsse/ + +Files: * +Copyright: 2017 J. King + 2017 Dustin Wilson +License: Expat + +License: Expat + Copyright (c) 2017 J. King, Dustin Wilson + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. diff --git a/dist/debian/rules b/dist/debian/rules index 626d6fa..8ff98a7 100644 --- a/dist/debian/rules +++ b/dist/debian/rules @@ -3,4 +3,5 @@ DH_VERBOSE = 1 %: - dh $@ \ No newline at end of file + dh $@ + diff --git a/dist/debian/source/format b/dist/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/dist/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt)