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.

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