Commit graph

70 commits

Author SHA1 Message Date
rillig
b885ff75ea mk/subst.mk: ignore directories in SUBST_FILES
Seen in multimedia/libmp4v2, where a pattern also matches the CVS
directory from the distfiles.
2020-03-22 13:19:50 +00:00
rillig
4d12683e99 mk/subst.mk: use the same severity for all messages
The severity now depends only on the setting of SUBST_NOOP_OK. Right now
this means that some former warnings will be reported as info only, but
that will change after switching the default of SUBST_NOOP_OK after
2020Q1. Then they will all be reported as warnings, followed by the final
error saying that the pattern has no effect.

This change makes it easier to detect inconsistencies and outdated
definitions, for example by setting the global SUBST_NOOP_OK=no and
redefining WARNING_MSG to actuall fail.
2020-03-22 12:15:59 +00:00
rillig
fdc3adecd5 mk/subst.mk: run diff in the default locale
The diff program is only used to produce informative output in the build
logs, nevertheless its output might be translated if there are lines that
do not end with a newline.
2020-03-21 19:26:12 +00:00
rillig
8e82112864 mk/subst.mk: add global SUBST_SHOW_DIFF variable
This is useful in bulk builds or when trying to understand what happens
under the hood, since the SUBST code leaves no .orig files around.
2020-03-21 13:30:35 +00:00
rillig
68730ad3f1 mk/subst.mk: fix bmake warnings in case of duplicate SUBST classes 2020-03-21 12:22:31 +00:00
rillig
d1f0656e94 mk/subst.mk: evaluate SUBST_MESSAGE only once, and late
The default value of SUBST_MESSAGE is based on SUBST_FILES, and that
variable may use the :sh modifier to list files from WRKSRC, which may
not exist at load time.
2020-03-20 09:00:44 +00:00
rillig
59545c5e44 mk/subst.mk: fix early evaluation of SUBST_FILES
In the case of pkglocaledir, the SUBST_FILES are generated by a shell
command. That command assumes that the WRKDIR already exists. Therefore
SUBST_FILES must be evaluated as late as possible.

See mk/configure/replace-localedir.mk; an example package that fails is
devel/gettext-tools.
2020-03-20 06:17:48 +00:00
rillig
a99bca4dad mk/subst.mk: add SUBST_NOOP_OK to catch typos and outdated definitions
In a bulk build with very strict settings (WARNING_MSG fails, as well as
no-op substitutions), it became clear that nearly all of the cases where
SUBST didn't replace anything were bugs in the package definition.

Most of them were just outdated, which is no surprise given that some
packages are already over 20 years old.

For backwards compatibility, SUBST_NOOP_OK defaults to "yes" right now.
After correcting the affected packages, the default will change to "no".
2020-03-19 16:57:35 +00:00
minskim
7f94d0a54c mk: Set LC_ALL=C to avoid encoding issue with tr and sed 2019-11-22 18:04:49 +00:00
rillig
ec4d6a7c7f mk/subst.mk: document variables used in the file, remove SUBST_TARGETS
All variables that are used or defined in the file are now listed in the
_VARGROUPS section.

The "is text file" command variable has been renamed since pkglint
thought the former variable name would specify a filename, not a shell
command.

The "is text file" command has been rewritten to only rely on tr(1)
instead of both tr(1) and wc(1). This makes it both simpler and maybe
also a little faster, since the file only has to be read once.

The SUBST_TARGETS variable has been removed since it is used nowhere
else. To get the list of all subst targets (should that ever be
necessary), use the expression ${SUBST_CLASSES:S,^,subst-,}.
2019-09-08 09:06:06 +00:00
rillig
89e7671cfc mk/subst.mk: use simpler words in the documentation, add an example 2019-04-28 12:31:15 +00:00
rillig
85d27b43fd mk/subst.mk: substitute embedded newlines, escape dots in variable names 2019-03-17 12:01:14 +00:00
rillig
858c6cfd69 mk/misc: make configuration for show-all targets more configurable
Up to now, there was a central list of variable name patterns that
defined whether a variable was printed as a sorted list, as a list or as
a single value.

Now each variable group decides on its own which of the variables are
printed in which way, using the usual glob patterns. This is more
flexible since different files sometimes differ in their naming
conventions.

Two variable groups are added: license (for everything related to
LICENSE) and go (for lang/go).
2018-11-30 18:38:19 +00:00
rillig
d578ca80ec Fix whitespace issues reported by pkglint 2018-10-08 20:35:00 +00:00
rillig
1cba6ef059 Allow package developers to easily see and check the SUBST changes. 2018-01-02 21:18:48 +00:00
rillig
913583c370 Fixed subst.mk not to corrupt files
Up to now, using subst.mk may have led to file corruption during active
package development. This happened when a sed(1) command had a syntax
error, in which case the whole sed(1) command was terminated, leaving an
empty original file behind.

This commit changes that behavior by applying the sed(1) commands to
the original file and saving the result in a temporary file. Only
after that succeeded is the original file overwritten.

During this rewrite, SUBST_POSTCMD has been removed, since it was
only used in one place (mk/wrapper), and since it relied on the exact
sequence of the internal commands. No package in either main pkgsrc
or pkgsrc-wip uses this variable right now.
2016-01-31 17:27:41 +00:00
dholland
2d17a64f1f Add note to SUBST_SED noting that -E is not a standard sed option.
From Leonardo Taccari in followup to PR 48254.
2013-10-13 21:38:36 +00:00
rillig
521367f105 See also: PLIST_SUBST 2008-01-26 15:23:21 +00:00
rillig
04cbcc5bc0 Made the wording more into an explanation. 2008-01-23 01:44:28 +00:00
rillig
884f21f398 If the package doesn't provide a SUBST_MESSAGE, generate a default one.
This way, file modifications cannot go unnoticed and at least appear in
the build logs. While here, fixed an ambiguity in the description of
SUBST_MESSAGE.
2008-01-18 11:26:11 +00:00
rillig
212334d5a8 Don't rely on file(1) to distinguish text files from binary files. This
has proven too unreliable in the past. For example, some Makefile.in
files were classified as "Quake I or II world or extension", just
because they happen to start with the letters "PACK". This method was
also subject to subtle differences in the locale.

The new method counts the number of NUL bytes in the file. It does not
depend on the locale settings. The -c option of wc(1) counts bytes, not
characters, and tr(1), which may interpret multibyte sequences, is
protected by LC_ALL. It should also work with the historical
implementations of tr(1) that could not handle NUL bytes and discarded
them, since this is exactly the intention.

See also:
* http://mail-index.netbsd.org/tech-pkg/2006/07/05/0000.html
* PR 37793
2008-01-18 11:16:08 +00:00
rillig
494c8050fe Replaced _PKG_SILENT and _PKG_DEBUG with RUN. 2008-01-18 10:41:05 +00:00
rillig
fa786ebc0c Explicitly mentioned that both SUBST_SED and SUBST_VARS may be used in a
class.
2007-11-19 23:38:03 +00:00
rillig
02052152d3 Before running _SUBST_IS_TEXT_FILE on a file, make sure that the file
exists.
2007-11-01 13:12:48 +00:00
wiz
23325b7421 Recognize XML files as text. 2007-04-05 18:33:09 +00:00
rillig
66bf916302 For all those who are interested in the inner workings of pkgsrc, there
is a new target "show-all" that fits to the existing "debug",
"show-tools", "show-vars" targets. It prints a list of the variables
that make up the public interface to pkgsrc. Running this target is
especially useful if you want to do some things, you know that they must
have been implemented but you don't know what it is called. It also
shows the "class" of a variable (user-defined, package-defined,
system-defined).
2007-03-15 22:54:24 +00:00
rillig
53cf03e2a6 Fixed the quoting for SUBST_VARS.*. Now every character gets replaced
properly. The regression test passes.
2007-03-07 21:27:59 +00:00
rillig
c55eb274b2 Some Makefile.in files start with the letters PACKAGE. NetBSD's file(1)
considers files starting with the letters PACK to be related to Quake.
2007-02-05 08:39:23 +00:00
rillig
a1fe379914 Since there are many cases where the string @FOO@ is replaced with the
pkgsrc variable ${FOO}, there is now a shorter variant for it. Instead
of defining SUBST_SED.*, just say SUBST_VARS.* = FOO.
2007-01-23 06:05:39 +00:00
rillig
4325294fae The new variable SUBST_SKIP_TEXT_CHECK.* can be set to "yes" to do the
substitutions in all files, whether or not file(1) says they are text.
2007-01-14 17:05:02 +00:00
rillig
86e14e4200 When a SUBST change leaves a file as-is, print an informational message.
For all messages, the current SUBST_CLASS is printed, too.
2007-01-11 12:12:12 +00:00
rillig
ea535fc2fd + keyword "subst" 2007-01-03 23:35:13 +00:00
reed
e89ec495e9 Also "Assembler source" is a text file for _SUBST_IS_TEXT_FILE.
(Really the file is a wdm config file. Noticed when building wdm.)
2006-12-10 02:25:13 +00:00
tron
5e12c6a0bc file(1) under NetBSD-sparc64 4.99.4 identifies the file
"gdk-pixbuf/Makefile.in" from the "gtk2" package as "libtool library file".
Change the textfile check to accept any file which file(1) identifies
as "<whatever>libtool<whateverelse>" to fix the build of the
"gtk2" package (and probably other packages).
2006-11-23 16:27:53 +00:00
rillig
7235ba2317 Clarify _who_ is supposed to set the SUBST_* variables. 2006-11-09 02:06:29 +00:00
rillig
465c404b46 Fixed the documentation for SUBST_SED.*, which is not _one_ sed
expression, but a list of sed expressions.
2006-07-02 09:35:05 +00:00
rillig
ba68c129fe SUBST_STAGE.* is currently not defined by all SUBST blocks, so disable
PKG_FAIL_REASON in that case. It didn't have an effect anyway for normal
builds, since subst.mk is included after checking PKG_FAIL_REASON.

Discussed with jlam.
2006-06-22 20:45:48 +00:00
rillig
56d01034de Simplified the code by reducing the number of different targets that are
evaluated. Now the SUBST_MESSAGE is only printed once when the
substitution is actually done. Before this change it had been printed
also when the subst-<class> target had been invoked a second time, but
the substitution didn't take place again, which had confused me. Also,
converted the code to use ${WARNING_MSG} and ${STEP_MSG}.
2006-06-17 22:42:00 +00:00
rillig
f134edb22f Reverted the change from 1.29 to 1.30, as it had led to build failures in
the "unwrap" class.
2006-01-08 01:07:35 +00:00
rillig
1f20649016 Added two missing :Q operators. One of them affects how the
SUBST_MESSAGE is printed. The ones that have been defined with "quotes"
in their Makefiles are printed with quotes (of course). This is the
consequence of the design pattern "quote-exactly-where-necessary", which
in fact should be have been applied to pkgsrc as a whole, but still isn't.
2006-01-07 23:27:41 +00:00
rillig
2e71854a23 Removed the use of ${FILE_CMD} from the substitution framework. The
detection whether a given file was a text file or some other file had
been unreliable. In the recent bulk builds, all of the warnings that had
appeared because of that unreliable detection had been false positives.
2006-01-07 18:43:05 +00:00
joerg
c750987c17 Adjust comment about SUBST_FILES to match reality:
absolute file names work as well.
2006-01-05 23:16:01 +00:00
rillig
e4af2b5124 Fixed some cases where the exitcode of child processes has been ignored.
This will cause package builds to fail instead of hiding bugs.
2006-01-01 22:52:16 +00:00
rillig
9a74bcedfd Fixed trivial pkglint warnings:
- Removed leading white-space in dependency lines.
- s/existant/existent/.
2006-01-01 22:30:35 +00:00
rillig
5878c465ce Allow absolute filenames for SUBST_FILES. Needed for converters/convmv and
maybe some others.
2005-12-06 17:17:30 +00:00
rillig
37b8605b92 Added another diagnostic message to distinguish the cases for non-text
file and non-existant file.
2005-11-24 20:02:40 +00:00
rillig
7dccf8e1ba A warning is printed for every non-text file. This helps in detecting
broken file(1) databases. It also gives an indication of whether this
test is necessary at all.
2005-11-17 23:17:02 +00:00
rillig
57994895c2 Changed the comment for SUBST_STAGE to be more complete. Started the other
sentences with an uppercase letter. No code changes.
2005-08-21 22:00:07 +00:00
rillig
54682e7ad9 Fixed a typo. 2005-06-09 19:49:48 +00:00
jlam
262ed77f43 Change instances where we stored shell command in a make variable into
variables that use the :sh modifier.  This still causes expansion to only
happen when referenced, and has the advantage of being :Q-safe.

Bring back the changes from revision 1.19 of mk/subst.mk now that the
problem noted above has been fixed.  This passes the buildlink-unwrap
regression test.
2005-05-20 21:36:05 +00:00