/
openrc-0.10.2-r5.ebuild
240 lines (194 loc) · 6.73 KB
/
openrc-0.10.2-r5.ebuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# Distributed under the terms of the GNU General Public License v2
EAPI="4"
inherit eutils flag-o-matic multilib pam toolchain-funcs
DESCRIPTION="OpenRC manages the services, startup and shutdown of a host"
HOMEPAGE="http://roy.marples.name/openrc"
PROVIDE="virtual/baselayout"
RESTRICT="mirror"
LICENSE="BSD-2"
SLOT="0"
KEYWORDS="*"
IUSE="debug elibc_glibc ncurses pam selinux static-libs unicode kernel_linux kernel_FreeBSD"
RDEPEND="kernel_linux? ( >=sys-apps/sysvinit-2.86-r11 )
kernel_FreeBSD? ( virtual/init sys-process/fuser-bsd )
ncurses? ( sys-libs/ncurses )
pam? ( virtual/pam )
>=sys-apps/baselayout-2.2
>=sys-fs/udev-135
sys-apps/iproute2"
DEPEND="ncurses? ( sys-libs/ncurses ) pam? ( virtual/pam ) virtual/os-headers"
GITHUB_REPO="${PN}"
GITHUB_USER="funtoo"
GITHUB_TAG="funtoo-openrc-0.10.2-r4"
NETV="1.3.1-r1"
GITHUB_REPO_CN="corenetwork"
GITHUB_TAG_CN="$NETV"
SRC_URI="
https://www.github.com/${GITHUB_USER}/${GITHUB_REPO}/tarball/${GITHUB_TAG} -> ${PN}-${GITHUB_TAG}.tar.gz
https://www.github.com/${GITHUB_USER}/${GITHUB_REPO_CN}/tarball/${GITHUB_TAG_CN} -> corenetwork-${NETV}.tar.gz
"
make_args() {
unset LIBDIR #266688
MAKE_ARGS="${MAKE_ARGS} LIBNAME=$(get_libdir) LIBEXECDIR=/$(get_libdir)/rc"
local brand="Unknown"
if use kernel_linux ; then
MAKE_ARGS="${MAKE_ARGS} OS=Linux"
brand="Linux"
elif use kernel_FreeBSD ; then
MAKE_ARGS="${MAKE_ARGS} OS=FreeBSD"
brand="FreeBSD"
fi
if use selinux; then
MAKE_ARGS="${MAKE_ARGS} MKSELINUX=yes"
fi
export BRANDING="Funtoo ${brand}"
if ! use static-libs; then
MAKE_ARGS="${MAKE_ARGS} MKSTATICLIBS=no"
fi
}
pkg_setup() {
export DEBUG=$(usev debug)
export MKPAM=$(usev pam)
export MKTERMCAP=$(usev ncurses)
}
src_unpack() {
unpack $A
# rename github directories to the names we're expecting:
local old=${WORKDIR}/${GITHUB_USER}-${PN}-*
mv $old "${WORKDIR}/${P}" || die "move fail 1"
old="${WORKDIR}/${GITHUB_USER}-corenetwork-*"
mv $old "${WORKDIR}/corenetwork-${NETV}" || die "move fail 2"
}
src_prepare() {
sed -i 's:0444:0644:' mk/sys.mk || die
sed -i "/^DIR/s:/openrc:/${PF}:" doc/Makefile || die #241342
if [[ ${PV} == "9999" ]] ; then
local ver="git-${EGIT_VERSION:0:6}"
sed -i "/^GITVER[[:space:]]*=/s:=.*:=${ver}:" mk/git.mk || die
fi
}
src_compile() {
make_args
tc-export CC AR RANLIB
emake ${MAKE_ARGS}
}
# set_config <file> <option name> <yes value> <no value> test
# a value of "#" will just comment out the option
set_config() {
local file="${D}/$1" var=$2 val com
eval "${@:5}" && val=$3 || val=$4
[[ ${val} == "#" ]] && com="#" && val='\2'
sed -i -r -e "/^#?${var}=/{s:=([\"'])?([^ ]*)\1?:=\1${val}\1:;s:^#?:${com}:}" "${file}"
}
set_config_yes_no() {
set_config "$1" "$2" YES NO "${@:3}"
}
src_install() {
make_args
emake ${MAKE_ARGS} DESTDIR="${D}" install
# move the shared libs back to /usr so ldscript can install
# more of a minimal set of files
# disabled for now due to #270646
#mv "${D}"/$(get_libdir)/lib{einfo,rc}* "${D}"/usr/$(get_libdir)/ || die
#gen_usr_ldscript -a einfo rc
gen_usr_ldscript libeinfo.so
gen_usr_ldscript librc.so
if ! use kernel_linux; then
keepdir /$(get_libdir)/rc/init.d
fi
keepdir /$(get_libdir)/rc/tmp
# Backup our default runlevels
dodir /usr/share/"${PN}"
cp -PR "${D}"/etc/runlevels "${D}"/usr/share/${PN} || die
rm -rf "${D}"/etc/runlevels
# Setup unicode defaults for silly unicode users
set_config_yes_no /etc/rc.conf unicode use unicode
# Cater to the norm
set_config_yes_no /etc/conf.d/keymaps windowkeys '(' use x86 '||' use amd64 ')'
# On HPPA, do not run consolefont by default (bug #222889)
if use hppa; then
rm -f "${D}"/usr/share/openrc/runlevels/boot/consolefont
fi
# Support for logfile rotation
insinto /etc/logrotate.d
newins "${FILESDIR}"/openrc.logrotate openrc
# install the gentoo pam.d file
newpamd "${FILESDIR}"/start-stop-daemon.pam start-stop-daemon
# Remove upstream networking parts:
for pat in ${D}/lib64/rc/net/ ${D}/etc/init.d/{net.lo,network,staticroute} \
${D}/usr/share/openrc/runlevels/boot/{net.lo,network,staticroute} \
${D}/etc/conf.d/{net,network,staticroute}; do
rm -rf "$pat" || die "Couldn't remove upstream $pat from source."
done
# Install funtoo networking parts:
cd ${WORKDIR}/corenetwork-${NETV} || die
dodoc docs/index.rst || die
exeinto /etc/init.d || die
doexe init.d/{netif.tmpl,netif.lo} || die
cp -a netif.d ${D}/etc || die
chown -R root:root ${D}/etc/netif.d || die
chmod -R 0644 ${D}/etc/netif.d || die
ln -s /etc/init.d/netif.lo ${D}/usr/share/openrc/runlevels/sysinit/netif.lo || die
}
add_init() {
local runl=$1
shift
if [ ! -e ${ROOT}/etc/runlevels/${runl} ]
then
install -d -m0755 ${ROOT}/etc/runlevels/${runl}
fi
for initd in $*
do
[[ -e ${ROOT}/etc/runlevels/${runl}/${initd} ]] && continue
elog "Auto-adding '${initd}' service to your ${runl} runlevel"
ln -snf /etc/init.d/${initd} "${ROOT}"/etc/runlevels/${runl}/${initd}
done
}
pkg_postinst() {
local runl
install -d -m0755 ${ROOT}/etc/runlevels
local runldir="${ROOT}usr/share/openrc/runlevels"
# Remove old baselayout links
rm -f "${ROOT}"/etc/runlevels/boot/{check{fs,root},rmnologin}
rm -f "${ROOT}"/etc/init.d/{depscan,runscript}.sh
rm -f "${ROOT}"/etc/runlevels/boot/netif.lo
# CREATE RUNLEVEL DIRECTORIES
# ===========================
# To ensure proper system operation, this portion of the script ensures that
# all of OpenRC's default initscripts in all runlevels are properly
# installed.
for runl in $( cd "$runldir"; echo * )
do
einfo "Processing $runl..."
einfo "Ensuring runlevel $runl has all required scripts..."
add_init $runl $( cd "$runldir/$runl"; echo * )
done
# Rather than try to migrate everyone using complex scripts, simply print
# names of initscripts that are in the user's runlevels but not provided by
# OpenRC. This loop can be upgraded to look for particular scripts that
# might have come from baselayout.
for runl in $( cd ${ROOT}/etc/runlevels; echo * )
do
[ ! -d ${runldir}/${runl} ] && continue
for init in $( cd "$runldir/$runl"; echo * )
do
if [ -e ${ROOT}/etc/runlevels/${runl}/${init} ] && [ ! -e ${runldir}/${runl}/${init} ]
then
echo "Initscript ${init} exists in runlevel ${runl} but not in OpenRC."
fi
done
done
# OTHER STUFF
# ===========
# update the dependency tree bug #224171
[[ "${ROOT}" = "/" ]] && "${ROOT}/$(get_libdir)"/rc/bin/rc-depend -u
elog "You should now update all files in /etc, using etc-update"
elog "or equivalent before rebooting."
elog
if path_exists -o "${ROOT}"/etc/conf.d/local.{start,stop} ; then
ewarn "/etc/conf.d/local.{start,stop} are deprecated. Please convert"
ewarn "your files to /etc/conf.d/local and delete the files."
fi
ewarn "Make sure that correct symlink exist"
ewarn "Re-establish it by ln -s /etc/init.d/netif.tmpl /etc/init.d/netif.ethX"
}