Magellan Linux

Annotation of /branches/magellan-next/core/initscripts/initscripts-0.7.0.3-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8399 - (hide annotations) (download)
Mon Jul 18 10:58:05 2011 UTC (12 years, 9 months ago) by niro
File size: 7824 byte(s)
auto added: ver bump to 0.7.0.3-r1
1 niro 8399 # $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     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     # enable network.service (systemd only)
235     if [ -x ${MROOT}/bin/systemctl ]
236     then
237     mstartunit network.service
238     fi
239    
240     # keep this only for transitional purposes
241     # do not ask the user about following files
242     #
243     # if they exist let config_protect process them
244     # but then remove the protected files, to keep only the original file
245     #
246     # file-root is ${MROOT}/etc
247     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"
248     local i file path
249     for i in ${CONFIG_IGNORE}
250     do
251     file="$(basename ${i})"
252     path="$(dirname ${i})/"
253     [[ ${path} == ./ ]] && path=""
254    
255     rm -f ${MROOT}/etc/${path}._cfg????_${file}
256     done
257    
258     # initscripts >= 0.5.0: rc file moved to /etc/conf.d/rc
259     if [[ -f ${MROOT}/etc/conf.d/rc ]] && [[ -f ${MROOT}/etc/sysconfig/rc ]]
260     then
261     rm -f ${MROOT}/etc/sysconfig/rc
262     fi
263    
264     # aliases and i368 got renamed to *.conf
265     local i
266     for i in aliases i386
267     do
268     if [[ -f ${MROOT}/etc/modules.d/${i} ]]
269     then
270     rm ${MROOT}/etc/modules.d/${i}
271     fi
272     done
273     }
274    
275     preinstall()
276     {
277     # ignore this while package building
278     if [[ ! -f /.installrc ]]
279     then
280     local package
281     for package in ${BLOCKER}
282     do
283     if [[ ! -z $(magequery -n ${package##*/}) ]]
284     then
285     echo -e ${COLRED}
286     echo -e "Error: ${package} is installed!!"
287     echo -e "This initscript flavor cannot co-exist ${package}."
288     echo -e "Please uninstall ${package} first!"
289     echo -e ${COLDEFAULT}
290     die "${package} found!"
291     fi
292     done
293     fi
294     }
295    
296     preremove()
297     {
298     # protect these files, that they do not get removed from the system
299     local CONFIG_IGNORE="fstab group hostname hosts passwd"
300     for i in ${CONFIG_IGNORE}
301     do
302     [[ -e ${MROOT}/etc/${i} ]] && touch ${MROOT}/etc/${i}
303     done
304     }