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.

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