Re: why does "make delete-old" not delete some directories?

From: Herbert J. Skuhra <herbert_at_gojira.at>
Date: Fri, 08 Apr 2022 11:57:57 UTC
On Thu, 07 Apr 2022 19:46:03 +0200, tech-lists wrote:
> 
> Hi,
> 
> Why does 'make delete-old' seemingly fail with some dirs and not
> others? 
> context is earlier stable/13 updated to stable/13 as of a few minutes
> ago.
> 
> root@redacted:/usr/src # yes | make delete-old
> 
> [...]
> rmdir: /usr/lib/debug/usr/lib/i18n: Directory not empty
> /usr/lib/debug/usr/lib/flua
> /usr/lib/debug/usr/lib/engines
> rmdir: /usr/lib/debug/usr/lib/clang/13.0.0/lib/freebsd: Directory not empty
> rmdir: /usr/lib/debug/usr/lib/clang/13.0.0/lib: Directory not empty
> rmdir: /usr/lib/debug/usr/lib/clang/13.0.0: Directory not empty
> rmdir: /usr/lib/debug/usr/lib/clang: Directory not empty
> rmdir: /usr/lib/debug/usr/lib: Directory not empty
> /usr/lib/debug/usr/bin
> rmdir: /usr/lib/debug/usr: Directory not empty
> /usr/lib/debug/sbin
> /usr/lib/debug/libexec
> /usr/lib/debug/lib/nvmecontrol
> /usr/lib/debug/lib/geom
> rmdir: /usr/lib/debug/lib/casper: Directory not empty
> rmdir: /usr/lib/debug/lib: Directory not empty
> rmdir: /usr/lib/debug/boot: Directory not empty
> /usr/lib/debug/bin
> [...]
> 
> root@redacted:/usr/src # file /usr/lib/debug/usr/lib/clang/13.0.0/lib/freebsd
> /usr/lib/debug/usr/lib/clang/13.0.0/lib/freebsd: directory

On my main and stable/13 systems after running make delete-old(-libs)
I have only the following leftovers:

% find /usr/lib/debug
/usr/lib/debug
/usr/lib/debug/boot
/usr/lib/debug/boot/kernel
/usr/lib/debug/boot/modules

Because of /usr/src/tools/build/mk/OptionalObsoleteFiles.inc:

   1646 .if ${MK_DEBUG_FILES} == no
   1647 .if exists(${DESTDIR}/usr/lib/debug)
   1648 DEBUG_DIRS!=find ${DESTDIR}/usr/lib/debug -mindepth 1 \
   1649     -type d \! -path "${DESTDIR}/usr/lib/debug/boot/*" \
   1650     | sed -e 's,^${DESTDIR}/,,'; echo
   1651 DEBUG_FILES!=find ${DESTDIR}/usr/lib/debug \
   1652     \! -type d \! -path "${DESTDIR}/usr/lib/debug/boot/*" \! -name "lib*.so*" \
   1653     | sed -e 's,^${DESTDIR}/,,'; echo
   1654 DEBUG_LIBS!=find ${DESTDIR}/usr/lib/debug \! -type d -name "lib*.so*" \
   1655     | sed -e 's,^${DESTDIR}/,,'; echo
   1656 OLD_DIRS+=${DEBUG_DIRS}
   1657 OLD_FILES+=${DEBUG_FILES}
   1658 OLD_LIBS+=${DEBUG_LIBS}
   1659 .endif
   1660 .endif

--
Herbert