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