Skip to content

Add native (system-Python) Salt packages for Linux - #70945

Draft
dwoz wants to merge 1 commit into
saltstack:3008.xfrom
dwoz:native-packages-3008.x
Draft

dwoz wants to merge 1 commit into
saltstack:3008.xfrom
dwoz:native-packages-3008.x

Conversation

@dwoz

@dwoz dwoz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Re-introduces the pre-onedir "native" packaging flavor where Salt installs into the distro's system Python under
/usr/lib/python3/<dist-packages|site-packages>/salt/ rather than the self-contained /opt/saltstack/salt/ relenv tree. Native and onedir coexist in the same spec/rules tree; flavor is selected at build time via rpmbuild --with native --define 'native_slug <slug>' or SALT_NATIVE=1 SALT_NATIVE_SLUG=<slug> debuild. The onedir rendered spec is semantically identical to today's upstream save for the SALT_SHELL latent-bug fix (useradd now honors the documented knob).

  • tools/pkg/native_deps.py: audit tool with audit/floors/vendor-plan/ list-platforms subcommands. Full 9-distro audit matrix committed under cicd/native-deps/ (AL2023, Debian 12/13, Fedora 43, Photon 5, Rocky 9, Ubuntu 22.04/24.04/26.04).

  • pkg/common/salt-vendor.pth: prepends salt/_vendor/ to sys.path at interpreter startup. .pth rather than sitecustomize.py because Debian's base python3 ships a sitecustomize.py that would shadow ours.

  • pkg/rpm/salt.spec: %bcond_with native plus forked %build / %install / %files / scriptlet blocks. Hardened mode is the default on native; onedir behavior unchanged aside from the SALT_SHELL fix. Native release is tagged .native so rpm -q reveals the flavor. New tools pkg build rpm --native --native-slug=<slug> wraps rpmbuild with vendor-wheel pre-staging.

  • pkg/debian/rules: SALT_NATIVE=1 branch does python3 -m build --wheel, pip-installs the wheel with DEB_PYTHON_INSTALL_LAYOUT= deb_system, materializes salt/_vendor/, drops salt-vendor.pth, redistributes /usr/bin scripts across per-daemon packages matching the onedir .links layout, and ships /etc/salt/.pkg-native so postinst scripts default to hardened mode. salt-common.preinst is sed-patched at build time to apply the hardened default before the marker file is unpacked. /etc/salt/pki/minion added to salt-minion.dirs.

  • .github/workflows/build-packages.yml: new native-rpm and native-deb jobs matrixed over (slug x arch), each building inside the matching ghcr.io salt-ci-containers image. Artifacts: salt----{rpm,deb}-native.

  • .github/workflows/templates/layout.yml.jinja: native_rpm paths- filter group + prepare-workflow output for the slug list. PR CI fires the native matrix only on changes to pkg/rpm/, pkg/common/salt-vendor.pth, tools/pkg/{build,native_deps}.py, or cicd/native-deps/**. Nightly/release always build the full matrix. Slug list lives in cicd/shared-gh-workflows-context.yml as native-rpm-slugs.

Verified end-to-end:

  • rpmbuild --with native --define 'native_slug photonos-5' produces 7 .native.x86_64.rpm; install into fresh Photon 5 container; salt-call --local test.ping returns True as the salt user with state dirs chowned under /var/lib/salt/minion/; operator overrides via /etc/sysconfig/salt-minion-setup (SALT_USER/GROUP/HOME/SHELL/NAME) all honored.

  • SALT_NATIVE=1 debuild produces 8 debs; install into fresh Debian 12 container; salt-call --local test.ping returns True as the salt user with vendored looseversion loaded from salt/_vendor/, state dirs chowned under /var/lib/salt/minion/.

What does this PR do?

What issues does this PR fix or reference?

Fixes

Previous Behavior

Remove this section if not relevant

New Behavior

Remove this section if not relevant

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes/No

@dwoz
dwoz requested a review from a team as a code owner November 25, 2026 07:05
@dwoz dwoz closed this Nov 25, 2026
@dwoz dwoz reopened this Nov 25, 2026
@dwoz
dwoz marked this pull request as draft November 25, 2026 08:01
@dwoz
dwoz force-pushed the native-packages-3008.x branch from 1e6b784 to fc5559e Compare November 25, 2026 09:31
Re-introduces the pre-onedir "native" packaging flavor where Salt
installs into the distro's system Python under
/usr/lib/python3/<dist-packages|site-packages>/salt/ rather than the
self-contained /opt/saltstack/salt/ relenv tree. Native and onedir
coexist in the same spec/rules tree; flavor is selected at build time
via `rpmbuild --with native --define 'native_slug <slug>'` or
`SALT_NATIVE=1 SALT_NATIVE_SLUG=<slug> debuild`. The onedir rendered
spec is semantically identical to today's upstream save for the
SALT_SHELL latent-bug fix (useradd now honors the documented knob).

* tools/pkg/native_deps.py: audit tool with audit/floors/vendor-plan/
  list-platforms subcommands. Full 9-distro audit matrix committed
  under cicd/native-deps/ (AL2023, Debian 12/13, Fedora 43, Photon 5,
  Rocky 9, Ubuntu 22.04/24.04/26.04).

* pkg/common/salt-vendor.pth: prepends salt/_vendor/ to sys.path at
  interpreter startup. .pth rather than sitecustomize.py because
  Debian's base python3 ships a sitecustomize.py that would shadow
  ours.

* pkg/rpm/salt.spec: %bcond_with native plus forked %build / %install
  / %files / scriptlet blocks. Hardened mode is the default on
  native; onedir behavior unchanged aside from the SALT_SHELL fix.
  Native release is tagged .native so `rpm -q` reveals the flavor.
  New `tools pkg build rpm --native --native-slug=<slug>` wraps
  rpmbuild with vendor-wheel pre-staging.

* pkg/debian/rules: SALT_NATIVE=1 branch does `python3 -m build
  --wheel`, pip-installs the wheel with DEB_PYTHON_INSTALL_LAYOUT=
  deb_system, materializes salt/_vendor/, drops salt-vendor.pth,
  redistributes /usr/bin scripts across per-daemon packages matching
  the onedir .links layout, and ships /etc/salt/.pkg-native so
  postinst scripts default to hardened mode. salt-common.preinst is
  sed-patched at build time to apply the hardened default before the
  marker file is unpacked. /etc/salt/pki/minion added to
  salt-minion.dirs.

* .github/workflows/build-packages.yml: new native-rpm and native-deb
  jobs matrixed over (slug x arch), each building inside the matching
  ghcr.io salt-ci-containers image. Artifacts:
  salt-<ver>-<arch>-<slug>-{rpm,deb}-native.

* .github/workflows/templates/layout.yml.jinja: native_rpm paths-
  filter group + prepare-workflow output for the slug list. PR CI
  fires the native matrix only on changes to pkg/rpm/,
  pkg/common/salt-vendor.pth, tools/pkg/{build,native_deps}.py, or
  cicd/native-deps/**. Nightly/release always build the full matrix.
  Slug list lives in cicd/shared-gh-workflows-context.yml as
  `native-rpm-slugs`.

Verified end-to-end:

  - rpmbuild --with native --define 'native_slug photonos-5' produces
    7 .native.x86_64.rpm; install into fresh Photon 5 container;
    salt-call --local test.ping returns True as the salt user with
    state dirs chowned under /var/lib/salt/minion/; operator
    overrides via /etc/sysconfig/salt-minion-setup
    (SALT_USER/GROUP/HOME/SHELL/NAME) all honored.

  - SALT_NATIVE=1 debuild produces 8 debs; install into fresh
    Debian 12 container; salt-call --local test.ping returns True
    as the salt user with vendored looseversion loaded from
    salt/_vendor/, state dirs chowned under /var/lib/salt/minion/.

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant