From 654424f3f7f302cd18a0e4c92b9c18458a0084b0 Mon Sep 17 00:00:00 2001 From: Dave Newson Date: Mon, 3 Jul 2023 09:17:31 +1000 Subject: [PATCH] Add the ability to build the Analyzer command as a phar file: meminfo.phar The meminfo.phar file can be built using ./bin/build-phar.sh The build script will; - pre-clean the build dir - Install the Vendor dependencies, - Install "Box" for phar packaging - Create meminfo.phar using Box. - Create an sha256 hash for meminfo.phar --- analyzer/.gitignore | 1 + analyzer/box.json.dist | 14 ++++++++++++++ bin/build-phar.sh | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 analyzer/box.json.dist create mode 100755 bin/build-phar.sh diff --git a/analyzer/.gitignore b/analyzer/.gitignore index 4fbb073..1ee95fc 100644 --- a/analyzer/.gitignore +++ b/analyzer/.gitignore @@ -1,2 +1,3 @@ +/.build/ /vendor/ /composer.lock diff --git a/analyzer/box.json.dist b/analyzer/box.json.dist new file mode 100644 index 0000000..f1cd2fc --- /dev/null +++ b/analyzer/box.json.dist @@ -0,0 +1,14 @@ +{ + "chmod": "0755", + "main": "bin/analyzer", + "output": ".build/meminfo.phar", + "directories": ["."], + "finder": [ + { + "name": "*.php", + "exclude": ["test", "tests"], + "in": "vendor" + } + ], + "stub": true +} diff --git a/bin/build-phar.sh b/bin/build-phar.sh new file mode 100755 index 0000000..fbf0c9b --- /dev/null +++ b/bin/build-phar.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -e + +cd analyzer + +# Prepare buld dir +rm -rf .build +mkdir .build + +# Install app deps +rm -rf vendor +composer install --no-dev + +# Install Box +curl -L -o .build/box.phar https://github.com/box-project/box/releases/download/3.9.0/box.phar + +# Compile Phar +php --define phar.read_only=0 .build/box.phar build + +# Create signature +sha256sum .build/meminfo.phar > .build/meminfo.phar.sha256