Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10297

Add SemVerRange support to apt package provider

    XMLWordPrintable

Details

    • Enhancement
    • Hide
      Add support of >, >=, <, <=, >=A <=B ranges for package version specified in :ensure

      If there is no version selected by the provided range or a package version is not respecting Debian package versioning (https://www.debian.org/doc/debian-policy/ch-controlfields.html#version), it will fall through default implementation
      Show
      Add support of >, >=, <, <=, >=A <=B ranges for package version specified in :ensure If there is no version selected by the provided range or a package version is not respecting Debian package versioning ( https://www.debian.org/doc/debian-policy/ch-controlfields.html#version), it will fall through default implementation
    • Needs Assessment

    Description

      Implement SemVerRange type support for the apt provider.

      Sample manifest with a range passed for a package:

      package { 'puppet-agent':
        # this will be parsed as: >= 6.0.0 < 6.1.0
        ensure => SemVerRange('~> 6.0')
      }
       
      package { 'puppet-agent':
        ensure => SemVerRange('>= 6.5')
      }
       
      package { 'puppet-agent':
        ensure => SemVerRange('< 6.4')
      }
       
      package { 'puppet-agent':
        # this is a valid range which we can support
        ensure => SemVerRange('~> 6.0 || ~> 6.11')
      }
      

      The apt provider does not support a version range passed in the install command, so we have to:

      • find out the available versions for a specific package (usually with apt-cache policy)
      • install the most recent package which respects the range.

      We should also make sure we don't take additional actions if the range is already satisfied (i.e. puppet apply with a SemVerRange should be idempotent)

      Sample code on how the ensure property can be treated inside the provider:

      if @resource.should(:ensure).is_a?(SemanticPuppet::VersionRange)
        # these should be sorted in descending order
        available_versions = `apt-cache -a show #{@resource.name} | grep Version | awk '{print $2}'`.split
        range = @resource.should(:ensure)
       
        available.versions.any? { |version| range.include?(version.to_stable) }
      end
      

      Example apt-get install with a specific version:

      apt-get install puppet-agent=6.3.0-1jessie

      Attachments

        Activity

          People

            ciprian.badescu Ciprian Badescu
            gabriel.nagy Gabriel Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support