From b4419f0088f3daa08ee30b864c132482aa64264c Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Tue, 2 May 2023 12:32:33 +0200 Subject: [PATCH 1/2] Plugins: Add build_windows_vendor_directory --- .../build_windows_vendor_directory.ps1 | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 monkey/agent_plugins/build_windows_vendor_directory.ps1 diff --git a/monkey/agent_plugins/build_windows_vendor_directory.ps1 b/monkey/agent_plugins/build_windows_vendor_directory.ps1 new file mode 100644 index 00000000000..5a3cdfddb9a --- /dev/null +++ b/monkey/agent_plugins/build_windows_vendor_directory.ps1 @@ -0,0 +1,32 @@ +param( + [Parameter(Mandatory = $true)] [string]$workspace, + [Parameter(Mandatory = $true)] [string]$plugin_type, + [Parameter(Mandatory = $true)] [string]$plugin_directory_name +) +Set-PSDebug -Trace 1 + +$plugin_path = Join-Path -Path $workspace -ChildPath "\monkey\monkey\agent_plugins\$plugin_type\$plugin_directory_name" + +Write-Output "Building Windows vendor directory" + +Set-Location $plugin_path + +Remove-Item $plugin_path\venv -Recurse -Force +& python -m venv "$plugin_path\venv" +& "$plugin_path\venv\Scripts\Activate.ps1" + +Write-Output "Python version: $(python --version)" +python -m pip install --upgrade pip +python -m pip install pipenv + +pipenv sync + +pipenv requirements >> requirements.txt +pip install -r requirements.txt -t src/vendor-windows +rm requirements.txt + +#exit venv +deactivate + +Compress-Archive -Path "$plugin_path\src\vendor-windows" -Destination "$workspace\vendor-windows.zip" +Remove-Item $plugin_path\venv -Recurse -Force From 8ee8970fb1b9a734d22400e2685baf5f565f1879 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Tue, 2 May 2023 14:24:42 +0200 Subject: [PATCH 2/2] Plugins: Build plugin with two os-specific vendor dirs --- monkey/agent_plugins/build_plugin.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/monkey/agent_plugins/build_plugin.sh b/monkey/agent_plugins/build_plugin.sh index cd1e7390378..31c94d17d50 100755 --- a/monkey/agent_plugins/build_plugin.sh +++ b/monkey/agent_plugins/build_plugin.sh @@ -21,9 +21,14 @@ command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" pushd "$PLUGIN_PATH" || fail "$PLUGIN_PATH does not exist" +VENDOR_DIR=vendor +if [ -d "src/vendor-windows" ]; then + VENDOR_DIR=vendor-linux +fi + pip install pipenv pipenv requirements >> requirements.txt -pip install -r requirements.txt -t src/vendor +pip install -r requirements.txt -t src/$VENDOR_DIR rm requirements.txt # Package everything up @@ -32,7 +37,7 @@ pushd "$PLUGIN_PATH/src" || fail "$PLUGIN_PATH/src does not exist" source_archive=$PLUGIN_PATH/$SOURCE_FILENAME tar -cf "$source_archive" --exclude __pycache__ --exclude .mypy_cache --exclude .pytest_cache --exclude .git --exclude .gitignore --exclude .DS_Store -- * -rm -rf vendor +rm -rf vendor* popd || exit 1 plugin_filename=$(get_plugin_filename) || fail "Failed to get plugin filename: $plugin_filename"