# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI=5 inherit eutils cmake-utils git-2 linux-info systemd DESCRIPTION="Encrypted networking for regular people" HOMEPAGE="https://github.com/cjdelisle/cjdns" EGIT_REPO_URI="git://github.com/cjdelisle/cjdns.git \ https://github.com/cjdelisle/cjdns.git" EGIT_COMMIT="cf1ca35a835a99ef3998a9f0e609fac337fe6d01" LICENSE="GPL-3" SLOT="0" KEYWORDS="~x86 ~amd64" IUSE="libsodium +nacl" REQUIRED_USE="^^ ( nacl libsodium )" DEPEND="dev-libs/libevent dev-libs/libuv libsodium? ( net-libs/libsodium ) nacl? ( net-libs/nacl )" RDEPEND="" # Static pkg_setup() { linux-info_pkg_setup if ! linux_config_exists; then eerror "Unable to check your kernel for TUN support" else CONFIG_CHECK="~TUN" ERROR_TUN="Your kernel lacks TUN support." fi } src_prepare() { local required_version="4.6" einfo "checking current gcc profile" if ! version_is_at_least ${required_version} $(gcc-version) ; then eerror "${P} requires gcc-${required_version} or greater to build." eerror "Have you gcc-config'ed to the latest version?" die "current gcc profile is less than ${required_version}" fi use nacl && epatch "${FILESDIR}/FindNaCl.cmake-${PV}.diff" use libsodium && epatch "${FILESDIR}/Findlibsodium.cmake-${PV}.diff" epatch "${FILESDIR}/FindLibuv.cmake-${PV}.diff" } src_configure() { if gcc-specs-pie ; then einfo "Enabling PIE..." export NO_PIE=0 else einfo "Disabling PIE..." export NO_PIE=1 fi #if use static ; then # export STATIC=1 #else # export NO_STATIC=1 #fi GIT_VERSION=${EGIT_COMMIT} cmake-utils_src_configure } src_test() { cd "${BUILD_DIR}" emake test } src_install() { systemd_dounit contrib/systemd/cjdns.service newinitd "$FILESDIR/cjdns.runscript" cjdns dodoc README.md rfcs/* cd "${CMAKE_BUILD_DIR}/admin/angel" || die "could not chdir to admin/angel" dolib.a libcjdns-*.a mv cjdroute2 cjdroute dosbin cjdns cjdroute } pkg_postinst() { local config_file="cjdroute.conf" local config_path="${ROOT}etc/${config_file}" if [[ ! -e "${config_path}" ]] ; then ebegin "Generating ${config_file}..." (umask 077 && cjdroute --genconf > "${T}/${config_file}") || die "cjdroute --genconf failed" mv "${T}/${config_file}" "${config_path}" eend ${?} || die "Failed to generate and install ${config_file}" elog "The keys in ${config_path} have been autogenerated during " elog "emerge, they are not defaults and do not need to be overwritten." fi elog "The OpenRC script will load attempt to load the TUN module if it " elog "it is not active, the systemd unit will not. To load TUN at boot " elog "'echo tun >> /etc/modules-load.d/cjdns.conf'" ewarn "Protect ${config_path}! A lost conf file means you have " ewarn "lost your password and connections and anyone who connected " ewarn "to you will no longer be able to connect. A *compromised* " ewarn "conf file means that other people can impersonate you on " ewarn "the network." einfo "The cjdns runscript will load the TUN kernel module automatically." einfo "If you are using systemd and have TUN built as a module, add tun " einfo "to /etc/modules-load.d/ for automatic loading at boot-time." einfo "echo tun > /etc/modules-load.d/cjnds.conf" }