Magellan Linux

Annotation of /branches/magellan-next/core/initscripts/initscripts-0.7.1.3-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8979 - (hide annotations) (download)
Fri Aug 26 20:41:16 2011 UTC (12 years, 8 months ago) by niro
File size: 7844 byte(s)
-dropped SysV support
1 niro 8979 # $Id$
2    
3     PNAME="initscripts"
4     PVER="0.7.1.3"
5     PBUILD="r2"
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     PCATEGORIE="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-0.11
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-28"
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} 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/conf.d/net.eth0"
126     config_protect_ignore+=" /etc/conf.d/net.routes"
127     minstalldir /etc/env.d || die
128     MCONFIG="/etc/env.d/01initscripts"
129     mclearconfig || die
130     maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die
131     }
132    
133     if [[ ${SYSVINIT_ENABLED} = y ]]
134     then
135     src_install_initscripts()
136     {
137     local flavor="sysvinit"
138     local config_protect_ignore
139     local MCONFIG
140    
141     cd ${SRCDIR}
142     common_install ${flavor} || die
143    
144     # CONFIG_PROTECT_MASK for /etc/rc.d/init.d
145     minstalldir /etc/env.d || die
146     MCONFIG="/etc/env.d/01${flavor}"
147     mclearconfig || die
148     maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die
149     config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4"
150     config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6"
151     config_protect_ignore+=" /etc/modules.autoload"
152     maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die
153     }
154     fi
155    
156     src_install_systemd-initscripts()
157     {
158     local flavor="systemd"
159     local config_protect_ignore
160     local MCONFIG
161    
162     cd ${SRCDIR}
163     common_install ${flavor} || die
164    
165     # install these binaries for old sysvinit compat only
166     if [[ ${SYSVINIT_ENABLED} = n ]]
167     then
168     minstalldir /sbin || die
169     minstallexec ${SRCDIR}/sysvinit/sbin/rc-config /sbin || die
170     minstalldir /etc/rc.d/init.d || die
171     minstallfile ${SRCDIR}/sysvinit/rc/functions /etc/rc.d/init.d/ || die
172     fi
173    
174     # CONFIG_PROTECT_MASK for /etc/rc.d/init.d
175     MCONFIG="/etc/env.d/01${flavor}"
176     minstalldir /etc/env.d || die
177     config_protect_ignore+=" /etc/systemd/system"
178     mclearconfig || die
179     maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die
180     }
181    
182     if [[ ${BUSYBOX_ENABLED} = y ]]
183     then
184     src_install_busybox-initscripts()
185     {
186     local flavor="busybox"
187     local config_protect_ignore
188     local MCONFIG
189    
190     cd ${SRCDIR}
191     common_install ${flavor} || die
192    
193     # CONFIG_PROTECT_MASK for /etc/rc.d/init.d
194     minstalldir /etc/env.d || die
195     MCONFIG="/etc/env.d/01${flavor}"
196     mclearconfig || die
197     maddconfig "CONFIG_PROTECT_MASK=\"/etc/rc.d/init.d\"" || die
198     config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.4"
199     config_protect_ignore+=" /etc/modules.autoload.d/kernel-2.6"
200     config_protect_ignore+=" /etc/modules.autoload"
201     maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die
202     # add conf.d/kernel to protect current udev|mdev configuration
203     config_protect_ignore+=" /etc/conf.d/kernel"
204     maddconfig "CONFIG_PROTECT_IGNORE=\"${config_protect_ignore}\"" || die
205     }
206     fi
207    
208     postinstall()
209     {
210     # emulate seq; its needed to run rc-config
211     # this fixes some annyoing warning when building
212     # livecd or bootstrapping a system.
213     # this hack will be removed when the toolchain is fixed
214     if [ ! -f /usr/bin/seq ]
215     then
216     echo "Using fake 'seq' command ..."
217     seq() {
218     start=$1
219     end=$2
220     for ((i=start; i < end+1; i++))
221     do
222     echo $i
223     done
224     }
225     export -f seq
226     fi
227    
228     # sysvinit and busybox only!
229     if [ -f ${MROOT}/etc/rc.d/init.d/functions ] &&
230     [[ ${BUSYBOX_ENABLED} = y ]] || [[ ${SYSVINIT_ENABLED} = y ]]
231     then
232     # create service state dir mountpoint
233     # needed by >=initscripts-0.3.2-r1
234     [ ! -d ${MROOT}/var/lib/init.d ] && install -d ${MROOT}/var/lib/init.d
235    
236     # mark this dir as undeletable
237     touch ${MROOT}/var/lib/init.d/.keep
238    
239     if [[ -x ${MROOT}/sbin/rc-config ]]
240     then
241     echo "Creating Runlevels ..."
242     local i
243     for i in checkfs cleanfs halt \
244     loadkeys localnet modules mountfs \
245     network reboot sendsignals \
246     setclock swap sysctl consolefont
247     do
248     echo -e "\tAdded ${i} ..."
249     ${MROOT}/sbin/rc-config del ${i} > /dev/null
250     ${MROOT}/sbin/rc-config add ${i} > /dev/null
251     done
252     fi
253     fi
254    
255     # enable network.service (systemd only)
256     if [ -x ${MROOT}/bin/systemctl ]
257     then
258     mstartunit network.service
259     fi
260    
261     # keep this only for transitional purposes
262     # do not ask the user about following files
263     #
264     # if they exist let config_protect process them
265     # but then remove the protected files, to keep only the original file
266     #
267     # file-root is ${MROOT}/etc
268     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"
269     local i file path
270     for i in ${CONFIG_IGNORE}
271     do
272     file="$(basename ${i})"
273     path="$(dirname ${i})/"
274     [[ ${path} == ./ ]] && path=""
275    
276     rm -f ${MROOT}/etc/${path}._cfg????_${file}
277     done
278    
279     # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc
280     if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]]
281     then
282     rm -f ${MROOT}/etc/sysconfig/rc
283     fi
284    
285     # aliases and i368 got renamed to *.conf
286     local i
287     for i in aliases i386
288     do
289     if [[ -f ${MROOT}/etc/modules.d/${i} ]]
290     then
291     rm ${MROOT}/etc/modules.d/${i}
292     fi
293     done
294     }
295    
296     preinstall()
297     {
298     # ignore this while package building
299     if [[ ! -f /.installrc ]]
300     then
301     local package
302     for package in ${BLOCKER}
303     do
304     if [[ ! -z $(magequery -n ${package##*/}) ]]
305     then
306     echo -e ${COLRED}
307     echo -e "Error: ${package} is installed!!"
308     echo -e "This initscript flavor cannot co-exist ${package}."
309     echo -e "Please uninstall ${package} first!"
310     echo -e ${COLDEFAULT}
311     die "${package} found!"
312     fi
313     done
314     fi
315     }
316    
317     preremove()
318     {
319     # protect these files, that they do not get removed from the system
320     local CONFIG_IGNORE="fstab hostname hosts"
321     for i in ${CONFIG_IGNORE}
322     do
323     [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i}
324     done
325     }