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.

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