Simply Robo input for Arch and Deb packaging

This commit is contained in:
J. King 2021-07-08 18:04:15 -04:00
parent f91b3c0120
commit 20ffb2484a

View file

@ -160,7 +160,7 @@ class RoboFile extends \Robo\Tasks {
/** Packages a given commit of the software into a release tarball /** Packages a given commit of the software into a release tarball
* *
* The version to package may be any Git tree-ish identifier: a tag, a branch, * The commit 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 * or any commit hash. If none is provided on the command line, Robo will prompt
* for a commit to package; the default is "HEAD". * for a commit to package; the default is "HEAD".
* *
@ -168,9 +168,9 @@ class RoboFile extends \Robo\Tasks {
* may not be equivalent due to subsequent changes in the exclude list, or because * may not be equivalent due to subsequent changes in the exclude list, or because
* of new tooling. * of new tooling.
*/ */
public function package(string $version = null): Result { public function package(string $commit = null): Result {
// establish which commit to package // establish which commit to package
$version = $this->commitVersion($version); $version = $this->commitVersion($commit);
$archVersion = preg_replace('/^([^-]+)-(\d+)-(\w+)$/', "$1.r$2.$3", $version); $archVersion = preg_replace('/^([^-]+)-(\d+)-(\w+)$/', "$1.r$2.$3", $version);
// name the generic release tarball // name the generic release tarball
$tarball = BASE."release/$version/arsse-$version.tar.gz"; $tarball = BASE."release/$version/arsse-$version.tar.gz";
@ -251,11 +251,26 @@ class RoboFile extends \Robo\Tasks {
return $result; return $result;
} }
/** Packages a release tarball into an Arch package */ /** Packages a given commit of the software into an Arch package
public function packageArch(string $tarball): Result { *
* 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".
*
* The Arch base-devel group should be installed for this.
*/
public function packageArch(string $commit = null): Result {
// establish which commit to package
$version = $this->commitVersion($commit);
$commit = $commit ?? "HEAD";
$tarball = BASE."release/$version/arsse-$version.tar.gz";
$dir = dirname($tarball).\DIRECTORY_SEPARATOR; $dir = dirname($tarball).\DIRECTORY_SEPARATOR;
// start a collection // start a collection
$t = $this->collectionBuilder(); $t = $this->collectionBuilder();
// build the generic release tarball if it doesn't exist
if (!file_exists($tarball)) {
$t->addTask($this->taskExec(BASE."robo package $commit"));
}
// extract the PKGBUILD from the tarball // extract the PKGBUILD from the tarball
$t->addCode(function() use ($tarball, $dir) { $t->addCode(function() use ($tarball, $dir) {
// because Robo doesn't support extracting a single file we have to do it ourselves // because Robo doesn't support extracting a single file we have to do it ourselves
@ -268,12 +283,20 @@ class RoboFile extends \Robo\Tasks {
return $t->run(); return $t->run();
} }
/** Packages a release tarball into a Debian package */ /** Packages a given commit of the software into source and binary Debian packages
public function packageDeb(string $tarball): Result { *
// validate the tarball name * The commit to package may be any Git tree-ish identifier: a tag, a branch,
if (!preg_match('/^arsse-(\d+(?:\.\d+)*)/', basename($tarball))) { * or any commit hash. If none is provided on the command line, Robo will prompt
throw new \Exception("Tarball is not named correctly"); * for a commit to package; the default is "HEAD".
} *
* The pbuilder tool should be installed for this.
*/
public function packageDeb(string $commit = null): Result {
// establish which commit to package
$version = $this->commitVersion($commit);
$commit = $commit ?? "HEAD";
$tarball = BASE."release/$version/arsse-$version.tar.gz";
// define some more variables
$tgz = BASE."release/pbuilder-arsse.tgz"; $tgz = BASE."release/pbuilder-arsse.tgz";
$bind = dirname(realpath($tarball)); $bind = dirname(realpath($tarball));
$script = BASE."dist/debian/pbuilder.sh"; $script = BASE."dist/debian/pbuilder.sh";
@ -285,6 +308,10 @@ class RoboFile extends \Robo\Tasks {
if (!file_exists($tgz)) { if (!file_exists($tgz)) {
$t->addTask($this->taskExec('sudo pbuilder create --basetgz '.escapeshellarg($tgz).' --mirror http://ftp.ca.debian.org/debian/ --extrapackages debhelper --extrapackages devscripts')); $t->addTask($this->taskExec('sudo pbuilder create --basetgz '.escapeshellarg($tgz).' --mirror http://ftp.ca.debian.org/debian/ --extrapackages debhelper --extrapackages devscripts'));
} }
// build the generic release tarball if it doesn't exist
if (!file_exists($tarball)) {
$t->addTask($this->taskExec(BASE."robo package $commit"));
}
// build the packages // build the packages
$t->addTask($this->taskExec('sudo pbuilder execute --basetgz '.escapeshellarg($tgz).' --bindmounts '.escapeshellarg($bind).' -- '.escapeshellarg($script).' '.escapeshellarg("$bind/".basename($tarball)))); $t->addTask($this->taskExec('sudo pbuilder execute --basetgz '.escapeshellarg($tgz).' --bindmounts '.escapeshellarg($bind).' -- '.escapeshellarg($script).' '.escapeshellarg("$bind/".basename($tarball))));
// take ownership of the output files // take ownership of the output files