dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / sys-fs / owfs / owfs-3.2_p2-r2.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7 DISTUTILS_OPTIONAL=1
8
9 inherit autotools distutils-r1 linux-info perl-functions systemd user
10
11 MY_P="${P/_/}"
12
13 DESCRIPTION="Access 1-Wire devices like a filesystem"
14 SRC_URI="mirror://sourceforge/owfs/${MY_P}.tar.gz"
15 HOMEPAGE="http://owfs.org/ https://sourceforge.net/projects/owfs/"
16 KEYWORDS="amd64 arm x86"
17
18 # Upstream uses crazy SONAME, https://github.com/owfs/owfs/commit/c696fa9b9b44f49c96b9f1c2b3159d277e0c1273
19 SLOT="0/${PV}"
20 LICENSE="GPL-2"
21
22 IUSE="debug ftdi ftpd fuse httpd parport perl python tcl usb zeroconf"
23 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
24
25 RDEPEND="
26         ftdi? ( dev-embedded/libftdi:0 )
27         fuse? ( sys-fs/fuse:0= )
28         perl? ( dev-lang/perl:= )
29         parport? ( sys-kernel/linux-headers )
30         python? ( ${PYTHON_DEPS} )
31         tcl? ( dev-lang/tcl:0= )
32         usb? ( virtual/libusb:0 )
33         zeroconf? ( net-dns/avahi[mdnsresponder-compat] )
34 "
35
36 DEPEND="${RDEPEND}
37         perl? ( dev-lang/swig )
38         python? ( dev-lang/swig )
39 "
40
41 PATCHES=(
42         "${FILESDIR}"/${PN}-3.1-vendordir.patch
43         "${FILESDIR}"/${PN}-3.1p4-sysmacros.patch
44 )
45
46 S="${WORKDIR}/${MY_P}"
47
48 OWUID="${OWUID:-owfs}"
49 OWGID="${OWGID:-owfs}"
50
51 pkg_setup() {
52         if use kernel_linux; then
53                 linux-info_pkg_setup
54
55                 if linux_config_exists; then
56                         if ! linux_chkconfig_present W1; then
57                                 ewarn "CONFIG_W1 isn't set. You will not be able to use 1-wire bus on this system!"
58                         fi
59                 else
60                         elog "Cannot find a linux kernel configuration. Continuing anyway."
61                 fi
62         fi
63
64         use perl && perl_set_version
65
66         enewgroup ${OWGID} 150
67         enewuser  ${OWUID} 150 -1 -1 ${OWGID}
68 }
69
70 src_prepare() {
71         default
72
73         # Support user's CFLAGS and LDFLAGS.
74         sed -i "s/@CPPFLAGS@/@CPPFLAGS@ ${CFLAGS}/" \
75                 module/swig/perl5/OW/Makefile.linux.in || die
76         sed -i "s/@LIBS@/@LIBS@ ${LDFLAGS}/" \
77                 module/swig/perl5/OW/Makefile.linux.in || die
78
79         eautoreconf
80 }
81
82 src_configure() {
83         # disable owpython since we can build python anyway
84         # and without it, we don't have to fix the build ;)
85         # disable owphp because it is not compatible with PHP-7, bug #651106
86         local myeconf=(
87                 $(use_enable debug)
88                 $(use_enable fuse owfs)
89                 $(use_enable ftdi)
90                 $(use_enable ftpd owftpd)
91                 $(use_enable httpd owhttpd)
92                 $(use_enable parport)
93                 $(use_enable perl owperl)
94                 --disable-owphp
95                 --disable-owpython
96                 $(use_enable tcl owtcl)
97                 $(use_enable zeroconf avahi)
98                 $(use_enable zeroconf zero)
99                 $(use_enable usb)
100                 --with-systemdsystemunitdir=$(systemd_get_systemunitdir)
101         )
102
103         if use httpd || use ftpd || use fuse; then
104                 myeconf+=( --enable-owserver )
105         else
106                 myeconf+=( --disable-owserver )
107         fi
108
109         econf ${myeconf[@]}
110 }
111
112 src_compile() {
113         default
114
115         if use python; then
116                 local CFLAGS="${CFLAGS} -fno-strict-aliasing"
117
118                 pushd module/ownet/python > /dev/null || die
119                 distutils-r1_src_compile
120                 popd > /dev/null || die
121
122                 pushd module/swig/python > /dev/null || die
123                 emake ow_wrap.c
124                 distutils-r1_src_compile
125                 popd > /dev/null || die
126         fi
127 }
128
129 src_test() { :; }
130
131 src_install() {
132         default
133
134         if use httpd || use ftpd || use fuse; then
135                 newinitd "${FILESDIR}"/owserver.initd-r1 owserver
136                 newconfd "${FILESDIR}"/owserver.confd owserver
137
138                 for i in httpd ftpd; do
139                         if use ${i}; then
140                                 newinitd "${FILESDIR}"/ow${i}.initd-r1 ow${i}
141                                 newconfd "${FILESDIR}"/ow${i}.confd ow${i}
142                         fi
143                 done
144
145                 if use fuse; then
146                         dodir /var/lib/owfs
147                         dodir /var/lib/owfs/mnt
148                         newinitd "${FILESDIR}"/owfs.initd-r1 owfs
149                         newconfd "${FILESDIR}"/owfs.confd owfs
150                 fi
151         fi
152
153         use perl && perl_delete_localpod
154
155         if use python; then
156                 pushd module/ownet/python > /dev/null || die
157                 distutils-r1_src_install
158                 popd > /dev/null || die
159
160                 pushd module/swig/python > /dev/null || die
161                 distutils-r1_src_install
162                 popd > /dev/null || die
163         fi
164
165         find "${D}" -name '*.la' -delete || die
166 }
167
168 pkg_postinst() {
169         if use httpd || use ftpd || use fuse; then
170                 echo
171                 if [[ ${OWUID} != root ]]; then
172                         ewarn
173                         ewarn "In order to allow the OWFS daemon user '${OWUID}' to read"
174                         ewarn "from and/or write to a 1 wire bus controller device, make"
175                         ewarn "sure the user has appropriate permission to access the"
176                         ewarn "corresponding device node/path (e.g. /dev/ttyS0), for example"
177                         ewarn "by adding the user to the group 'uucp' (for serial devices)"
178                         ewarn "or 'usb' (for USB devices accessed via usbfs on /proc/bus/usb),"
179                         ewarn "or install an appropriate UDEV rules (see http://owfs.org/index.php?page=udev-and-usb"
180                         ewarn "for more information)."
181                         ewarn
182                         if use fuse; then
183                                 ewarn "In order to allow regular users to read from and/or write to"
184                                 ewarn "1 wire bus devices accessible via the owfs FUSE filesystem"
185                                 ewarn "client and its filesystem mountpoint, make sure the user is"
186                                 ewarn "a member of the group '${OWGID}'."
187                                 ewarn
188                         fi
189                         echo
190                 fi
191         fi
192 }