Annotation of /branches/R11-stable/core/initscripts/initscripts-0.8.1-r1.smage2
Parent Directory | Revision Log
Revision 17008 -
(hide annotations)
(download)
Thu Apr 4 15:34:52 2013 UTC (11 years, 5 months ago) by niro
File size: 8890 byte(s)
Thu Apr 4 15:34:52 2013 UTC (11 years, 5 months ago) by niro
File size: 8890 byte(s)
-release branches/R11-stable
1 | niro | 16964 | # $Id$ |
2 | |||
3 | PNAME="initscripts" | ||
4 | PVER="0.8.1" | ||
5 | PBUILD="r1" | ||
6 | |||
7 | # enable busybox initscripts y|n | ||
8 | # disabled atm, busybox missing in tree | ||
9 | BUSYBOX_ENABLED="n" | ||
10 | # enable sysvinit initscripts y|n | ||
11 | # disabled, we have replaced sysvinit with systemd | ||
12 | SYSVINIT_ENABLED="n" | ||
13 | |||
14 | SPLIT_PACKAGES="systemd-initscripts" | ||
15 | |||
16 | [[ ${BUSYBOX_ENABLED} = y ]] && SPLIT_PACKAGES+=" busybox-initscripts" | ||
17 | [[ ${SYSVINIT_ENABLED} = y ]] && SPLIT_PACKAGES+=" initscripts" | ||
18 | |||
19 | PCAT="sys-apps" | ||
20 | HOMEPAGE="http://magellan-linux.net" | ||
21 | |||
22 | # the pkgs "coreutils, findutils, sed, gawk, bzip2, tar, rsync, wget" | ||
23 | # are needed to fix the /etc/profile issue | ||
24 | COMMON_DEPEND=">= sys-apps/base-files-0.5 | ||
25 | >= sys-apps/mage-release-R11 | ||
26 | >= sys-apps/coreutils-5 | ||
27 | >= sys-apps/findutils-4 | ||
28 | >= sys-apps/grep-2 | ||
29 | >= sys-apps/sed-4 | ||
30 | >= sys-apps/gawk-3 | ||
31 | >= app-arch/bzip2-1 | ||
32 | >= sys-apps/tar-1 | ||
33 | >= net-misc/rsync-2 | ||
34 | >= net-misc/wget-1 | ||
35 | >= sys-apps/which-2.20" | ||
36 | |||
37 | SYSTEMD_DEPEND=">= sys-apps/systemd-197" | ||
38 | |||
39 | SDEPEND="${COMMON_DEPEND} | ||
40 | ${SYSTEMD_DEPEND}" | ||
41 | |||
42 | if [[ ${BUSYBOX_ENABLED} = y ]] | ||
43 | then | ||
44 | BUSYBOX_DEPEND=">= sys-apps/busybox-1.17" | ||
45 | SDEPEND="${SDEPEND} | ||
46 | ${BUSYBOX_DEPEND}" | ||
47 | fi | ||
48 | |||
49 | if [[ ${SYSVINIT_ENABLED} = y ]] | ||
50 | then | ||
51 | SYSVINIT_DEPEND=">= sys-apps/sysvinit-2.88" | ||
52 | SDEPEND="${SDEPEND} | ||
53 | ${SYSVINIT_DEPEND}" | ||
54 | fi | ||
55 | |||
56 | PROVIDE="virtual/initscripts" | ||
57 | |||
58 | SRCFILE="${PNAME}-${PVER}.tar.bz2" | ||
59 | SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" | ||
60 | |||
61 | sminclude mtools | ||
62 | |||
63 | SRC_URI=( mirror://${PNAME}/${SRCFILE} ) | ||
64 | |||
65 | SPECIAL_VARS="BLOCKER SYSVINIT_ENABLED BUSYBOX_ENABLED" | ||
66 | |||
67 | if [[ ${SYSVINIT_ENABLED} = y ]] | ||
68 | then | ||
69 | split_info_initscripts() | ||
70 | { | ||
71 | DESCRIPTION="Magellan Initscripts for sysVinit." | ||
72 | DEPEND="${COMMON_DEPEND} | ||
73 | ${SYSVINIT_DEPEND}" | ||
74 | |||
75 | BLOCKER="sys-apps/systemd-initscripts sys-apps/busybox-initscripts" | ||
76 | } | ||
77 | fi | ||
78 | |||
79 | split_info_systemd-initscripts() | ||
80 | { | ||
81 | DESCRIPTION="Magellan Initscripts for systemd." | ||
82 | DEPEND="${COMMON_DEPEND} | ||
83 | ${SYSTEMD_DEPEND}" | ||
84 | |||
85 | BLOCKER="sys-apps/initscripts sys-apps/busybox-initscripts" | ||
86 | } | ||
87 | |||
88 | if [[ ${BUSYBOX_ENABLED} = y ]] | ||
89 | then | ||
90 | split_info_busybox-initscripts() | ||
91 | { | ||
92 | DESCRIPTION="Magellan Initscripts for busybox." | ||
93 | DEPEND="${COMMON_DEPEND} | ||
94 | ${BUSYBOX_DEPEND}" | ||
95 | |||
96 | BLOCKER="sys-apps/initscripts sys-apps/systemd-initscripts" | ||
97 | } | ||
98 | fi | ||
99 | |||
100 | src_prepare() | ||
101 | { | ||
102 | munpack ${SRCFILE} || die | ||
103 | } | ||
104 | |||
105 | src_compile() | ||
106 | { | ||
107 | cd ${SRCDIR} | ||
108 | mmake || die | ||
109 | } | ||
110 | |||
111 | common_install() | ||
112 | { | ||
113 | local method="$1" | ||
114 | local MCONFIG | ||
115 | local config_protect_ignore | ||
116 | |||
117 | cd ${SRCDIR} | ||
118 | make DESTDIR=${BINDIR} LIBDIR=/usr/lib SBINDIR=/usr/sbin install_${method} || die | ||
119 | |||
120 | # always keep this files even if the user edited them | ||
121 | config_protect_ignore="/etc/fstab" | ||
122 | config_protect_ignore+=" /etc/hostname" | ||
123 | config_protect_ignore+=" /etc/hosts" | ||
124 | config_protect_ignore+=" /etc/inittab" | ||
125 | config_protect_ignore+=" /etc/locale.conf" | ||
126 | config_protect_ignore+=" /etc/vconsole.conf" | ||
127 | config_protect_ignore+=" /etc/conf.d/net.eth0" | ||
128 | config_protect_ignore+=" /etc/conf.d/net.routes" | ||
129 | minstalldir /etc/env.d || die | ||
130 | MCONFIG="/etc/env.d/01initscripts" | ||
131 | mclearconfig || die | ||
132 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die | ||
133 | } | ||
134 | |||
135 | if [[ ${SYSVINIT_ENABLED} = y ]] | ||
136 | then | ||
137 | src_install_initscripts() | ||
138 | { | ||
139 | local flavor="sysvinit" | ||
140 | local config_protect_ignore | ||
141 | local MCONFIG | ||
142 | |||
143 | cd ${SRCDIR} | ||
144 | common_install ${flavor} || die | ||
145 | |||
146 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d | ||
147 | minstalldir /etc/env.d || die | ||
148 | MCONFIG="/etc/env.d/01${flavor}" | ||
149 | mclearconfig || die | ||
150 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die | ||
151 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" | ||
152 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" | ||
153 | config_protect_ignore+=" /etc/modules.autoload" | ||
154 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die | ||
155 | } | ||
156 | fi | ||
157 | |||
158 | src_install_systemd-initscripts() | ||
159 | { | ||
160 | local flavor="systemd" | ||
161 | local config_protect_ignore | ||
162 | local MCONFIG | ||
163 | |||
164 | cd ${SRCDIR} | ||
165 | common_install ${flavor} || die | ||
166 | |||
167 | # install these binaries for old sysvinit compat only | ||
168 | if [[ ${SYSVINIT_ENABLED} = n ]] | ||
169 | then | ||
170 | minstalldir /usr/sbin || die | ||
171 | minstallexec ${SRCDIR}/sysvinit/sbin/rc-config /usr/sbin || die | ||
172 | minstalldir /etc/rc.d/init.d || die | ||
173 | minstallfile ${SRCDIR}/sysvinit/rc/functions /etc/rc.d/init.d/ || die | ||
174 | fi | ||
175 | |||
176 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d | ||
177 | MCONFIG="/etc/env.d/01${flavor}" | ||
178 | minstalldir /etc/env.d || die | ||
179 | config_protect_ignore+=" /etc/systemd/system" | ||
180 | mclearconfig || die | ||
181 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die | ||
182 | } | ||
183 | |||
184 | if [[ ${BUSYBOX_ENABLED} = y ]] | ||
185 | then | ||
186 | src_install_busybox-initscripts() | ||
187 | { | ||
188 | local flavor="busybox" | ||
189 | local config_protect_ignore | ||
190 | local MCONFIG | ||
191 | |||
192 | cd ${SRCDIR} | ||
193 | common_install ${flavor} || die | ||
194 | |||
195 | # CONFIG_PROTECT_MASK for /etc/rc.d/init.d | ||
196 | minstalldir /etc/env.d || die | ||
197 | MCONFIG="/etc/env.d/01${flavor}" | ||
198 | mclearconfig || die | ||
199 | maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die | ||
200 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4" | ||
201 | config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6" | ||
202 | config_protect_ignore+=" /etc/modules.autoload" | ||
203 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die | ||
204 | # add conf.d/kernel to protect current udev|mdev configuration | ||
205 | config_protect_ignore+=" /etc/conf.d/kernel" | ||
206 | maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die | ||
207 | } | ||
208 | fi | ||
209 | |||
210 | postinstall() | ||
211 | { | ||
212 | # emulate seq; its needed to run rc-config | ||
213 | # this fixes some annyoing warning when building | ||
214 | # livecd or bootstrapping a system. | ||
215 | # this hack will be removed when the toolchain is fixed | ||
216 | if [ ! -f /usr/bin/seq ] | ||
217 | then | ||
218 | echo "Using fake 'seq' command ..." | ||
219 | seq() { | ||
220 | start=$1 | ||
221 | end=$2 | ||
222 | for ((i=start; i < end+1; i++)) | ||
223 | do | ||
224 | echo $i | ||
225 | done | ||
226 | } | ||
227 | export -f seq | ||
228 | fi | ||
229 | |||
230 | # move old /etc/conf.d/locale to /etc/locale.conf | ||
231 | if [ -f ${MROOT}/etc/conf.d/locale ] | ||
232 | then | ||
233 | echo "Moving ${MROOT}/etc/conf.d/locale -> ${MROOT}/etc/locale.conf" | ||
234 | cp ${MROOT}/etc/conf.d/locale ${MROOT}/etc/locale.conf | ||
235 | rm ${MROOT}/etc/conf.d/locale | ||
236 | fi | ||
237 | |||
238 | # generate a valid /etc/vconsole.conf from old data | ||
239 | if [ -f ${MROOT}/etc/conf.d/consolefont ] && [ -f ${MROOT}/etc/conf.d/keymap ] | ||
240 | then | ||
241 | echo "Generating ${MROOT}/etc/vconsole.conf with /etc/conf.d data" | ||
242 | local consolefont=$(source ${MROOT}/etc/conf.d/consolefont; echo "${CONSOLEFONT}") | ||
243 | local keymap=$(source ${MROOT}/etc/conf.d/keymap; echo "${KEYMAP}") | ||
244 | cat > ${MROOT}/etc/vconsole.conf << EOF | ||
245 | KEYMAP=${keymap} | ||
246 | FONT=${consolefont} | ||
247 | FONT_MAP=8851-1_to_uni | ||
248 | EOF | ||
249 | echo "Deleting old ${MROOT}/etc/conf.d/consolefont" | ||
250 | rm ${MROOT}/etc/conf.d/consolefont | ||
251 | echo "Deleting old ${MROOT}/etc/conf.d/keymap" | ||
252 | rm ${MROOT}/etc/conf.d/keymap | ||
253 | fi | ||
254 | |||
255 | # sysvinit and busybox only! | ||
256 | if [ -f ${MROOT}/etc/rc.d/init.d/functions ] && | ||
257 | [[ ${BUSYBOX_ENABLED} = y ]] || [[ ${SYSVINIT_ENABLED} = y ]] | ||
258 | then | ||
259 | # create service state dir mountpoint | ||
260 | # needed by >=initscripts-0.3.2-r1 | ||
261 | [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d | ||
262 | |||
263 | # mark this dir as undeletable | ||
264 | touch ${MROOT}/var/lib/init.d/.keep | ||
265 | |||
266 | if [[ -x ${MROOT}/usr/sbin/rc-config ]] | ||
267 | then | ||
268 | echo "Creating Runlevels ..." | ||
269 | local i | ||
270 | for i in checkfs cleanfs halt \ | ||
271 | loadkeys localnet modules mountfs \ | ||
272 | network reboot sendsignals \ | ||
273 | setclock swap sysctl consolefont | ||
274 | do | ||
275 | echo -e "\tAdded ${i} ..." | ||
276 | ${MROOT}/usr/sbin/rc-config del ${i} > /dev/null | ||
277 | ${MROOT}/usr/sbin/rc-config add ${i} > /dev/null | ||
278 | done | ||
279 | fi | ||
280 | fi | ||
281 | |||
282 | # enable network.service (systemd only) | ||
283 | if [ -x ${MROOT}/usr/bin/systemctl ] | ||
284 | then | ||
285 | mstartunit network.service | ||
286 | fi | ||
287 | |||
288 | # keep this only for transitional purposes | ||
289 | # do not ask the user about following files | ||
290 | # | ||
291 | # if they exist let config_protect process them | ||
292 | # but then remove the protected files, to keep only the original file | ||
293 | # | ||
294 | # file-root is ${MROOT}/etc | ||
295 | local CONFIG_IGNORE="fstab hostname hosts inittab conf.d/net.eth0 modules.autoload.d/kernel-2.4 modules.autoload.d/kernel-2.6 modules.autoload" | ||
296 | local i file path | ||
297 | for i in ${CONFIG_IGNORE} | ||
298 | do | ||
299 | file="$(basename ${i})" | ||
300 | path="$(dirname ${i})/" | ||
301 | [[ ${path} == ./ ]] && path="" | ||
302 | |||
303 | rm -f ${MROOT}/etc/${path}._cfg????_${file} | ||
304 | done | ||
305 | |||
306 | # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc | ||
307 | if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]] | ||
308 | then | ||
309 | rm -f ${MROOT}/etc/sysconfig/rc | ||
310 | fi | ||
311 | |||
312 | # aliases and i368 got renamed to *.conf | ||
313 | local i | ||
314 | for i in aliases i386 | ||
315 | do | ||
316 | if [[ -f ${MROOT}/etc/modules.d/${i} ]] | ||
317 | then | ||
318 | rm ${MROOT}/etc/modules.d/${i} | ||
319 | fi | ||
320 | done | ||
321 | } | ||
322 | |||
323 | preinstall() | ||
324 | { | ||
325 | # ignore this while package building | ||
326 | if [[ ! -f /.installrc ]] | ||
327 | then | ||
328 | local package | ||
329 | for package in ${BLOCKER} | ||
330 | do | ||
331 | if [[ ! -z $(magequery -n ${package##*/}) ]] | ||
332 | then | ||
333 | echo -e ${COLRED} | ||
334 | echo -e "Error: ${package} is installed!!" | ||
335 | echo -e "This initscript flavor cannot co-exist ${package}." | ||
336 | echo -e "Please uninstall ${package} first!" | ||
337 | echo -e ${COLDEFAULT} | ||
338 | die "${package} found!" | ||
339 | fi | ||
340 | done | ||
341 | fi | ||
342 | } | ||
343 | |||
344 | preremove() | ||
345 | { | ||
346 | # protect these files, that they do not get removed from the system | ||
347 | local CONFIG_IGNORE="fstab hostname hosts" | ||
348 | for i in ${CONFIG_IGNORE} | ||
349 | do | ||
350 | [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i} | ||
351 | done | ||
352 | } |