Bug 191055 - [build] [bsd.progs.mk] make install with bsd.progs.mk installs FILES/SCRIPTS multiple times if PROGS is specified
Summary: [build] [bsd.progs.mk] make install with bsd.progs.mk installs FILES/SCRIPTS ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Enji Cooper
URL:
Keywords:
: 191054 191955 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-06-15 08:01 UTC by Enji Cooper
Modified: 2015-09-23 23:22 UTC (History)
5 users (show)

See Also:


Attachments
Fix for bug 191054 and bug 191055 (1.29 KB, patch)
2014-07-02 23:26 UTC, Enji Cooper
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2014-06-15 08:01:45 UTC
If I specify PROGS and FILES/SCRIPTS, I've noticed that it installs files multiple times. It should only try to install FILES/SCRIPTS once.

I've provided an example below:

% uname -a
FreeBSD isilon-fuji-current.local 11.0-CURRENT FreeBSD 11.0-CURRENT #5 0d2be6b(isilon-atf): Sun Jun  8 21:34:32 PDT 2014     root@fuji-current.local:/usr/obj/usr/src/sys/FUJI  i386
% cat *
# Makefile
FILESDIR=/tmp/share

FILES=	c

BINDIR=	/tmp/bin

PROGS=	a b

MAN=

.include <bsd.progs.mk>
/* a.c */
#include <stdio.h>

int
main(void)
{

	printf("hello world!\n");
	return (0);
}
/* b.c */
#include <stdio.h>

int
main(void)
{

	printf("hello world!\n");
	return (0);
}
/* c */
This directory contains a simple C app that says, "hello world!"
% make install
install -o root -g wheel  -m 444 c /tmp/share
(cd /root/make_install_installs_files_multiple_times && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=a  install)
install -s -o root -g wheel -m 555   a /tmp/bin/a
install -o root -g wheel  -m 444 c /tmp/share
(cd /root/make_install_installs_files_multiple_times && make -f Makefile _RECURSING_PROGS=  SUBDIR= PROG=b  install)
install -s -o root -g wheel -m 555   b /tmp/bin/b
install -o root -g wheel  -m 444 c /tmp/share
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2014-06-26 02:15:47 UTC
refine summary.
Comment 2 Enji Cooper freebsd_committer freebsd_triage 2014-07-02 23:26:42 UTC
Created attachment 144354 [details]
Fix for bug 191054 and bug 191055

The attached patch improves the status quo a bit. It doesn't fix installing everything multiple times, but it does fix installing SCRIPTS multiple times.

Sponsored-by: EMC / Isilon Storage Division
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2014-07-02 23:47:21 UTC
(In reply to yaneurabeya from comment #2)
> Created attachment 144354 [details]
> Fix for bug 191054 and bug 191055
> 
> The attached patch improves the status quo a bit. It doesn't fix installing
> everything multiple times, but it does fix installing SCRIPTS multiple times.

In all actuality, I meant "building, installing, cleaning".
 
> Sponsored-by: EMC / Isilon Storage Division
Comment 4 Julio Merino,+1 347 694 0576,New York City freebsd_committer freebsd_triage 2014-07-25 02:32:07 UTC
*** Bug 191054 has been marked as a duplicate of this bug. ***
Comment 5 Julio Merino,+1 347 694 0576,New York City freebsd_committer freebsd_triage 2014-07-25 02:37:44 UTC
I think the patch looks reasonable but I need to play with it a bit.  Build-testing now.
Comment 6 Ed Maste freebsd_committer freebsd_triage 2014-09-05 16:58:03 UTC
This issue breaks -DNO_ROOT installs -- see bug 191955
Comment 7 Julio Merino,+1 347 694 0576,New York City freebsd_committer freebsd_triage 2014-09-08 13:07:53 UTC
Oh wow.  I started looking at this a month and a half ago already and never got back to it.  Time flies.

Garrett, now that you are a committer, can you take care of your own patch? :-)

As mentioned, the patch looks good to me.  Needs testing with "make tinderbox" and also with -DNO_ROOT as apparently that's broken because of this change too.
Comment 8 Enji Cooper freebsd_committer freebsd_triage 2014-09-24 04:44:15 UTC
*** Bug 191955 has been marked as a duplicate of this bug. ***
Comment 9 Enji Cooper freebsd_committer freebsd_triage 2014-09-24 04:47:08 UTC
Fixed in r272055. Awaiting MFC timeout.
Comment 10 Enji Cooper freebsd_committer freebsd_triage 2014-10-23 00:53:38 UTC
This hasn't been fully resolved. Reopening this bug.
Comment 11 Enji Cooper freebsd_committer freebsd_triage 2014-10-23 00:54:12 UTC
*** Bug 191955 has been marked as a duplicate of this bug. ***
Comment 12 commit-hook freebsd_committer freebsd_triage 2015-09-23 23:21:21 UTC
A commit references this bug:

Author: bdrewery
Date: Wed Sep 23 23:20:51 UTC 2015
New revision: 288158
URL: https://svnweb.freebsd.org/changeset/base/288158

Log:
  Fix most cases of bsd.progs.mk running duplicate or missing commands.

  This mostly fixes an interaction with bsd.test.mk with PROGS and SCRIPTS.
  This was most notable with 'make clean' and 'make install', which r281055
  and r272055 attempted to address but were inadequate.

  It also addresses similar issues in bsd.progs.mk when not using bsd.test.mk.

  This also fixes cases of NOT running commands in the parent when using
  bsd.progs.mk:
    - 'make clean' was not run for the main process for Makefiles which had both
      FILES and SUBDIR but no PROGS or SCRIPTS.  This usually was just a
      leftover Kyuafile.auto.  One such example is usr.bin/bmake/tests/sysmk/t1/2.
    - 'make obj' was not running in the current directory with bsd.test.mk due
      to early inclusion of bsd.subdir.mk.  This was not really a problem due to
      the SUBDIRS using 'mkdir -p' for their objdirs.

  There were subtle bugs causing this wrong behavior:
    1. bsd.progs.mk needs to set SCRIPTS to empty when recursing to avoid
       the sub-makes from installing, cleaning or building the SCRIPTS;
       only the parent make should be doing this.  r281055 effectively did
       the same but wasn't enough.
    2. CLEANFILES may contain (especially from *.test.mk) files which only
       the parent should clean, such as from FILES and SCRIPTS.  To resolve
       sub-makes also cleaning these, reset CLEANFILES and CLEANDIRS in the
       children before including bsd.prog.mk.  A tempting alternative would be
       to only handle CLEANFILES in the parent but then the child bsd.prog.mk
       CLEANFILES of per-PROGS wouldn't be setup.
    3. bsd.subdir.mk was included too soon in bsd.test.mk.  It needs to be
       included after bsd.prog.mk as the SCRIPTS logic is short-circuitted if
       'install:' is already defined (which bsd.subdir.mk does).  There is
       actually no need to include bsd.subdir.mk from bsd.test.mk as bsd.prog.mk
       and bsd.obj.mk will do so in the proper order.  The description in r257095
       covers this for FILES and was fixed differently, though changing the
       handling of target(install) in bsd.prog.mk may make sense after more
       research.
    4. bsd.progs.mk had extra logic to handle recursing SCRIPTS if PROGS was
       empty, which isn't its business to be doing.  SCRIPTS is handled fine
       by bsd.prog.mk.  This mostly reverts and reworks the fix in r259209 and
       partially reverts r272055.
    5. bsd.progs.mk has no need to depend 'all:' on SCRIPTS and FILES.  These
       are handled by bsd.prog.mk/bsd.files.mk fine.  This also partially reverts
       r272055.
    6. bsd.progs.mk was not drop-in safe for bsd.prog.mk.  Move the PROGS
       check from r273186 to allow it to be used safely.

  Specific tested cases:
    SCRIPTS:no PROGS:no FILES:yes SUBDIR:yes
      usr.bin/bmake/tests/sysmk/t1/2

    SCRIPTS:yes PROGS:no FILES:yes SUBDIR:no
      usr.bin/bmake/tests/sysmk/t1/2/1

    SCRIPTS:yes PROGS:yes FILES:yes SUBDIR:yes
      lib/libthr/tests

    SCRIPTS:yes PROGS:no FILES:yes SUBDIR:no
      usr.bin/yacc/tests
      libexec/atf/atf-sh/tests

  A full buildworld/installworld/clean comparison with mtree was also done.
  The only relevant difference was the new fixed behavior of removing
  Kyuafile.auto from the objdir in 'clean'.

  Converting SCRIPTS to be a special case FILES group will make this less
  fragile and is being explored.

  One known remaining issue is 'cleandepend' removing the tags files for
  every recursive call.

  Note that the 'make clean' command runs for the CURDIR last, which can make
  it appear to run multiple times when cleaning in tests/, but each command is
  for a SUBDIR returning up the chain.  This is purely bsd.subdir.mk behavior.

  PR:		191055
  PR:		191955
  MFC after:	2 weeks
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  head/share/mk/bsd.prog.mk
  head/share/mk/bsd.progs.mk
  head/share/mk/bsd.test.mk
Comment 13 Bryan Drewery freebsd_committer freebsd_triage 2015-09-23 23:22:25 UTC
This should be fixed now.