mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +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
|
# Temporary files
|
||||||
|
|
||||||
/release/
|
|
||||||
/documentation/
|
/documentation/
|
||||||
/manual/
|
/manual/
|
||||||
/tests/coverage/
|
/tests/coverage/
|
||||||
|
@ -12,6 +11,9 @@
|
||||||
/config.php
|
/config.php
|
||||||
/.php_cs.cache
|
/.php_cs.cache
|
||||||
/tests/.phpunit.result.cache
|
/tests/.phpunit.result.cache
|
||||||
|
/release/*
|
||||||
|
|
||||||
|
!/release/settings.default.php
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
|
|
67
RoboFile.php
67
RoboFile.php
|
@ -194,7 +194,7 @@ class RoboFile extends \Robo\Tasks {
|
||||||
if (!$result->wasSuccessful()) {
|
if (!$result->wasSuccessful()) {
|
||||||
return $result;
|
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
|
// start by getting the list of files from the tarball
|
||||||
$archive = new \Archive_Tar($tarball);
|
$archive = new \Archive_Tar($tarball);
|
||||||
$filelist = array_flip(array_column($archive->listContent(), "filename"));
|
$filelist = array_flip(array_column($archive->listContent(), "filename"));
|
||||||
|
@ -203,7 +203,6 @@ class RoboFile extends \Robo\Tasks {
|
||||||
// Produce an Arch PKGBUILD if appropriate
|
// Produce an Arch PKGBUILD if appropriate
|
||||||
if (isset($filelist['arsse/dist/arch/PKGBUILD'])) {
|
if (isset($filelist['arsse/dist/arch/PKGBUILD'])) {
|
||||||
$t->addCode(function() use ($tarball, $archive) {
|
$t->addCode(function() use ($tarball, $archive) {
|
||||||
$this->say("Preparing PKGBUILD");
|
|
||||||
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||||
$archive->extractList("arsse/dist/arch/PKGBUILD", $dir, "arsse/dist/arch/", false);
|
$archive->extractList("arsse/dist/arch/PKGBUILD", $dir, "arsse/dist/arch/", false);
|
||||||
// update the tarball's checksum
|
// update the tarball's checksum
|
||||||
|
@ -220,7 +219,6 @@ class RoboFile extends \Robo\Tasks {
|
||||||
// Produce an RPM spec file if appropriate
|
// Produce an RPM spec file if appropriate
|
||||||
if (isset($filelist['arsse/dist/rpm/arsse.spec'])) {
|
if (isset($filelist['arsse/dist/rpm/arsse.spec'])) {
|
||||||
$t->addCode(function() use ($tarball, $archive) {
|
$t->addCode(function() use ($tarball, $archive) {
|
||||||
$this->say("Preparing RPM spec file");
|
|
||||||
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||||
$archive->extractList("arsse/dist/rpm/arsse.spec", $dir, "arsse/dist/rpm/", false);
|
$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
|
// 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
|
// save commit description to VERSION file for reference
|
||||||
$t->addTask($this->taskWriteToFile($dir."VERSION")->text($version));
|
$t->addTask($this->taskWriteToFile($dir."VERSION")->text($version));
|
||||||
// perform Composer installation in the temp location with dev dependencies
|
if (file_exists($dir."docs") || file_exists($dir."manpages")) {
|
||||||
$t->addTask($this->taskComposerInstall()->arg("-q")->dir($dir));
|
// 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")) {
|
if (file_exists($dir."manpages")) {
|
||||||
// generate manpages
|
// generate manpages
|
||||||
$t->addTask($this->taskExec("./robo manpage")->dir($dir));
|
$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));
|
$t->addTask($this->taskExec("./robo manual -q")->dir($dir));
|
||||||
}
|
}
|
||||||
// perform Composer installation in the temp location for final output
|
// 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
|
// delete unwanted files
|
||||||
$t->addTask($this->taskFilesystemStack()->remove([
|
$t->addTask($this->taskFilesystemStack()->remove([
|
||||||
$dir.".git",
|
$dir.".git",
|
||||||
|
@ -440,7 +440,7 @@ class RoboFile extends \Robo\Tasks {
|
||||||
// re-pack the tarball using a specific name special to Debian
|
// 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));
|
$t->addTask($this->taskPack($dir."arsse_$baseVersion.orig.tar.gz")->addDir("arsse-$baseVersion", $base));
|
||||||
// pack the debian tarball
|
// 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
|
// generate the DSC file
|
||||||
$t->addCode(function() use ($t, $debVersion, $baseVersion, $dir, $base) {
|
$t->addCode(function() use ($t, $debVersion, $baseVersion, $dir, $base) {
|
||||||
try {
|
try {
|
||||||
|
@ -452,7 +452,8 @@ class RoboFile extends \Robo\Tasks {
|
||||||
return $this->taskWriteToFile($dir."arsse_$debVersion.dsc")->text($dsc)->run();
|
return $this->taskWriteToFile($dir."arsse_$debVersion.dsc")->text($dsc)->run();
|
||||||
});
|
});
|
||||||
// delete any existing files
|
// 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"));
|
$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();
|
return $t->run();
|
||||||
}
|
}
|
||||||
|
@ -466,35 +467,39 @@ class RoboFile extends \Robo\Tasks {
|
||||||
* Generic release tarballs will always be generated, but distribution-specific
|
* Generic release tarballs will always be generated, but distribution-specific
|
||||||
* packages are skipped when the required tools are not available
|
* 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")) {
|
if (!$this->toolExists("git")) {
|
||||||
throw new \Exception("Git is required in PATH to produce packages");
|
throw new \Exception("Git is required in PATH to produce packages");
|
||||||
}
|
}
|
||||||
[$commit,] = $this->commitVersion($commit);
|
[$commit, $version] = $this->commitVersion($commit);
|
||||||
// determine whether the distribution-specific packages can be built
|
$tarball = BASE."release/$version/arsse-$version.tar.gz";
|
||||||
$dist = [
|
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||||
'Arch' => $this->toolExists("git", "makepkg", "updpkgsums"),
|
// build the generic release tarball and related files if the tarball doesn't exist
|
||||||
'Deb' => $this->toolExists("git", "sudo", "pbuilder"),
|
if (!file_exists($tarball)) {
|
||||||
];
|
$result = $this->taskExec(BASE."robo package $commit")->run();
|
||||||
// start a collection
|
if (!$result->wasSuccessful()) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// import settings
|
||||||
|
$settings = (@include BASE."release/settings.default.php");
|
||||||
$t = $this->collectionBuilder();
|
$t = $this->collectionBuilder();
|
||||||
// build the generic release tarball
|
foreach ($settings as $target => $s) {
|
||||||
$t->addTask($this->taskExec(BASE."robo package:generic $commit"));
|
// glob the recipe and use the first one found
|
||||||
// build other packages
|
$recipe = glob($dir.$s['recipe']);
|
||||||
foreach ($dist as $distro => $run) {
|
if (!$recipe) {
|
||||||
if ($run) {
|
$this->say("Build target '$target' skipped");
|
||||||
$subcmd = strtolower($distro);
|
continue;
|
||||||
$t->addTask($this->taskExec(BASE."robo package:$subcmd $commit"));
|
|
||||||
}
|
}
|
||||||
|
$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();
|
return $t->run();
|
||||||
// note any packages which were not built
|
|
||||||
foreach ($dist as $distro => $run) {
|
|
||||||
if (!$run) {
|
|
||||||
$this->say("Packages for $distro skipped");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generates static manual pages in the "manual" directory
|
/** 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 $@
|
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"
|
# 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
|
cp dist/systemd/arsse-fetch.service debian/arsse.service
|
||||||
sed -i -se 's/^PartOf=.*//' debian/arsse.service
|
sed -i -se 's/^PartOf=.*//' debian/arsse.service
|
||||||
|
@ -24,3 +24,5 @@ execute_before_dh_install:
|
||||||
# Change PHP-FPM socket paths
|
# Change PHP-FPM socket paths
|
||||||
cp -r dist/apache dist/nginx debian
|
cp -r dist/apache dist/nginx debian
|
||||||
sed -i -se 's/arsse\.sock/php-fpm.sock/' debian/apache/arsse.conf debian/nginx/arsse.conf
|
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