Skip to content

Commit

Permalink
Use Composer script, fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed Sep 28, 2022
1 parent 00f477f commit 8de75d8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
36 changes: 0 additions & 36 deletions Classes/Composer/InstallerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit 8de75d8

Please sign in to comment.