Bug 227193 - ports-mgmt/pkg: pkg updating only recognizes exact string matches for port origins
Summary: ports-mgmt/pkg: pkg updating only recognizes exact string matches for port or...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-pkg mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-02 01:34 UTC by david
Modified: 2019-10-10 01:18 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (pkg)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description david 2018-04-02 01:34:45 UTC
The Porter's Handbook, section 11.2.1, contains a passage:

Note:

It is recommended that the AFFECTS line contains a glob matching all the ports affected by the entry so that automated tools can parse it as easily as possible. If an update concerns all the existing BIND 9 versions the AFFECTS content must be users of dns/bind9*, it must not be users of BIND 9


However, empirical observations (ref., e.g., the email thread that starts at <http://docs.FreeBSD.org/cgi/mid.cgi?20180331142525.GE1272>) and inspection of the code in pkg-1.10.5's src/updating.c:

                tmp = NULL;
                if (found == 0) {
                        if (strstr(line, "AFFECTS") != NULL) {
                                SLIST_FOREACH(port, &origins, next) {
                                        if (caseinsensitive) {
                                                if ((tmp = strcasestr(line, port->origin)) != NULL) {
                                                        break;
                                                }
                                        } else {
                                                if ((tmp = strstr(line, port->origin)) != NULL) {
                                                        break;
                                                }
                                        }
                                }
                                if (tmp != NULL) {
                                        if ((date != NULL) && strncmp(dateline, date, 8) < 0) {
                                                continue;
                                        }
                                        printf("%s%s",dateline, line);
                                        found = 1;
                                }
                        }
                } else {
                        printf("%s",line);
                }


shows that "pkg updating" cannot make constructive use of "globs" -- and if they are specified in ports/UPDATING, "pkg updating" will fail to match such entries to any installed port, and will thus fail to display the entries for affected ports.

That said, another way to address the inconsistency (between the Porter's Handbook recommendation and the code in updating.c) would be to change the recommendation (and corresponding practice) to only use port origin specifiers that "pkg updating" will recognize: I am not in a position to make a claim as to which approach makes more sense (either now or in the future).

(Indeed: it may well be that it may be better to use regular expressions, rather than globs -- in which case code, documentation, and practice would each need to change.  But that's not my call.)
Comment 1 Yuichiro NAITO 2019-10-10 01:10:04 UTC
pkg 1.12.0 should fix this. Please try it.
Comment 2 david 2019-10-10 01:18:38 UTC
Thank you; it appears to do so:

g1-49(11.3-S)[4] grep -B 3 '/perl' /usr/ports/UPDATING | head -5
  https://docs.ejabberd.im/admin/upgrade/from_19.05_to_19.08/ 

20190812:
  AFFECTS: users of lang/perl5*
--
g1-49(11.3-S)[5] pkg -v
1.12.0
g1-49(11.3-S)[6] pkg info -o perl\*
perl5-5.30.0                   lang/perl5.30
g1-49(11.3-S)[7] pkg updating -d 20190811
20190812:
  AFFECTS: users of lang/perl5*
  AUTHOR: mat@FreeBSD.org

  The default Perl version has been switched to Perl 5.30.  If you are using
  binary packages to upgrade your system, you do not have anything to do, pkg
  upgrade will do the right thing.  For the other people, follow the
  instructions in entry 20161103, it should still be the same.

g1-49(11.3-S)[8] 

I believe this issue may be closed.