Magellan Linux

Contents of /mage/trunk/include/alx.minc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 893 - (show annotations) (download)
Mon Aug 3 19:56:44 2009 UTC (14 years, 8 months ago) by niro
File size: 3881 byte(s)
-import from 0.9.0-cvs
1 # alx specific functions
2
3 add_conf_prot()
4 {
5 local i
6
7 for i in $@
8 do
9 export CONFIG_PROTECT="${CONFIG_PROTECT} ${i}"
10 done
11 }
12
13 add_conf_prot_mask()
14 {
15 local i
16
17 for i in $@
18 do
19 export CONFIG_PROTECT_MASK="${CONFIG_PROTECT_MASK} ${i}"
20 done
21 }
22
23 # updates /boot/grub/grub.conf with given params
24 # example: alx_grub_update kernel-image-name description
25 alx_grub_update()
26 {
27 local KERNEL_IMAGE
28 local KERNEL_DESCRIPTION
29 local old_image
30
31 KERNEL_IMAGE="$1"
32 KERNEL_DESCRIPTION="$2"
33
34 # some checks
35 if [ -z "${KERNEL_IMAGE}" ]
36 then
37 echo "At least a kernel-image must be given"
38 return 1
39 fi
40
41 [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}"
42
43 if [ ! -f /boot/grub/grub.conf ]
44 then
45 echo "/boot/grub/grub.conf not found"
46 return 1
47 fi
48
49 # fix description
50 sed -i "s:^\(title=\).*:\1${KERNEL_DESCRIPTION}:" /boot/grub/grub.conf
51
52 # fix kernel image
53 old_image="$(basename $(cat /boot/grub/grub.conf|grep kernel |cut -d' ' -f2))"
54 sed -i "s:${old_image}:${KERNEL_IMAGE}:" /boot/grub/grub.conf
55 }
56
57 # updates /boot/grub/grub.conf with given params
58 # example: alx_grub_update kernel-image-name description
59 alx_grub_update_new()
60 {
61 local KERNEL_IMAGE
62 local KERNEL_DESCRIPTION
63 local i
64 local rootfs
65 local grubroot
66 local OLD_IFS
67 local grubconf="/boot/grub/grub.conf"
68
69 KERNEL_IMAGE="$1"
70 KERNEL_DESCRIPTION="$2"
71
72 # some checks
73 if [ -z "${KERNEL_IMAGE}" ]
74 then
75 echo "At least a kernel-image must be given"
76 return 1
77 fi
78
79 [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}"
80
81 if [ ! -f ${grubconf} ]
82 then
83 echo "${grubconf} not found"
84 return 1
85 fi
86
87 # first of all get the first rootfs instance
88 for i in $(< ${grubconf})
89 do
90 rootfs="$(echo ${i} | grep root=)"
91 [[ -n ${rootfs} ]] && break
92 done
93
94 # then get the grub-root
95 OLD_IFS="$IFS"
96 IFS=$'\n'
97 for i in $(< ${grubconf})
98 do
99 grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"
100 [[ -n ${grubroot} ]] && break
101 done
102 IFS="${OLD_IFS}"
103
104 # fix description
105 : > ${grubconf}
106 echo "default 0" >> ${grubconf}
107 echo "timeout 3" >> ${grubconf}
108 # using roots current password
109 echo "password --md5 $(cat /etc/shadow | grep root | cut -d: -f2)" >> ${grubconf}
110 echo >> ${grubconf}
111 acho "# normal boot" >> ${grubconf}
112 echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf}
113 echo "root ${grubroot}" >> ${grubconf}
114 echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet" >> ${grubconf}
115 echo >> ${grubconf}
116 echo "# admin boots" >> ${grubconf}
117 echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf}
118 echo "lock" >> ${grubconf}
119 echo "root ${grubroot}" >> ${grubconf}
120 echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet hardware-auto-detection" >> ${grubconf}
121 echo >> ${grubconf}
122 echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf}
123 echo "lock" >> ${grubconf}
124 echo "root ${grubroot}" >> ${grubconf}
125 echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet alx-reset-settings" >> ${grubconf}
126 }
127
128 # checks if compilation should be against alx
129 target_alx_dev()
130 {
131 local i
132
133 if [ -n "${MAGE_TARGETS}" ]
134 then
135 for i in ${MAGE_TARGETS}
136 do
137 [[ ${i} = -alx_dev ]] && return 0
138
139 # alx-dev will always build when building target alx,
140 # so target alx ist also allowed to be alx-dev
141 [[ ${i} = -alx ]] && return 0
142 done
143 fi
144
145 # nothing match, we are *not* on alx linux
146 return 1
147 }
148
149 # check if compilation should be against stripped down alx for livecds
150 target_alx_livecd()
151 {
152 if [ -n "${MAGE_TARGETS}" ]
153 then
154 for i in ${MAGE_TARGETS}
155 do
156 [[ ${i} = alx_livecd ]] && return 0
157 done
158 fi
159
160 # nothing match, we are *not* on alx linux
161 return 1
162 }
163
164 # check if compilation should be against stripped down alx
165 target_alx()
166 {
167 if [ -n "${MAGE_TARGETS}" ]
168 then
169 for i in ${MAGE_TARGETS}
170 do
171 [[ ${i} = -alx ]] && return 0
172 done
173 fi
174
175 # nothing match, we are *not* on alx linux
176 return 1
177 }