mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

507 lines
15 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/linux/linux.conf
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. pkg_linux_mode=image
  23. pkg_linux_cross=""
  24. case "$xpkg-" in
  25. *-source-*)
  26. unset splitdesc_dev
  27. pkg_linux_mode=source ;;
  28. *-src-*)
  29. abort "If you want to build a source package, use '${xpkg//src/source}'.";;
  30. esac
  31. echo_status "Preparing to build a linux kernel $pkg_linux_mode package."
  32. case "$xpkg" in
  33. *-cross-*)
  34. pkg_linux_cross="${xpkg#**-cross-}"
  35. abort "Building linux kernel cross packages isn't supported yet."
  36. ;;
  37. esac
  38. treever=${xpkg/linux/}
  39. treever=${treever/-*/}
  40. : ${vanilla_ver:=$ver}
  41. if [[ ${vanilla_ver} == 2.6.* ]] ; then
  42. vanilla_ver=$( echo ${vanilla_ver} | cut -d. -f-3 )
  43. fi
  44. srctar="linux-${vanilla_ver}.tar.bz2"
  45. lx_extraversion=""
  46. lx_kernelrelease=""
  47. if [ -z "$pkg_linux_cross" ]
  48. then
  49. lx_cpu=$( echo "$arch_machine" | \
  50. sed -e s/x86$/i386/ -e s/powerpc/ppc/ \
  51. -e s/hppa/parisc/ -e s/i.86/i386/ \
  52. -e s/sun4u/sparc64/ -e s/arm.*/arm/ \
  53. -e s/sa110/arm/ -e s/s390x/s390/ \
  54. -e s/parisc64/parisc/ )
  55. if [ $arch = sparc -a "$ROCKCFG_SPARC_64BIT_KERNEL" = 1 ] ; then
  56. lx_cpu=sparc64 ;
  57. KCC=sparc64-unknown-linux-gnu-gcc
  58. archprefix=sparc64-unknown-linux-gnu-
  59. fi
  60. else
  61. lx_cpu=$( echo "$pkg_linux_cross" | \
  62. sed -e s/x86$/i386/ -e s/powerpc/ppc/ \
  63. -e s/hppa/parisc/ -e s/i.86/i386/ \
  64. -e s/sun4u/sparc64/ -e s/arm.*/arm/ \
  65. -e s/sa110/arm/ -e s/s390x/s390/ \
  66. -e s/mips.*/mips/ -e s/parisc64/parisc/ )
  67. fi
  68. MAKE="$MAKE ARCH=$lx_cpu CROSS_COMPILE=$archprefix KCC=$KCC"
  69. # correct the abolute path for patchfiles supplied in the .desc file
  70. for x in $patchfiles ; do
  71. if [ ! -e "$x" -a -n "${x##*/*}" ] ; then
  72. var_remove patchfiles " " "$x"
  73. var_append patchfiles " " "$archdir/$x"
  74. fi
  75. done
  76. # add kernel specific patchfiles
  77. for x in $confdir/linux$treever/*.patch; do
  78. var_append patchfiles " " "$x"
  79. done
  80. # add hppa patch if needed
  81. if [[ "$arch" == hppa && "$vanillaver" == 2.6.* ]]; then
  82. var_insert patchfiles " " "$archdir/patch-2.6.*-pa*.bz2"
  83. fi
  84. auto_config ()
  85. {
  86. case "$arch" in
  87. powerpc)
  88. defconfig="configs/common_defconfig"
  89. ;;
  90. *)
  91. defconfig="defconfig"
  92. ;;
  93. esac
  94. if [ -f $base/architecture/$arch/kernel$treever.conf.sh ] ; then
  95. echo " using: architecture/$arch/kernel$treever.conf.sh"
  96. . $base/architecture/$arch/kernel$treever.conf.sh > .config
  97. elif [ -f $base/architecture/$arch/kernel$treever.conf.m4 ] ; then
  98. echo " using: architecture/$arch/kernel$treever.conf.m4"
  99. m4 -I $base/architecture/$arch -I $base/architecture/share \
  100. $base/architecture/$arch/kernel$treever.conf.m4 > .config
  101. elif [ -f $base/architecture/$arch/kernel$treever.conf ] ; then
  102. echo " using: architecture/$arch/kernel$treever.conf"
  103. cp $base/architecture/$arch/kernel$treever.conf .config
  104. elif [ -f $base/architecture/$arch/kernel.conf.sh ] ; then
  105. echo " using: architecture/$arch/kernel.conf.sh"
  106. . $base/architecture/$arch/kernel.conf.sh > .config
  107. elif [ -f $base/architecture/$arch/kernel.conf.m4 ] ; then
  108. echo " using: architecture/$arch/kernel.conf.m4"
  109. m4 -I $base/architecture/$arch -I $base/architecture/share \
  110. $base/architecture/$arch/kernel.conf.m4 > .config
  111. elif [ -f $base/architecture/$arch/kernel.conf ] ; then
  112. echo " using: architecture/$arch/kernel.conf"
  113. cp $base/architecture/$arch/kernel.conf .config
  114. else
  115. echo " using: no rock kernel config found"
  116. cp arch/$lx_cpu/$defconfig .config
  117. fi
  118. echo " merging (system default): 'arch/$lx_cpu/$defconfig'"
  119. grep '^CONF.*=y' arch/$lx_cpu/$defconfig | cut -f1 -d= | \
  120. while read tag ; do egrep -q "(^| )$tag[= ]" .config || echo "$tag=y"
  121. done >> .config ; cp .config .config.1
  122. # all modules needs to be first so modules can be disabled by i.e.
  123. # the targets later
  124. echo "Enabling all modules ..."
  125. yes '' | eval $MAKE no2modconfig > /dev/null ; cp .config .config.2
  126. if [ -f $base/target/$target/kernel$treever.conf.sh ] ; then
  127. confscripts="$base/target/$target/kernel$treever.conf.sh $confscripts"
  128. elif [ -f $base/target/$target/kernel.conf.sh ] ; then
  129. confscripts="$base/target/$target/kernel.conf.sh $confscripts"
  130. fi
  131. for x in $confscripts ; do
  132. echo " running: $x"
  133. . $x .config
  134. done
  135. cp .config .config.3
  136. # merge various text/plain config files
  137. for x in $base/config/$config/linux.cfg \
  138. $base/target/$target/kernel.conf \
  139. $base/target/$target/kernel$treever.conf ; do
  140. if [ -f $x ] ; then
  141. echo " merging: '$x'"
  142. tag="$(sed '/CONFIG_/ ! d; s,.*CONFIG_\([^ =]*\).*,\1,' \
  143. $x | tr '\n' '|')"
  144. egrep -v "\bCONFIG_($tag)\b" < .config > .config.4
  145. sed 's,\(CONFIG_.*\)=n,# \1 is not set,' \
  146. $x >> .config.4
  147. cp .config.4 .config
  148. fi
  149. done
  150. # create a valid .config
  151. yes '' | eval $MAKE oldconfig > /dev/null ; cp .config .config.5
  152. # last disable broken stuff
  153. rm -f /tmp/$$.sed
  154. list="CONFIG_THIS_DOES_NOT_EXIST"
  155. for x in $pkg_linux_brokenfiles ; do
  156. if [ -f "$x" ] ; then
  157. echo "Disable broken file: $x"
  158. list="$list `tr ' ' '\t' < $x | cut -f1 | grep '^CONFIG_'`"
  159. fi
  160. done
  161. for x in $list ; do
  162. echo "s,^$x=.\$,# $x is not set,;" >> /tmp/$$.sed
  163. done
  164. sed -f /tmp/$$.sed < .config > .config.6
  165. cp .config.6 .config ; rm -f /tmp/$$.sed
  166. # create a valid .config (dependencies might need to be disabled)
  167. yes '' | eval $MAKE oldconfig > /dev/null
  168. # save final config
  169. cp .config .config_modules
  170. echo "Creating config without modules ...."
  171. sed "s,\(CONFIG_.*\)=m,# \1 is not set," .config > .config_new
  172. mv .config_new .config
  173. # create a valid .config (dependencies might need to be disabled)
  174. yes '' | eval $MAKE oldconfig > /dev/null
  175. mv .config .config_nomods
  176. # which .config to use?
  177. if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = "modules" ] ; then
  178. cp .config_modules .config
  179. else
  180. cp .config_nomods .config
  181. fi
  182. }
  183. lx_grabextraversion () {
  184. local ev
  185. ev=$( sed -n -e 's,^[ \t]*EXTRAVERSION[ \t]*=[ \t]*\([^ \t]*\),\1,p' Makefile | tail -n 1 )
  186. if [ "$ev" ]; then
  187. lx_extraversion="${lx_extraversion}$ev"
  188. # keep intact but commented since the second EXTRAVERSION
  189. # definition, and clean the first.
  190. sed -e 's,^\([ \t]*EXTRAVERSION[ \t]*=.*\),#\1,g' \
  191. -e 's,^#\(EXTRAVERSION =\).*,\1,' \
  192. Makefile > Makefile.new
  193. mv Makefile.new Makefile
  194. fi
  195. }
  196. lx_injectextraversion () {
  197. lx_extraversion="${lx_extraversion}-rock"
  198. # inject final EXTRAVERSION into Makefile
  199. sed -i -e "s,^\([ \t]*EXTRAVERSION[ \t]*\)=.*,\1= ${lx_extraversion},g" Makefile
  200. # update version.h - we only do this, because some other freaky
  201. # projects like rsbac change EXTRAVERSION in other Makefiles ...
  202. rerun=""; eval $MAKE include/linux/version.h | grep -q "is up to date" && rerun=1
  203. if [ "$rerun" ] ; then
  204. echo "WARNING: Your system's timer resolution is too low ..."
  205. sleep 1 ; touch Makefile
  206. eval $MAKE include/linux/version.h
  207. fi
  208. # get kernel_release
  209. lx_kernelrelease="$( echo -e "#include <linux/version.h>\nUTS_RELEASE" \
  210. > conftest.c && \
  211. gcc -E -I./include conftest.c | tail -n 1 \
  212. | cut -d '"' -f 2 && rm -f conftest.c )"
  213. }
  214. lx_config ()
  215. {
  216. echo "Generic linux source patching and configuration ..."
  217. # grab extraversion from vanilla
  218. lx_grabextraversion
  219. hook_eval prepatch
  220. apply_patchfiles "lx_grabextraversion"
  221. hook_eval postpatch
  222. echo "Redefining some VERSION flags ..."
  223. lx_injectextraversion
  224. if [[ $treever = 24* ]] ; then
  225. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  226. eval $MAKE symlinks
  227. cp $confdir/autoconf.h include/linux/
  228. touch include/linux/modversions.h
  229. fi
  230. if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
  231. echo "Using \$base/config/\$config/linux.cfg."
  232. echo "Since automatic generation is disabled ..."
  233. cp -v $base/config/$config/linux.cfg .config
  234. else
  235. echo "Automatically creating default configuration ...."
  236. auto_config
  237. fi
  238. echo "... configuration finished!"
  239. if [[ $treever != 24* ]] ; then
  240. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  241. eval $MAKE include/asm
  242. yes '' | eval $MAKE oldconfig > /dev/null
  243. fi
  244. lx_cleanup
  245. echo "Generic linux source configuration finished."
  246. }
  247. pkg_linux_brokenfiles="$base/architecture/$arch/kernel-disable.lst \
  248. $base/architecture/$arch/kernel$treever-disable.lst \
  249. $confdir/linux$treever/disable-broken.lst $pkg_linux_brokenfiles"
  250. lx_source() {
  251. echo "Extracting the Linux Kernel Sources [$vanilla_ver] ... "
  252. tar $taropt $archdir/$srctar
  253. cd linux-$vanilla_ver
  254. if [ -e $archdir/patch-${ver}.bz2 ] ; then
  255. echo "Patching up to $ver ..."
  256. bzcat $archdir/patch-${ver}.bz2 | patch $patchopt
  257. fi
  258. echo "Correcting ownership and permissions ..."
  259. chown -R 0:0 . ; chmod -R u=rwX,go=rX .
  260. }
  261. lx_cleanup() {
  262. echo "Clean up the *.orig and *~ files ... "
  263. find -name '*.orig' -o -name '*~' | xargs rm -f
  264. rm -f .config.old .config.[1-9]
  265. }
  266. main_lx_src() {
  267. lx_source
  268. lx_config
  269. echo "Copying to $root/usr/src/linux-${lx_kernelrelease} ..."
  270. cd $root/usr/src
  271. rm -rf linux-${lx_kernelrelease}
  272. cp -r $builddir/linux-$vanilla_ver linux-${lx_kernelrelease}
  273. if [ "${xpkg%-source}" = "$ROCKCFG_PKG_LINUX_DEFAULT" ] ; then
  274. rm -f linux
  275. ln -svf linux-${lx_kernelrelease} $root/usr/src/linux
  276. fi
  277. echo "Copying kernel patches ... "
  278. rm -rf linux$treever-patches ; mkdir -p linux$treever-patches
  279. echo "This directory contains all the stuff used by ROCK Linux" > linux$treever-patches/README
  280. echo "to build the Kernel (in addition to the official Kernel Sources)." >> linux$treever-patches/README
  281. cp -v $patchfiles linux$treever-patches/
  282. cd linux-${lx_kernelrelease}
  283. if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
  284. # create a valid .config (new settings may be available etc.)
  285. yes '' | eval $MAKE oldconfig > /dev/null
  286. else
  287. cp -v .config_nomods ../linux$treever-patches/config_nomods.txt
  288. cp -v .config_modules ../linux$treever-patches/config_modules.txt
  289. fi
  290. # can fail in stage 0-1 ...
  291. if [ $stagelevel -gt 1 ] && [[ $treever = 24* ]] ; then
  292. echo "Creating dependencies (e.g. for versioned symbols) ..."
  293. eval $MAKE dep-files
  294. fi
  295. if [ $stagelevel -gt 1 ] && [[ $treever = 26* ]] ; then
  296. echo "Creating scripts/* because external modules need it ..."
  297. eval $MAKE scripts/
  298. fi
  299. lx_cleanup
  300. }
  301. main_lx() {
  302. lx_source
  303. lx_config
  304. # we need to rerun the oldconfig since the used .config
  305. # might not match the one used in the last oldconfig run
  306. # (e.g. the nomods is run last - and normally the module
  307. # one is used)
  308. yes '' | eval $MAKE oldconfig > /dev/null
  309. if [[ $treever = 24* ]] ; then
  310. echo "Creating dependencies ..."
  311. eval $MAKE -j 1 dep
  312. fi
  313. echo "Cleanup kernel ..."
  314. eval $MAKE -j 1 clean > /dev/null
  315. echo "Building the kernel ..."
  316. [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ] && default=1
  317. case "$lx_cpu" in
  318. i386)
  319. eval $MAKE bzImage
  320. cp -vf arch/i386/boot/bzImage $root/boot/vmlinuz_${lx_kernelrelease}
  321. [ "$default" ] && \
  322. cp -vf arch/i386/boot/bzImage $root/boot/vmlinuz
  323. ;;
  324. x86_64)
  325. eval $MAKE bzImage
  326. cp -vf arch/x86_64/boot/bzImage $root/boot/vmlinuz_${lx_kernelrelease}
  327. [ "$default" ] && \
  328. cp -vf arch/x86_64/boot/bzImage $root/boot/vmlinuz
  329. ;;
  330. alpha)
  331. eval $MAKE vmlinux
  332. gzip < vmlinux > $root/boot/vmlinux_${lx_kernelrelease}.gz
  333. [ "$default" ] && \
  334. cp -vf $root/boot/vmlinux_$ver-rock.gz $root/boot/vmlinux.gz
  335. ;;
  336. arm)
  337. eval $MAKE zImage
  338. cp -vf arch/arm/boot/zImage $root/boot/zImage_${lx_kernelrelease}
  339. [ "$default" ] && \
  340. cp -vf arch/arm/boot/zImage $root/boot/zImage
  341. ;;
  342. mips)
  343. eval $MAKE vmlinux
  344. $BUILDCC arch/mips/boot/elf2ecoff.c -o elf2ecoff
  345. ./elf2ecoff vmlinux vmlinux.ecoff
  346. cp -vf vmlinux.ecoff $root/boot/vmlinux_${lx_kernelrelease}.ecoff
  347. [ "$default" ] && \
  348. cp -vf vmlinux.ecoff $root/boot/
  349. ;;
  350. ppc)
  351. eval $MAKE vmlinux
  352. cp -vf vmlinux $root/boot/vmlinux_${lx_kernelrelease}
  353. [ "$default" ] && \
  354. cp -vf vmlinux $root/boot/vmlinux
  355. eval $MAKE zImage
  356. for x in arch/ppc/boot/images/zImage.* ; do
  357. cp -v $x $root/boot/${x/arch\/ppc\/boot\/images\//}-$ver
  358. done
  359. ;;
  360. sparc)
  361. if [ "$treever" = 24 ] ; then
  362. eval $MAKE vmlinux
  363. else
  364. eval $MAKE image
  365. fi
  366. cp -vf vmlinux $root/boot/vmlinux32_${lx_kernelrelease}
  367. [ "$default" ] && \
  368. gzip -9 < vmlinux > $root/boot/vmlinux32.gz
  369. ;;
  370. sparc64)
  371. eval $MAKE vmlinux
  372. cp -vf vmlinux $root/boot/vmlinux64_${lx_kernelrelease}
  373. [ "$default" ] && \
  374. gzip -9 < vmlinux > $root/boot/vmlinux64.gz
  375. ;;
  376. um)
  377. eval $MAKE linux
  378. cp -vf linux $root/boot/linux_${lx_kernelrelease}
  379. [ "$default" ] && \
  380. cp -vf linux $root/boot/linux
  381. ;;
  382. *)
  383. eval $MAKE vmlinux
  384. cp -vf vmlinux $root/boot/vmlinux_${lx_kernelrelease}
  385. [ "$default" ] && \
  386. cp -vf vmlinux $root/boot/vmlinux
  387. ;;
  388. esac
  389. cp -vf .config $root/boot/kconfig_${lx_kernelrelease}
  390. cp -vf System.map $root/boot/System.map-${lx_kernelrelease}
  391. [ "$default" ] && cp -vf System.map $root/boot/System.map
  392. # only build modules if enabled in the kernel config,
  393. # otherwise a build error will occur
  394. if [ "`egrep "^CONFIG_MODULES=[ym]" .config`" ] ; then
  395. echo "Building the modules ..."
  396. eval $MAKE modules
  397. echo "Installing the modules ..."
  398. if [ $stagelevel -le 1 ] ; then
  399. eval $MAKE modules_install \
  400. INSTALL_MOD_PATH=$root DEPMOD=/bin/true
  401. else
  402. eval $MAKE modules_install DEPMOD=/bin/true
  403. echo "Running 'depmod -a -q -F /boot/System.map ${lx_kernelrelease}' .."
  404. depmod -a -q -F /boot/System.map-${lx_kernelrelease} ${lx_kernelrelease}
  405. for x in /lib/modules/${lx_kernelrelease}/modules.*
  406. do [ -f $x ] && add_flist $x; done
  407. fi
  408. else
  409. echo "No module support configured for this kernel ..."
  410. mkdir -p $root/lib/modules/${lx_kernelrelease}
  411. fi
  412. # fix /lib/modules/${ver}/{build,source} symlinks
  413. rm -f $root/lib/modules/${lx_kernelrelease}/build
  414. rm -f $root/lib/modules/${lx_kernelrelease}/source
  415. ln -sf ../../../usr/src/linux-${lx_kernelrelease} \
  416. $root/lib/modules/${lx_kernelrelease}/build
  417. ln -sf ../../../usr/src/linux-${lx_kernelrelease} \
  418. $root/lib/modules/${lx_kernelrelease}/source
  419. if [ "$default" ] ; then
  420. if [ -z "$root" ]; then
  421. mkinitrd empty ${lx_kernelrelease}
  422. rm -f /boot/initrd.img
  423. ln -s initrd-${lx_kernelrelease}.img /boot/initrd.img
  424. fi
  425. fi
  426. }
  427. autoextract=0
  428. case "$pkg_linux_mode" in
  429. source)
  430. createdocs=0
  431. custmain="main_lx_src"
  432. ;;
  433. image)
  434. custmain="main_lx"
  435. ;;
  436. esac
  437. # ignore pseudo-deps to other modules
  438. var_append flistrfilter "|" ".*lib/modules/.*/.*"