You are not logged in.
Hello,
I have my selfmade powersave script, for which I have a PKGBUILD. It requires either udisks or udisks2.
Is there a way I can have makepkg see if either of the two is installed and choose that as dependency - or if none is installed just install udisks?
Thanks in advance!
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
you can check it using
whereis
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
I see. I suppose I should add a bit of bash before the build() function to check if either udisks or udisks2 is installed and accordingly, add either udisks or udisks2 to the depends array. I will look how other packages do that now and see if I can get it to work.
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Of course, that won't work if someone's building it from within a clean chroot.
I'd pick one or the other as a default dependency, then let the user change it if they prefer the other. Leave a comment in the PKGBUILD to let the user know that the option is there.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
So that's why my perfect bash script isn't working
_check_for_udisks_or_udisks2() {
UDISKS=$(whereis -b udisks)
UDISKS2=$(whereis -b udisks2)
if [ -z "$UDISKS2" ] ; then
depends+=('udisks2')
elif [ -z "$UDISKS" ] ; then
depends+=('udisks')
else
depends+=('udisks')
fi
}
But yea, I'll just put udisks2 as standard.
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Well "won't work" was a bit vague on my part. It should still "work", but it won't be reflective of the user's actual system, it'll just fall back on the final else statement since neither versions of udisks are in base{,-devel}.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
While I'm not suggesting it would work or would be a good idea, I just wanted to comment on the 'bash'ing itself. The following code is entirely functionally equivalent to your bit:
_check_for_udisks_or_udisks2() {
UDISKS2=$(whereis -b udisks2)
if [ -z "$UDISKS2" ] ; then
depends+=('udisks2')
else
depends+=('udisks')
fi
}
EDIT: wait, shouldn't those be "-n"s in the conditionals, not "-z"s? This could be why it wasn't working.
Last edited by Trilby (2012-11-02 23:05:53)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
While I'm not suggesting it would work or would be a good idea, I just wanted to comment on the 'bash'ing itself. The following code is entirely functionally equivalent to your bit:
Pfft... instead of bashing (pun intended) me here, how about replying to my email?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
The problem is that udisks and udisks2 don't conflict with each other, and udisks2 doesn't provide udisks. Your best option here is to put both in as optional dependencies and print a message in the .install that the user needs to pick one and install it. Chances are they have one installed already anyway.
Offline
EDIT: wait, shouldn't those be "-n"s in the conditionals, not "-z"s? This could be why it wasn't working.
whereis always puts stuff on stdout and returns successfully. Use where instead,
if where udisks2 &> /dev/null ; then [...]
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline