Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Best way to detect architecture in ebuild?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
big_gie
Apprentice
Apprentice


Joined: 31 Aug 2004
Posts: 158

PostPosted: Mon Jan 09, 2012 9:12 pm    Post subject: Best way to detect architecture in ebuild? Reply with quote

Hi all,

I'm looking for the official way of detecting the machine's architecture in an ebuild.

I need this because some binary packages have different SRC_URI for different architectures and thus a different S too.

I was using if "[[ "${ARCH}" == "amd64" ]]; then" before but a user reported that ARCH was not set when using cave/paludis (https://github.com/nbigaouette/ebuilds/issues/8), so I changed this to "if use amd64; then". It seems that doing so breaks every other users though...

I could not find any information on the best way to handle these architecture dependencies in ebuilds... It seems SRC_URI can take advantage of use flags:
Code:
SRC_URI="
    x86?   ( http://url/${ARCHIVE_X86}   )
    amd64? ( http://url/${ARCHIVE_AMD64} )
"

but what about setting "S" (or other variables)? I tried:
Code:
S="
    x86?   ( http://url/${ARCHIVE_X86}   )
    amd64? ( http://url/${ARCHIVE_AMD64} )
"
without success... the "arch ? ..." usage seems to be available only inside functions and not for variables. Thus the ebuilds get complicated because of that...

Where can I find information on how to manage different architecture more easily?

Thanks a lot.
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Tue Jan 10, 2012 12:14 am    Post subject: Reply with quote

Code:
$(uname -m)
?

Just did a quick try with this in an "einfo" and it gets evaluated, so should work everywhere in the ebuild - can't say anything about paludis or other packagemanagers, though.
_________________
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Back to top
View user's profile Send private message
dol-sen
Retired Dev
Retired Dev


Joined: 30 Jun 2002
Posts: 2805
Location: Richmond, BC, Canada

PostPosted: Tue Jan 10, 2012 1:03 am    Post subject: Reply with quote

You were on the right track with the arch use flags.

http://devmanual.gentoo.org/ebuild-writing/variables/index.html#src_uri

A little bit farther down that page is another section tilted: Version and Name Formatting Issues. It shows some info about odd handling odd naming, etc.. That will go hand in hand with:

http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=2&chap=3

under: Including version numbers in SRC_URI and S.

That should get you all fixed up. Also for IRC help there is also #gentoo-dev-help on the freenode network.
_________________
Brian
Porthole, the Portage GUI frontend irc@freenode: #gentoo-guis, #porthole, Blog
layman, gentoolkit, CoreBuilder, esearch...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum