Bug 230287 - Mk/Uses/perl5.mk: Check existence of directory before "find" command usage for this directory
Summary: Mk/Uses/perl5.mk: Check existence of directory before "find" command usage fo...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-08-02 06:15 UTC by lightside
Modified: 2018-08-02 08:39 UTC (History)
6 users (show)

See Also:


Attachments
Proposed patch (since 473539 revision) (720 bytes, patch)
2018-08-02 06:15 UTC, lightside
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lightside 2018-08-02 06:15:58 UTC
Created attachment 195755 [details]
Proposed patch (since 473539 revision)

Hello.

I noticed, that some ports, which have USES+=perl5 (and USE_PERL5=build), started to report about non existing "<..>/work/stage/usr/local/lib/perl5/site_perl" directory, when using some "find" command.
For example, x11-servers/xorg-server port:
-8<--
# cd /usr/ports/x11-servers/xorg-server
# make stage
<..>
find: /usr/ports/x11-servers/xorg-server/work/stage/usr/local/lib/perl5/site_perl: No such file or directory
install  -s -m 0644 /usr/ports/x11-servers/xorg-server/work/xorg-server-1.18.4/hw/xfree86/dixmods/.libs/libglx.so  /usr/ports/x11-servers/xorg-server/work/stage/usr/local/lib/xorg/modules/extensions/.xorg/
<..>
# make clean
===>  Cleaning for xorg-server-1.18.4_9,1
-->8-

ftp/wget port:
-8<--
# cd /usr/ports/ftp/wget
# make stage
<..>
Making install in testenv
find: /usr/ports/wget/work/stage/usr/local/lib/perl5/site_perl: No such file or directory
====> Compressing man pages (compress-man)
<..>
# make clean
===>  Cleaning for wget-1.19.5
-->8-

I found, that this is because of ports r473539 changes, which added removal of README.pod files, if they exists in "${STAGEDIR}${PREFIX}/${SITE_PERL_REL}" directory.

I propose to add some check for "${STAGEDIR}${PREFIX}/${SITE_PERL_REL}" directory before find command usage for this directory:
-8<--
@[ -d "${STAGEDIR}${PREFIX}/${SITE_PERL_REL}" ] && \
	${FIND} ${STAGEDIR}${PREFIX}/${SITE_PERL_REL} -name README.pod -delete || :
-->8-

Similar to what was used for "${STAGEDIR}${SITE_MAN3}" directory:
https://svnweb.freebsd.org/ports/head/Mk/Uses/perl5.mk?view=markup&pathrev=473539#l306
-8<--
@[ -d "${STAGEDIR}${SITE_MAN3}" ] && \
	${FIND} ${STAGEDIR}${SITE_MAN3} -name '*::README.3' -delete || :
-->8-

How to check:
% [ -d "/usr/ports" ] && echo exists || echo not exists
exists
% find /usr/ports -maxdepth 1 -name Makefile
/usr/ports/Makefile
% cd /usr/ports && find * -maxdepth 0 -name Makefile
Makefile
% [ -d "/usr/ports/nonexistent" ] && echo exists || echo not exists
not exists
% find /usr/ports/nonexistent -maxdepth 1 -name Makefile
find: /usr/ports/nonexistent: No such file or directory
% [ -d "/usr/ports/nonexistent" ] && find /usr/ports/nonexistent -maxdepth 1 -name Makefile

Also possible to redirect message about non-existing directory to /dev/null:
% sh -c "find /usr/ports/nonexistent -maxdepth 1 -name Makefile 2>/dev/null"
% sh -c "cd /usr/ports/nonexistent 2>/dev/null && find * -maxdepth 0 -name Makefile"

CC: mat@
Comment 1 lightside 2018-08-02 06:21:28 UTC
Not related:
I didn't find "Ports Framework" component, when submitting bug report to "Ports & Packages". But was able to change it after submit.
Sorry about possible not related CC (or it was automatic, except mat@ and perl@).
Comment 2 Mathieu Arnold freebsd_committer freebsd_triage 2018-08-02 07:18:12 UTC
I've had this review opened for a while https://reviews.freebsd.org/D16440 because someone reported this a week ago, they never told me if it fixed the problem. If it does, please do tell and I'll commit it.
Comment 3 lightside 2018-08-02 08:19:54 UTC
(In reply to comment #2)
> I've had this review opened for a while https://reviews.freebsd.org/D16440
> because someone reported this a week ago, they never told me if it fixed
> the problem.
Looks like, we proposed identical patches, while you did it about a week ago. I didn't check FreeBSD differential revisions for this issue before this PR. Thanks for noticing about this.

(In reply to comment #2)
> If it does, please do tell and I'll commit it.
If apply patch, then in case of mentioned ports (ftp/wget, x11-servers/xorg-server, etc.), it doesn't report message about "find: <..>/work/stage/usr/local/lib/perl5/site_perl: No such file or directory".
Comment 4 lightside 2018-08-02 08:22:29 UTC
Comment on attachment 195755 [details]
Proposed patch (since 473539 revision)

Obsoleted patch, because of duplicate of review D16440.
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-08-02 08:36:09 UTC
A commit references this bug:

Author: mat
Date: Thu Aug  2 08:35:11 UTC 2018
New revision: 476224
URL: https://svnweb.freebsd.org/changeset/ports/476224

Log:
  Fix spurious errors.

  PR:		230287
  Sponsored by:	Absolight
  Differential Revision:	https://reviews.freebsd.org/D16440

Changes:
  head/Mk/Uses/perl5.mk
Comment 6 commit-hook freebsd_committer freebsd_triage 2018-08-02 08:39:14 UTC
A commit references this bug:

Author: mat
Date: Thu Aug  2 08:38:38 UTC 2018
New revision: 476225
URL: https://svnweb.freebsd.org/changeset/ports/476225

Log:
  MFH: r476224

  Fix spurious errors.

  PR:		230287
  Sponsored by:	Absolight
  Differential Revision:	https://reviews.freebsd.org/D16440

Changes:
_U  branches/2018Q3/
  branches/2018Q3/Mk/Uses/perl5.mk