Gentoo Archives: gentoo-dev

From: Alec Warner <antarus@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] cygwin prefix patch: request for eyeballs
Date: Tue, 27 Mar 2012 17:29:28
Message-Id: CAAr7Pr_Otgwob8+Jfa+yF7GUo0dgT6V2CMiSi-Tb5PvuHH6V_w@mail.gmail.com
In Reply to: Re: [gentoo-dev] cygwin prefix patch: request for eyeballs by "Gregory M. Turner"
1 On Mon, Mar 26, 2012 at 11:39 PM, Gregory M. Turner <gmt@×××××.us> wrote:
2 > ----- Original Message -----
3 >> On Mon, Mar 26, 2012 at 4:12 PM, Gregory M. Turner <gmt@×××××.us>
4 >> wrote:
5 >> > https://github.com/gmt/gmt-cygwin-overlay/blob/master/sys-apps/portage/files/portage-2.2.01.20271-cygdll_protect.patch
6 >
7 >> Consistency in the style would be nice.
8 >>
9 >> For instance in cygdll-update:
10 >>
11 >> # Here you have spaces after the $( and before the )
12 >> extra_protection="$( portageq cygdll_protect_list ${EROOT} )"
13 >>
14 >> # Later on you don't put spaces...
15 >> eval $(portageq envvar -v CYGDLL_PROTECT PORTAGE_HOSTNAME \
16 >> +     PORTAGE_CONFIGROOT PORTAGE_INST_GID PORTAGE_INST_UID \
17 >> +     PORTAGE_TMPDIR EROOT USERLAND)
18 >
19 > yes, good point, (the latter is cut-and-paste from etc-update, the former my own; I do that habitually as a way to avoid learning how tokenization works in bash :)
20 >
21 >> Assuming $PORTAGE_BASH is always bash, you should use [[ consistently
22 >> in your bash.
23 >
24 > vs. "["?  That sounds like cut-paste from etc-update again -- it seems to have been coded with sh support in mind.  Don't think that matters for cygwin (in fact it'd better not, the way I coded it), so, well spotted, I'll fix it.
25 >
26 >> IMHO it is a common mistake to write your own argument processing, is
27 >> there a reason getops is not appropriate (portability?)
28 >
29 > Got me there -- I'm a getopts ignoramus.
30 >
31 >> Onto the python:
32 >>
33 >> if os.environ.__contains__("PORTAGE_PYTHONPATH"):
34 >>
35 >> Any reason why
36 >> if "PORTAGE_PYTHONPATH" not in os.environ:
37 >> was not used?
38 >
39 > indeed, couldn't I just use 'if not os.environ["PORTAGE_PYTONPATH"]:' (if the python executable were "False" or "0" would something stupid happen?)?  Also cut-paste from portage, but I did notice it, and had the exact same question.  After my initial, unprintable reaction :)
40
41 If PORTAGE_PYTHONPATH is not in os.environ then it will raise a
42 KeyError, that is why we are doing a contains to begin with.
43
44 >
45 > Maybe the answer is buried somewhere in the docs ... afaik in 2.7, "x in foo" <=> "foo.__contains__(x)" (?).  Guess I'd need to double check 2.7 and 3.2 docs as well to be sure.
46
47 I'm not saying they are not equal, I'm saying foo.__contains__ is ugly as sin.
48
49 >
50 > One idea: maybe meant as future-proofing against security bugs that could open up in future pythons.  I'll try to find blame (or whatever they call that in cvs) on this line of code, maybe we can ask the culprit himself.
51
52 annotate ;)
53
54 >
55 >> Python functions are not perl, don't pass 'argv' to the function.
56 >>
57 >> If the function takes to arguments, it should be:
58 >>
59 >> def func1(arg1, arg2)
60 >> If some of the args have defaults:
61 >> def func1(arg1, arg2=5)
62 >
63 > Hm, are you looking at bin/portage_master_lock when you mention this?  It's cut-and-paste from portageq (starting to see a pattern yet? :) )
64
65 Bad code in portage? INCONCEIVABLE.
66
67 >
68 >> I've never seen anyone use <> before; I didn't even know it existed.
69 >> Most folks use !=.
70 >
71 > Sounds right, I'll seek and destroy.
72 >
73 >> I can't really imagine why people do stuff like share
74 >> /var/lib/portage
75 >> across machines, so adding a bunch of complexity just to make it work
76 >> seems nuts to me. That being said I have not worked on portage in
77 >> years and Zac seems happier to support weird use cases.
78 >
79 > Yikes, that's a pretty good critique, I'm afraid.  Almost painful to read :)
80
81 I'm a pretty blunt fellow.
82
83 >
84 > I decided to go ahead and implement this first, because I've seen some real-world file-sharing setups serving cygwin to clusters of development workstations, and secondly, because the consensus on #gentoo-portage was that this was a supported use-case.
85
86 Indeed, as I said I am not upstream, I'm just an opinionated dick ;)
87
88 >
89 > Anyhow, seeing as how I already implemented it, it's too late for me to decide that it's too much work :)
90 >
91 > In my defense, I thought it would be way less involved and it just kinda feature-creep'ed up on me.  By the time I figured out what a monster I'd created I was kinda pot-stuck.
92
93 Its not the largest patch I've seen ;p
94
95 >
96 > -gmt
97 >

Replies

Subject Author
Re: [gentoo-dev] cygwin prefix patch: request for eyeballs "Gregory M. Turner" <gmt@×××××.us>