Skip to content

[BUG] pkg.installed fails to detect packages by their origin name on FreeBSD #67126

@amendlik

Description

@amendlik

Description
On FreeBSD, packages can be installed by either their "package name" or their "origin name". For example, if I want to install the zstd library for PHP, I can use either of the following commands:

  • Package name: pkg install php84-zstd
  • Origin name: pkg install archivers/php-zstd

Salt added support for this in v2015.5.4 (6b0f4fc) but the change did not enable Salt to detect the installed package when run in test mode (state.test).

Setup

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on AWS EC2
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD
  • classic packaging
  • onedir packaging
  • used bootstrap to install

Steps to Reproduce the behavior
Create a state that installs a FreeBSD package using the origin name, such as:

java:
  pkg.installed:
    - name: java/openjdk17

Apply the state with salt-call state.apply as usual.

# salt-call state.apply openjdk
local:
----------
          ID: java
    Function: pkg.installed
        Name: java/openjdk17
      Result: True
     Comment: The following packages were installed/updated: java/openjdk17
     Started: 16:47:42.969697
    Duration: 17525.373 ms
     Changes:
              ----------
              openjdk17:
                  ----------
                  new:
                      17.0.12+7.1
                  old:

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:  17.525 s

Run the state again in test mode using salt-call state.test, and it will fail to detect the installed package.

# salt-call state.test openjdk
local:
----------
          ID: java
    Function: pkg.installed
        Name: java/openjdk17
      Result: None
     Comment: The following packages would be installed/updated: java/openjdk17
     Started: 16:49:46.899851
    Duration: 1250.466 ms
     Changes:
              ----------
              java/openjdk17:
                  ----------
                  new:
                      installed
                  old:

Summary for local
------------
Succeeded: 1 (unchanged=1, changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   1.250 s

Expected behavior
State runs in test mode should detect the installed package and report no changes.

# sudo salt-call state.test openjdk
local:
----------
          ID: java
    Function: pkg.installed
        Name: java/openjdk17
      Result: True
     Comment: All specified packages are already installed
     Started: 16:53:12.661629
    Duration: 82.012 ms
     Changes:

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  82.012 ms

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3006.8

Python Version:
        Python: 3.11.10 (main, Oct 31 2024, 01:10:40) [Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15

Dependency Versions:
          cffi: 1.17.1
      cherrypy: Not Installed
      dateutil: 2.9.0
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: 1.7.2
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.1.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.1
     pycparser: 2.22
      pycrypto: Not Installed
  pycryptodome: 3.20.0
        pygit2: 1.14.1
  python-gnupg: Not Installed
        PyYAML: 6.0.1
         PyZMQ: 25.0.2
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.5

System Versions:
          dist: freebsd 14.2
        locale: utf-8
       machine: amd64
       release: 14.2-RELEASE
        system: FreeBSD
       version: FreeBSD 14.2

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions