mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Build debian packages with OBS
This commit is contained in:
parent
10265561d8
commit
62aca930f8
4 changed files with 61 additions and 33 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,6 +1,5 @@
|
|||
# Temporary files
|
||||
|
||||
/release/
|
||||
/documentation/
|
||||
/manual/
|
||||
/tests/coverage/
|
||||
|
@ -12,6 +11,9 @@
|
|||
/config.php
|
||||
/.php_cs.cache
|
||||
/tests/.phpunit.result.cache
|
||||
/release/*
|
||||
|
||||
!/release/settings.default.php
|
||||
|
||||
# Dependencies
|
||||
|
||||
|
|
67
RoboFile.php
67
RoboFile.php
|
@ -194,7 +194,7 @@ class RoboFile extends \Robo\Tasks {
|
|||
if (!$result->wasSuccessful()) {
|
||||
return $result;
|
||||
}
|
||||
// if the generic tarball could be built, try to Arch, Debian, and RPM files; these might legitimately not exist in old releases
|
||||
// if the generic tarball could be built, try to produce Arch, Debian, and RPM files; these might legitimately not exist in old releases
|
||||
// start by getting the list of files from the tarball
|
||||
$archive = new \Archive_Tar($tarball);
|
||||
$filelist = array_flip(array_column($archive->listContent(), "filename"));
|
||||
|
@ -203,7 +203,6 @@ class RoboFile extends \Robo\Tasks {
|
|||
// Produce an Arch PKGBUILD if appropriate
|
||||
if (isset($filelist['arsse/dist/arch/PKGBUILD'])) {
|
||||
$t->addCode(function() use ($tarball, $archive) {
|
||||
$this->say("Preparing PKGBUILD");
|
||||
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||
$archive->extractList("arsse/dist/arch/PKGBUILD", $dir, "arsse/dist/arch/", false);
|
||||
// update the tarball's checksum
|
||||
|
@ -220,7 +219,6 @@ class RoboFile extends \Robo\Tasks {
|
|||
// Produce an RPM spec file if appropriate
|
||||
if (isset($filelist['arsse/dist/rpm/arsse.spec'])) {
|
||||
$t->addCode(function() use ($tarball, $archive) {
|
||||
$this->say("Preparing RPM spec file");
|
||||
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||
$archive->extractList("arsse/dist/rpm/arsse.spec", $dir, "arsse/dist/rpm/", false);
|
||||
// perform a do-nothing filesystem operation since we need a Robo task result
|
||||
|
@ -273,8 +271,10 @@ class RoboFile extends \Robo\Tasks {
|
|||
}
|
||||
// save commit description to VERSION file for reference
|
||||
$t->addTask($this->taskWriteToFile($dir."VERSION")->text($version));
|
||||
// perform Composer installation in the temp location with dev dependencies
|
||||
$t->addTask($this->taskComposerInstall()->arg("-q")->dir($dir));
|
||||
if (file_exists($dir."docs") || file_exists($dir."manpages")) {
|
||||
// perform Composer installation in the temp location with dev dependencies to include Robo and Daux
|
||||
$t->addTask($this->taskExec("composer install")->arg("-q")->dir($dir));
|
||||
}
|
||||
if (file_exists($dir."manpages")) {
|
||||
// generate manpages
|
||||
$t->addTask($this->taskExec("./robo manpage")->dir($dir));
|
||||
|
@ -284,7 +284,7 @@ class RoboFile extends \Robo\Tasks {
|
|||
$t->addTask($this->taskExec("./robo manual -q")->dir($dir));
|
||||
}
|
||||
// perform Composer installation in the temp location for final output
|
||||
$t->addTask($this->taskComposerInstall()->dir($dir)->noDev()->optimizeAutoloader()->arg("--no-scripts")->arg("-q"));
|
||||
$t->addTask($this->taskExec("composer install")->dir($dir)->arg("--no-dev")->arg("-o")->arg("--no-scripts")->arg("-q"));
|
||||
// delete unwanted files
|
||||
$t->addTask($this->taskFilesystemStack()->remove([
|
||||
$dir.".git",
|
||||
|
@ -440,7 +440,7 @@ class RoboFile extends \Robo\Tasks {
|
|||
// re-pack the tarball using a specific name special to Debian
|
||||
$t->addTask($this->taskPack($dir."arsse_$baseVersion.orig.tar.gz")->addDir("arsse-$baseVersion", $base));
|
||||
// pack the debian tarball
|
||||
$t->addTask($this->taskPack($dir."arsse_$debVersion.debian.tar.gz")->addDir("debian", $base."dist"));
|
||||
$t->addTask($this->taskPack($dir."arsse_$debVersion.debian.tar.gz")->addDir("debian", $base."dist/debian"));
|
||||
// generate the DSC file
|
||||
$t->addCode(function() use ($t, $debVersion, $baseVersion, $dir, $base) {
|
||||
try {
|
||||
|
@ -452,7 +452,8 @@ class RoboFile extends \Robo\Tasks {
|
|||
return $this->taskWriteToFile($dir."arsse_$debVersion.dsc")->text($dsc)->run();
|
||||
});
|
||||
// delete any existing files
|
||||
$t->AddTask($this->taskFilesystemStack()->remove(BASE."release/$version/arsse_$baseVersion.orig.tar.gz")->remove(BASE."release/$version/arsse_$debVersion.debian.tar.gz")->remove(BASE."release/$version/arsse_$debVersion.dsc"));
|
||||
$t->AddTask($this->taskFilesystemStack()->remove([BASE."release/$version/arsse_$baseVersion.orig.tar.gz", BASE."release/$version/arsse_$debVersion.debian.tar.gz", BASE."release/$version/arsse_$debVersion.dsc"]));
|
||||
// copy the new files over
|
||||
$t->addTask($this->taskFilesystemStack()->copy($dir."arsse_$baseVersion.orig.tar.gz", BASE."release/$version/arsse_$baseVersion.orig.tar.gz")->copy($dir."arsse_$debVersion.debian.tar.gz", BASE."release/$version/arsse_$debVersion.debian.tar.gz")->copy($dir."arsse_$debVersion.dsc", BASE."release/$version/arsse_$debVersion.dsc"));
|
||||
return $t->run();
|
||||
}
|
||||
|
@ -466,35 +467,39 @@ class RoboFile extends \Robo\Tasks {
|
|||
* 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): Result {
|
||||
public function packageBin(string $commit = null, string $target = null): Result {
|
||||
if (!$this->toolExists("git")) {
|
||||
throw new \Exception("Git is required in PATH to produce packages");
|
||||
}
|
||||
[$commit,] = $this->commitVersion($commit);
|
||||
// determine whether the distribution-specific packages can be built
|
||||
$dist = [
|
||||
'Arch' => $this->toolExists("git", "makepkg", "updpkgsums"),
|
||||
'Deb' => $this->toolExists("git", "sudo", "pbuilder"),
|
||||
];
|
||||
// start a collection
|
||||
[$commit, $version] = $this->commitVersion($commit);
|
||||
$tarball = BASE."release/$version/arsse-$version.tar.gz";
|
||||
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||
// build the generic release tarball and related files if the tarball doesn't exist
|
||||
if (!file_exists($tarball)) {
|
||||
$result = $this->taskExec(BASE."robo package $commit")->run();
|
||||
if (!$result->wasSuccessful()) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
// import settings
|
||||
$settings = (@include BASE."release/settings.default.php");
|
||||
$t = $this->collectionBuilder();
|
||||
// build the generic release tarball
|
||||
$t->addTask($this->taskExec(BASE."robo package:generic $commit"));
|
||||
// build other packages
|
||||
foreach ($dist as $distro => $run) {
|
||||
if ($run) {
|
||||
$subcmd = strtolower($distro);
|
||||
$t->addTask($this->taskExec(BASE."robo package:$subcmd $commit"));
|
||||
foreach ($settings as $target => $s) {
|
||||
// glob the recipe and use the first one found
|
||||
$recipe = glob($dir.$s['recipe']);
|
||||
if (!$recipe) {
|
||||
$this->say("Build target '$target' skipped");
|
||||
continue;
|
||||
}
|
||||
$recipe = escapeshellarg($recipe[0]);
|
||||
$dist = "--dist ".escapeshellarg($s['dist']);
|
||||
$repo = implode(" ", array_map(function($repo) {
|
||||
return "--repo ".escapeshellarg($repo);
|
||||
}, $s['repos']));
|
||||
$t->addTask($this->taskExec("sudo build $dist $repo $recipe"));
|
||||
// TODO: copy output back
|
||||
}
|
||||
$out = $t->run();
|
||||
// note any packages which were not built
|
||||
foreach ($dist as $distro => $run) {
|
||||
if (!$run) {
|
||||
$this->say("Packages for $distro skipped");
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
return $t->run();
|
||||
}
|
||||
|
||||
/** Generates static manual pages in the "manual" directory
|
||||
|
|
4
dist/debian/rules
vendored
4
dist/debian/rules
vendored
|
@ -5,7 +5,7 @@ DH_VERBOSE = 1
|
|||
%:
|
||||
dh $@
|
||||
|
||||
execute_before_dh_install:
|
||||
override_dh_install:
|
||||
# Adapt the systemd service 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"
|
||||
cp dist/systemd/arsse-fetch.service debian/arsse.service
|
||||
sed -i -se 's/^PartOf=.*//' debian/arsse.service
|
||||
|
@ -24,3 +24,5 @@ execute_before_dh_install:
|
|||
# Change PHP-FPM socket paths
|
||||
cp -r dist/apache dist/nginx debian
|
||||
sed -i -se 's/arsse\.sock/php-fpm.sock/' debian/apache/arsse.conf debian/nginx/arsse.conf
|
||||
# Execute dh_install as normal
|
||||
dh_install
|
||||
|
|
19
release/settings.default.php
Normal file
19
release/settings.default.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
return [
|
||||
//'arch' => [
|
||||
// 'type' => "arch",
|
||||
// 'repos' => ["http://mirror.csclub.uwaterloo.ca/archlinux/core/os/x86_64/", "http://mirror.csclub.uwaterloo.ca/archlinux/extra/os/x86_64/"],
|
||||
// 'keys' => [],
|
||||
// 'dist' => "arch",
|
||||
// 'recipe' => "PKGBUILD",
|
||||
// 'output' => "*.pkg.tar.zst",
|
||||
//],
|
||||
'deb' => [
|
||||
'type' => "debian",
|
||||
'repos' => ["http://ftp.ca.debian.org/debian/?dist=buster&component=main"],
|
||||
'keys' => [],
|
||||
'dist' => "debian10",
|
||||
'recipe' => "*.dsc",
|
||||
'output' => "*.deb",
|
||||
],
|
||||
];
|
Loading…
Reference in a new issue