From 26001ed8ebc3eed78d8bdaa96a28a89d7b62052a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 28 Jul 2023 18:27:25 +0100 Subject: [PATCH] Remove salt execution and state modules only when building the windows package Signed-off-by: Pedro Algarvio --- pkg/common/env-cleanup-rules.yml | 76 +++++----- pkg/windows/msi/build_pkg.ps1 | 232 +++++++++++++++++++++++++++++-- pkg/windows/nsis/build_pkg.ps1 | 232 +++++++++++++++++++++++++++++-- pkg/windows/prep_salt.ps1 | 208 --------------------------- 4 files changed, 480 insertions(+), 268 deletions(-) diff --git a/pkg/common/env-cleanup-rules.yml b/pkg/common/env-cleanup-rules.yml index 6a0ff594a97..09708110473 100644 --- a/pkg/common/env-cleanup-rules.yml +++ b/pkg/common/env-cleanup-rules.yml @@ -49,6 +49,44 @@ ci: # Help files - "**/*.chm" - "**/Scripts/wmitest*" + +pkg: + darwin: + dir_patterns: + - *ci_darwin_dir_patterns + - "**/pkgconfig" + - "**/share" + - "**/artifacts/salt/opt" + - "**/artifacts/salt/etc" + - "**/artifacts/salt/Lib" + file_patterns: + - *ci_darwin_file_patterns + linux: + dir_patterns: + - *ci_linux_dir_patterns + file_patterns: + - *ci_linux_file_patterns + windows: + dir_patterns: + - *ci_windows_dir_patterns + - "**/salt/share" + - "**/site-packages/pywin32_system32" + file_patterns: + - *ci_windows_file_patterns + - "**/Scripts/py.exe" + - "**/Scripts/pyw.exe" + - "**/Scripts/venvlauncher.exe" + - "**/Scripts/venvwlauncher.exe" + - "**/Scripts/wheel*" + - "**/doc" + - "**/readme" + - "**/salt/salt-api*" + - "**/salt/salt-key*" + - "**/salt/salt-run*" + - "**/salt/salt-syndic*" + - "**/salt/salt-unity*" + - "**/salt/spm*" + - "**/salt/wheel*" # Non Windows execution modules - "**/site-packages/salt/modules/aacme.py*" - "**/site-packages/salt/modules/aix.py*" @@ -231,41 +269,3 @@ ci: - "**/site-packages/salt/states/virt.py.py*" - "**/site-packages/salt/states/zfs.py*" - "**/site-packages/salt/states/zpool.py*" - -pkg: - darwin: - dir_patterns: - - *ci_darwin_dir_patterns - - "**/pkgconfig" - - "**/share" - - "**/artifacts/salt/opt" - - "**/artifacts/salt/etc" - - "**/artifacts/salt/Lib" - file_patterns: - - *ci_darwin_file_patterns - linux: - dir_patterns: - - *ci_linux_dir_patterns - file_patterns: - - *ci_linux_file_patterns - windows: - dir_patterns: - - *ci_windows_dir_patterns - - "**/salt/share" - - "**/site-packages/pywin32_system32" - file_patterns: - - *ci_windows_file_patterns - - "**/Scripts/py.exe" - - "**/Scripts/pyw.exe" - - "**/Scripts/venvlauncher.exe" - - "**/Scripts/venvwlauncher.exe" - - "**/Scripts/wheel*" - - "**/doc" - - "**/readme" - - "**/salt/salt-api*" - - "**/salt/salt-key*" - - "**/salt/salt-run*" - - "**/salt/salt-syndic*" - - "**/salt/salt-unity*" - - "**/salt/spm*" - - "**/salt/wheel*" diff --git a/pkg/windows/msi/build_pkg.ps1 b/pkg/windows/msi/build_pkg.ps1 index 897d60782e6..f5fa7ce234e 100644 --- a/pkg/windows/msi/build_pkg.ps1 +++ b/pkg/windows/msi/build_pkg.ps1 @@ -73,17 +73,19 @@ function VerifyOrDownload ($local_file, $URL, $SHA256) { # Script Variables #------------------------------------------------------------------------------- -$WEBCACHE_DIR = "$env:TEMP\msi_build_cache_dir" -$DEPS_URL = "https://repo.saltproject.io/windows/dependencies" -$PROJECT_DIR = $(git rev-parse --show-toplevel) -$BUILD_DIR = "$PROJECT_DIR\pkg\windows\build" -$BUILDENV_DIR = "$PROJECT_DIR\pkg\windows\buildenv" -$SCRIPTS_DIR = "$BUILDENV_DIR\Scripts" -$PYTHON_BIN = "$SCRIPTS_DIR\python.exe" -$BUILD_ARCH = $(. $PYTHON_BIN -c "import platform; print(platform.architecture()[0])") -$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName -$RUNTIME_DIR = [System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory() -$CSC_BIN = "$RUNTIME_DIR\csc.exe" +$WEBCACHE_DIR = "$env:TEMP\msi_build_cache_dir" +$DEPS_URL = "https://repo.saltproject.io/windows/dependencies" +$PROJECT_DIR = $(git rev-parse --show-toplevel) +$BUILD_DIR = "$PROJECT_DIR\pkg\windows\build" +$BUILDENV_DIR = "$PROJECT_DIR\pkg\windows\buildenv" +$SCRIPTS_DIR = "$BUILDENV_DIR\Scripts" +$SITE_PKGS_DIR = "$BUILDENV_DIR\Lib\site-packages" +$BUILD_SALT_DIR = "$SITE_PKGS_DIR\salt" +$PYTHON_BIN = "$SCRIPTS_DIR\python.exe" +$BUILD_ARCH = $(. $PYTHON_BIN -c "import platform; print(platform.architecture()[0])") +$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName +$RUNTIME_DIR = [System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory() +$CSC_BIN = "$RUNTIME_DIR\csc.exe" if ( $BUILD_ARCH -eq "64bit" ) { $BUILD_ARCH = "AMD64" @@ -263,6 +265,214 @@ Write-Host "Packaging *.dll's to *.CA.dll: " -NoNewline "$SCRIPT_DIR\CustomAction01\CustomAction.config" > build.tmp CheckExitCode +#------------------------------------------------------------------------------- +# Remove Non-Windows Execution Modules +#------------------------------------------------------------------------------- +Write-Host "Removing Non-Windows Execution Modules: " -NoNewline +$modules = "acme", + "aix", + "alternatives", + "apcups", + "apf", + "apt", + "arista", + "at", + "bcache", + "blockdev", + "bluez", + "bridge", + "bsd", + "btrfs", + "ceph", + "container_resource", + "cron", + "csf", + "daemontools", + "deb*", + "devmap", + "dpkg", + "ebuild", + "eix", + "eselect", + "ethtool", + "extfs", + "firewalld", + "freebsd", + "genesis", + "gentoo", + "glusterfs", + "gnomedesktop", + "groupadd", + "grub_legacy", + "guestfs", + "htpasswd", + "ilo", + "img", + "incron", + "inspector", + "ipset", + "iptables", + "iwtools", + "k8s", + "kapacitor", + "keyboard", + "keystone", + "kmod", + "layman", + "linux", + "localemod", + "locate", + "logadm", + "logrotate", + "lvs", + "lxc", + "mac", + "makeconf", + "mdadm", + "mdata", + "monit", + "moosefs", + "mount", + "napalm", + "netbsd", + "netscaler", + "neutron", + "nfs3", + "nftables", + "nova", + "nspawn", + "openbsd", + "openstack", + "openvswitch", + "opkg", + "pacman", + "parallels", + "parted", + "pcs", + "pkgin", + "pkgng", + "pkgutil", + "portage_config", + "postfix", + "poudriere", + "powerpath", + "pw_", + "qemu_", + "quota", + "redismod", + "restartcheck", + "rh_", + "riak", + "rpm", + "runit", + "s6", + "scsi", + "sensors", + "service", + "shadow", + "smartos", + "smf", + "snapper", + "solaris", + "solr", + "ssh_", + "supervisord", + "sysbench", + "sysfs", + "sysrc", + "system", + "test_virtual", + "timezone", + "trafficserver", + "tuned", + "udev", + "upstart", + "useradd", + "uswgi", + "varnish", + "vbox", + "virt", + "xapi", + "xbpspkg", + "xfs", + "yum*", + "zfs", + "znc", + "zpool", + "zypper" +$modules | ForEach-Object { + Remove-Item -Path "$BUILD_SALT_DIR\modules\$_*" -Recurse + if ( Test-Path -Path "$BUILD_SALT_DIR\modules\$_*" ) { + Write-Result "Failed" -ForegroundColor Red + Write-Host "Failed to remove: $BUILD_SALT_DIR\modules\$_" + exit 1 + } +} +Write-Result "Success" -ForegroundColor Green + +#------------------------------------------------------------------------------- +# Remove Non-Windows State Modules +#------------------------------------------------------------------------------- +Write-Host "Removing Non-Windows State Modules: " -NoNewline +$states = "acme", + "alternatives", + "apt", + "at", + "blockdev", + "ceph", + "cron", + "csf", + "deb", + "eselect", + "ethtool", + "firewalld", + "glusterfs", + "gnome", + "htpasswd", + "incron", + "ipset", + "iptables", + "k8s", + "kapacitor", + "keyboard", + "keystone", + "kmod", + "layman", + "linux", + "lxc", + "mac", + "makeconf", + "mdadm", + "monit", + "mount", + "nftables", + "pcs", + "pkgng", + "portage", + "powerpath", + "quota", + "redismod", + "smartos", + "snapper", + "ssh", + "supervisord", + "sysrc", + "trafficserver", + "tuned", + "vbox", + "virt.py", + "zfs", + "zpool" +$states | ForEach-Object { + Remove-Item -Path "$BUILD_SALT_DIR\states\$_*" -Recurse + if ( Test-Path -Path "$BUILD_SALT_DIR\states\$_*" ) { + Write-Result "Failed" -ForegroundColor Red + Write-Host "Failed to remove: $BUILD_SALT_DIR\states\$_" + exit 1 + } +} +Write-Result "Success" -ForegroundColor Green + #------------------------------------------------------------------------------- # Remove compiled files #------------------------------------------------------------------------------- diff --git a/pkg/windows/nsis/build_pkg.ps1 b/pkg/windows/nsis/build_pkg.ps1 index 8c964014e7f..2573e20998b 100644 --- a/pkg/windows/nsis/build_pkg.ps1 +++ b/pkg/windows/nsis/build_pkg.ps1 @@ -51,17 +51,19 @@ function Write-Result($result, $ForegroundColor="Green") { # Script Variables #------------------------------------------------------------------------------- -$PROJECT_DIR = $(git rev-parse --show-toplevel) -$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName -$BUILD_DIR = "$PROJECT_DIR\pkg\windows\build" -$BUILDENV_DIR = "$PROJECT_DIR\pkg\windows\buildenv" -$INSTALLER_DIR = "$SCRIPT_DIR\installer" -$SCRIPTS_DIR = "$BUILDENV_DIR\Scripts" -$PYTHON_BIN = "$SCRIPTS_DIR\python.exe" -$PY_VERSION = [Version]((Get-Command $PYTHON_BIN).FileVersionInfo.ProductVersion) -$PY_VERSION = "$($PY_VERSION.Major).$($PY_VERSION.Minor)" -$NSIS_BIN = "$( ${env:ProgramFiles(x86)} )\NSIS\makensis.exe" -$ARCH = $(. $PYTHON_BIN -c "import platform; print(platform.architecture()[0])") +$PROJECT_DIR = $(git rev-parse --show-toplevel) +$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName +$BUILD_DIR = "$PROJECT_DIR\pkg\windows\build" +$BUILDENV_DIR = "$PROJECT_DIR\pkg\windows\buildenv" +$INSTALLER_DIR = "$SCRIPT_DIR\installer" +$SCRIPTS_DIR = "$BUILDENV_DIR\Scripts" +$SITE_PKGS_DIR = "$BUILDENV_DIR\Lib\site-packages" +$BUILD_SALT_DIR = "$SITE_PKGS_DIR\salt" +$PYTHON_BIN = "$SCRIPTS_DIR\python.exe" +$PY_VERSION = [Version]((Get-Command $PYTHON_BIN).FileVersionInfo.ProductVersion) +$PY_VERSION = "$($PY_VERSION.Major).$($PY_VERSION.Minor)" +$NSIS_BIN = "$( ${env:ProgramFiles(x86)} )\NSIS\makensis.exe" +$ARCH = $(. $PYTHON_BIN -c "import platform; print(platform.architecture()[0])") if ( $ARCH -eq "64bit" ) { $ARCH = "AMD64" @@ -133,6 +135,214 @@ if ( Test-Path -Path "$INSTALLER_DIR\salt.ico" ) { exit 1 } +#------------------------------------------------------------------------------- +# Remove Non-Windows Execution Modules +#------------------------------------------------------------------------------- +Write-Host "Removing Non-Windows Execution Modules: " -NoNewline +$modules = "acme", + "aix", + "alternatives", + "apcups", + "apf", + "apt", + "arista", + "at", + "bcache", + "blockdev", + "bluez", + "bridge", + "bsd", + "btrfs", + "ceph", + "container_resource", + "cron", + "csf", + "daemontools", + "deb*", + "devmap", + "dpkg", + "ebuild", + "eix", + "eselect", + "ethtool", + "extfs", + "firewalld", + "freebsd", + "genesis", + "gentoo", + "glusterfs", + "gnomedesktop", + "groupadd", + "grub_legacy", + "guestfs", + "htpasswd", + "ilo", + "img", + "incron", + "inspector", + "ipset", + "iptables", + "iwtools", + "k8s", + "kapacitor", + "keyboard", + "keystone", + "kmod", + "layman", + "linux", + "localemod", + "locate", + "logadm", + "logrotate", + "lvs", + "lxc", + "mac", + "makeconf", + "mdadm", + "mdata", + "monit", + "moosefs", + "mount", + "napalm", + "netbsd", + "netscaler", + "neutron", + "nfs3", + "nftables", + "nova", + "nspawn", + "openbsd", + "openstack", + "openvswitch", + "opkg", + "pacman", + "parallels", + "parted", + "pcs", + "pkgin", + "pkgng", + "pkgutil", + "portage_config", + "postfix", + "poudriere", + "powerpath", + "pw_", + "qemu_", + "quota", + "redismod", + "restartcheck", + "rh_", + "riak", + "rpm", + "runit", + "s6", + "scsi", + "sensors", + "service", + "shadow", + "smartos", + "smf", + "snapper", + "solaris", + "solr", + "ssh_", + "supervisord", + "sysbench", + "sysfs", + "sysrc", + "system", + "test_virtual", + "timezone", + "trafficserver", + "tuned", + "udev", + "upstart", + "useradd", + "uswgi", + "varnish", + "vbox", + "virt", + "xapi", + "xbpspkg", + "xfs", + "yum*", + "zfs", + "znc", + "zpool", + "zypper" +$modules | ForEach-Object { + Remove-Item -Path "$BUILD_SALT_DIR\modules\$_*" -Recurse + if ( Test-Path -Path "$BUILD_SALT_DIR\modules\$_*" ) { + Write-Result "Failed" -ForegroundColor Red + Write-Host "Failed to remove: $BUILD_SALT_DIR\modules\$_" + exit 1 + } +} +Write-Result "Success" -ForegroundColor Green + +#------------------------------------------------------------------------------- +# Remove Non-Windows State Modules +#------------------------------------------------------------------------------- +Write-Host "Removing Non-Windows State Modules: " -NoNewline +$states = "acme", + "alternatives", + "apt", + "at", + "blockdev", + "ceph", + "cron", + "csf", + "deb", + "eselect", + "ethtool", + "firewalld", + "glusterfs", + "gnome", + "htpasswd", + "incron", + "ipset", + "iptables", + "k8s", + "kapacitor", + "keyboard", + "keystone", + "kmod", + "layman", + "linux", + "lxc", + "mac", + "makeconf", + "mdadm", + "monit", + "mount", + "nftables", + "pcs", + "pkgng", + "portage", + "powerpath", + "quota", + "redismod", + "smartos", + "snapper", + "ssh", + "supervisord", + "sysrc", + "trafficserver", + "tuned", + "vbox", + "virt.py", + "zfs", + "zpool" +$states | ForEach-Object { + Remove-Item -Path "$BUILD_SALT_DIR\states\$_*" -Recurse + if ( Test-Path -Path "$BUILD_SALT_DIR\states\$_*" ) { + Write-Result "Failed" -ForegroundColor Red + Write-Host "Failed to remove: $BUILD_SALT_DIR\states\$_" + exit 1 + } +} +Write-Result "Success" -ForegroundColor Green + #------------------------------------------------------------------------------- # Remove compiled files #------------------------------------------------------------------------------- diff --git a/pkg/windows/prep_salt.ps1 b/pkg/windows/prep_salt.ps1 index 45ee93eaabe..544d513ab60 100644 --- a/pkg/windows/prep_salt.ps1 +++ b/pkg/windows/prep_salt.ps1 @@ -278,214 +278,6 @@ $directories | ForEach-Object { } } -#------------------------------------------------------------------------------- -# Remove Non-Windows Execution Modules -#------------------------------------------------------------------------------- -Write-Host "Removing Non-Windows Execution Modules: " -NoNewline -$modules = "acme", - "aix", - "alternatives", - "apcups", - "apf", - "apt", - "arista", - "at", - "bcache", - "blockdev", - "bluez", - "bridge", - "bsd", - "btrfs", - "ceph", - "container_resource", - "cron", - "csf", - "daemontools", - "deb*", - "devmap", - "dpkg", - "ebuild", - "eix", - "eselect", - "ethtool", - "extfs", - "firewalld", - "freebsd", - "genesis", - "gentoo", - "glusterfs", - "gnomedesktop", - "groupadd", - "grub_legacy", - "guestfs", - "htpasswd", - "ilo", - "img", - "incron", - "inspector", - "ipset", - "iptables", - "iwtools", - "k8s", - "kapacitor", - "keyboard", - "keystone", - "kmod", - "layman", - "linux", - "localemod", - "locate", - "logadm", - "logrotate", - "lvs", - "lxc", - "mac", - "makeconf", - "mdadm", - "mdata", - "monit", - "moosefs", - "mount", - "napalm", - "netbsd", - "netscaler", - "neutron", - "nfs3", - "nftables", - "nova", - "nspawn", - "openbsd", - "openstack", - "openvswitch", - "opkg", - "pacman", - "parallels", - "parted", - "pcs", - "pkgin", - "pkgng", - "pkgutil", - "portage_config", - "postfix", - "poudriere", - "powerpath", - "pw_", - "qemu_", - "quota", - "redismod", - "restartcheck", - "rh_", - "riak", - "rpm", - "runit", - "s6", - "scsi", - "sensors", - "service", - "shadow", - "smartos", - "smf", - "snapper", - "solaris", - "solr", - "ssh_", - "supervisord", - "sysbench", - "sysfs", - "sysrc", - "system", - "test_virtual", - "timezone", - "trafficserver", - "tuned", - "udev", - "upstart", - "useradd", - "uswgi", - "varnish", - "vbox", - "virt", - "xapi", - "xbpspkg", - "xfs", - "yum*", - "zfs", - "znc", - "zpool", - "zypper" -$modules | ForEach-Object { - Remove-Item -Path "$BUILD_SALT_DIR\modules\$_*" -Recurse - if ( Test-Path -Path "$BUILD_SALT_DIR\modules\$_*" ) { - Write-Result "Failed" -ForegroundColor Red - Write-Host "Failed to remove: $BUILD_SALT_DIR\modules\$_" - exit 1 - } -} -Write-Result "Success" -ForegroundColor Green - -#------------------------------------------------------------------------------- -# Remove Non-Windows State Modules -#------------------------------------------------------------------------------- -Write-Host "Removing Non-Windows State Modules: " -NoNewline -$states = "acme", - "alternatives", - "apt", - "at", - "blockdev", - "ceph", - "cron", - "csf", - "deb", - "eselect", - "ethtool", - "firewalld", - "glusterfs", - "gnome", - "htpasswd", - "incron", - "ipset", - "iptables", - "k8s", - "kapacitor", - "keyboard", - "keystone", - "kmod", - "layman", - "linux", - "lxc", - "mac", - "makeconf", - "mdadm", - "monit", - "mount", - "nftables", - "pcs", - "pkgng", - "portage", - "powerpath", - "quota", - "redismod", - "smartos", - "snapper", - "ssh", - "supervisord", - "sysrc", - "trafficserver", - "tuned", - "vbox", - "virt.py", - "zfs", - "zpool" -$states | ForEach-Object { - Remove-Item -Path "$BUILD_SALT_DIR\states\$_*" -Recurse - if ( Test-Path -Path "$BUILD_SALT_DIR\states\$_*" ) { - Write-Result "Failed" -ForegroundColor Red - Write-Host "Failed to remove: $BUILD_SALT_DIR\states\$_" - exit 1 - } -} -Write-Result "Success" -ForegroundColor Green - Write-Host "Removing __pycache__ directories: " -NoNewline $found = Get-ChildItem -Path "$BUILD_DIR" -Filter "__pycache__" -Recurse $found | ForEach-Object {