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