Compare commits

...

No commits in common. 'e9' and 'i10cf' have entirely different histories.
e9 ... i10cf

5
.gitignore vendored

@ -1,4 +1 @@
salt-*.tar.gz
SaltTesting-*.tar.gz
*.src.rpm
results_salt/
SOURCES/salt-3006.8.tar.gz

@ -0,0 +1 @@
cff6fe9151cc8d1c231ce166aac975450d72c118 SOURCES/salt-3006.8.tar.gz

@ -0,0 +1,267 @@
From 1d1b727772b4c866cabacb0a6b942285c4c31be9 Mon Sep 17 00:00:00 2001
From: Sergey Cherevko <s.cherevko@msvsphere-os.ru>
Date: Mon, 20 Jan 2025 16:25:50 +0300
Subject: [PATCH 1/2] Added MSVSphere support
---
salt/cloud/deploy/bootstrap-salt.sh | 87 ++++++++++++++++++-
salt/grains/core.py | 4 +-
.../pkg/integration/test_enabled_disabled.py | 1 +
.../pytests/pkg/integration/test_salt_user.py | 1 +
tests/pytests/pkg/integration/test_version.py | 1 +
tests/support/pkg.py | 7 +-
6 files changed, 95 insertions(+), 6 deletions(-)
diff --git a/salt/cloud/deploy/bootstrap-salt.sh b/salt/cloud/deploy/bootstrap-salt.sh
index c632146..d530c3f 100644
--- a/salt/cloud/deploy/bootstrap-salt.sh
+++ b/salt/cloud/deploy/bootstrap-salt.sh
@@ -1081,7 +1081,7 @@ __strip_duplicates() {
__sort_release_files() {
KNOWN_RELEASE_FILES=$(echo "(arch|alpine|centos|debian|ubuntu|fedora|redhat|suse|\
mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|void|lsb|system|\
- oracle|os|almalinux|rocky)(-|_)(release|version)" | sed -E 's:[[:space:]]::g')
+ oracle|os|almalinux|rocky|msvsphere)(-|_)(release|version)" | sed -E 's:[[:space:]]::g')
primary_release_files=""
secondary_release_files=""
# Sort know VS un-known files first
@@ -1095,7 +1095,7 @@ __sort_release_files() {
done
# Now let's sort by know files importance, max important goes last in the max_prio list
- max_prio="redhat-release centos-release oracle-release fedora-release almalinux-release rocky-release"
+ max_prio="redhat-release centos-release oracle-release fedora-release almalinux-release rocky-release sphere-release"
for entry in $max_prio; do
if [ "$(echo "${primary_release_files}" | grep "$entry")" != "" ]; then
primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\\(.*\\)\\($entry\\)\\(.*\\):\\2 \\1 \\3:g")
@@ -1226,6 +1226,7 @@ __gather_linux_system_info() {
oracle ) n="Oracle Linux" ;;
almalinux ) n="AlmaLinux" ;;
rocky ) n="Rocky Linux" ;;
+ rocky ) n="MSVSphere" ;;
system )
while read -r line; do
[ "${n}x" != "systemx" ] && break
@@ -1973,14 +1974,14 @@ elif [ "${DISTRO_NAME_L}" = "debian" ]; then
__debian_codename_translation
fi
-if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]; then
+if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky|msvsphere)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]; then
echoerror "${DISTRO_NAME} does not have major version pegged packages support"
exit 1
fi
# Only RedHat based distros have testing support
if [ "${ITYPE}" = "testing" ]; then
- if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky)')" = "" ]; then
+ if [ "$(echo "${DISTRO_NAME_L}" | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky|msvsphere)')" = "" ]; then
echoerror "${DISTRO_NAME} does not have testing packages support"
exit 1
fi
@@ -5719,6 +5720,84 @@ install_almalinux_check_services() {
#
#######################################################################################################################
+#######################################################################################################################
+#
+# MSVSphere Install Functions
+#
+install_msvsphere_stable_deps() {
+ install_centos_stable_deps || return 1
+ return 0
+}
+
+install_msvsphere_git_deps() {
+ install_centos_git_deps || return 1
+ return 0
+}
+
+install_msvsphere_onedir_deps() {
+ install_centos_onedir_deps || return 1
+ return 0
+}
+
+install_msvsphere_testing_deps() {
+ install_centos_testing_deps || return 1
+ return 0
+}
+
+install_msvsphere_stable() {
+ install_centos_stable || return 1
+ return 0
+}
+
+install_msvsphere_git() {
+ install_centos_git || return 1
+ return 0
+}
+
+install_msvsphere_onedir() {
+ install_centos_onedir || return 1
+ return 0
+}
+
+install_msvsphere_testing() {
+ install_centos_testing || return 1
+ return 0
+}
+
+install_msvsphere_stable_post() {
+ install_centos_stable_post || return 1
+ return 0
+}
+
+install_msvsphere_git_post() {
+ install_centos_git_post || return 1
+ return 0
+}
+
+install_msvsphere_onedir_post() {
+ install_centos_onedir_post || return 1
+ return 0
+}
+
+install_msvsphere_testing_post() {
+ install_centos_testing_post || return 1
+ return 0
+}
+
+install_msvsphere_restart_daemons() {
+ install_centos_restart_daemons || return 1
+ return 0
+}
+
+install_msvsphere_check_services() {
+ install_centos_check_services || return 1
+ return 0
+}
+#
+# Ended MSVSphere Install Functions
+#
+#######################################################################################################################
+
#######################################################################################################################
#
# Rocky Linux Install Functions
diff --git a/salt/grains/core.py b/salt/grains/core.py
index 17a1d68..bbd3830 100644
--- a/salt/grains/core.py
+++ b/salt/grains/core.py
@@ -1772,6 +1772,7 @@ _OS_NAME_MAP = {
"cloudserve": "CloudLinux",
"cloudlinux": "CloudLinux",
"almalinux": "AlmaLinux",
+ "msvsphere": "MSVSphere",
"pidora": "Fedora",
"scientific": "ScientificLinux",
"synology": "Synology",
@@ -2145,7 +2146,7 @@ def _os_release_quirks_for_oscodename(os_release):
# Astra Linux has no version codename, but Salt used
# to report the variant ID as oscodename.
return os_release.get("VARIANT_ID")
- if os_release["ID"] in ("almalinux", "rocky"):
+ if os_release["ID"] in ("almalinux", "rocky", "msvsphere"):
# VERSION_CODENAME is not set, but the codename is
# mentioned in PRETTY_NAME and VERSION.
match = _VERSION_RE.match(os_release.get("VERSION", ""))
@@ -2234,6 +2235,7 @@ def _linux_distribution_data():
"debian",
"linuxmint",
"mendel",
+ "msvsphere",
"pop",
"rocky",
"ubuntu",
diff --git a/tests/pytests/pkg/integration/test_enabled_disabled.py b/tests/pytests/pkg/integration/test_enabled_disabled.py
index 99097b1..b4eef3c 100644
--- a/tests/pytests/pkg/integration/test_enabled_disabled.py
+++ b/tests/pytests/pkg/integration/test_enabled_disabled.py
@@ -14,6 +14,7 @@ def test_services(install_salt, salt_cli, salt_minion):
elif install_salt.distro_id in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
diff --git a/tests/pytests/pkg/integration/test_salt_user.py b/tests/pytests/pkg/integration/test_salt_user.py
index 74bf458..2f50614 100644
--- a/tests/pytests/pkg/integration/test_salt_user.py
+++ b/tests/pytests/pkg/integration/test_salt_user.py
@@ -191,6 +191,7 @@ def test_paths_log_rotation(
if install_salt.distro_id not in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py
index 24a665d..61e967c 100644
--- a/tests/pytests/pkg/integration/test_version.py
+++ b/tests/pytests/pkg/integration/test_version.py
@@ -128,6 +128,7 @@ def test_compare_pkg_versions_redhat_rc(version, install_salt):
if install_salt.distro_id not in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
diff --git a/tests/support/pkg.py b/tests/support/pkg.py
index d9c6487..eed579a 100644
--- a/tests/support/pkg.py
+++ b/tests/support/pkg.py
@@ -114,6 +114,7 @@ class SaltPkgInstall:
if self.distro_id in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
@@ -131,6 +132,7 @@ class SaltPkgInstall:
if self.distro_id in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
@@ -147,6 +149,7 @@ class SaltPkgInstall:
if self.distro_id in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
@@ -171,6 +174,7 @@ class SaltPkgInstall:
if self.distro_id in (
"almalinux",
"rocky",
+ "msvsphere",
"centos",
"redhat",
"amzn",
@@ -611,7 +615,7 @@ class SaltPkgInstall:
"3006.0"
)
distro_name = self.distro_name
- if distro_name in ("almalinux", "rocky", "centos", "fedora"):
+ if distro_name in ("almalinux", "rocky", "centos", "fedora", "msvsphere"):
distro_name = "redhat"
root_url = "salt/py3/"
if self.classic:
@@ -620,6 +624,7 @@ class SaltPkgInstall:
if self.distro_name in [
"almalinux",
"rocky",
+ "msvsphere",
"redhat",
"centos",
"amazon",
--
2.43.5

@ -0,0 +1,26 @@
From 82fd2b26deb3dd04d08576415622f017527ba072 Mon Sep 17 00:00:00 2001
From: Sergey Cherevko <s.cherevko@msvsphere-os.ru>
Date: Wed, 22 Jan 2025 16:23:32 +0300
Subject: [PATCH 2/2] Using timezone-aware objects to represent datetimes in
UTC
---
salt/grains/core.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/salt/grains/core.py b/salt/grains/core.py
index bbd3830..42f5ef5 100644
--- a/salt/grains/core.py
+++ b/salt/grains/core.py
@@ -2904,7 +2904,7 @@ def ip_fqdn():
if not ret["ipv" + ipv_num]:
ret[key] = []
else:
- start_time = datetime.datetime.utcnow()
+ start_time = datetime.datetime.now(datetime.UTC)
try:
info = socket.getaddrinfo(_fqdn, None, socket_type)
ret[key] = list({item[4][0] for item in info})
--
2.43.5

@ -0,0 +1,15 @@
--- salt-3006.1/requirements/base.txt~ 2023-05-05 12:53:34.000000000 -0500
+++ salt-3006.1/requirements/base.txt 2023-05-24 09:59:08.874838801 -0500
@@ -9,4 +9,3 @@
packaging>=21.3
looseversion
# We need contextvars for salt-ssh
-contextvars
--- a/requirements/zeromq.txt~ 2024-02-20 16:04:07.000000000 -0600
+++ b/requirements/zeromq.txt 2024-02-22 14:27:46.531045353 -0600
@@ -2,5 +2,3 @@
-r crypto.txt
pyzmq>=20.0.0
-pyzmq==25.0.2 ; sys_platform == "win32"
-pyzmq==25.1.2 ; sys_platform == "darwin"

@ -0,0 +1,24 @@
--- a/salt/ext/tornado/netutil.py~ 2023-05-05 12:53:34.000000000 -0500
+++ b/salt/ext/tornado/netutil.py 2023-07-24 11:27:02.376824349 -0500
@@ -54,8 +54,8 @@
elif ssl is None:
ssl_match_hostname = SSLCertificateError = None # type: ignore
else:
- import backports.ssl_match_hostname
- ssl_match_hostname = backports.ssl_match_hostname.match_hostname
+ import urllib3.util.ssl_match_hostname
+ ssl_match_hostname = urllib3.util.ssl_match_hostname
SSLCertificateError = backports.ssl_match_hostname.CertificateError # type: ignore
if hasattr(ssl, 'SSLContext'):
--- a/salt/ext/tornado/netutil.py~ 2023-07-24 11:50:02.836988664 -0500
+++ b/salt/ext/tornado/netutil.py 2023-07-24 11:50:52.217539638 -0500
@@ -56,7 +56,7 @@
else:
import urllib3.util.ssl_match_hostname
ssl_match_hostname = urllib3.util.ssl_match_hostname
- SSLCertificateError = backports.ssl_match_hostname.CertificateError # type: ignore
+ SSLCertificateError = urllib3.util.ssl_match_hostname.CertificateError # type: ignore
if hasattr(ssl, 'SSLContext'):
if hasattr(ssl, 'create_default_context'):

@ -0,0 +1,3 @@
#Type Name ID GECOS Home directory Shell
u salt - "Salt" /etc/salt /bin/bash
g salt -

@ -10,11 +10,11 @@
%global py3_shebang_flags %(echo %py3_shebang_flags | sed s/s//)
Name: salt
Version: 3005.4
Release: 1%{?dist}
Version: 3006.8
Release: 1%{?dist}.inferit
Summary: A parallel remote execution system
Group: System Environment/Daemons
License: ASL 2.0
License: Apache-2.0
URL: https://saltproject.io/
Source0: %{pypi_source}
Source1: %{name}-proxy@.service
@ -26,7 +26,7 @@ Source6: %{name}-master.service
Source7: %{name}-syndic.service
Source8: %{name}-minion.service
Source9: %{name}-api.service
Source10: README.fedora
Source10: README
Source11: %{name}-common.logrotate
Source12: %{name}.bash
Source13: %{name}.fish
@ -38,8 +38,13 @@ Source18: %{name}-master.fish
Source19: %{name}-minion.fish
Source20: %{name}-run.fish
Source21: %{name}-syndic.fish
Source22: %{name}.sysusers
Patch0: contextvars.patch
Patch1: match_hostname.patch
# MSVSphere
Patch1001: 0001-Added-MSVSphere-support.patch
Patch1002: 0002-Using-timezone-aware-objects-to-represent-datetimes-in-UTC.patch
BuildArch: noarch
%ifarch %{ix86} x86_64
@ -50,10 +55,11 @@ Requires: pciutils
Requires: which
Requires: dnf-utils
Requires: logrotate
Requires: python3-tornado
BuildRequires: systemd-rpm-macros
BuildRequires: python3-devel
BuildRequires: python3-toml
%{?sysusers_requires_compat}
%description
Salt is a distributed remote execution system used to execute commands and
@ -167,6 +173,8 @@ install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}/proxy.d
# Add the config files
install -p -m 0640 conf/minion %{buildroot}%{_sysconfdir}/%{name}/minion
install -p -m 0640 conf/master %{buildroot}%{_sysconfdir}/%{name}/master
# Use salt user on nre master installations
sed -i 's/#user: root/user: salt/g' %{buildroot}%{_sysconfdir}/%{name}/master
install -p -m 0600 conf/cloud %{buildroot}%{_sysconfdir}/%{name}/cloud
install -p -m 0640 conf/roster %{buildroot}%{_sysconfdir}/%{name}/roster
install -p -m 0640 conf/proxy %{buildroot}%{_sysconfdir}/%{name}/proxy
@ -202,8 +210,11 @@ install -p -m 0644 %{SOURCE21} %{buildroot}%{fish_dir}/%{name}-syndic.fish
# ZSH completion
mkdir -p %{buildroot}%{zsh_dir}
install -p -m 0644 pkg/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
install -p -m 0644 pkg/common/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
# Salt user and group
install -p -D -m 0644 %{SOURCE22} %{buildroot}%{_sysusersdir}/salt.conf
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/gpgkeys
%check
%pyproject_check_import -t
@ -211,10 +222,10 @@ install -p -m 0644 pkg/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
%files -f %{pyproject_files}
%license LICENSE
%doc README.fedora
%doc README
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/bash_completion.d/%{name}.bash
%{_var}/cache/%{name}
%dir %{_var}/cache/%{name}/
%{_var}/log/%{name}
%{_bindir}/spm
%doc %{_mandir}/man1/spm.1*
@ -223,6 +234,7 @@ install -p -m 0644 pkg/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
%dir %{_sysconfdir}/%{name}/pki/
%{fish_dir}/%{name}*.fish
%{zsh_dir}/_%{name}
%{_bindir}/salt-pip
%files master
%doc %{_mandir}/man7/%{name}.7*
@ -237,9 +249,11 @@ install -p -m 0644 pkg/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
%{_bindir}/%{name}-master
%{_bindir}/%{name}-run
%{_unitdir}/%{name}-master.service
%config(noreplace) %{_sysconfdir}/%{name}/master
%config(noreplace) %{_sysconfdir}/%{name}/master.d
%config(noreplace) %{_sysconfdir}/%{name}/pki/master
%{_sysusersdir}/salt.conf
%config(noreplace) %attr(0750, salt, salt) %{_sysconfdir}/%{name}/master
%config(noreplace) %attr(0750, salt, salt) %{_sysconfdir}/%{name}/master.d
%config(noreplace) %attr(0750, salt, salt) %{_sysconfdir}/%{name}/pki/master
%config(noreplace) %attr(0750, salt, salt) %{_sysconfdir}/%{name}/gpgkeys
%files minion
%doc %{_mandir}/man1/%{name}-call.1*
@ -291,7 +305,11 @@ install -p -m 0644 pkg/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
%preun api
%systemd_preun %{name}-api.service
%pre master
%sysusers_create_compat %{SOURCE22}
%post master
chown salt:salt %{_sysconfdir}/%{name}/gpgkeys -R
%systemd_post %{name}-master.service
%post syndic
@ -317,11 +335,58 @@ install -p -m 0644 pkg/%{name}.zsh %{buildroot}%{zsh_dir}/_%{name}
%changelog
* Mon Oct 30 2023 Gwyn Ciesla <gwync@protonmail.com> - 3005.4-1
- 3005.4
* Wed Jan 22 2025 Sergey Cherevko <s.cherevko@msvsphere-os.ru> - 3006.8-1.inferit
- Added MSVSphere support
- Using timezone-aware objects to represent datetimes in UTC
* Thu May 02 2024 Gwyn Ciesla <gwync@protonmail.com> - 3006.8-1
- 3006.8
* Thu Feb 22 2024 Gwyn Ciesla <gwync@protonmail.com> - 3006.7-1
- 3006.7
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3006.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Dec 14 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.5-1
- 3006.5
* Mon Oct 30 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.4-1
- 3006.4
* Wed Sep 20 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.3-2
- Patch correction.
* Mon Sep 11 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.3-1
- 3006.3
* Fri Aug 11 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.2-1
- 3006.2
* Mon Jul 24 2023 Salman Butt <cn137@protonmail.com> - 3006.1-6
- SPDX license update.
* Mon Jul 24 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.1-5
- Patch for dnf5 support from upstream.
- Fix Python 3.12 issue.
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3006.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Wed Jun 28 2023 Python Maint <python-maint@redhat.com> - 3006.1-3
- Rebuilt for Python 3.12
* Wed May 24 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.1-2
- Add salt user for master per upstream.
* Wed May 24 2023 Gwyn Ciesla <gwync@protonmail.com> - 3006.1-1
- 3006.1
* Mon May 22 2023 Jonathan Steffan <jsteffan@fedoraproject.org>- 3005.1-4
- Add patch for py3.10 support (RHBZ#2189782)
* Tue Sep 05 2023 Gwyn Ciesla <gwync@protonmail.com> - 3005.2-1
- 3005.2
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3005.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Mon Oct 10 2022 Robby Callicotte <rcallicotte@fedoraproject.org> - 3005.1-2
- Removed macros from changelog

@ -1,20 +0,0 @@
--- salt-3005/requirements/base.txt.fix 2022-08-25 17:13:58.740984435 -0600
+++ salt-3005/requirements/base.txt 2022-08-25 17:14:14.428036445 -0600
@@ -4,5 +4,4 @@ PyYAML
MarkupSafe
requests>=1.0.0
distro>=1.0.1
-contextvars
psutil>=5.0.0
--- salt-3005.2/requirements/zeromq.txt~ 2023-08-03 12:27:49.000000000 -0500
+++ salt-3005.2/requirements/zeromq.txt 2023-09-05 15:00:22.172125782 -0500
@@ -1,8 +1,4 @@
-r base.txt
-r crypto.txt
-pyzmq<=20.0.0; python_version < "3.6"
-pyzmq>=20.0.0; python_version >= "3.6"
-# We can't use 23+ on Windows until they fix this:
-# https://github.com/zeromq/pyzmq/issues/1472
-pyzmq>=20.0.0,<=22.0.3 ; sys_platform == "win32"
+pyzmq>=20.0.0

@ -1,214 +0,0 @@
diff -Naur a/salt/modules/rpmbuild_pkgbuild.py b/salt/modules/rpmbuild_pkgbuild.py
--- a/salt/modules/rpmbuild_pkgbuild.py 2019-07-02 10:15:07.035874718 -0600
+++ b/salt/modules/rpmbuild_pkgbuild.py 2019-07-02 10:55:34.147934899 -0600
@@ -140,7 +140,9 @@
tgtattrs = tgt.split('-')
if tgtattrs[0] == 'amzn':
distset = '--define "dist .{0}1"'.format(tgtattrs[0])
- elif tgtattrs[1] in ['6', '7']:
+ elif tgtattrs[0] == 'amzn2':
+ distset = '--define "dist .{0}"'.format(tgtattrs[0])
+ elif tgtattrs[1] in ['6', '7', '8']:
distset = '--define "dist .el{0}"'.format(tgtattrs[1])
else:
distset = ''
@@ -173,6 +175,19 @@
return deps_list
+def _check_repo_gpg_phrase_utils():
+ '''
+ Check for /usr/libexec/gpg-preset-passphrase is installed
+ '''
+ util_name = '/usr/libexec/gpg-preset-passphrase'
+ if __salt__['file.file_exists'](util_name):
+ return True
+ else:
+ raise CommandExecutionError(
+ 'utility \'{0}\' needs to be installed'.format(util_name)
+ )
+
+
def make_src_pkg(dest_dir, spec, sources, env=None, template=None, saltenv='base', runas='root'):
'''
Create a source rpm from the given spec file and sources
@@ -450,8 +465,14 @@
Use a passphrase with the signing key presented in ``keyid``.
Passphrase is received from Pillar data which could be passed on the
- command line with ``pillar`` parameter. For example:
+ command line with ``pillar`` parameter.
+ .. versionadded:: 2018.2.1
+
+ RHEL 8 and above leverages gpg-agent and gpg-preset-passphrase for
+ caching keys, etc.
+
+ For example:
.. code-block:: bash
pillar='{ "gpg_passphrase" : "my_passphrase" }'
@@ -485,10 +506,27 @@
'''
SIGN_PROMPT_RE = re.compile(r'Enter pass phrase: ', re.M)
- define_gpg_name = ''
+ local_keygrip_to_use = None
+ local_key_fingerprint = None
local_keyid = None
local_uids = None
+ define_gpg_name = ''
phrase = ''
+ retrc = 0
+ use_gpg_agent = False
+
+ res = {
+ 'retcode': 1,
+ 'stdout': '',
+ 'stderr': 'initialization value'
+ }
+
+ if gnupghome and env is None:
+ env = {}
+ env['GNUPGHOME'] = gnupghome
+
+ if __grains__.get('osmajorrelease') >= 7:
+ use_gpg_agent = True
if keyid is not None:
# import_keys
@@ -517,8 +555,29 @@
if keyid == gpg_key['keyid'][8:]:
local_uids = gpg_key['uids']
local_keyid = gpg_key['keyid']
+ if use_gpg_agent:
+ local_keygrip_to_use = gpg_key['fingerprint']
+ local_key_fingerprint = gpg_key['fingerprint']
break
+ if use_gpg_agent:
+ cmd = 'gpg --with-keygrip --list-secret-keys'
+ local_keys2_keygrip = __salt__['cmd.run'](cmd, runas=runas, env=env)
+ local_keys2 = iter(local_keys2_keygrip.splitlines())
+ try:
+ for line in local_keys2:
+ if line.startswith('sec'):
+ line_fingerprint = next(local_keys2).lstrip().rstrip()
+ if local_key_fingerprint == line_fingerprint:
+ lkeygrip = next(local_keys2).split('=')
+ local_keygrip_to_use = lkeygrip[1].lstrip().rstrip()
+ break
+ except StopIteration:
+ raise SaltInvocationError(
+ 'unable to find keygrip associated with fingerprint \'{0}\' for keyid \'{1}\''
+ .format(local_key_fingerprint, local_keyid)
+ )
+
if local_keyid is None:
raise SaltInvocationError(
'The key ID \'{0}\' was not found in GnuPG keyring at \'{1}\''
@@ -527,6 +586,15 @@
if use_passphrase:
phrase = __salt__['pillar.get']('gpg_passphrase')
+ if use_gpg_agent:
+ _check_repo_gpg_phrase_utils()
+ cmd = '/usr/libexec/gpg-preset-passphrase --verbose --preset --passphrase "{0}" {1}'.format(phrase, local_keygrip_to_use)
+ retrc = __salt__['cmd.retcode'](cmd, runas=runas, env=env)
+ if retrc != 0:
+ raise SaltInvocationError(
+ 'Failed to preset passphrase, error {1}, '
+ 'check logs for further details'.format(retrc)
+ )
if local_uids:
define_gpg_name = '--define=\'%_signature gpg\' --define=\'%_gpg_name {0}\''.format(
@@ -553,43 +621,54 @@
number_retries = timeout / interval
times_looped = 0
error_msg = 'Failed to sign file {0}'.format(abs_file)
- cmd = 'rpm {0} --addsign {1}'.format(define_gpg_name, abs_file)
- preexec_fn = functools.partial(salt.utils.user.chugid_and_umask, runas, None)
- try:
- stdout, stderr = None, None
- proc = salt.utils.vt.Terminal(
- cmd,
- shell=True,
- preexec_fn=preexec_fn,
- stream_stdout=True,
- stream_stderr=True
- )
- while proc.has_unread_data:
- stdout, stderr = proc.recv()
- if stdout and SIGN_PROMPT_RE.search(stdout):
- # have the prompt for inputting the passphrase
- proc.sendline(phrase)
- else:
- times_looped += 1
+ if use_gpg_agent:
+ cmd = 'rpmsign --verbose --key-id={0} --addsign {1}'.format(local_keyid, abs_file)
+ retrc |= __salt__['cmd.retcode'](cmd, runas=runas, cwd=repodir, use_vt=True, env=env)
+ if retrc != 0:
+ raise SaltInvocationError(
+ 'Signing encountered errors for command \'{0}\', '
+ 'return error {1}, check logs for further details'.format(
+ cmd,
+ retrc)
+ )
+ else:
+ cmd = 'rpm {0} --addsign {1}'.format(define_gpg_name, abs_file)
+ preexec_fn = functools.partial(salt.utils.user.chugid_and_umask, runas, None)
+ try:
+ stdout, stderr = None, None
+ proc = salt.utils.vt.Terminal(
+ cmd,
+ shell=True,
+ preexec_fn=preexec_fn,
+ stream_stdout=True,
+ stream_stderr=True
+ )
+ while proc.has_unread_data:
+ stdout, stderr = proc.recv()
+ if stdout and SIGN_PROMPT_RE.search(stdout):
+ # have the prompt for inputting the passphrase
+ proc.sendline(phrase)
+ else:
+ times_looped += 1
+
+ if times_looped > number_retries:
+ raise SaltInvocationError(
+ 'Attemping to sign file {0} failed, timed out after {1} seconds'
+ .format(abs_file, int(times_looped * interval))
+ )
+ time.sleep(interval)
- if times_looped > number_retries:
+ proc_exitstatus = proc.exitstatus
+ if proc_exitstatus != 0:
raise SaltInvocationError(
- 'Attemping to sign file {0} failed, timed out after {1} seconds'
- .format(abs_file, int(times_looped * interval))
+ 'Signing file {0} failed with proc.status {1}'
+ .format(abs_file, proc_exitstatus)
)
- time.sleep(interval)
-
- proc_exitstatus = proc.exitstatus
- if proc_exitstatus != 0:
- raise SaltInvocationError(
- 'Signing file {0} failed with proc.status {1}'
- .format(abs_file, proc_exitstatus)
- )
- except salt.utils.vt.TerminalException as err:
- trace = traceback.format_exc()
- log.error(error_msg, err, trace)
- finally:
- proc.close(terminate=True, kill=True)
+ except salt.utils.vt.TerminalException as err:
+ trace = traceback.format_exc()
+ log.error(error_msg, err, trace)
+ finally:
+ proc.close(terminate=True, kill=True)
cmd = 'createrepo --update {0}'.format(repodir)
return __salt__['cmd.run_all'](cmd, runas=runas)

@ -1 +0,0 @@
SHA512 (salt-3005.4.tar.gz) = 31c699fc369c1f3c47f4f3a9a572381dd8c54323771194bdcc73128b55d983da7338b03061a6cdec6631aca62048e5829ea38687c3b0fdb1cdcbd5df9d000f05
Loading…
Cancel
Save