-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Daniel Drake wrote: > Marijn Schouten (hkBst) wrote: >> use_mime() { >> local WORD=$(ifv "$2" "$2" "$1") >> >> ifuse "$1" "${WORD};" >> } >> >> for generating a string of ';'-separated mime-types based on use flags. >> >> The explanation of this function is: >> >> #set WORD to argument 2 or if that is empty to argument 1 >> #output "${WORD};" if use flag $1 is set (or if it starts with ! and >> is unset) >> #otherwise don't output anything > > I don't quite understand what this function does. What ebuild nastiness > does it replace, or what does it allow that was not previously possible? > (can you give an example?)
It's something I built following some questions by lack in #gentoo-dev-help. Perhaps he can clarify if necessary. [di okt 30 2007] [18:02:10] <lack> Now, I want to have each ebuild have a global variable called 'APPMIME' that somehow contains the mime-types available and the associated USE flags, such that the eclass that actually creates the .desktop file can appropriately go through and add only the mime-types that are enabled by the USE flags. <zlin> no, there is no such convenience function. <lack> That's too bad - it would be pretty useful. Oh well, I'll have to write some sort of fancy function in the ebuild then. <hkBst> lack: what about APPMIME="thing1 $(usev thing2)" ? <zlin> I you think such a flattener would be really useful I suppose you can suggest it on -dev@ .. <lack> hkBst: Hm, that's not too bad. <zlin> *If <lack> I wonder, would that work like: APPMIME="one;$(if usev thing2;thing3);thing4"? <lack> Maybe I'd have to do some odd escaping in that case of a semicolon-separated list. <hkBst> lack: why do you want it to be ;-separated? <lack> Because that's the eventual format of 'MIME=type/one;type/two' in the .desktop file. <lack> If I could just set up the variable so the eclass doesn't have to actually do any parsing that would be easiest. <lack> APPMIME="type/one;type/two$(if use foo ';type/foo1;type/foo2')$(if use bar ';type/barx;type/bary')" Perhaps? <zlin> usemime() { useq $1 && echo "$2;"; }; APPMIME="thing1;$(usemime useflag thing2)$(usemime useflag2 "thing3;thing4")thing5" <lack> Ah, that usemime feature looks useful, thanks! But usemime() { useq $1 && echo "$2;"; } lacks default arguments and ifuse provides a nicer interface if you want to do output, which is the use case I am proposing ifuse for. Some other examples: in dev-scheme/bigloo-3.0b_p2 I use (econf doesn't work): ./configure \ $(use java && echo "--jvm=yes --java=$(java-config --java) - --javac=$(java-config --javac)") \ - --prefix=/usr \ # --bee=$(if use fullbee; then echo full; else echo partial; fi) it would be a bit nicer if I could just write: ./configure \ $(ifuse java "--jvm=yes --java=$(java-config --java) --javac=$(java-config - --javac)") \ - --prefix=/usr \ # --bee=$(ifuse fullbee full partial) The example from <http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=2&chap=1> if use gnutls ; then myconf="${myconf} --enable-ssl --with-ssl=gnutls" elif use ssl ; then myconf="${myconf} --enable-ssl --with-ssl=openssl" else myconf="${myconf} --disable-ssl" fi econf \ # Other stuff ${myconf} \ || die "configure failed" could become: econf \ # Other stuff $(ifuse gnutls "--enable-ssl --with-ssl=gnutls" \ $(ifuse ssl "--enable-ssl --with-ssl=openssl" --disable-ssl)) \ || die "configure failed" which may require some getting used to. But no functionality will be lost, so if you prefer the old way, all your existing methods will continue to work. There will just be another option. Marijn - -- Marijn Schouten (hkBst), Gentoo Lisp project <http://www.gentoo.org/proj/en/lisp/>, #gentoo-lisp on FreeNode -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHKzmzp/VmCx0OL2wRAk8bAJ9rDW57WStJ79PBpXIbQN9phEv6GwCcChaR OqLUSnsTRttVwFdmCwDnW7I= =Zw+z -----END PGP SIGNATURE----- -- [EMAIL PROTECTED] mailing list