aboutsummaryrefslogtreecommitdiff
blob: f6015d082899424179fea191155201c865871b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
#!/bin/bash

get_KV() {
	if [ "${CMD_NO_KERNEL_SOURCES}" = '1' -a -e "${CMD_KERNCACHE}" ]
	then
		[ -d ${TEMP} ] && gen_die "temporary directory already exists! Exiting."
		(umask 077 && mkdir ${TEMP}) || {
			gen_die "Could not create temporary directory! Exiting."
		}
		/bin/tar -xj -C ${TEMP} -f ${CMD_KERNCACHE} kerncache.config 
		if [ -e ${TEMP}/kerncache.config ]
		then
			KERN_24=0
			VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
			PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
			SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
			EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
			if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' ]
			then
				LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"`
				KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
			else
				KERN_24=1
				KV=${VER}.${PAT}.${SUB}${EXV}
			fi

		else
			rm -r ${TEMP}
			gen_die "Could not find kerncache.config in the kernel cache! Exiting."
		fi
		rm -r ${TEMP}

	else
		# Configure the kernel
		# If BUILD_KERNEL=0 then assume --no-clean, menuconfig is cleared

		VER=`grep ^VERSION\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
		PAT=`grep ^PATCHLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
		SUB=`grep ^SUBLEVEL\ \= ${KERNEL_DIR}/Makefile | awk '{ print $3 };'`
		EXV=`grep ^EXTRAVERSION\ \= ${KERNEL_DIR}/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
		if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' -a -e ${KERNEL_DIR}/.config ]
		then
			KERN_24=0
			cd ${KERNEL_DIR}
			compile_generic prepare kernel > /dev/null 2>&1
			cd - > /dev/null 2>&1
			if [ -f ${KERNEL_DIR}/include/linux/version.h ]
			then
				UTS_RELEASE=`grep UTS_RELEASE ${KERNEL_DIR}/include/linux/version.h | sed -e 's/#define UTS_RELEASE "\(.*\)"/\1/'`
				LOV=`echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//"`
				KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
			else
				LCV=`grep ^CONFIG_LOCALVERSION= ${KERNEL_DIR}/.config | sed -r -e "s/.*=\"(.*)\"/\1/"`
				KV=${VER}.${PAT}.${SUB}${EXV}${LCV}
			fi
		else
			KERN_24=1
			KV=${VER}.${PAT}.${SUB}${EXV}
		fi

	fi

	if isTrue "${CMD_DISKLABEL}"
	then
		DISKLABEL=1
	else
		DISKLABEL=0
	fi
}

determine_real_args() {
	if [ "${CMD_DEBUGFILE}" != '' ]
	then
		DEBUGFILE="${CMD_DEBUGFILE}"
	fi

	if [ "${CMD_MAKEOPTS}" != '' ]
	then
		MAKEOPTS="${CMD_MAKEOPTS}"
	fi

	if [ "${CMD_KERNELDIR}" != '' ]
	then
		KERNEL_DIR=${CMD_KERNELDIR}
	else
		KERNEL_DIR=${DEFAULT_KERNEL_SOURCE}
	fi
	
	if [ "${CMD_NO_KERNEL_SOURCES}" != "1" ]
	then
		if [ ! -d ${KERNEL_DIR} ]
		then
			gen_die "kernel source directory \"${KERNEL_DIR}\" was not found!"
		fi
	fi

	if [ "${CMD_KERNCACHE}" != "" ]
	then	
		if [ "${KERNEL_DIR}" = '' -a "${CMD_NO_KERNEL_SOURCES}" != "1" ]
		then
			gen_die 'No kernel source directory!'
		fi
		if [ ! -e "${KERNEL_DIR}" -a "${CMD_NO_KERNEL_SOURCES}" != "1" ]
		then
			gen_die 'No kernel source directory!'
		fi
	else	
		if [ "${KERNEL_DIR}" = '' ]
		then
			gen_die 'Kernel Cache specified but no kernel tree to verify against!'
		fi
	fi
	
	if [ "${CMD_KERNNAME}" != "" ]
	then
		KNAME=${CMD_KERNNAME}
	else
		KNAME="genkernel"
	fi
	
	if [ "${CMD_KERNEL_MAKE}" != '' ]
	then
		KERNEL_MAKE="${CMD_KERNEL_MAKE}"
	fi

	if [ "${KERNEL_MAKE}" = '' ]
	then
		KERNEL_MAKE='make'
	fi

	if [ "${CMD_UTILS_MAKE}" != '' ]
	then
		UTILS_MAKE="${CMD_UTILS_MAKE}"
	fi

	if [ "${UTILS_MAKE}" = '' ]
	then
		UTILS_MAKE='make'
	fi

	if [ "${CMD_KERNEL_CC}" != '' ]
	then
		KERNEL_CC="${CMD_KERNEL_CC}"
	fi

	if [ "${CMD_KERNEL_LD}" != '' ]
	then
		KERNEL_LD="${CMD_KERNEL_LD}"
	fi

	if [ "${CMD_KERNEL_AS}" != '' ]
	then
		KERNEL_AS="${CMD_KERNEL_AS}"
	fi
	
	if [ "${CMD_KERNEL_CROSS_COMPILE}" != '' ]
	then
		KERNEL_CROSS_COMPILE="${CMD_KERNEL_CROSS_COMPILE}"
	fi

	if [ "${CMD_UTILS_CC}" != '' ]
	then
		UTILS_CC="${CMD_UTILS_CC}"
	fi

	if [ "${CMD_UTILS_LD}" != '' ]
	then
		UTILS_LD="${CMD_UTILS_LD}"
	fi

	if [ "${CMD_UTILS_AS}" != '' ]
	then
		UTILS_AS="${CMD_UTILS_AS}"
	fi
	
	CACHE_DIR=`arch_replace "${CACHE_DIR}"`
	CACHE_CPIO_DIR="${CACHE_DIR}/cpio"
	BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
	MODULE_INIT_TOOLS_BINCACHE=`cache_replace "${MODULE_INIT_TOOLS_BINCACHE}"`
	MODUTILS_BINCACHE=`cache_replace "${MODUTILS_BINCACHE}"`
	DIETLIBC_BINCACHE=`cache_replace "${DIETLIBC_BINCACHE}"`
	DIETLIBC_BINCACHE_TEMP=`cache_replace "${DIETLIBC_BINCACHE_TEMP}"`
	DEVFSD_BINCACHE=`cache_replace "${DEVFSD_BINCACHE}"`
	DEVFSD_CONF_BINCACHE=`cache_replace "${DEVFSD_CONF_BINCACHE}"`
	UDEV_BINCACHE=`cache_replace "${UDEV_BINCACHE}"`
	DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"`
	LVM2_BINCACHE=`cache_replace "${LVM2_BINCACHE}"`
	DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
	UNIONFS_BINCACHE=`cache_replace "${UNIONFS_BINCACHE}"`
	UNIONFS_MODULES_BINCACHE=`cache_replace "${UNIONFS_MODULES_BINCACHE}"`
	BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
  
	DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"`
	BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"`
	BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
	MODULE_INIT_TOOLS_BINCACHE=`arch_replace "${MODULE_INIT_TOOLS_BINCACHE}"`
	MODUTILS_BINCACHE=`arch_replace "${MODUTILS_BINCACHE}"`
	DIETLIBC_BINCACHE=`arch_replace "${DIETLIBC_BINCACHE}"`
	DIETLIBC_BINCACHE_TEMP=`arch_replace "${DIETLIBC_BINCACHE_TEMP}"`
	DEVFSD_BINCACHE=`arch_replace "${DEVFSD_BINCACHE}"`
	DEVFSD_CONF_BINCACHE=`arch_replace "${DEVFSD_CONF_BINCACHE}"`
	UDEV_BINCACHE=`arch_replace "${UDEV_BINCACHE}"`
	DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"`
	LVM2_BINCACHE=`arch_replace "${LVM2_BINCACHE}"`
	DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
	UNIONFS_BINCACHE=`arch_replace "${UNIONFS_BINCACHE}"`
	UNIONFS_MODULES_BINCACHE=`arch_replace "${UNIONFS_MODULES_BINCACHE}"`
	BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
	
	if [ "${CMD_BOOTSPLASH}" != '' ]
	then
		BOOTSPLASH=${CMD_BOOTSPLASH}
	fi

	if isTrue ${BOOTSPLASH}
	then
		BOOTSPLASH=1
	else
		BOOTSPLASH=0
	fi

	if [ "${CMD_GENSPLASH}" != '' ]
	then
		GENSPLASH=${CMD_GENSPLASH}
	fi

	if isTrue ${GENSPLASH}
	then
		GENSPLASH=1
	else
		GENSPLASH=0
	fi

	if isTrue ${COMPRESS_INITRD}
	then
		COMPRESS_INITRD=1
	else
		COMPRESS_INITRD=0
	fi

	if isTrue ${CMD_POSTCLEAR}
	then
		POSTCLEAR=1
	else
		POSTCLEAR=0
	fi
	
	if [ "${CMD_MRPROPER}" != '' ]
	then
		MRPROPER="${CMD_MRPROPER}"
	fi
	if [ "${CMD_MENUCONFIG}" != '' ]
	then
		MENUCONFIG="${CMD_MENUCONFIG}"
	fi
	if [ "${CMD_CLEAN}" != '' ]
	then
		CLEAN="${CMD_CLEAN}"
		if ! isTrue ${CLEAN}
		then
			MRPROPER=0
		fi
	fi

	if [ "${CMD_MINKERNPACKAGE}" != '' ]
	then
		MINKERNPACKAGE="${CMD_MINKERNPACKAGE}"
	fi
	
	if [ "${CMD_MODULESPACKAGE}" != '' ]
	then
		MODULESPACKAGE="${CMD_MODULESPACKAGE}"
	fi

	if [ "${CMD_KERNCACHE}" != '' ]
	then
		KERNCACHE="${CMD_KERNCACHE}"
	fi
	
	if [ "${CMD_NOINITRDMODULES}" != '' ]
	then
		NOINITRDMODULES="${CMD_NOINITRDMODULES}"
	fi
	
	if [ "${CMD_INITRAMFS_OVERLAY}" != '' ]
	then
		INITRAMFS_OVERLAY="${CMD_INITRAMFS_OVERLAY}"
	fi

	if [ "${CMD_MOUNTBOOT}" != '' ]
	then
		MOUNTBOOT="${CMD_MOUNTBOOT}"
	fi

	if isTrue ${MOUNTBOOT}
	then
		MOUNTBOOT=1
	else
		MOUNTBOOT=0
	fi

	if [ "${CMD_SAVE_CONFIG}" != '' ]
	then
		SAVE_CONFIG="${CMD_SAVE_CONFIG}"
	fi

	if isTrue "${SAVE_CONFIG}"
	then
		SAVE_CONFIG=1
	else
		SAVE_CONFIG=0
	fi
  
	if isTrue "${CMD_SYMLINK}"
	then
		SYMLINK=1
	else
		SYMLINK=0
	fi
	
	if [ "${CMD_INSTALL_MOD_PATH}" != '' ]
	then
		INSTALL_MOD_PATH="${CMD_INSTALL_MOD_PATH}"
	fi

	if [ "${CMD_BOOTLOADER}" != '' ]
	then
		BOOTLOADER="${CMD_BOOTLOADER}"
                
		if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
		then
			BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
			BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
		fi
	fi

	if isTrue "${CMD_OLDCONFIG}"
	then
		OLDCONFIG=1
	else
		OLDCONFIG=0
	fi

	if isTrue "${CMD_NO_UDEV}"
	then
		UDEV=0
		if isTrue "${CMD_NO_DEVFS}"
		then
		    DEVFS=0
		else
		    DEVFS=1
		fi
	else
		UDEV=1
		DEVFS=0
	fi
	
	if isTrue "${CMD_NO_DEVFS}"
	then
		DEVFS=0
	fi
	
	if isTrue "${CMD_DEVFS}"
	then
		DEVFS=1
		UDEV=0
	fi

	if isTrue "${CMD_LVM2}"
	then
		LVM2=1
	else
		LVM2=0
	fi
	
	if isTrue "${CMD_EVMS2}"
	then
		EVMS2=1
	else
		EVMS2=0
	fi
	
	if isTrue "${CMD_UNIONFS}"
	then
		UNIONFS=1
	else
		UNIONFS=0
	fi
	
	if isTrue "${CMD_NO_BUSYBOX}"
	then
		BUSYBOX=0
	else
		BUSYBOX=1
	fi
	
	if isTrue "${CMD_DMRAID}"
	then
		DMRAID=1
	else
		DMRAID=0
	fi
	
	get_KV
	UNIONFS_MODULES_BINCACHE=`kv_replace "${UNIONFS_MODULES_BINCACHE}"`
}