You are not logged in.

#1 2012-11-02 17:21:56

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Question about dependencies

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

#2 2012-11-02 18:53:47

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Question about dependencies

you can check it using

whereis

Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2012-11-02 19:04:14

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Question about dependencies

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

#4 2012-11-02 19:14:26

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,786
Website

Re: Question about dependencies

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

#5 2012-11-02 19:42:35

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Question about dependencies

So that's why my perfect bash script isn't working tongue

_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

#6 2012-11-02 20:36:09

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,786
Website

Re: Question about dependencies

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}. tongue


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

#7 2012-11-02 23:03:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Question about dependencies

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

#8 2012-11-03 14:51:56

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Question about dependencies

Trilby wrote:

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? big_smile


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

#9 2012-11-07 09:09:51

sudokode
Member
Registered: 2010-06-27
Posts: 5

Re: Question about dependencies

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

#10 2012-11-07 15:13:24

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Question about dependencies

Trilby wrote:

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

Board footer

Powered by FluxBB