Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3153

export: /usr/pkg: bad variable name trying to use pkgsrc package_module on NetBSD 8

    XMLWordPrintable

    Details

      Description

      While trying to validate the change on NetBSD 8 I got an error running my test policy.

      localhost# cf-agent -KIf ./promises.cf
      export: /usr/pkg: bad variable name
          info: Error occurred while getting supported API version.
         error: unsupported package module wrapper API version: -1
         error: Some error occurred while contacting package module - promise: unarj
      

      I ran the module manually to find where exactly it was failing.

      localhost# sh -xe /var/cfengine/modules/packages/pkgsrc supports-api-version
      + '[' -f /etc/shrc ']'
      + . /etc/shrc
      + '[' -n '' ']'
      + export 'PATH=/opt/local/bin:/opt/local/sbin:/opt/pkg/bin:/opt/pkg/sbin:/usr/pkg/bin:/usr/pkg/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin:/usr/X11R7/bin:/usr/local/sbin:/usr/local/bin:/var/cfengine/bin:/var/cfengine/bin'
      + + + pkg_infogrepcut -X MACHINE_ARCH -d pkg_install
       =
       -f 2
      + export MACHINE_ARCH=x86_64
      + + pkg_infocut -pq -d pkg_install ' '
       -f 2
      + export PKG_ROOT=/usr/pkg /usr/pkg
      export: /usr/pkg: bad variable name
      

      It's failing on this line.

      export PKG_ROOT=$(pkg_info -pq pkg_install | cut -d ' ' -f 2)
      

      It seems pkg_info output some unexpected information, namely the PACKAGE MAY NOT BE DELETED lines.

      localhost# pkg_info -p pkg_install
      Information for pkg_install-20180425:
      
      *** PACKAGE MAY NOT BE DELETED ***
      Prefix(s):
              CWD to: /usr/pkg
              CWD to: /usr/pkg
      *** PACKAGE MAY NOT BE DELETED ***
      
      localhost# pkg_info -p cfengine
      Information for cfengine-3.7.3nb1:
      
      Prefix(s):
              CWD to: /usr/pkg
              CWD to: /usr/pkg
      

      Actually, no, that's not the reason (-q suppresses those strings. It's because it returned multiple prefixes and the module expected only one.

      Test Platform: https://app.vagrantup.com/NetBSD/boxes/NetBSD-8.0
      Vagrant File

      # -*- mode: ruby -*-
      # vi: set ft=ruby :
      Vagrant.configure("2") do |config|
      
        # Every Vagrant development environment requires a box. You can search for
        # boxes at https://vagrantcloud.com/search.
              config.vm.box = "NetBSD/NetBSD-8.0"
              config.ssh.shell = "sh"
              config.vm.provider :virtualbox do |vb|
                vb.customize ["modifyvm", :id, "--audio", "none"]
               end
      end
      

      Test Policy

      bundle agent main
      {
        packages:
          "unarj"
            policy => "present",
            #version => "2.65nb1",
            package_module => pkgsrc;
          
      }
      bundle common def
      {
      vars:
            # Package inventory refresh
            "package_module_query_installed_ifelapsed" -> { "CFE-2771" }
              string => "60", # 1 hour
              if => not( isvariable( $(this.promiser) ));
      
            "package_module_query_updates_ifelapsed" -> { "CFE-2771" }
              string => "1440", # 1 day
              if => not( isvariable( $(this.promiser) ));
      
      }
      body package_module pkgsrc
      # @brief Define details used when interfacing with the pkgsrc package
      # module.
      #
      # **Example:**
      # ```cf3
      # bundle agent main
      # {
      #   packages:
      #       "vim"
      #         policy => "present",
      #         package_module => pkgsrc;
      # }
      # ```
      {
          query_installed_ifelapsed => "$(def.package_module_query_installed_ifelapsed)";
          query_updates_ifelapsed => "$(def.package_module_query_updates_ifelapsed)";
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel