You have a single quoted string containing a backslash followed by a
linefeed (newline). Unlike double quotes or unquoted strings, this has
no special meaning. The string will contain a literal backslash and a
linefeed.
If you wanted to break the line but not add a linefeed to the string,
stop the single quote, break the line, and reopen it.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
Since files and arguments are strings passed the same way, programs
can't properly determine which is which, and rely on dashes to determine
what's what.
A file named -f (touch -- -f) will not be deleted by the problematic
code. It will instead be interpreted as a command line option, and rm
will even report success.
Using ./* will instead cause the glob to be expanded into ./-f, which no
program will treat as an option.
It is not possible to use `-f *` because -f only forces the next
argument to be a directory, a later directory named -delete would mess
things up.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
By default, read will interpret backslashes before spaces and line
feeds, and otherwise strip them. This is rarely expected or desired.
Normally you just want to read data, which is what read -r does. You
should always use -r unless you have a good reason not to.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
It's common to use A && B to run B when A is true, and A || C to run C
when A is false.
However, combining them into A && B || C is not the same as if A then B
else C.
In this case, if A is true but B is false, C will run.
If an if clause is used instead, this problem is avoided.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
When command expansions are unquoted, word splitting and globbing will
occur. This often manifests itself by breaking when filenames contain
spaces.
Trying to fix it by adding quotes or escapes to the data will not work.
Instead, quote the command substitution itself.
If the command substitution outputs multiple pieces of data, use a loop
instead.
Add an exception when using set -- where splitting is intended.
PR: 227109
Submitted by: mat
Exp-run by: antoine
Sponsored by: Absolight
Backtick command substitution `STATEMENT` is legacy syntax with several
issues.
- It has a series of undefined behaviors related to quoting in POSIX.
- It imposes a custom escaping mode with surprising results.
- It's exceptionally hard to nest.
$(STATEMENT) command substitution has none of these problems, and is
therefore strongly encouraged.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
In the original code, the return value of mycmd is ignored, and export
will instead always return true. This may prevent conditionals, set -e
and traps from working correctly.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
cd can fail for a variety of reasons: misspelled paths, missing
directories, missing permissions, broken symlinks and more.
If/when it does, the script will keep going and do all its operations in
the wrong directory. This can be messy, especially if the operations
involve creating or deleting a lot of files.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
ShellCheck has noticed that you reference a variable that is not
assigned in the script, which has a name remarkably similar to one that
is explicitly assigned. You should verify that the variable name is
spelled correctly.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
ShellCheck has detected that you have a command that just consists of a
command substitution.
This is typically done in order to try to get the shell to execute a
command, because $(..) does indeed execute commands. However, it's also
replaced by the output of that command.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
export takes a variable name, but shellcheck has noticed that you give
it an expanded variable instead. The problematic code does not export
MYVAR but a variable called foo if any.
Add exception when using indirections where the variable to extract is
actually the value of the variable.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
You have specified multiple patterns in a case statement, where one will
always override the other. The pattern being overridden is indicated
with a SC2222 warning.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
Double quotes around $@ prevents globbing and word splitting of
individual elements, while still expanding to multiple separate
arguments.
Add exceptions when splitting is the intended behavior.
PR: 227109
Submitted by: mat
Sponsored by: Absolight
The behavior when concatenating a string and array is rarely intended.
The preceeding string is prefixed to the first array element, while the
succeeding string is appended to the last one. The middle array elements
are unaffected.
For example, with the parameters foo,bar,baz, "--flag=$@" is equivalent
to the three arguments "--flag=foo" "bar" "baz".
PR: 227109
Submitted by: mat
Sponsored by: Absolight
'strip -x', and splitting out debug symbols with objcopy, will leave
a .symtab section but will still remove the .debug_info section. file(1)
shows this distinction as well after the use of 'strip -x':
work/tcl8.7a1/unix/libtcl8.7.so: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, with debug_info, not stripped
work/stage/usr/local/lib/libtcl8.7.so: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, not stripped
This fixes false-positives when using install-strip and symbol splitting.
With hat: portmgr
This only handles the default CC=cc but is enough to significantly improve
INDEX/Poudriere ports var gathering due to reducing around a dozen cc
fork+exec for every port that all have the same result. These values
are reused during the port build as well which reduces more fork+exec
contention there.
Approved by: portmgr (implicit)
This will avoid renamed/removed variables being orphaned, and allows for
exporting variables in ports_env that are not wanted to be exported in
sub-makes via _EXPORTED_VARS.
Approved by: portmgr (implicit)
Rather than replacing patches that are effectively the same but with
different timestamps, drop the new version and let the old version remain in
place. This yields a `make makepatch` that doesn't try and produce unwanted
churn.
Approved by: portmgr (mat)
Differential Revision: https://reviews.freebsd.org/D13960
This checks whether rubygem based ports have all of their dependencies
in Gemfile(s) satisfied by what's currently installed. Sample output:
====> Running Q/A tests (stage-qa)
Warning: Dependencies defined in /usr/ports/www/gitlab/work/stage/usr/local/www/gitlab/Gemfile are not satisfied
These ports could (!) be broken at runtime. Be aware: some projects
defines multiple Gemfiles and not all are used at runtime. For example
www/gitlab has two Gemfiles, but only one is used for testing and warnings
about it can be ignored.
Approved by: portmgr (mat), lifanov
Differential Revision: https://reviews.freebsd.org/D11865
Currently, only python shebangs (e.g. /bin/python, /usr/local/bin/python,
/usr/bin/env python etc.) are reported by stage Q/A and fixed by
USES=shebangfix. We need to do the same for python[23] as well.
Before the problem was not noticeable since many ports had e.g.
USES=python:2, which added a dependency on python2 metaport, however
that's going to switch to USES=python:2.7, and neither it, nor more
widely used USES=python adds a dependency on metaports, so there's
very high probability that python[23] links are not available.
Approved by: portmgr (mat)
Differential Revision: https://reviews.freebsd.org/D13571
This would have given an error when:
- The port uses DIST_SUBDIR
- That sub-directory does not exist
- The current user does not have permission to write in DISTDIR.
Something like:
$ sudo rmdir /usr/ports/distfiles/gallery2
$ make fetch-urlall-list
mkdir: /usr/ports/distfiles/gallery2: Permission denied
*** Error code 1
PR: 222819
Reported by: sunpoet
Sponsored by: Absolight
- Pass MAKEFLAGS down into do-depends properly.
- Remove redundant dependencies, run-depends and lib-depends, from
targets that already depend on earlier targets that depend on
the needed targets.
Reported by: emaste
With hat: portmgr
- Enable FLAVORS.
- Make make describe flavors aware.
- Add a qa check for unique package names amongst flavors.
- Make MOVEDlint understand flavors.
- Add a bit of sanity check to make sure FLAVORS stay lowercase.
- Various fixes.
Reviewed by: portmgr
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D12577
part of USE_QT5, since all of those suggestions are wrong.
Approved by: rakuco (mentor), tcberner (mentor), portmgr (mat)
Differential Revision: https://reviews.freebsd.org/D12526
**Do not start migrating any ports, a hook will prevent it**
This has been a long awaiting feature, most of the work has been done by
bapt, bdrewery and antoine, I am just the one actually doing the commit.
All this informations, and more to come are in the first link to our wiki
in the bottom block. A roadmap is in the second link.
To define a different flavors in a port, before any include, set:
FLAVORS= flavor1 flavor2 [...]
The first flavor in the list will be the default.
You can then check for flavors after includ'ing bsd.port.options.mk with:
.if ${FLAVOR} == flavor2
[some stuff]
.endif
To build flavor2, simply run:
make FLAVOR=flavor2
To depend on a specific flavor, write @<flavor> at the end of the depend
string, like:
RUN_DEPENDS= something:origin@foo
Submitted by: bapt, bdrewery, antoine
Reviewed by: portmgr
More infos: https://wiki.freebsd.org/Ports/FlavorsMigration
Todo List: https://wiki.freebsd.org/Ports/FlavorsAndSubPackages
With hat: portmgr
Differential Revision: https://reviews.freebsd.org/D10327
* Once upon a time, we checked all of STAGEDIR/PREFIX's executable
files.
* We then decided too many false positives were found, so we switched to
only checking executable files in bin/sbin/libexec/www, and also
symlinks that were in there.
* And then, we decided to go back to check all of STAGEDIR/PREFIX's
executable files, but forgot to remove the checks for symlinks (which
are now useless because we already check all the executable files.)
Reported by: lifanov
Sponsored by: Absolight
This checks whether rubygem ports have all of their dependencies
in gemspec satisfied by what's currently installed. Sample output:
====> Running Q/A tests (stage-qa)
Error: RubyGem dependency archive-tar-minitar = 0.5.2 is not satisfied.
*** Error code 1
Stop.
make: stopped in /usr/home/lifanov/src/svn/freebsd/ports/head/archivers/rubygem-fpm
These ports would be broken at runtime.
Big thanks to:
swills - discussion
mat - reviews
antoine - exp runs
sunpoet - fixing several dozens of ports :)
PR: 220605
Reviewed by: mat, sunpoet
Approved by: portmgr (mat)
Differential Revision: https://reviews.freebsd.org/D11841