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.

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