Skip to content

Commit 67a0595

Browse files
Vitexusclaude
andcommitted
fix: write composer.json name into autoload.php at build time, no runtime file I/O
Replace runtime json_decode(file_get_contents()) fallback with a build-time sed injection: debian/rules replaces the 'unknown' placeholder with the PKG_SOURCE value (jq .name from composer.json), keeping full compatibility with composer package naming conventions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 56ee154 commit 67a0595

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

debian/autoload.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
foreach (\Composer\InstalledVersions::getAllRawData() as $d) {
2626
$versions = array_merge($versions, $d['versions'] ?? []);
2727
}
28-
$_cj = @json_decode(@file_get_contents(__DIR__ . '/composer.json'), true);
29-
$name = defined('APP_NAME') ? APP_NAME : ($_cj['name'] ?? basename(__DIR__));
28+
$name = defined('APP_NAME') ? APP_NAME : 'unknown';
3029
$version = defined('APP_VERSION') ? APP_VERSION : '0.0.0';
3130
$versions[$name] = ['pretty_version' => $version, 'version' => $version,
3231
'reference' => null, 'type' => 'library', 'install_path' => __DIR__,

debian/rules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ override_dh_install:
2020
dh_install
2121
sed -i "1a defined('APP_NAME') || define('APP_NAME', '$(PKG_SOURCE)');" \
2222
debian/php-vitexsoftware-ease-html-widgets/usr/share/php/EaseHtmlWidgets/autoload.php
23+
sed -i "s|: 'unknown'|: '$(PKG_SOURCE)'|" \\
24+
debian/php-vitexsoftware-ease-html-widgets/usr/share/php/EaseHtmlWidgets/autoload.php
2325
sed -i "2a defined('APP_VERSION') || define('APP_VERSION', '$(PKG_VERSION)');" \
2426
debian/php-vitexsoftware-ease-html-widgets/usr/share/php/EaseHtmlWidgets/autoload.php

0 commit comments

Comments
 (0)