-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.php
More file actions
81 lines (65 loc) · 1.87 KB
/
Copy pathbuild.php
File metadata and controls
81 lines (65 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env php
<?php
/**
* Build script for BinktermPHP Installer PHAR
*
* Usage: php build.php
*/
// Check if phar.readonly is disabled
if (ini_get('phar.readonly')) {
echo "Error: phar.readonly must be disabled in php.ini\n";
echo "Run with: php -d phar.readonly=0 build.php\n";
exit(1);
}
$pharFile = 'binkterm-installer.phar';
$buildDir = __DIR__;
// Remove existing PHAR if it exists
if (file_exists($pharFile)) {
unlink($pharFile);
}
echo "Building PHAR archive...\n";
try {
$phar = new Phar($pharFile);
// Start buffering to improve performance
$phar->startBuffering();
// Add files to the PHAR
echo "Adding files...\n";
// Add main install script
$phar->addFile($buildDir . '/install.php', 'install.php');
echo " + install.php\n";
// Add source files
$phar->addFile($buildDir . '/src/ansicliconsole.php', 'src/ansicliconsole.php');
echo " + src/ansicliconsole.php\n";
// Add cron.example
$phar->addFile($buildDir . '/cron.example', 'cron.example');
echo " + cron.example\n";
// Create a stub (entry point)
$stub = <<<'STUB'
#!/usr/bin/env php
<?php
/**
* BinktermPHP Installer PHAR
*/
Phar::mapPhar('binkterm-installer.phar');
require 'phar://binkterm-installer.phar/install.php';
__HALT_COMPILER();
STUB;
$phar->setStub($stub);
// Stop buffering and write changes
$phar->stopBuffering();
// Make it executable on Unix-like systems
if (PHP_OS_FAMILY !== 'Windows') {
chmod($pharFile, 0755);
}
echo "\nBuild complete!\n";
echo "PHAR file: $pharFile\n";
echo "Size: " . number_format(filesize($pharFile)) . " bytes\n";
echo "\nUsage:\n";
echo " php $pharFile [options]\n";
if (PHP_OS_FAMILY !== 'Windows') {
echo " ./$pharFile [options]\n";
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
exit(1);
}