You are not logged in.

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

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,474
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,079

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: The Netherlands
Registered: 2010-03-30
Posts: 2,474
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: 5,556

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: ASUS P8Z77-V PRO // Processor: Intel Core i7-3770K 3.4GHz // GFX: nVidia GeForce GTX 970 Ti // RAM: 32GB (4x 8GB) Corsair DDR3 (@ 2133MHz) // Storage: 1x 3TB Seagate SATAII 5x 1TB Samsung SATAII, 2x 120GB Corsair SSD

Offline

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

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,474
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: 5,556

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: ASUS P8Z77-V PRO // Processor: Intel Core i7-3770K 3.4GHz // GFX: nVidia GeForce GTX 970 Ti // RAM: 32GB (4x 8GB) Corsair DDR3 (@ 2133MHz) // Storage: 1x 3TB Seagate SATAII 5x 1TB Samsung SATAII, 2x 120GB Corsair SSD

Offline

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

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,216
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)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

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

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,474
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 Moderator
Registered: 2009-06-15
Posts: 3,575

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