sysutils/libudisks; not always needed dependency, EXTRA_PATCHES, and make makepatch

From: Pau Amma <pauamma_at_gundo.com>
Date: Thu, 24 Mar 2022 04:49:25 UTC
I'm finally getting around to upgrading sysutils/libudisks to 2.9.4 
(it's been 7.5 months and another released version in-between) and while 
doing that, I'm trying to get rid of the spurious dependency on polkit 
when udisksctl (only thing that actually needs it) is disabled (enabled 
by default).

The way I handled that in the 2.9.2 port was:
- require polkit unconditionally
- build everything including udisksctl
- rm udisksctl in the post-install-UDISKSCTL-off target

This is less than ideal because of the wasted resources and the 
pointless dependency. So I'm considering a different approach this time:

UDISKSCTL_BUILD_DEPENDS=        pkaction:sysutils/polkit
UDISKSCTL_LIB_DEPENDS=  libpolkit-agent-1.so:sysutils/polkit \
                         libpolkit-gobject-1.so:sysutils/polkit
# Remove check for polkit and references to it if udisksctl is disabled
UDISKSCTL_EXTRA_PATCHES_OFF=    ${PATCHDIR}/UDISKSCTL-off

Generating both sets of patch files with make makepatch will be a 
problem, though:
- make makepatch with UDISKSCTL enabled doesn't generate the extra 
patches
- make makepatch with UDISKSCTL disabled does, but lumps them in with 
the rest, so if I copy them all to  noudisksctl, they overlap, 
contradict, and confuse make patch
- having 2 sets of patch files each in its own directory, 
UDISKSCTL_EXTRA_PATCHES_OFF and UDISKSCTL_EXTRA_PATCHES_ON, with no 
common patches in ${PATCHDIR}

I'm considering a semi-automated way to tease out what's unique to the 
UDISKSCTL disabled set of patches:
1- generate the UDISKSCTL on set of patches, stash them somewhere
2- generate the UDISKSCTL off set of patches, stash them somewhere else
3- process both sets to spit out common changes (put in ${PATCHDIR}), 
changes unique to UDISKSCTL off (go to ${PATCHDIR}/UDISKSCTL-off), and 
(not needed here but good for future-proofing) changes unique to 
UDISKSCTL on (would go to ${PATCHDIR}/UDISKSCTL-on)

For 3, proper application of interdiff --no-revert-omitted and 
combine-diff from misc/patchutils may work unless I misremember set 
algebra (not unlikely, after 40+ years):
- combinediff a.diff b.diff > a-union-b.diff
- interdiff --no-revert-omitted a.diff b.diff > unique-to-a.diff
- interdiff --no-revert-omitted b.diff a.diff > unique-to-b.diff
- interdiff a-union-b.diff unique-to-a.diff | interdiff 
--no-revert-omitted /dev/stdin unique-to-b.diff > a-inter-b.diff

Can someone confirm my impression that this method would work?

Otherwise, I'd have to write something in perl, probably using 
Text::Diff::Parser) because perl is likely installed for portlint and I 
really don't want to implement a diff file parser in awk.

So before I embark into that, is there any shortcoming? And or am I 
overthinking this and is there an easier solution (to this or my initial 
prothat what I'm considering?
-- 
#BlackLivesMatter #TransWomenAreWomen #AccessibilityMatters 
#StandWithUkrainians
English: he/him/his (singular they/them/their/theirs OK)
French: il/le/lui (iel/iel and ielle/ielle OK)
Tagalog: siya/niya/kaniya (please avoid sila/nila/kanila)