openrc-0.38.3-r1.ebuild (9857B)
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 debug ncurses init pam newnet prefix +netifrc selinux static-libs 22 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 !prefix? ( 46 kernel_linux? ( 47 !init? ( >=sys-apps/sysvinit-2.86-r6[selinux?] ) 48 init? ( !sys-apps/sysvinit ) 49 virtual/tmpfiles 50 ) 51 kernel_FreeBSD? ( sys-freebsd/freebsd-sbin ) 52 ) 53 selinux? ( 54 >=sec-policy/selinux-base-policy-2.20170204-r4 55 >=sec-policy/selinux-openrc-2.20170204-r4 56 ) 57 !<app-shells/gentoo-bashcomp-20180302 58 !<app-shells/gentoo-zsh-completions-20180228 59 " 60 61 PDEPEND="netifrc? ( net-misc/netifrc )" 62 63 src_prepare() { 64 default 65 if [[ ${PV} == "9999" ]] ; then 66 local ver="git-${EGIT_VERSION:0:6}" 67 sed -i "/^GITVER[[:space:]]*=/s:=.*:=${ver}:" mk/gitver.mk || die 68 fi 69 } 70 71 src_compile() { 72 unset LIBDIR #266688 73 74 MAKE_ARGS="${MAKE_ARGS} 75 LIBNAME=$(get_libdir) 76 LIBEXECDIR=${EPREFIX}/lib/rc 77 MKBASHCOMP=yes 78 MKNET=$(usex newnet) 79 MKSELINUX=$(usex selinux) 80 MKSYSVINIT=$(usex init) 81 MKAUDIT=$(usex audit) 82 MKPAM=$(usev pam) 83 MKSTATICLIBS=$(usex static-libs) 84 MKZSHCOMP=yes" 85 86 local brand="Unknown" 87 if use kernel_linux ; then 88 MAKE_ARGS="${MAKE_ARGS} OS=Linux" 89 brand="Linux" 90 elif use kernel_FreeBSD ; then 91 MAKE_ARGS="${MAKE_ARGS} OS=FreeBSD" 92 brand="FreeBSD" 93 fi 94 export BRANDING="Gentoo ${brand}" 95 use prefix && MAKE_ARGS="${MAKE_ARGS} MKPREFIX=yes PREFIX=${EPREFIX}" 96 export DEBUG=$(usev debug) 97 export MKTERMCAP=$(usev ncurses) 98 99 tc-export CC AR RANLIB 100 emake ${MAKE_ARGS} 101 } 102 103 # set_config <file> <option name> <yes value> <no value> test 104 # a value of "#" will just comment out the option 105 set_config() { 106 local file="${ED}/$1" var=$2 val com 107 eval "${@:5}" && val=$3 || val=$4 108 [[ ${val} == "#" ]] && com="#" && val='\2' 109 sed -i -r -e "/^#?${var}=/{s:=([\"'])?([^ ]*)\1?:=\1${val}\1:;s:^#?:${com}:}" "${file}" 110 } 111 112 set_config_yes_no() { 113 set_config "$1" "$2" YES NO "${@:3}" 114 } 115 116 src_install() { 117 emake ${MAKE_ARGS} DESTDIR="${D}" install 118 119 # move the shared libs back to /usr so ldscript can install 120 # more of a minimal set of files 121 # disabled for now due to #270646 122 #mv "${ED}"/$(get_libdir)/lib{einfo,rc}* "${ED}"/usr/$(get_libdir)/ || die 123 #gen_usr_ldscript -a einfo rc 124 gen_usr_ldscript libeinfo.so 125 gen_usr_ldscript librc.so 126 127 if ! use kernel_linux; then 128 keepdir /lib/rc/init.d 129 fi 130 keepdir /lib/rc/tmp 131 132 # Backup our default runlevels 133 dodir /usr/share/"${PN}" 134 cp -PR "${ED}"/etc/runlevels "${ED}"/usr/share/${PN} || die 135 rm -rf "${ED}"/etc/runlevels 136 137 # Setup unicode defaults for silly unicode users 138 set_config_yes_no /etc/rc.conf unicode use unicode 139 140 # Cater to the norm 141 set_config_yes_no /etc/conf.d/keymaps windowkeys '(' use x86 '||' use amd64 ')' 142 143 # On HPPA, do not run consolefont by default (bug #222889) 144 if use hppa; then 145 rm -f "${ED}"/usr/share/openrc/runlevels/boot/consolefont 146 fi 147 148 # Support for logfile rotation 149 insinto /etc/logrotate.d 150 newins "${FILESDIR}"/openrc.logrotate openrc 151 152 # install gentoo pam.d files 153 newpamd "${FILESDIR}"/start-stop-daemon.pam start-stop-daemon 154 newpamd "${FILESDIR}"/start-stop-daemon.pam supervise-daemon 155 156 # install documentation 157 dodoc ChangeLog *.md 158 if use newnet; then 159 dodoc README.newnet 160 fi 161 } 162 163 add_boot_init() { 164 local initd=$1 165 local runlevel=${2:-boot} 166 # if the initscript is not going to be installed and is not 167 # currently installed, return 168 [[ -e "${ED}"/etc/init.d/${initd} || -e "${EROOT}"etc/init.d/${initd} ]] \ 169 || return 170 [[ -e "${EROOT}"etc/runlevels/${runlevel}/${initd} ]] && return 171 172 # if runlevels dont exist just yet, then create it but still flag 173 # to pkg_postinst that it needs real setup #277323 174 if [[ ! -d "${EROOT}"etc/runlevels/${runlevel} ]] ; then 175 mkdir -p "${EROOT}"etc/runlevels/${runlevel} 176 touch "${EROOT}"etc/runlevels/.add_boot_init.created 177 fi 178 179 elog "Auto-adding '${initd}' service to your ${runlevel} runlevel" 180 ln -snf /etc/init.d/${initd} "${EROOT}"etc/runlevels/${runlevel}/${initd} 181 } 182 add_boot_init_mit_config() { 183 local config=$1 initd=$2 184 if [[ -e ${EROOT}${config} ]] ; then 185 if [[ -n $(sed -e 's:#.*::' -e '/^[[:space:]]*$/d' "${EROOT}"${config}) ]] ; then 186 add_boot_init ${initd} 187 fi 188 fi 189 } 190 191 pkg_preinst() { 192 local f LIBDIR=$(get_libdir) 193 194 # avoid default thrashing in conf.d files when possible #295406 195 if [[ -e "${EROOT}"etc/conf.d/hostname ]] ; then 196 ( 197 unset hostname HOSTNAME 198 source "${EROOT}"etc/conf.d/hostname 199 : ${hostname:=${HOSTNAME}} 200 [[ -n ${hostname} ]] && set_config /etc/conf.d/hostname hostname "${hostname}" 201 ) 202 fi 203 204 # set default interactive shell to sulogin if it exists 205 set_config /etc/rc.conf rc_shell /sbin/sulogin "#" test -e /sbin/sulogin 206 207 # termencoding was added in 0.2.1 and needed in boot 208 has_version ">=sys-apps/openrc-0.2.1" || add_boot_init termencoding 209 210 # swapfiles was added in 0.9.9 and needed in boot (february 2012) 211 has_version ">=sys-apps/openrc-0.9.9" || add_boot_init swapfiles 212 213 if ! has_version ">=sys-apps/openrc-0.11"; then 214 add_boot_init sysfs sysinit 215 fi 216 217 if ! has_version ">=sys-apps/openrc-0.11.3" ; then 218 migrate_udev_mount_script 219 fi 220 221 # these were added in 0.12. 222 if ! has_version ">=sys-apps/openrc-0.12"; then 223 add_boot_init loopback 224 225 # ensure existing /etc/conf.d/net is not removed 226 # undoes the hack to get around CONFIG_PROTECT in openrc-0.11.8 and earlier 227 # this needs to stay in openrc ebuilds for a long time. :( 228 # Added in 0.12. 229 if [[ -f "${EROOT}"etc/conf.d/net ]]; then 230 einfo "Modifying conf.d/net to keep it from being removed" 231 cat <<-EOF >>"${EROOT}"etc/conf.d/net 232 233 # The network scripts are now part of net-misc/netifrc 234 # In order to avoid sys-apps/${P} from removing this file, this comment was 235 # added; you can safely remove this comment. Please see 236 # /usr/share/doc/netifrc*/README* for more information. 237 EOF 238 fi 239 fi 240 has_version ">=sys-apps/openrc-0.14" || add_boot_init binfmt 241 242 if ! has_version ">=sys-apps/openrc-0.18.3"; then 243 add_boot_init mtab 244 if [[ -f "${EROOT}"etc/mtab ]] && [[ ! -L "${EROOT}"etc/mtab ]]; then 245 ewarn "${EROOT}etc/mtab will be replaced with a" 246 ewarn "symbolic link to /proc/self/mounts on the next" 247 ewarn "reboot." 248 ewarn "Change the setting in ${EROOT}etc/conf.d/mtab" 249 ewarn "if you do not want this to happen." 250 fi 251 fi 252 253 has_version ">=sys-apps/openrc-0.35" || add_boot_init cgroups sysinit 254 255 } 256 257 # >=OpenRC-0.11.3 requires udev-mount to be in the sysinit runlevel with udev. 258 migrate_udev_mount_script() { 259 if [ -e "${EROOT}"etc/runlevels/sysinit/udev -a \ 260 ! -e "${EROOT}"etc/runlevels/sysinit/udev-mount ]; then 261 add_boot_init udev-mount sysinit 262 fi 263 return 0 264 } 265 266 pkg_postinst() { 267 local LIBDIR=$(get_libdir) 268 269 # Make our runlevels if they don't exist 270 if [[ -z "${REPLACING_VERSIONS}" ]]; then 271 einfo "Copying across default runlevels" 272 cp -RPp "${EROOT}"usr/share/${PN}/runlevels "${EROOT}"etc 273 rm -f "${EROOT}"etc/runlevels/.add_boot_init.created 274 else 275 if [[ ! -e "${EROOT}"etc/runlevels/sysinit/devfs ]] ; then 276 mkdir -p "${EROOT}"etc/runlevels/sysinit 277 cp -RPp "${EROOT}"usr/share/${PN}/runlevels/sysinit/* \ 278 "${EROOT}"etc/runlevels/sysinit 279 fi 280 if [[ ! -e "${EROOT}"etc/runlevels/shutdown/mount-ro ]] ; then 281 mkdir -p "${EROOT}"etc/runlevels/shutdown 282 cp -RPp "${EROOT}"usr/share/${PN}/runlevels/shutdown/* \ 283 "${EROOT}"etc/runlevels/shutdown 284 fi 285 if [[ ! -e "${EROOT}"etc/runlevels/nonetwork/local ]]; then 286 cp -RPp "${EROOT}"usr/share/${PN}/runlevels/nonetwork \ 287 "${EROOT}"etc/runlevels 288 fi 289 fi 290 291 if use hppa; then 292 elog "Setting the console font does not work on all HPPA consoles." 293 elog "You can still enable it by running:" 294 elog "# rc-update add consolefont boot" 295 fi 296 297 # Added for 0.35. 298 if use kernel_linux && [[ ! -h "${EROOT}"/lib ]]; then 299 if [[ -d "${EROOT}$(get_libdir)"/rc ]]; then 300 cp -RPp "${EROOT}$(get_libdir)/rc" "${EROOT}"lib 301 fi 302 elif ! use kernel_linux; then 303 if [[ -d "${EROOT}$(get_libdir)"/rc ]]; then 304 cp -RPp "${EROOT}$(get_libdir)/rc" "${EROOT}"lib 305 fi 306 fi 307 308 # update the dependency tree after touching all files #224171 309 [[ "${EROOT}" = "/" ]] && "${EROOT}"/lib/rc/bin/rc-depend -u 310 311 if ! use newnet && ! use netifrc; then 312 ewarn "You have emerged OpenRc without network support. This" 313 ewarn "means you need to SET UP a network manager such as" 314 ewarn " net-misc/netifrc, net-misc/dhcpcd, net-misc/wicd," 315 ewarn "net-misc/NetworkManager, or net-vpn/badvpn." 316 ewarn "Or, you have the option of emerging openrc with the newnet" 317 ewarn "use flag and configuring /etc/conf.d/network and" 318 ewarn "/etc/conf.d/staticroute if you only use static interfaces." 319 ewarn 320 fi 321 322 if use newnet && [ ! -e "${EROOT}"etc/runlevels/boot/network ]; then 323 ewarn "Please add the network service to your boot runlevel" 324 ewarn "as soon as possible. Not doing so could leave you with a system" 325 ewarn "without networking." 326 ewarn 327 fi 328 }