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.

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