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.

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