logo

overlay

My (experimental) gentoo overlay

openrc-0.41.2.ebuild (6296B)


      1 # Copyright 1999-2019 Gentoo Authors
      2 # Distributed under the terms of the GNU General Public License v2
      3 
      4 EAPI=6
      5 
      6 inherit flag-o-matic pam toolchain-funcs
      7 
      8 DESCRIPTION="OpenRC manages the services, startup and shutdown of a host"
      9 HOMEPAGE="https://github.com/openrc/openrc/"
     10 
     11 if [[ ${PV} == "9999" ]]; then
     12 	EGIT_REPO_URI="https://github.com/OpenRC/${PN}.git"
     13 	inherit git-r3
     14 else
     15 	SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
     16 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd"
     17 fi
     18 
     19 LICENSE="BSD-2"
     20 SLOT="0"
     21 IUSE="audit bash debug init ncurses pam newnet prefix +netifrc selinux
     22 	static-libs unicode kernel_linux kernel_FreeBSD"
     23 
     24 COMMON_DEPEND="kernel_FreeBSD? ( || ( >=sys-freebsd/freebsd-ubin-9.0_rc sys-process/fuser-bsd ) )
     25 	ncurses? ( sys-libs/ncurses:0= )
     26 	pam? (
     27 		sys-auth/pambase
     28 		virtual/pam
     29 	)
     30 	audit? ( sys-process/audit )
     31 	kernel_linux? (
     32 		sys-process/psmisc
     33 		!<sys-process/procps-3.3.9-r2
     34 	)
     35 	selinux? (
     36 		sys-apps/policycoreutils
     37 		>=sys-libs/libselinux-2.6
     38 	)
     39 	!<sys-apps/baselayout-2.1-r1
     40 	!<sys-fs/udev-init-scripts-27"
     41 DEPEND="${COMMON_DEPEND}
     42 	virtual/os-headers
     43 	ncurses? ( virtual/pkgconfig )"
     44 RDEPEND="${COMMON_DEPEND}
     45 	bash? ( app-shells/bash )
     46 	!prefix? (
     47 		kernel_linux? (
     48 			!init? ( >=sys-apps/sysvinit-2.86-r6[selinux?] )
     49 			init? ( !sys-apps/sysvinit )
     50 			virtual/tmpfiles
     51 		)
     52 		kernel_FreeBSD? ( sys-freebsd/freebsd-sbin )
     53 	)
     54 	selinux? (
     55 		>=sec-policy/selinux-base-policy-2.20170204-r4
     56 		>=sec-policy/selinux-openrc-2.20170204-r4
     57 	)
     58 	!<app-shells/gentoo-bashcomp-20180302
     59 	!<app-shells/gentoo-zsh-completions-20180228
     60 "
     61 
     62 PDEPEND="netifrc? ( net-misc/netifrc )"
     63 
     64 src_prepare() {
     65 	default
     66 	if [[ ${PV} == "9999" ]] ; then
     67 		local ver="git-${EGIT_VERSION:0:6}"
     68 		sed -i "/^GITVER[[:space:]]*=/s:=.*:=${ver}:" mk/gitver.mk || die
     69 	fi
     70 }
     71 
     72 src_compile() {
     73 	unset LIBDIR #266688
     74 
     75 	MAKE_ARGS="${MAKE_ARGS}
     76 		LIBNAME=$(get_libdir)
     77 		LIBEXECDIR=${EPREFIX}/lib/rc
     78 		MKBASHCOMP=yes
     79 		MKNET=$(usex newnet)
     80 		MKSELINUX=$(usex selinux)
     81 		MKAUDIT=$(usex audit)
     82 		MKPAM=$(usev pam)
     83 		MKSTATICLIBS=$(usex static-libs)
     84 		MKSYSVINIT=$(usex init)
     85 		MKZSHCOMP=yes
     86 		SH=$(usex bash /bin/bash /bin/sh)"
     87 
     88 	local brand="Unknown"
     89 	if use kernel_linux ; then
     90 		MAKE_ARGS="${MAKE_ARGS} OS=Linux"
     91 		brand="Linux"
     92 	elif use kernel_FreeBSD ; then
     93 		MAKE_ARGS="${MAKE_ARGS} OS=FreeBSD"
     94 		brand="FreeBSD"
     95 	fi
     96 	export BRANDING="Gentoo ${brand}"
     97 	use prefix && MAKE_ARGS="${MAKE_ARGS} MKPREFIX=yes PREFIX=${EPREFIX}"
     98 	export DEBUG=$(usev debug)
     99 	export MKTERMCAP=$(usev ncurses)
    100 
    101 	tc-export CC AR RANLIB
    102 	emake ${MAKE_ARGS}
    103 }
    104 
    105 # set_config <file> <option name> <yes value> <no value> test
    106 # a value of "#" will just comment out the option
    107 set_config() {
    108 	local file="${ED}/$1" var=$2 val com
    109 	eval "${@:5}" && val=$3 || val=$4
    110 	[[ ${val} == "#" ]] && com="#" && val='\2'
    111 	sed -i -r -e "/^#?${var}=/{s:=([\"'])?([^ ]*)\1?:=\1${val}\1:;s:^#?:${com}:}" "${file}"
    112 }
    113 
    114 set_config_yes_no() {
    115 	set_config "$1" "$2" YES NO "${@:3}"
    116 }
    117 
    118 src_install() {
    119 	emake ${MAKE_ARGS} DESTDIR="${D}" install
    120 
    121 	# move the shared libs back to /usr so ldscript can install
    122 	# more of a minimal set of files
    123 	# disabled for now due to #270646
    124 	#mv "${ED}"/$(get_libdir)/lib{einfo,rc}* "${ED}"/usr/$(get_libdir)/ || die
    125 	#gen_usr_ldscript -a einfo rc
    126 	gen_usr_ldscript libeinfo.so
    127 	gen_usr_ldscript librc.so
    128 
    129 	if ! use kernel_linux; then
    130 		keepdir /lib/rc/init.d
    131 	fi
    132 	keepdir /lib/rc/tmp
    133 
    134 	# Setup unicode defaults for silly unicode users
    135 	set_config_yes_no /etc/rc.conf unicode use unicode
    136 
    137 	# Cater to the norm
    138 	set_config_yes_no /etc/conf.d/keymaps windowkeys '(' use x86 '||' use amd64 ')'
    139 
    140 	# On HPPA, do not run consolefont by default (bug #222889)
    141 	if use hppa; then
    142 		rm -f "${ED}"/etc/runlevels/boot/consolefont
    143 	fi
    144 
    145 	# Support for logfile rotation
    146 	insinto /etc/logrotate.d
    147 	newins "${FILESDIR}"/openrc.logrotate openrc
    148 
    149 	# install gentoo pam.d files
    150 	newpamd "${FILESDIR}"/start-stop-daemon.pam start-stop-daemon
    151 	newpamd "${FILESDIR}"/start-stop-daemon.pam supervise-daemon
    152 
    153 	# install documentation
    154 	dodoc ChangeLog *.md
    155 	if use newnet; then
    156 		dodoc README.newnet
    157 	fi
    158 
    159 	# start all the tty at boot except tty1 to not conflict with OpenRC output
    160 	if use init; then
    161 		for n in 2 3 4 5 6; do
    162 			dosym "/etc/init.d/agetty" "/etc/init.d/agetty.tty${n}"
    163 			dosym "/etc/init.d/agetty.tty${n}" "/etc/runlevel/boot/agetty.tty${n}"
    164 		done
    165 		# I like to keep a tty for OpenRC
    166 		#dosym "/etc/init.d/agetty" "${ED}/etc/init.d/agetty.1"
    167 		#dosym "/etc/init.d/agetty.1" "/etc/runlevel/default/agetty.1"
    168 	fi
    169 }
    170 
    171 pkg_preinst() {
    172 	# avoid default thrashing in conf.d files when possible #295406
    173 	if [[ -e "${EROOT}"etc/conf.d/hostname ]] ; then
    174 		(
    175 		unset hostname HOSTNAME
    176 		source "${EROOT}"etc/conf.d/hostname
    177 		: ${hostname:=${HOSTNAME}}
    178 		[[ -n ${hostname} ]] && set_config /etc/conf.d/hostname hostname "${hostname}"
    179 		)
    180 	fi
    181 
    182 	# set default interactive shell to sulogin if it exists
    183 	set_config /etc/rc.conf rc_shell /sbin/sulogin "#" test -e /sbin/sulogin
    184 	return 0
    185 }
    186 
    187 pkg_postinst() {
    188 	if use hppa; then
    189 		elog "Setting the console font does not work on all HPPA consoles."
    190 		elog "You can still enable it by running:"
    191 		elog "# rc-update add consolefont boot"
    192 	fi
    193 
    194 	# Added for 0.35.
    195 	if use kernel_linux && [[ ! -h "${EROOT}"/lib ]]; then
    196 		if [[ -d "${EROOT}$(get_libdir)"/rc ]]; then
    197 			cp -RPp "${EROOT}$(get_libdir)/rc" "${EROOT}"lib
    198 		fi
    199 	elif ! use kernel_linux; then
    200 		if [[ -d "${EROOT}$(get_libdir)"/rc ]]; then
    201 			cp -RPp "${EROOT}$(get_libdir)/rc" "${EROOT}"lib
    202 		fi
    203 	fi
    204 
    205 	if ! use newnet && ! use netifrc; then
    206 		ewarn "You have emerged OpenRc without network support. This"
    207 		ewarn "means you need to SET UP a network manager such as"
    208 		ewarn "	net-misc/netifrc, net-misc/dhcpcd, net-misc/wicd,"
    209 		ewarn "net-misc/NetworkManager, or net-vpn/badvpn."
    210 		ewarn "Or, you have the option of emerging openrc with the newnet"
    211 		ewarn "use flag and configuring /etc/conf.d/network and"
    212 		ewarn "/etc/conf.d/staticroute if you only use static interfaces."
    213 		ewarn
    214 	fi
    215 
    216 	if use newnet && [ ! -e "${EROOT}"etc/runlevels/boot/network ]; then
    217 		ewarn "Please add the network service to your boot runlevel"
    218 		ewarn "as soon as possible. Not doing so could leave you with a system"
    219 		ewarn "without networking."
    220 		ewarn
    221 	fi
    222 }