Page MenuHomeFreeBSD

Add a USES_LOCAL to allow plugging into framework.
Needs ReviewPublic

Authored by bdrewery on Jan 9 2015, 9:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 22 2023, 11:29 PM
Unknown Object (File)
Nov 6 2023, 7:08 PM
Unknown Object (File)
Oct 24 2023, 9:27 AM
Unknown Object (File)
Jan 8 2023, 6:21 AM
Unknown Object (File)
Apr 13 2017, 10:05 AM
Unknown Object (File)
Dec 31 2016, 8:43 PM
Unknown Object (File)
Dec 23 2016, 6:42 AM
Unknown Object (File)
Oct 19 2016, 10:15 AM
Subscribers

Details

Reviewers
None
Group Reviewers
portmgr
Summary

USES_LOCAL will allow adding your own USES files that can be used
to add your own features. Primarily it is intended to be used from make.conf
to apply to all or a match subset of ports via ${CURDIR} checking. This is a
replacement for using bsd.port.local.mk as touching that file is problematic
due to it being tracked in the repository and can become quite polluted
depending on level of customization.

One such example of this is a custom hook I am using for work to remove manpages,
symbols and static libraries from plists. They are moved into a separate packaging
mechanism that we already had in place for such files. This broke when I moved
our build to a sandbox poudriere build.

Another example we've done at work is to designate certain ports as being part of
our SDK. If a port is part of the SDK it is installed into a different PREFIX,
with its own MTREE ran before install, and special handling of where some files
are installed such as pkgconfig files so they still go into LOCALBASE.

Having a USES_LOCAL makes it simpler to maintain customizations in the ports tree
without modifying various ports or the framework.

This also allows for "plugins" in Poudriere, which I am still experimenting
with. A plugin would be a collection of hooks and Uses.local files that are
synced into the ports tree before build. My reasoning for this is that I've
been writing hooks to do part of something that is also partially handled by
a checked in Mk/ file. Keeping them in the same location makes maintenance of them
simpler. Example implementation at https://github.com/bdrewery/poudriere-private/compare/release-3.1...plugins?expand=1

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bdrewery retitled this revision from to Add a USES_LOCAL to allow plugging into framework..
bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
bdrewery added a reviewer: portmgr.

Why not just reuse USES?
and just look on USES_DIR

.for f in ${USES}
.undef _use_found
.for u in ${USES_DIR_LOCAL_PRE} ${USESDIR} ${USES_DIR_LOCAL_POST}
.if exists(${u}/${f:C/\:.*//}.mk) && !defined(_use_found)
.include "${u}/${f:C/\:.*//}.mk"
_use_found=1
.endif
.endfor
.if !defined(_use_found)
IGNORE= Error: unkonwn ${f}
.endif
.endfor

multiple benifits here:
better error on unkown uses
ability to override a USES by creating your own in USES_DIR_LOCAL_PRE

In D1475#3, @bapt wrote:

Why not just reuse USES?
and just look on USES_DIR

.for f in ${USES}
.undef _use_found
.for u in ${USES_DIR_LOCAL_PRE} ${USESDIR} ${USES_DIR_LOCAL_POST}
.if exists(${u}/${f:C/\:.*//}.mk) && !defined(_use_found)
.include "${u}/${f:C/\:.*//}.mk"
_use_found=1
.endif
.endfor
.if !defined(_use_found)
IGNORE= Error: unkonwn ${f}
.endif
.endfor

multiple benifits here:
better error on unkown uses
ability to override a USES by creating your own in USES_DIR_LOCAL_PRE

You can't define or add to USES from make.conf with that method. Most port Makefiles use USES= rather than USES+=. So the alternative is placing your own USES+= in bsd.port.local.mk which defeats one of the goals.

Also from experience in merging Mk/ the past year into my work tree, Mk/Uses changes a lot. It's far less risk prone to have a separate directory for custom files to not accidentally lose one.

In D1475#5, @bdrewery wrote:
In D1475#3, @bapt wrote:

Why not just reuse USES?
and just look on USES_DIR

.for f in ${USES}
.undef _use_found
.for u in ${USES_DIR_LOCAL_PRE} ${USESDIR} ${USES_DIR_LOCAL_POST}
.if exists(${u}/${f:C/\:.*//}.mk) && !defined(_use_found)
.include "${u}/${f:C/\:.*//}.mk"
_use_found=1
.endif
.endfor
.if !defined(_use_found)
IGNORE= Error: unkonwn ${f}
.endif
.endfor

multiple benifits here:
better error on unkown uses
ability to override a USES by creating your own in USES_DIR_LOCAL_PRE

You can't define or add to USES from make.conf with that method. Most port Makefiles use USES= rather than USES+=. So the alternative is placing your own USES+= in bsd.port.local.mk which defeats one of the goals.

Also from experience in merging Mk/ the past year into my work tree, Mk/Uses changes a lot. It's far less risk prone to have a separate directory for custom files to not accidentally lose one.

Unless we still use a USES_LOCAL and have the loop go over both USES and USES_LOCAL. That would work.

I discussed with bapt in private and am testing his idea.

Here is a sample plugin I am using this for: https://gist.github.com/bdrewery/757e0983eec65906c7aa

It is to move all manpages/static libs out of packages and into a different staging area to work into an existing packaging mechanism we already have. It's a hammer until sub-packages/flavours work.

isn't it superceeded by overlays?