[Bug 267364] "make install" target does not fail if dependency "fake-pkg" fails

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 26 Oct 2022 13:40:17 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267364

            Bug ID: 267364
           Summary: "make install" target does not fail if dependency
                    "fake-pkg" fails
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: garga@FreeBSD.org
          Reporter: michael.osipov@siemens.com
          Assignee: garga@FreeBSD.org
             Flags: maintainer-feedback?(garga@FreeBSD.org)

This can be reproduced on 12-STABLE and 13-STABLE. Consider the following
correct behavior with pkg (prod host):
=================
root@deblndw011x:~
# uname -a
FreeBSD deblndw011x.ad001.siemens.net 12.3-STABLE FreeBSD 12.3-STABLE 53bc9be1c
GENERIC  amd64
root@deblndw011x:~
# pkg upgrade git
Updating ldadw-base repository catalogue...
ldadw-base repository is up to date.
All repositories are up to date.
pkg: websvn-php74 has a missing dependency: php74-pear-Text_Diff
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
        git: 2.37.3 -> 2.38.1_1

Number of packages to be upgraded: 1

The process will require 3 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Upgrading git from 2.37.3 to 2.38.1_1...
===> Creating groups.
Using existing group 'git_daemon'.
===> Creating users
Creating user 'git_daemon' with uid '964'.
pw: uid `964' has already been allocated
pkg: PRE-INSTALL script failed
root@deblndw011x:~
# echo $?
3
=================

"pkg upgrade" fails here since the create users pre-install scripts fails. The
reason is that my passwd uses NIS with "+:*:::::" where, for historical
reasons, the regular users have been created with id below 1000. (This I can't
change for the moment, but simply depicts the bug):
=================
# id 964
uid=964(krenek_k) gid=121(cad) groups=121(cad),305(svn5)
=================

So pkg does the right here, it spawns the "sh -c .." process and this line
fails:
"${PW} useradd git_daemon -u 964 -g 964  -c "git daemon" -d /nonexistent -s
/usr/sbin/nologin" (checked libpkg and pkg source)

Now when running in the ports dir "make -d A install" gives me:
=================
...
221452 + /usr/bin/env 'PORTSDIR=/usr/ports' 'FORCE_POST='
/usr/local/sbin/pkg-static register -i /usr/ports/devel/git/work-default/stage
-m /usr/ports/devel/git/work-default/.metadir -f
/usr/ports/devel/git/work-default/.PLIST.mktmp
221453 Installing git-2.38.1_1...
221454 ===> Creating groups.
221455 Using existing group 'git_daemon'.
221456 ===> Creating users
221457 Creating user 'git_daemon' with uid '964'.
221458 pw: uid `964' has already been allocated
221459 pkg-static: PRE-INSTALL script failed
221460 If you installed the GITWEB option please follow these instructions:
...
=================

Internally "fake-pkg" is invoked by "install" target. The exit code is ignored
from pkg-static, but pkg-static does properly fail (test host):
=================
root@deblndw013x1v:/usr/ports/devel/git
# uname -a
FreeBSD deblndw013x1v.ad001.siemens.net 13.1-STABLE FreeBSD 13.1-STABLE #16
ebaebf5b0: Sat Sep 17 10:55:01 CEST 2022    
root@deblndw013x1v.ad001.siemens.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
amd64
root@deblndw013x1v:/usr/ports/devel/git
# /usr/local/sbin/pkg-static register -i
/usr/ports/devel/git/work-default/stage -m
/usr/ports/devel/git/work-default/.metadir -f
/usr/ports/devel/git/work-default/.PLIST.mktmp
root@deblndw013x1v:/usr/ports/devel/git
# echo $?
1
=================

Surprisingly when "make fake-pkg" is invoked manually it does properly fail:
=================
root@deblndw013x1v:/usr/ports/devel/git
# make create-manifest
root@deblndw013x1v:/usr/ports/devel/git
# make fake-pkg
===>   Registering installation for git-2.38.1_1
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/git
================

with "-d A":
================
Result of ${.MAKE.EXPORTED:u} is "LANG LC_ALL META_MODE"
+ /usr/bin/env 'PORTSDIR=/usr/ports' 'FORCE_POST=' /usr/local/sbin/pkg-static
register -i /usr/ports/devel/git/work-default/stage -m
/usr/ports/devel/git/work-default/.metadir -f
/usr/ports/devel/git/work-default/.PLIST.mktmp

*** Failed target:  fake-pkg
*** Failed command: /usr/bin/env PORTSDIR=/usr/ports FORCE_POST=""
/usr/local/sbin/pkg-static register -i /usr/ports/devel/git/work-default/stage
-m /usr/ports/devel/git/work-default/.metadir -f
/usr/ports/devel/git/work-default/.PLIST.mktmp
*** Error code 1
HashTable targets: size=128 numEntries=198 maxchain=5
HashTable Global variables: size=512 numEntries=1487 maxchain=9

Stop.
make: stopped in /usr/ports/devel/git
Global: .ERROR_TARGET = fake-pkg
Global:delete .ERROR_CMD (not found)
==============

While I don't understand fully why it fails, I am certain that the issue is in
"bsd.port.mk" lines 5321 to 5372 where the ${INSTALL_COOKIE} depends on
fake-pkg, but the build does not fail.

While I can work around this issue by adding the user manually, but this
depicts that there is clearly a bug in the framework. fake-pkg is supplied by
_INSTALL_SUSEQ.

-- 
You are receiving this mail because:
You are the assignee for the bug.