mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Integrate RPM packaging into tasks
The packages themselves are not ready yet. Also adds RPM changelog
This commit is contained in:
parent
45d419f82f
commit
bc93dca240
3 changed files with 46 additions and 60 deletions
78
RoboFile.php
78
RoboFile.php
|
@ -244,7 +244,10 @@ class RoboFile extends \Robo\Tasks {
|
|||
}
|
||||
// establish which commit to package
|
||||
[$commit, $version] = $this->commitVersion($commit);
|
||||
$archVersion = preg_replace('/^([^-]+)-(\d+)-(\w+)$/', "$1.r$2.$3", $version);
|
||||
preg_match('/^([^-]+)(?:-(\d+)-(\w+))?$/', $version, $m);
|
||||
$archVersion = $m[1].($m[2] ? ".r$m[2].$m[3]" : "");
|
||||
$baseVersion = $m[1];
|
||||
$release = $m[2];
|
||||
// name the generic release tarball
|
||||
$tarball = BASE."release/$version/arsse-$version.tar.gz";
|
||||
// start a collection
|
||||
|
@ -257,17 +260,30 @@ class RoboFile extends \Robo\Tasks {
|
|||
return $result;
|
||||
}
|
||||
try {
|
||||
if (file_exists($dir."dist/debian")) {
|
||||
// generate the Debian changelog; this also validates our original changelog
|
||||
$debianChangelog = $this->changelogDebian($this->changelogParse(file_get_contents($dir."CHANGELOG"), $version), $version);
|
||||
// save the Debian-format changelog
|
||||
$t->addTask($this->taskWriteToFile($dir."dist/debian/changelog")->text($debianChangelog));
|
||||
}
|
||||
// Perform Arch-specific tasks
|
||||
if (file_exists($dir."dist/arch")) {
|
||||
// patch the Arch PKGBUILD file with the correct version string
|
||||
$t->addTask($this->taskReplaceInFile($dir."dist/arch/PKGBUILD")->regex('/^pkgver=.*$/m')->to("pkgver=$archVersion"));
|
||||
// patch the Arch PKGBUILD file with the correct source file
|
||||
$t->addTask($this->taskReplaceInFile($dir."dist/arch/PKGBUILD")->regex('/^source=\("arsse-[^"]+"\)$/m')->to('source=("'.basename($tarball).'")'));
|
||||
// perform Debian-specific tasks
|
||||
if (file_exists($dir."dist/debian")) {
|
||||
// generate the Debian changelog; this also validates our original changelog
|
||||
$changelog = $this->changelogParse(file_get_contents($dir."CHANGELOG"), $version);
|
||||
$debianChangelog = $this->changelogDebian($changelog, $version);
|
||||
// save the Debian-format changelog
|
||||
$t->addTask($this->taskWriteToFile($dir."dist/debian/changelog")->text($debianChangelog));
|
||||
// perform RPM-specific tasks
|
||||
if (file_exists($dir."dist/rpm")) {
|
||||
// patch the spec file with the correct version and release
|
||||
$t->addTask($this->taskReplaceInFile($dir."dist/rpm/arsse.spec")->regex('/^Version: .*$/m')->to("Version: $baseVersion"));
|
||||
$t->addTask($this->taskReplaceInFile($dir."dist/rpm/arsse.spec")->regex('/^Release: .*$/m')->to("Release: $release"));
|
||||
// patch the spec file with the correct tarball name
|
||||
$t->addTask($this->taskReplaceInFile($dir."dist/rpm/arsse.spec")->regex('/^Source0: .*$/m')->to("Source0: arsse-$version.tar.gz"));
|
||||
// append the RPM changelog to the spec file
|
||||
$t->addTask($this->taskWriteToFile($dir."dist/rpm/arsse.spec")->append(true)->text("\n\n%changelog\n".$this->changelogRPM($changelog, $version)));
|
||||
}
|
||||
}
|
||||
}
|
||||
// save commit description to VERSION file for reference
|
||||
$t->addTask($this->taskWriteToFile($dir."VERSION")->text($version));
|
||||
|
@ -336,40 +352,6 @@ class RoboFile extends \Robo\Tasks {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/** Packages a given commit of the software into an Arch 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 Arch base-devel group should be installed for this.
|
||||
*/
|
||||
public function packageArch(string $commit = null): Result {
|
||||
if (!$this->toolExists("git", "makepkg", "updpkgsums")) {
|
||||
throw new \Exception("Git, makepkg, and updpkgsums are required in PATH to produce Arch packages");
|
||||
}
|
||||
// establish which commit to package
|
||||
[$commit, $version] = $this->commitVersion($commit);
|
||||
$tarball = BASE."release/$version/arsse-$version.tar.gz";
|
||||
$dir = dirname($tarball).\DIRECTORY_SEPARATOR;
|
||||
// start a collection
|
||||
$t = $this->collectionBuilder();
|
||||
// build the generic release tarball if it doesn't exist
|
||||
if (!file_exists($tarball)) {
|
||||
$t->addTask($this->taskExec(BASE."robo package:generic $commit"));
|
||||
}
|
||||
// extract the PKGBUILD from the tarball
|
||||
$t->addCode(function() use ($tarball, $dir) {
|
||||
// because Robo doesn't support extracting a single file we have to do it ourselves
|
||||
(new \Archive_Tar($tarball))->extractList("arsse/dist/arch/PKGBUILD", $dir, "arsse/dist/arch/", false);
|
||||
// perform a do-nothing filesystem operation since we need a Robo task result
|
||||
return $this->taskFilesystemStack()->chmod($dir."PKGBUILD", 0644)->run();
|
||||
})->completion($this->taskFilesystemStack()->remove($dir."PKGBUILD"));
|
||||
// build the package
|
||||
$t->addTask($this->taskExec("makepkg -Ccf")->dir($dir));
|
||||
return $t->run();
|
||||
}
|
||||
|
||||
/** Packages a release tarball into a Debian source package
|
||||
*
|
||||
* The commit to package may be any Git tree-ish identifier: a tag, a branch,
|
||||
|
@ -628,16 +610,12 @@ class RoboFile extends \Robo\Tasks {
|
|||
}
|
||||
$out = "";
|
||||
foreach ($log as $entry) {
|
||||
// normalize the version string
|
||||
preg_match('/^(\d+(?:\.\d+)*(?:-\d+)?).+$/D', $entry['version'], $m);
|
||||
$version = $m[1];
|
||||
// output the entry
|
||||
$out .= "-------------------------------------------------------------------\n";
|
||||
$out .= DateTimeImmutable::createFromFormat("!Y-m-d", $entry['date'], new \DateTimeZone("UTC"))->format("D, M d 00:00:00 \U\T\C Y");
|
||||
$out .= " - ";
|
||||
$out .= "* ";
|
||||
$out .= DateTimeImmutable::createFromFormat("!Y-m-d", $entry['date'], new \DateTimeZone("UTC"))->format("D M d Y");
|
||||
$out .= " ";
|
||||
$out .= "J. King <jking@jkingweb.ca>";
|
||||
$out .= " - ";
|
||||
$out .= "$version\n\n";
|
||||
$out .= " ";
|
||||
$out .= "{$entry['version']}\n";
|
||||
foreach ($entry['features'] as $item) {
|
||||
$out .= "- ".trim(preg_replace("/^/m", " ", $item))."\n";
|
||||
}
|
||||
|
|
4
dist/rpm/arsse.spec
vendored
4
dist/rpm/arsse.spec
vendored
|
@ -110,10 +110,10 @@ install -m 644 dist/sysuser.conf %{buildroot}%{_sysusersdir}/system-user-arsse.c
|
|||
%{_sysusersdir}/system-user-arsse.conf
|
||||
|
||||
%pre
|
||||
%service_add_pre arsse.service demo1.service
|
||||
%service_add_pre arsse.service arsse.service
|
||||
|
||||
%post
|
||||
%service_add_post arsse.service demo1.service
|
||||
%service_add_post arsse.service arsse.service
|
||||
|
||||
%preun
|
||||
%service_del_preun arsse.service
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
<?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",
|
||||
'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' => "/usr/src/packages/ARCHPKGS/*.pkg.tar.zst",
|
||||
],
|
||||
'debian' => [
|
||||
'type' => "debian",
|
||||
'repos' => ["http://ftp.ca.debian.org/debian/?dist=buster&component=main"],
|
||||
'keys' => [],
|
||||
'dist' => "debian10",
|
||||
'type' => "debian",
|
||||
'repos' => ["http://ftp.ca.debian.org/debian/?dist=buster&component=main"],
|
||||
'keys' => [],
|
||||
'dist' => "debian10",
|
||||
'recipe' => "*.dsc",
|
||||
'output' => "/usr/src/packages/DEBS/*.deb",
|
||||
],
|
||||
'suse' => [
|
||||
'type' => "rpm",
|
||||
'repos' => ["http://mirror.csclub.uwaterloo.ca/opensuse/distribution/leap/15.3/repo/oss/"],
|
||||
'keys' => ["gpg-pubkey-39db7c82-5f68629b", "gpg-pubkey-65176565-5d94a381", "gpg-pubkey-307e3d54-5aaa90a5", "gpg-pubkey-3dbdc284-53674dd4"],
|
||||
'dist' => "sl15.3",
|
||||
'recipe' => "arsse.spec",
|
||||
'output' => "/home/abuild/rpmbuild/RPMS/noarch/*.rpm",
|
||||
],
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue