1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 05:44:53 +00:00

Move output out of build-root when built

This commit is contained in:
J. King 2021-07-19 18:08:51 -04:00
parent 62aca930f8
commit 45d419f82f
2 changed files with 24 additions and 56 deletions

View file

@ -370,45 +370,6 @@ class RoboFile extends \Robo\Tasks {
return $t->run(); return $t->run();
} }
/** Packages a given commit of the software a binary Debian package
*
* 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
* for a commit to package; the default is "HEAD".
*
* The pbuilder tool should be installed for this.
*/
public function packageDeb(string $commit = null): Result {
if (!$this->toolExists("git", "sudo", "pbuilder")) {
throw new \Exception("Git, sudo, and pbuilder are required in PATH to produce Debian packages");
}
// establish which commit to package
[$commit, $version] = $this->commitVersion($commit);
$tarball = BASE."release/$version/arsse-$version.tar.gz";
// define some more variables
$tgz = BASE."release/pbuilder-arsse.tgz";
$bind = dirname($tarball);
$script = BASE."dist/debian/pbuilder.sh";
$user = trim(`id -un`);
$group = trim(`id -gn`);
// start a task collection
$t = $this->collectionBuilder();
// check that the pbuilder base exists and create it if it does not
if (!file_exists($tgz)) {
$t->addTask($this->taskFilesystemStack()->mkdir(BASE."release"));
$t->addTask($this->taskExec('sudo pbuilder create --basetgz '.escapeshellarg($tgz).' --mirror http://ftp.ca.debian.org/debian/ --extrapackages "debhelper devscripts lintian"'));
}
// build the generic release tarball if it doesn't exist
if (!file_exists($tarball)) {
$t->addTask($this->taskExec(BASE."robo package:generic $commit"));
}
// build the packages
$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
$t->addTask($this->taskExec("sudo chown -R $user:$group ".escapeshellarg($bind)));
return $t->run();
}
/** Packages a release tarball into a Debian source package /** Packages a release tarball into a Debian source package
* *
* The commit 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,
@ -463,13 +424,10 @@ class RoboFile extends \Robo\Tasks {
* The commit 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".
*
* Generic release tarballs will always be generated, but distribution-specific
* packages are skipped when the required tools are not available
*/ */
public function packageBin(string $commit = null, string $target = null): Result { public function packageBin(string $commit = null, string $target = null): Result {
if (!$this->toolExists("git")) { if (!$this->toolExists("git", "build", "sudo")) {
throw new \Exception("Git is required in PATH to produce packages"); throw new \Exception("Git OBS-Build are required in PATH to produce packages");
} }
[$commit, $version] = $this->commitVersion($commit); [$commit, $version] = $this->commitVersion($commit);
$tarball = BASE."release/$version/arsse-$version.tar.gz"; $tarball = BASE."release/$version/arsse-$version.tar.gz";
@ -496,8 +454,18 @@ class RoboFile extends \Robo\Tasks {
$repo = implode(" ", array_map(function($repo) { $repo = implode(" ", array_map(function($repo) {
return "--repo ".escapeshellarg($repo); return "--repo ".escapeshellarg($repo);
}, $s['repos'])); }, $s['repos']));
$t->addTask($this->taskExec("sudo build $dist $repo $recipe")); // perform the build
// TODO: copy output back $t->addTask($this->taskExec("sudo build --clean $dist $repo $recipe"));
// move the output files alongside the tarball
$t->addCode(function() use ($dir, $s, $target) {
$dir = $dir.$target.\DIRECTORY_SEPARATOR;
$stack = $this->taskFilesystemStack()->mkdir($dir);
foreach (glob("/var/tmp/build-root".$s['output']) as $f) {
$name = basename($f);
$stack->remove($dir.$name)->rename($f, $dir.$name);
}
return $stack->run();
});
} }
return $t->run(); return $t->run();
} }

View file

@ -1,19 +1,19 @@
<?php <?php
return [ return [
//'arch' => [ 'arch' => [
// 'type' => "arch", 'type' => "arch",
// 'repos' => ["http://mirror.csclub.uwaterloo.ca/archlinux/core/os/x86_64/", "http://mirror.csclub.uwaterloo.ca/archlinux/extra/os/x86_64/"], 'repos' => ["http://mirror.csclub.uwaterloo.ca/archlinux/core/os/x86_64/", "http://mirror.csclub.uwaterloo.ca/archlinux/extra/os/x86_64/"],
// 'keys' => [], 'keys' => [],
// 'dist' => "arch", 'dist' => "arch",
// 'recipe' => "PKGBUILD", 'recipe' => "PKGBUILD",
// 'output' => "*.pkg.tar.zst", 'output' => "/usr/src/packages/ARCHPKGS/*.pkg.tar.zst",
//], ],
'deb' => [ 'debian' => [
'type' => "debian", 'type' => "debian",
'repos' => ["http://ftp.ca.debian.org/debian/?dist=buster&component=main"], 'repos' => ["http://ftp.ca.debian.org/debian/?dist=buster&component=main"],
'keys' => [], 'keys' => [],
'dist' => "debian10", 'dist' => "debian10",
'recipe' => "*.dsc", 'recipe' => "*.dsc",
'output' => "*.deb", 'output' => "/usr/src/packages/DEBS/*.deb",
], ],
]; ];