Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Composer script, fixes #1 #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use Composer script, fixes #1
  • Loading branch information
hlubek committed Sep 28, 2022
commit 8de75d84c653ce58651d6ed1acac1e73665ee83e
36 changes: 0 additions & 36 deletions Classes/Composer/InstallerScripts.php
Original file line number Diff line number Diff line change
@@ -10,39 +10,6 @@
class InstallerScripts
{

private const PRUNNER_DISPATCH_SCRIPT = <<<'EOD'
#!/bin/sh

# Polyfill for realpath which is not available on macOS per default (see https://stackoverflow.com/a/18443300)
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(readlink "$(basename "$1")")
while [ "$LINK" ]; do
cd "$(dirname "$LINK")"
LINK=$(readlink "$(basename "$1")")
done
REALPATH="$PWD/$(basename "$1")"
cd "$OURPWD"
echo "$REALPATH"
}

SCRIPTS_DIR=$(dirname "$(realpath $0)")

OS_TYPE=$(uname -s)
ARCH_TYPE=$(uname -m)

# Make a very simple check if we have a bundled binary for the right OS / architecture
BIN_TARGET="${SCRIPTS_DIR}/${OS_TYPE}_${ARCH_TYPE}/prunner"

if [ -f "$BIN_TARGET" ]; then
$BIN_TARGET $@
else
echo "Unsupported OS or architecture"
exit 1
fi
EOD;

const DEFAULT_VERSION_TO_INSTALL = '0.8.1';

public static function postUpdateAndInstall()
@@ -94,8 +61,5 @@ public static function postUpdateAndInstall()

echo '> Prunner extracted to ' . $platformSpecificTargetDirectory . "\n";
}

file_put_contents($baseDirectory . '/prunner', self::PRUNNER_DISPATCH_SCRIPT);
chmod($baseDirectory . '/prunner', 0755);
}
}
28 changes: 28 additions & 0 deletions Resources/Private/Scripts/prunner
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# Polyfill for realpath which is not available on macOS per default (see https://stackoverflow.com/a/18443300)
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(readlink "$(basename "$1")")
while [ "$LINK" ]; do
cd "$(dirname "$LINK")"
LINK=$(readlink "$(basename "$1")")
done
REALPATH="$PWD/$(basename "$1")"
cd "$OURPWD"
echo "$REALPATH"
}

OS_TYPE=$(uname -s)
ARCH_TYPE=$(uname -m)

# Make a very simple check if we have a bundled binary for the right OS / architecture
BIN_TARGET="prunner/${OS_TYPE}_${ARCH_TYPE}/prunner"

if [ -f "$BIN_TARGET" ]; then
$BIN_TARGET $@
else
echo "Unsupported OS or architecture"
exit 1
fi