Skip to content

Commit 1e335eb

Browse files
Vitexusclaude
andcommitted
feat: apply pack-as-deb skill — modernise Debian packaging
- Add debian/autoload.php with system autoloaders (ease-core, ease-fluentpdo), PSR-4 for SpojeNet\Cnb\, and InstalledVersions block - Rewrite debian/rules: PKG_VERSION/PKG_SOURCE/PKG_TYPE Make vars, install autoload.php in override_dh_install, patch require_once paths, inject APP_NAME/APP_VERSION/InstalledVersions via sed; add override_dh_auto_test for appstreamcli validation; drop moreutils - Update debian/control: replace moreutils with appstream in Build-Depends - Fix metainfo: component type console-application, stock icon cnb-cache, provides binaries, add releases, fix description - Uncomment/correct metainfo install line in debian/cnb-cache.install - Add man pages: cnb-cache-init.1, cnb-cache-update.1, cnb-cache.manpages - Modernise phinx-adapter.php: replace per-class EaseCore includes with require_once autoload.php - Skip cnb-cache-mysql/pgsql in Jenkinsfile test stage (no DB server) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 470b134 commit 1e335eb

11 files changed

Lines changed: 902 additions & 578 deletions

composer.lock

Lines changed: 780 additions & 539 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

debian/Jenkinsfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ distributions.each { distro ->
8888
artifacts.each { deb_file ->
8989
if (deb_file.endsWith('.deb')) {
9090
def pkgName = deb_file.tokenize('/')[-1].replaceFirst(/_.*/, '')
91+
if (pkgName ==~ /.*-(mysql|pgsql)/) {
92+
echo "Skipping ${pkgName} - requires a running database server"
93+
return
94+
}
9195
def distroCodename = sh(
9296
script: "lsb_release -sc",
9397
returnStdout: true

debian/autoload.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once '/usr/share/php/Ease/autoload.php';
6+
require_once '/usr/share/php/EaseFluentPDO/autoload.php';
7+
8+
spl_autoload_register(function (string $class): void {
9+
$prefix = 'SpojeNet\\Cnb\\';
10+
if (str_starts_with($class, $prefix)) {
11+
$file = '/usr/lib/cnb-cache/' . str_replace('\\', '/', substr($class, strlen($prefix))) . '.php';
12+
if (file_exists($file)) {
13+
require $file;
14+
}
15+
}
16+
});
17+
18+
(function (): void {
19+
$versions = [];
20+
foreach (\Composer\InstalledVersions::getAllRawData() as $d) {
21+
$versions = array_merge($versions, $d['versions'] ?? []);
22+
}
23+
$name = 'unknown';
24+
$version = '0.0.0';
25+
$versions[$name] = ['pretty_version' => $version, 'version' => $version,
26+
'reference' => null, 'type' => 'library', 'install_path' => __DIR__,
27+
'aliases' => [], 'dev_requirement' => false];
28+
\Composer\InstalledVersions::reload([
29+
'root' => ['name' => $name, 'pretty_version' => $version, 'version' => $version,
30+
'reference' => null, 'type' => 'library', 'install_path' => __DIR__,
31+
'aliases' => [], 'dev' => false],
32+
'versions' => $versions,
33+
]);
34+
})();

debian/cnb-cache-init.1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.TH CNB-CACHE-INIT 1 "" "cnb-cache" "User Commands"
2+
.SH NAME
3+
cnb\-cache\-init \- Initialize the CNB currency rate cache database
4+
.SH SYNOPSIS
5+
.B cnb-cache-init
6+
[\fB\-e\fR \fIENVFILE\fR]
7+
.SH DESCRIPTION
8+
Downloads historical exchange rates from the Czech National Bank and stores them
9+
in the configured SQL database.
10+
The number of days of history to fetch is controlled by the KEEP_DAYS configuration variable.
11+
.SH OPTIONS
12+
.TP
13+
.BR \-e ", " \-\-environment=\fIENVFILE\fR
14+
Path to the environment configuration file (default: /etc/cnb-cache/cnb-cache.env).
15+
.SH FILES
16+
.TP
17+
.I /etc/cnb-cache/cnb-cache.env
18+
Main configuration file.
19+
.SH SEE ALSO
20+
.BR cnb-cache-update (1)
21+
.SH AUTHOR
22+
Vítězslav Dvořák <info@vitexsoftware.cz>

debian/cnb-cache-update.1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.TH CNB-CACHE-UPDATE 1 "" "cnb-cache" "User Commands"
2+
.SH NAME
3+
cnb\-cache\-update \- Update the CNB currency rate cache
4+
.SH SYNOPSIS
5+
.B cnb-cache-update
6+
[\fB\-e\fR \fIENVFILE\fR]
7+
.SH DESCRIPTION
8+
Fetches today's exchange rates from the Czech National Bank and stores them
9+
in the configured SQL database, then removes rates older than KEEP_DAYS days.
10+
.SH OPTIONS
11+
.TP
12+
.BR \-e ", " \-\-environment=\fIENVFILE\fR
13+
Path to the environment configuration file (default: /etc/cnb-cache/cnb-cache.env).
14+
.SH FILES
15+
.TP
16+
.I /etc/cnb-cache/cnb-cache.env
17+
Main configuration file.
18+
.SH SEE ALSO
19+
.BR cnb-cache-init (1)
20+
.SH AUTHOR
21+
Vítězslav Dvořák <info@vitexsoftware.cz>

debian/cnb-cache.install

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ debian/conf/cnb-cache.service etc/avahi/services
1212
bin/* usr/bin
1313
src/init.php usr/lib/cnb-cache
1414
src/update.php usr/lib/cnb-cache
15-
#debian/cz.spojenet.cnb-cache.metainfo.xml usr/share/metainfo/
16-
#debian/cz.spojenet.cnb-cache.desktop usr/share/applications/
15+
debian/io.github.spoje_net.cnb_cache.metainfo.xml usr/share/metainfo/
16+
#debian/cz.spojenet.cnb-cache.desktop usr/share/applications/
1717
cnb-cache.svg usr/share/icons/hicolor/scalable/apps/
1818
example.env etc/cnb-cache

debian/cnb-cache.manpages

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
debian/cnb-cache-init.1
2+
debian/cnb-cache-update.1

debian/conf/phinx-adapter.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,7 @@
77
* @copyright 2021-2024 Vitex Software
88
*/
99

10-
include_once '/usr/share/php/EaseCore/Atom.php';
11-
include_once '/usr/share/php/EaseCore/Shared.php';
12-
include_once '/usr/share/php/EaseCore/Molecule.php';
13-
include_once '/usr/share/php/EaseCore/Logger/Logging.php';
14-
include_once '/usr/share/php/EaseCore/Sand.php';
15-
include_once '/usr/share/php/EaseCore/Functions.php';
16-
include_once '/usr/share/php/EaseCore/Logger/Message.php';
17-
include_once '/usr/share/php/EaseCore/Logger/Loggingable.php';
18-
include_once '/usr/share/php/EaseCore/Logger/Loggingable.php';
19-
include_once '/usr/share/php/EaseCore/Logger/ToMemory.php';
20-
include_once '/usr/share/php/EaseCore/recordkey.php';
21-
include_once '/usr/share/php/EaseCore/Brick.php';
22-
include_once '/usr/share/php/EaseCore/Person.php';
23-
include_once '/usr/share/php/EaseCore/Anonym.php';
24-
include_once '/usr/share/php/EaseCore/User.php';
25-
include_once '/usr/share/php/EaseCore/Logger/ToStd.php';
26-
include_once '/usr/share/php/EaseCore/Logger/ToSyslog.php';
27-
include_once '/usr/share/php/EaseCore/Logger/ToConsole.php';
28-
include_once '/usr/share/php/EaseCore/Logger/Regent.php';
29-
include_once '/usr/share/php/EaseCore/Logger/ToMemory.php';
30-
include_once '/usr/share/php/EaseCore/Exception.php';
31-
include_once '/usr/share/php/EaseFluentPDO/Orm.php';
32-
include_once '/usr/share/php/EaseFluentPDO/Engine.php';
10+
require_once '/usr/lib/cnb-cache/autoload.php';
3311

3412
if (file_exists('/etc/cnb-cache/cnb-cache.env')) {
3513
\Ease\Shared::instanced()->loadConfig('/etc/cnb-cache/cnb-cache.env', true);

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Source: cnb-cache
22
Section: unknown
33
Priority: optional
44
Maintainer: Vítězslav Dvořák <info@vitexsoftware.cz>
5-
Build-Depends: debhelper-compat (= 13), jq, moreutils
5+
Build-Depends: debhelper-compat (= 13), jq, appstream
66
Standards-Version: 4.5.1
77
Homepage: https://github.com/Spoje-NET/CNB-cache
88
Rules-Requires-Root: no
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<component type="desktop-application">
2+
<component type="console-application">
33
<id>io.github.spoje_net.cnb_cache</id>
44
<metadata_license>MIT</metadata_license>
55
<project_license>MIT</project_license>
66
<name>cnb-cache</name>
77
<summary>CNB Currency rate Cache</summary>
88
<description>
99
<p>
10-
Keep the history of specified currencies stored in SQL database. Mandatory dependencies for use CNB cache with SQLite database Mandatory dependencies for use CNB cache with MySQL/MariaDB databas
10+
Downloads and caches exchange rates from the Czech National Bank into a SQL database.
11+
Supports SQLite, MySQL/MariaDB, and PostgreSQL backends.
1112
</p>
1213
</description>
14+
<icon type="stock">cnb-cache</icon>
1315
<categories>
14-
<category>Utility</category>
16+
<category>Finance</category>
17+
<category>ConsoleOnly</category>
1518
</categories>
1619
<url type="homepage">https://github.com/Spoje-NET/CNB-Cache</url>
1720
<url type="bugtracker">https://github.com/Spoje-NET/CNB-Cache/issues</url>
1821
<developer id="io.github.spoje_net">
1922
<name>Spoje.Net</name>
2023
</developer>
24+
<provides>
25+
<binary>cnb-cache-init</binary>
26+
<binary>cnb-cache-update</binary>
27+
</provides>
28+
<releases>
29+
<release version="0.1.0" date="2025-01-25"/>
30+
</releases>
2131
<content_rating type="oars-1.1"/>
2232
</component>

0 commit comments

Comments
 (0)