Skip to content

Commit 7a1e6cb

Browse files
Vitexusclaude
andcommitted
fix: inject APP_NAME/APP_VERSION and populate Composer\InstalledVersions in Debian autoloader
- debian/control: add composer as first Depends (or replace composer-debian) to guarantee /usr/share/php/Composer/InstalledVersions.php is present - debian/autoload.php: require InstalledVersions.php and call reload() to accumulate per-package data across chained autoloaders; APP_NAME/APP_VERSION constants pin the root package identity - debian/rules: inject guarded defined()||define() constants at build time using PKG_SOURCE/PKG_VERSION from dpkg-parsechangelog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0c853cb commit 7a1e6cb

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

debian/autoload.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,23 @@
1717
}
1818
}
1919
});
20+
21+
require_once '/usr/share/php/Composer/InstalledVersions.php';
22+
23+
(function (): void {
24+
$versions = [];
25+
foreach (\Composer\InstalledVersions::getAllRawData() as $d) {
26+
$versions = array_merge($versions, $d['versions'] ?? []);
27+
}
28+
$name = defined('APP_NAME') ? APP_NAME : 'unknown';
29+
$version = defined('APP_VERSION') ? APP_VERSION : '0.0.0';
30+
$versions[$name] = ['pretty_version' => $version, 'version' => $version,
31+
'reference' => null, 'type' => 'library', 'install_path' => __DIR__,
32+
'aliases' => [], 'dev_requirement' => false];
33+
\Composer\InstalledVersions::reload([
34+
'root' => ['name' => $name, 'pretty_version' => $version, 'version' => $version,
35+
'reference' => null, 'type' => 'project', 'install_path' => __DIR__,
36+
'aliases' => [], 'dev' => false],
37+
'versions' => $versions,
38+
]);
39+
})();

debian/rules

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
66
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
77

8+
PKG_VERSION := $(shell dpkg-parsechangelog -S Version | sed 's/~.*//')
9+
PKG_SOURCE := $(shell dpkg-parsechangelog -S Source)
10+
811
%:
912
dh $@
1013

@@ -15,3 +18,7 @@ override_dh_install:
1518
mkdir -p debian/tmp
1619
jq '.version = "'`dpkg-parsechangelog | sed -n 's/^Version: //p'| sed 's/~.*//'`'"' debian/composer.json |sponge debian/tmp/composer.json
1720
dh_install
21+
sed -i "1a defined('APP_NAME') || define('APP_NAME', '$(PKG_SOURCE)');" \
22+
debian/php-vitexsoftware-ease-html-widgets/usr/share/php/EaseHtmlWidgets/autoload.php
23+
sed -i "2a defined('APP_VERSION') || define('APP_VERSION', '$(PKG_VERSION)');" \
24+
debian/php-vitexsoftware-ease-html-widgets/usr/share/php/EaseHtmlWidgets/autoload.php

0 commit comments

Comments
 (0)