#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.171 2021/01/26 12:13:21 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.172 2021/11/08 13:33:05 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
return $l;
}
+sub validate_pkgname
+{
+ my ($self, $state, $pkgname) = @_;
+
+ my $revision = $state->defines('REVISION_CHECK');
+ my $epoch = $state->defines('EPOCH_CHECK');
+ my $flavor_list = $state->defines('FLAVOR_LIST_CHECK');
+ if ($revision eq '') {
+ $revision = -1;
+ }
+ if ($epoch eq '') {
+ $epoch = -1;
+ }
+ my $okay_flavors = {map {($_, 1)} split(/\s+/, $flavor_list) };
+ my $v = OpenBSD::PackageName->from_string($pkgname);
+ my $errors = 0;
+ if ($v->{version}->p != $revision) {
+ $state->errsay("REVISION mismatch (REVISION=#1)", $revision);
+ $errors++;
+ }
+ if ($v->{version}->v != $epoch) {
+ $state->errsay("EPOCH mismatch (EPOCH=#1)", $epoch);
+ $errors++;
+ }
+ for my $f (keys %{$v->{flavors}}) {
+ if (!exists $okay_flavors->{$f}) {
+ $state->errsay("bad FLAVOR #1 (admissible flavorss #2)",
+ $f, $flavor_list);
+ $errors++;
+ }
+ }
+ if ($errors) {
+ $state->fatal("Can't continue");
+ }
+}
+
sub run_command
{
my ($self, $state) = @_;
if (!defined $plist->pkgname) {
$state->fatal("can't write unnamed packing-list");
}
+ if (defined $state->defines('REVISION_CHECK')) {
+ $self->validate_pkgname($state, $plist->pkgname);
+ }
if (defined $state->opt('q')) {
if (defined $state->opt('Q')) {
-.\" $OpenBSD: pkg_create.1,v 1.120 2021/01/29 15:58:56 espie Exp $
+.\" $OpenBSD: pkg_create.1,v 1.121 2021/11/08 13:33:06 espie Exp $
.\"
.\" Documentation and design originally from FreeBSD. All the code has
.\" been rewritten since. We keep the documentation's notice:
.\" [jkh] Took John's changes back and made some additional extensions for
.\" better integration with FreeBSD's new ports collection.
.\"
-.Dd $Mdocdate: January 29 2021 $
+.Dd $Mdocdate: November 8 2021 $
.Dt PKG_CREATE 1
.Os
.Sh NAME
.It Cm USE_GROFF
Set to 1 to have groff format manpages behind the scenes during
package creation.
+.It Cm REVISION_CHECK , EPOCH_CHECK , FLAVOR_LIST_CHECK
+Set automatically by
+.Xr bsd.port.mk 5
+to values that help
+.Nm
+catch a few errors in package naming.
.El
.It Fl d Oo Fl Oc Ns Ar desc
Fetch long description for package from file