owfs-3.1_p4.ebuild 4.5 KB

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