Re: pkg-2.4.1 broken?

Jan Henrik Sylvester <[email protected]>
Newsgroups gmane.os.freebsd.devel.ports
Message-ID <[email protected]>
On 11/5/25 3:33 PM, Stefan Esser wrote:
> Am 05.11.25 um 12:35 schrieb Jan Henrik Sylvester:
>> I do not think so. Line 3913 and following of portmaster explicitly 
>> removes / usr/local/lib/compat/pkg (in many cases):
>>
>> [ -z "$temp" ] && temp=`find $LOCALBASE_COMPAT -type d -empty 2>/dev/ 
>> null`
>> if pm_isdir "$temp"; then
>>      pm_sv Deleting the empty $LOCALBASE_COMPAT
>>      pm_rmdir_s $temp
>> fi
>> unset temp
> 
> I have no idea why this was added by the original author, but I'm going
> to remove that section. In fact /usr/local/lib/compat/pkg is neither
> defined in the base system's mtree files, nor included anywhere in the
> *.mk files, except for

I remember that it was just a convention of different tools like 
portmaster before pkgng was a thing and that it was created by these 
tools and not by the port system itself, but I may be wrong.

Now it is created by @dir lib/compat/pkg in 
/usr/ports/ports-mgmt/pkg/pkg-plist and it should not be deleted by 
anything else.

That is the reason for:

# rmdir /usr/local/lib/compat/pkg
# pkg create pkg
Creating package for pkg-2.4.1
pkg: dir '/usr/local/lib/compat/pkg' is missing
pkg: package creation failed

Of course, running portmaster and then 'pkg create pkg' can have the 
same effect (maybe depending on the flags of portmaster).

> But the OP did have "pkg" not "pkg-static" in the posted log message,
> which seems to indicate that it was actually output from "make package",
> and that command makes pkg build the package from the contents of the
> work/stage directory only, with no regard to the presence of compat/pkg
> on the base system.

I did say that I used 'pkg create pkg-2.4.1' after upgrading pkg from 
2.3.1_1 to 2.4.1 using portmaster.

> There shouldn't be any directories below compat/pkg, and therefore a
> depth check would not make a difference.

That is why I said 'probably' and 'I should stop looking'. There should 
not be a subdirectory, but if there is one, it will be deleted, but if 
there are two on the same level, they will not be deleted. Really weird 
behavior. And if you start looking for the same construct in other 
places in portmaster, some have depth (the version that is incompatible 
with for example GNU find), some have mindepth and maxdepth, and some 
have none. I am not sure if all of them are on purpose. For example, 
line 1779 looks dangerous too me. I would never write it like that, but 
maybe it is fine. In line 3897, the whole mechanism fails if there is an 
empty subdirectory, but at least it checks if $LOCALBASE_COMPAT is a 
directory, not if $temp is one like in line 3913. There are so many 
places that you really have to look hard to understand if they are 
'safe'. That is mixed with code that simply cannot work, but does no 
harm like pm_sv I mentioned, which was probably meant to be used for 
verbose messages concerning non root use, but is used for extra verbose 
messages.

I have been using portmaster for many years and it still works well for 
some tasks, but I do not think anyone will put in the effort to clean it 
up and really fix it. Thank you for trying to keep it usable.

Best,
Jan Henrik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.