Page MenuHomeFreeBSD

Clean up all directories created by `make hier`

Authored by ngie on Dec 23 2018, 11:48 PM.



The logic I introduced in r322511 unfortunately left chflags schg'ed
directories behind created by make hier (in the stock /etc/mtree
files, this is limited to /var/empty).

The proposed change calls chflags -R 0 and rm -Rf ... to clean all
of the directories that could not be removed by ${MAKE} clean.
${MAKE} clean in calls cleandir/cleanobj, which handles
the first directory tree walk/removal.

Test Plan
$ sudo make check
rpc_test:get_svc_addr_tcp  ->  skipped: clnt_create (: RPC: Port mapper failure - RPC: Timed out)  [120.243s]
rpc_test:get_svc_addr_udp  ->  skipped: clnt_create (: RPC: Port mapper failure - RPC: Timed out)  [120.098s]
rpc_test:raw  ->  passed  [0.007s]
rpc_test:tcp  ->  skipped: Cannot create server 1  [0.028s]
rpc_test:tcp_poll  ->  skipped: Cannot create server 1  [0.017s]
rpc_test:udp  ->  skipped: Cannot create server 1  [0.006s]
rpc_test:udp_poll  ->  skipped: Cannot create server 1  [0.015s]
xdr_test:xdr  ->  passed  [0.004s]

Results file id is usr_obj_usr_src_amd64.amd64_lib_libc_tests_rpc_checkdir_usr_tests_lib_libc_rpc.20181223-233838-068392
Results saved to /root/.kyua/store/results.usr_obj_usr_src_amd64.amd64_lib_libc_tests_rpc_checkdir_usr_tests_lib_libc_rpc.20181223-233838-068392.db

8/8 passed (0 failed)
(cd /usr/src/lib/libc/tests/rpc &&  DEPENDFILE=.depend.rpc_test  NO_SUBDIR=1 make -f /usr/src/lib/libc/tests/rpc/Makefile _RECURSING_PROGS=t   PROG=rpc_test  clean)
rm -f  rpc_test.full.bc rpc_test.full.ll rpc_test rpc_test.bc rpc_test.ll rpc_test.full rpc_test.debug t_rpc.o t_rpc.bco t_rpc.llo
(cd /usr/src/lib/libc/tests/rpc &&  DEPENDFILE=.depend.xdr_test  NO_SUBDIR=1 make -f /usr/src/lib/libc/tests/rpc/Makefile _RECURSING_PROGS=t   PROG=xdr_test  clean)
rm -f  xdr_test.full.bc xdr_test.full.ll xdr_test xdr_test.bc xdr_test.ll xdr_test.full xdr_test.debug h_testbits_xdr.o t_xdr.o h_testbits_xdr.bco t_xdr.bco h_testbits_xdr.llo t_xdr.llo
rm -f h_testbits.h h_testbits.c h_testbits_xdr.c Kyuafile Kyuafile.tmp
rm -rf checkdir
rm: checkdir/var/empty: Operation not permitted
rm: checkdir/var: Directory not empty
rm: checkdir: Directory not empty
*** Error code 1 (ignored)
[ngie@pinklady-fbsd-current /usr/src/lib/libc/tests/rpc]$ ls `make check -VDESTDIR`
ls: /usr/obj/usr/src/amd64.amd64/lib/libc/tests/rpc/checkdir: No such file or directory

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

ngie created this revision.Dec 23 2018, 11:48 PM

If you tag the commit with rS Phab will make a link automatically: rS322511

123 ↗(On Diff #52269)

How many files do we expect in ${DESTDIR}?

Other chflags uses do a rm 2>/dev/null; chflags -R; rm dance to avoid a slow recursive chflags. Perhaps not necessary here.

jtl added a comment.Jan 11 2019, 7:30 PM

Since make clean runs first, I'm assuming the only things left will be things with flags set? If so, what you propose is probably correct (and we don't need the rm/chflags/rm "dance" optimization).

OTOH, if the overall number of files will be small, it might be better to run chflags before make clean and not do a special 'rm'.

Just my 2c.

ngie added inline comments.Jan 11 2019, 8:35 PM
123 ↗(On Diff #52269)

What @jtl said is correct. ${MAKE} clean effectively performs the rm -Rf dance. The second chflags -R 0/rm -Rf dance is to eliminate the remaining paths that were left behind, which with the stock mtree files is only 1 path:

$ grep -r schg /etc/mtree/
/etc/mtree/BSD.var.dist:    empty           mode=0555 flags=schg

I should be more explicit about that point in my commit message.

ngie edited the summary of this revision. (Show Details)Jan 12 2019, 2:07 AM
ngie marked an inline comment as done.
This revision was not accepted when it landed; it landed in state Needs Review.Feb 6 2019, 9:24 PM
This revision was automatically updated to reflect the committed changes.