Commit graph

66 commits

Author SHA1 Message Date
rillig
5859bdc50b regress/infra-unittests: document creative AC_ARG_WITH in lang/mono4 2020-05-23 07:30:18 +00:00
rillig
4c58410ecc mk/configure: fix check for unknown configure options 2020-05-22 15:21:15 +00:00
rillig
da17aee62b regess/infra-unittests: add test for unknown configure option 2020-05-22 15:10:17 +00:00
rillig
e45d2e3458 mk/pkgformat/metadata.mk: fix relative paths in PATCHDIR and FILESDIR
Before, relative paths had been stored as-is.  This affected those
packages that defined PATCHDIR or FILESDIR as relative directory instead
of prefixing it with ${.CURDIR}.

Since there are already several other paths that are interpreted relative
to the package directory (CONFLICTS, DEPENDS), allow PATCHDIR and
FILESDIR to be specified as relative paths, too.  This makes the package
Makefiles a bit shorter.
2020-05-21 18:48:43 +00:00
rillig
cc8614f669 mk/configure: completely rewrite check for unknown configure options
The previous implementation could not reliably detect outdated configure
options.  This was apparent in devel/gettext-tools, where the option
--with-included-libcroco had become unknown between May 2019 and May
2020, but the check was not run.

The behavior is the same in the pkgsrc default configuration.  Only if
GNU_CONFIGURE_STRICT=yes, the new check is activated and will make
packages fail that previously succeeded to build.  Since that variable is
not widely known, there won't be much sudden breakage, if any.
2020-05-21 13:42:10 +00:00
rillig
806ef3dba2 regress/infra-unittests: demonstrate relative paths in +BUILD_VERSION
Pointed out by wiz@.

This occured in math/libixion/Makefile.common until 2020-05-19, and still
occurs in math/xyconvert/Makefile.  In all other packages, PKGDIR is
prefixed with  ${.CURDIR} and is thus an absolute path.

It should not be necessary to always specify PATCHDIR as an absolute
path, and the code in mk/pkgformat/pkg/metadata.mk seems to be the only
place where relative paths are handled wrong.
2020-05-19 06:09:53 +00:00
rillig
dc03fe5b2b regress/infra-unittests: remove unnecessary tmpdir handling
The test infrastructure from test.subr already takes care of setting up a
temporary directory.
2020-05-19 05:14:18 +00:00
rillig
1126482bd5 mk/configure/replace-interpreter.mk: silently skip broken symlinks
Like directories, they probably come from shell globs.

Seen in misc/byobu.
2020-05-18 06:06:34 +00:00
rillig
6adb284e6e regress/infra-unittests: add test for variable precedence 2020-05-17 13:35:35 +00:00
rillig
83a6b93b31 regress/infra-unittests: replace double quotes with single quotes 2020-05-16 20:22:41 +00:00
rillig
67d8ae7d2b mk/subst.mk: change default value for SUBST_NOOP_OK from yes to no
This makes the SUBST blocks stricter than before, to detect outdated or
unnecessary definitions.

Filename patterns that are not affected by any of the SUBST_SED
expressions make the build fail.  It is still ok if only some of the
files from a pattern are affected and some aren't.

The latest bulk build shows that most of the build failures are fixed.
The packages that fail in that build are mostly due to other failures,
like missing C headers, wrong PLIST files, unresolved references at link
time.  There may be a few packages that still fail because of this, but
these are near the leaves of the dependency tree.

https://mail-index.netbsd.org/pkgsrc-bulk/2020/05/14/msg018919.html
2020-05-16 19:02:32 +00:00
rillig
f0feafbfc1 mk/subst.mk: properly detect s,a,a,1 as identity substitution
Seen in games/bastet.  The 1 is not necessary though since it only
repeats the default behavior of sed.
2020-05-16 12:43:10 +00:00
rillig
8e1a21443b regress/infra-unittests: clean up test code, add portability
The test can now be run with bash and ksh as well.

Bash exits if a function call returns failure, the NetBSD /bin/sh
doesn't.  After reading POSIX, sections "2.9.1 Simple Commands" and "set
-e", I'm in favor of bash here.

Ksh exits in "set -eu" mode if "$@" is used but no arguments are given.
2020-05-12 05:34:04 +00:00
rillig
d3db3fb365 regress/infra-unittests: clean up test code for subst.mk
There had been unnecessary variations in the code.
2020-05-12 04:35:55 +00:00
rillig
4675cfa4dc regress/infra-unittests: replace remaining double with single quotes 2020-05-12 04:22:44 +00:00
rillig
33257cda70 regress/infra-unittests: replace double quotes with single quotes
Strings in single quotes are simpler to understand and also need fewer
pixels on the screen.
2020-05-11 20:22:31 +00:00
rillig
21aab909de mk/subst.mk: fix edge case in detection of identity substitutions
In a basic regular expression, a dollar-sign only means end-of-string if
it appears at the end of the pattern, or (at the choice of the
implementation) at the end of a \(...\) subexpression.

This affects the package converters/help2man that uses a regular
expression containing a dollar in a non-final position.  This regular
expression had not been detected as an identity substitution even though
it is one.
2020-05-11 19:52:13 +00:00
rillig
ca4881183b regress/infra-unittests: add tests for identity substitutions 2020-05-11 19:17:22 +00:00
rillig
62f1272cfc regress/infra-unittests: run tests in a temporary directory
This isolates the tests from the test infrastructure and allows the test
infrastructure to create arbitrary files for its own purpose without
affecting any of the tests.
2020-05-11 19:13:10 +00:00
rillig
e21ea1b833 regress/infra-unittests: parse command line options [-kv] [-f filter] 2020-05-09 17:41:08 +00:00
rillig
a864fd9c2e regress/infra-unittests: indent here-documents 2020-05-09 17:10:38 +00:00
rillig
e4719c2d8a mk/subst.mk: allow identity substitutions with escaped dots
This fixes the build of converters/help2man in SUBST_NOOP_OK=no mode.
2020-05-06 06:14:56 +00:00
rillig
a669b77182 regress/infra-unittests: add tests for portability checks
Files like Makefile.am and configure.ac are usually not used during a
build, therefore there's no point in checking these for shell portability
issues.
2020-05-05 06:11:29 +00:00
rillig
78ff56665f mk/check/check-portability: opt-in for newer portability checks
There are a few portability checks that have been existing for years.
Later additions need an opt-in phase to avoid breaking existing usages.

https://mail-index.netbsd.org/tech-pkg/2020/05/04/msg023084.html
2020-05-05 05:55:25 +00:00
rillig
80ac4ecc53 mk/check/check-portability: fix error message when no patches are found 2020-05-04 21:48:18 +00:00
rillig
4b2126055f mk/check/check-portability: skip X.in if X is patched
A commonly occuring scenario is that a package patches the configure
script, but that the corresponding configure.in contains shell code that
is not portable.  In cases like these, configure.in is typically not used
during the build, therefore there is no need to check it for portability.

This also applies to all other combinations where a file is patched and
the corresponding file.in contains unportable shell code.
2020-05-04 21:32:48 +00:00
rillig
ff016ffa31 mk/help: do not treat continuation lines as textual comments 2020-05-03 09:51:07 +00:00
rillig
4e2bff9c98 mk/help: only list help topics that have associated keywords 2020-05-03 08:49:16 +00:00
rillig
16f52645ce regress/infra-unittests: demonstrate wrong help topics without keywords 2020-05-03 08:42:22 +00:00
rillig
f7a84dcc8b regress/infra-unittests: add more tests for subst.mk
Having quotes around the sed commands does not change their meaning.
These quotes must not lead to syntax errors when parsing the shell
command.  This happened in mk/subst.mk r1.91 because the double quote was
accidentally escaped.
2020-05-02 06:48:59 +00:00
rillig
ad23776a43 mk/subst.mk: fix shell parse error for special sed expressions
The escaping inside the backticks had been wrong.  Because of this,
parentheses and semicolons were interpreted as shell syntax.

Switching to $(...) command substitution removes the need for quoting
some of the characters and makes the whole command simpler to understand.
Doing the escaping for the backticks command properly would have involved
lots of special cases.

The $(...) command substitution was used sparingly in pkgsrc up to now
because some older or broken shells do not support it.  Since these
shells do not end up as the shell that runs the commands from Makefiles,
that's not a problem.
2020-05-02 05:52:09 +00:00
rillig
b51e961dae mk/subst.mk: fix typo in diagnostic 2020-05-01 19:53:48 +00:00
rillig
b3df1a4978 regress/infra-unittests: fix syntax error in test.subr
ShellCheck complained about a parse error in the empty functions, which
agrees with the shell grammar given in IEEE 1003.1, both the 2004 Edition
and the 2018 Edition.
2020-05-01 14:14:12 +00:00
rillig
d834a09e98 mk/subst.mk: switch command substitution back to backticks
To work properly, the $(...) should have been $$(...).

In pkgsrc the command substitution is usually done via `backticks`, for
compatibility with /bin/sh from Solaris.  To fix the shell parse errors,
the special characters are properly escaped inside the command
substitution.
2020-05-01 06:42:32 +00:00
rillig
ac62ef6aaf mk/subst.mk: fix combination of SUBST_FILTER_CMD with SUBST_NOOP_OK=no
Since SUBST_FILTER_CMD is a shell command, it may contain arbitrary
characters.  The condition in mk/subst.mk that tested whether
SUBST_FILTER_CMD was the default filter command was evaluated at run
time.  In such an evaluation, the variables (lhs and rhs) are fully
expanded before parsing the condition.  This means that these variables
must not contain quotes or unquoted condition operators.

Exactly this situation came up in one of the regression tests.  The
quoted "0-9" was copied verbatimly into the condition, including the
quotes.  The resulting condition was:

	"tr -d "0-9"" == "LC_ALL=C /usr/bin/sed "

This produced a syntax error because of the left-hand side. Adding a :Q
modifier would have helped for the left-hand side, but this would have
been necessary for the right-hand side as well.  Since an empty SUBST_SED
is defined not to "contain only identity substitutions", the first
condition can simply be removed.

The whole condition in the shell program had not worked anyway since it
expanded to either "[ true ]" or to "[ false ]", and both of these
commands exited successfully.
2020-04-29 22:46:42 +00:00
rillig
4bafb8759a mk/subst.mk: allow identity substitutions in SUBST_NOOP_OK=no mode
There are several cases where patterns like s|man|${PKGMANDIR}| appear in
SUBST_SED.  Up to now, these had been categorized as no-ops and required
extra code to make the package build when SUBST_NOOP_OK was set to "no".

This was against the original intention of SUBST_NOOP_OK, which was to
find outdated substitution patterns that do not occur in SUBST_FILES
anymore, most often because the packages have been updated since.

The identity substitutions do appear in the files, they just don't change
them.  Typical cases are for PKGMANDIR, DEVOSSAUDIO, PREFIX, and these
variables may well be different in another pkgsrc setup.  These patterns
are therefore excluded from the SUBST_NOOP_OK check.
2020-04-29 18:33:56 +00:00
rillig
1a4cff42cf regress/infra-unittests: bring files into normal form 2020-04-26 12:46:33 +00:00
rillig
2efb021f39 regress/infra-unittests: add tests for patch(1) 2020-04-26 12:46:01 +00:00
rillig
6f096dea69 regress/infra-unittests: add test for subst.mk with unreadable file 2020-04-26 12:21:39 +00:00
rillig
5a278be828 mk/subst.mk: warn about all noop patterns before erroring out 2020-04-23 19:30:29 +00:00
rillig
aef7a2d723 mk/subst.mk: omit ./ for sanely named files, quote filename patterns 2020-04-23 19:16:49 +00:00
rillig
e5c5b9dd0c regress/infra-unittests: ensure that subst.mk preserves the x bit 2020-04-23 18:52:55 +00:00
rillig
bc31ec4ea6 regress/infra-unittests: add more tests for subst.mk 2020-04-23 18:30:37 +00:00
rillig
058d3e5132 mk/subst.mk: document that SUBST_VARS does not support dollar 2020-04-18 15:04:34 +00:00
rillig
434300ee2a regress/infra-unittests: remove accidental file copying 2020-04-18 14:06:06 +00:00
rillig
2bacc5cd9b mk/subst.mk: make error message for filename pattern easier readable 2020-04-18 12:59:42 +00:00
rillig
2a5426f9ce mk/subst.mk: avoid undefined behavior in regular expressions
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
says in section 9.3.2 BRE Ordinary Characters that only very few
characters may be preceded with a backslash.

As a side effect, this change allows parentheses in the variable names
listed in SUBST_VARS (even if that will never happen in practice).

The reason that the regression test had not replaced VAR.[] before was
simply that this variable had not been listed in SUBST_VARS.
2020-04-18 12:21:10 +00:00
rillig
c7a475a5e0 regress/infra-unittests: add example tests for mk/help/help.awk
There are many more scenarios that need test cases, but this is a start.
2020-03-30 06:40:53 +00:00
rillig
5ae9338639 regress/infra-unittests: add test for SUBST_FILES without effect 2020-03-28 12:08:28 +00:00
rillig
b17ebc4cec regress/infra-unittests: rewrite documentation, adjust code a little
The documentation now starts with a high-level introduction instead of
listing only the details.

The name of the function test_file had to be changed since the old name
was not expressive enough. Same for the variable real_pkgsrcdir.
2020-03-27 22:56:29 +00:00