Skip to content

Commit 2b61a6a

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 5a8da94 commit 2b61a6a

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
@@ -32,8 +32,7 @@
3232
foreach (\Composer\InstalledVersions::getAllRawData() as $d) {
3333
$versions = array_merge($versions, $d['versions'] ?? []);
3434
}
35-
$_cj = @json_decode(@file_get_contents(__DIR__ . '/composer.json'), true);
36-
$name = defined('APP_NAME') ? APP_NAME : ($_cj['name'] ?? basename(__DIR__));
35+
$name = defined('APP_NAME') ? APP_NAME : 'unknown';
3736
$version = defined('APP_VERSION') ? APP_VERSION : '0.0.0';
3837
$versions[$name] = ['pretty_version' => $version, 'version' => $version,
3938
'reference' => null, 'type' => 'library', 'install_path' => __DIR__,

debian/rules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ override_dh_install:
1515
install -D -m 0644 debian/autoload.php debian/php-spojenet-ipex-b2b/usr/share/php/IPEXB2B/autoload.php
1616
sed -i "1a defined('APP_NAME') || define('APP_NAME', '$(PKG_SOURCE)');" \
1717
debian/php-spojenet-ipex-b2b/usr/share/php/IPEXB2B/autoload.php
18+
sed -i "s|: 'unknown'|: '$(PKG_SOURCE)'|" \\
19+
debian/php-spojenet-ipex-b2b/usr/share/php/IPEXB2B/autoload.php
1820
sed -i "2a defined('APP_VERSION') || define('APP_VERSION', '$(PKG_VERSION)');" \
1921
debian/php-spojenet-ipex-b2b/usr/share/php/IPEXB2B/autoload.php
2022
# Register with pkg-php-tools

0 commit comments

Comments
 (0)