puppetlabs / puppetlabs-apt

Puppet module to help manage Apt
https://forge.puppetlabs.com/puppetlabs/apt
Apache License 2.0
215 stars 462 forks source link

Ubuntu packages may contain dot #1074

Closed xepa closed 1 year ago

xepa commented 1 year ago

Describe the Bug

apt::mark { 'containerd.io': setting => 'hold' }

Expected Behavior

Package should be held (this is a regression)

Steps to Reproduce

Mark any package containing a . in the package name

Environment

Additional Context

there are some other packages with a . in the name.

tinuzz commented 1 year ago

To add to this: the regexp used in apt::mark is wrong on more than just the dot, for Debian and Ubuntu:

  if $title !~ /^[a-zA-Z0-9\-_]+$/ {
    fail("Invalid package name: ${title}")
  }

As per the Debian Policy manual:

Package names (both source and binary) must consist only of lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.). They must be at least two characters long and must start with an alphanumeric character.

So, the '+' and '.' are missing, and the '_' should go.

xepa commented 1 year ago

It might be better to refactor the regex to the following this would satisfy the title policy of Debian (and I would assume Ubuntu), just let me know and I can refactor it in the PR for this issue

^[a-z0-9]{2}[a-z0-9.+\-]*$

edit: updated, you are right, bit quick of me thanks @tinuzz

tinuzz commented 1 year ago

Just a small note: in a character class, the dot and the plus sign don't have to be escaped.

xepa commented 1 year ago

I have updated the PR to reflect the latest input of @tinuzz