Gentoo Archives: gentoo-dev

From: Peter Volkov <pva@g.o>
To: gentoo-dev@l.g.o, djc@g.o
Subject: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild
Date: Fri, 01 Oct 2010 13:08:01
Message-Id: 1285938445.5868.244.camel@tablet
1 В Пнд, 27/09/2010 в 11:37 +0000, Dirkjan Ochtman (djc) пишет:
2 > src_prepare() {
3 > epatch "${FILESDIR}/${PN}-2.1_rc13-peercred.patch"
4 > epatch "${FILESDIR}/${PN}-2.1_rc20-pkcs11.patch"
5 > use ipv6 && epatch "${WORKDIR}/${PN}-2.1.1-ipv6-${IPV6_VERSION}.patch"
6 > use eurephia && epatch "${DISTDIR}/${PN}-2.1.0_eurephia.patch"
7 > sed -i \
8 > -e "s/gcc \${CC_FLAGS}/\${CC} \${CFLAGS} -Wall/" \
9 > -e "s/-shared/-shared \${LDFLAGS}/" \
10 > plugin/*/Makefile || die "sed failed"
11 > eautoreconf
12
13 Is autoreconf really necessary here? Looks like it is redundant in case
14 ipv6 or eurephia are disabled.
15
16 > src_configure() {
17
18 > econf ${myconf} \
19 > $(use_enable passwordsave password-save) \
20 > $(use_enable ssl) \
21 > $(use_enable ssl crypto) \
22 > $(use_enable iproute2) \
23 > || die "configure failed"
24
25 || die is redundant here.
26
27
28 > src_compile() {
29 > use static && sed -i -e '/^LIBS/s/LIBS = /LIBS = -static /' Makefile
30 >
31 > emake || die "make failed"
32 >
33 > if ! use minimal ; then
34 > cd plugin
35 > for i in $( ls 2>/dev/null ); do
36
37 This is bad construction:
38 http://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29
39
40 > [[ ${i} == "README" || ${i} == "examples" || ${i} == "defer" ]] && continue
41 > [[ ${i} == "auth-pam" ]] && ! use pam && continue
42 > einfo "Building ${i} plugin"
43 > cd "${i}"
44 > emake CC=$(tc-getCC) || die "make failed"
45 > cd ..
46
47 I think pushd/popd are better suited for this then cd "${dir}" / cd ..
48
49 > done
50 > cd ..
51 > fi
52 > }
53
54 > # remove empty dir
55 > rmdir "${D}/usr/share/doc/openvpn"
56
57 || die is prudent here.
58
59 > # Empty dir
60 > dodir /etc/openvpn
61 > keepdir /etc/openvpn
62
63 dodir is redundant: keepdir will create directory.
64
65 > # Install some helper scripts
66 > exeinto /etc/openvpn
67 > doexe "${FILESDIR}/up.sh"
68 > doexe "${FILESDIR}/down.sh"
69
70 || die after doexe is really good idea.
71
72 > # Install the init script and config file
73 > newinitd "${FILESDIR}/${PN}-2.1.init" openvpn
74 > newconfd "${FILESDIR}/${PN}-2.1.conf" openvpn
75
76 || die absent
77
78 > # install examples, controlled by the respective useflag
79 > if use examples ; then
80 > # dodoc does not supportly support directory traversal, #15193
81 > insinto /usr/share/doc/${PF}/examples
82 > doins -r sample-{config-files,keys,scripts} contrib
83 > prepalldocs
84 > fi
85
86 > # Install plugins and easy-rsa
87 > if ! use minimal ; then
88 > cd easy-rsa/2.0
89 > make install "DESTDIR=${D}/usr/share/${PN}/easy-rsa"
90 > cd ../..
91 >
92 > exeinto "/usr/$(get_libdir)/${PN}"
93 > doexe plugin/*/*.so
94 > fi
95 > }
96 >
97 > pkg_postinst() {
98 > # Add openvpn user so openvpn servers can drop privs
99 > # Clients should run as root so they can change ip addresses,
100 > # dns information and other such things.
101 > enewgroup openvpn
102 > enewuser openvpn "" "" "" openvpn
103 >
104 > if [[ -n $(ls /etc/openvpn/*/local.conf 2>/dev/null) ]] ; then
105
106 I'd suggested [ -e /etc/openvpn/*/local.conf ] here, but probably there
107 are better alternatives. Also ${ROOT} is missed here.
108
109 > ewarn "WARNING: The openvpn init script has changed"
110 > ewarn ""
111 > fi
112 >
113 > einfo "The openvpn init script expects to find the configuration file"
114 > einfo "openvpn.conf in /etc/openvpn along with any extra files it may need."
115
116 This information is for users, so, please, use elog here.
117
118 > einfo ""
119 > einfo "To create more VPNs, simply create a new .conf file for it and"
120 > einfo "then create a symlink to the openvpn init script from a link called"
121 > einfo "openvpn.newconfname - like so"
122 > einfo " cd /etc/openvpn"
123 > einfo " ${EDITOR##*/} foo.conf"
124 > einfo " cd /etc/init.d"
125 > einfo " ln -s openvpn openvpn.foo"
126 > einfo ""
127 > einfo "You can then treat openvpn.foo as any other service, so you can"
128 > einfo "stop one vpn and start another if you need to."
129 >
130 > if grep -Eq "^[ \t]*(up|down)[ \t].*" "${ROOT}/etc/openvpn"/*.conf 2>/dev/null ; then
131 > ewarn ""
132 > ewarn "WARNING: If you use the remote keyword then you are deemed to be"
133 > ewarn "a client by our init script and as such we force up,down scripts."
134 > ewarn "These scripts call /etc/openvpn/\$SVCNAME-{up,down}.sh where you"
135 > ewarn "can move your scripts to."
136 > fi
137 >
138 > if ! use minimal ; then
139 > einfo ""
140 > einfo "plugins have been installed into /usr/$(get_libdir)/${PN}"
141 > fi
142 >
143 > if use ipv6 ; then
144 > einfo ""
145 > einfo "This build contains IPv6-Patch from JuanJo Ciarlante."
146 > einfo "For more information please visit:"
147 > einfo "http://github.com/jjo/openvpn-ipv6"
148 > fi
149 >
150 > if use eurephia ; then
151 > einfo ""
152 > einfo "This build contains eurephia patch."
153 > einfo "For more information please visit:"
154 > einfo "http://www.eurephia.net/"
155 > fi
156 > }
157
158 --
159 Peter.

Replies