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.

250 lines
8.2 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/linux24/lx_config.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2003 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. treever=${pkg/linux/} ; treever=${treever/-*/}
  23. hook_add prepare 3 'archdir="$base/download/mirror/l"'
  24. [ "$vanilla_ver" ] || vanilla_ver="$ver"
  25. srctar="linux-${vanilla_ver}.tar.bz2"
  26. lx_cpu=`echo "$arch_machine" | sed -e s/x86$/i386/ \
  27. -e s/i.86/i386/ -e s/powerpc/ppc/ -e s/hppa/parisc/`
  28. lx_extraversion=""
  29. lx_kernelrelease=""
  30. lx_tempdir=""
  31. [ $arch = sparc -a "$ROCKCFG_SPARC_64BIT_KERNEL" = 1 ] && \
  32. lx_cpu=sparc64
  33. MAKE="$MAKE ARCH=$lx_cpu CROSS_COMPILE=$archprefix KCC=$KCC"
  34. # correct the abolute path for patchfiles supplied in the .desc file
  35. for x in $patchfiles ; do
  36. if [ ! -e "$x" -a -n "${x##*/*}" ] ; then
  37. var_remove patchfiles " " "$x"
  38. var_append patchfiles " " "$base/download/mirror/${x:0:1}/$x"
  39. fi
  40. done
  41. auto_config ()
  42. {
  43. if [ -f $base/architecture/$arch/kernel$treever.conf.sh ] ; then
  44. echo " using: architecture/$arch/kernel$treever.conf.sh"
  45. . $base/architecture/$arch/kernel$treever.conf.sh > .config
  46. elif [ -f $base/architecture/$arch/kernel$treever.conf.m4 ] ; then
  47. echo " using: architecture/$arch/kernel$treever.conf.m4"
  48. m4 -I $base/architecture/$arch -I $base/architecture/share \
  49. $base/architecture/$arch/kernel$treever.conf.m4 > .config
  50. elif [ -f $base/architecture/$arch/kernel$treever.conf ] ; then
  51. echo " using: architecture/$arch/kernel$treever.conf"
  52. cp $base/architecture/$arch/kernel$treever.conf .config
  53. elif [ -f $base/architecture/$arch/kernel.conf.sh ] ; then
  54. echo " using: architecture/$arch/kernel.conf.sh"
  55. . $base/architecture/$arch/kernel.conf.sh > .config
  56. elif [ -f $base/architecture/$arch/kernel.conf.m4 ] ; then
  57. echo " using: architecture/$arch/kernel.conf.m4"
  58. m4 -I $base/architecture/$arch -I $base/architecture/share \
  59. $base/architecture/$arch/kernel.conf.m4 > .config
  60. elif [ -f $base/architecture/$arch/kernel.conf ] ; then
  61. echo " using: architecture/$arch/kernel.conf"
  62. cp $base/architecture/$arch/kernel.conf .config
  63. else
  64. echo " using: no rock kernel config found"
  65. cp arch/$lx_cpu/defconfig .config
  66. fi
  67. echo " merging (system default): 'arch/$lx_cpu/defconfig'"
  68. grep '^CONF.*=y' arch/$lx_cpu/defconfig | cut -f1 -d= | \
  69. while read tag ; do egrep -q "(^| )$tag[= ]" .config || echo "$tag=y"
  70. done >> .config ; cp .config .config.1
  71. # all modules needs to be first so modules can be disabled by i.e.
  72. # the targets later
  73. echo "Enabling all modules ..."
  74. yes '' | eval $MAKE no2modconfig > /dev/null ; cp .config .config.2
  75. if [ -f $base/target/$target/kernel$treever.conf.sh ] ; then
  76. confscripts="$base/target/$target/kernel$treever.conf.sh $confscripts"
  77. elif [ -f $base/target/$target/kernel.conf.sh ] ; then
  78. confscripts="$base/target/$target/kernel.conf.sh $confscripts"
  79. fi
  80. for x in $confscripts ; do
  81. echo " running: $x"
  82. sh $x .config
  83. done
  84. cp .config .config.3
  85. # merge various text/plain config files
  86. for x in $base/config/$config/linux.cfg \
  87. $base/target/$target/kernel.conf ; do
  88. if [ -f $x ] ; then
  89. echo " merging: '$x'"
  90. tag="$(sed '/CONFIG_/ ! d; s,.*CONFIG_\([^ =]*\).*,\1,' \
  91. $x | tr '\n' '|')"
  92. egrep -v "\bCONFIG_($tag)\b" < .config > .config.4
  93. sed 's,\(CONFIG_.*\)=n,# \1 is not set,' \
  94. $x >> .config.4
  95. cp .config.4 .config
  96. fi
  97. done
  98. # create a valid .config
  99. yes '' | eval $MAKE oldconfig > /dev/null ; cp .config .config.5
  100. # last disable broken stuff
  101. rm -f /tmp/$$.sed
  102. list="CONFIG_THIS_DOES_NOT_EXIST"
  103. for x in $pkg_linux_brokenfiles ; do
  104. if [ -f "$x" ] ; then
  105. echo "Disable broken file: $x"
  106. list="$list `tr ' ' '\t' < $x | cut -f1 | grep '^CONFIG_'`"
  107. fi
  108. done
  109. for x in $list ; do
  110. echo "s,^$x=.\$,# $x is not set,;" >> /tmp/$$.sed
  111. done
  112. sed -f /tmp/$$.sed < .config > .config.6
  113. cp .config.6 .config ; rm -f /tmp/$$.sed
  114. # create a valid .config (dependencies might need to be disabled)
  115. yes '' | eval $MAKE oldconfig > /dev/null
  116. # save final config
  117. cp .config .config_modules
  118. echo "Creating config without modules ...."
  119. sed "s,\(CONFIG_.*\)=m,# \1 is not set," .config > .config_new
  120. mv .config_new .config
  121. # create a valid .config (dependencies might need to be disabled)
  122. yes '' | eval $MAKE oldconfig > /dev/null
  123. mv .config .config_nomods
  124. # which .config to use?
  125. if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = "modules" ] ; then
  126. cp .config_modules .config
  127. else
  128. cp .config_nomods .config
  129. fi
  130. }
  131. lx_grabextraversion () {
  132. local ev
  133. ev=$( sed -n -e 's,^[ \t]*EXTRAVERSION[ \t]*=[ \t]*\([^ \t]*\),\1,p' Makefile | tail -n 1 )
  134. if [ "$ev" ]; then
  135. lx_extraversion="${lx_extraversion}$ev"
  136. # keep intact but commented since the second EXTRAVERSION
  137. # definition, and clean the first.
  138. sed -e 's,^\([ \t]*EXTRAVERSION[ \t]*=.*\),#\1,g' \
  139. -e 's,^#\(EXTRAVERSION =\).*,\1,' \
  140. Makefile > Makefile.new
  141. mv Makefile.new Makefile
  142. fi
  143. }
  144. lx_injectextraversion () {
  145. lx_extraversion="${lx_extraversion}-rock"
  146. # inject final EXTRAVERSION into Makefile
  147. sed -i -e "s,^\([ \t]*EXTRAVERSION[ \t]*\)=.*,\1= ${lx_extraversion},g" Makefile
  148. # update version.h - we only do this, because some other freaky
  149. # projects like rsbac change EXTRAVERSION in other Makefiles ...
  150. rerun=""; eval $MAKE include/linux/version.h | grep -q "is up to date" && rerun=1
  151. if [ "$rerun" ] ; then
  152. echo "WARNING: Your system's timer resolution is too low ..."
  153. sleep 1 ; touch Makefile
  154. eval $MAKE include/linux/version.h
  155. fi
  156. # get kernel_release
  157. lx_kernelrelease="$( echo -e "#include <linux/version.h>\nUTS_RELEASE" \
  158. > conftest.c && \
  159. gcc -E -I./include conftest.c | tail -n 1 \
  160. | cut -d '"' -f 2 && rm -f conftest.c )"
  161. # rename temp directory
  162. if [ "${lx_tempdir}" ]; then
  163. cd ..
  164. rm -rf linux-${lx_kernelrelease} ; mv ${lx_tempdir} linux-${lx_kernelrelease}
  165. ln -sf $PWD/linux-${lx_kernelrelease} $builddir/linux-${vanilla_ver}
  166. if [ "${pkg%-src}" = "$ROCKCFG_DEFAULT_KERNEL" ] ; then
  167. rm -f linux
  168. ln -svf linux-${lx_kernelrelease} linux
  169. fi
  170. cd linux-${lx_kernelrelease}
  171. fi
  172. }
  173. lx_config ()
  174. {
  175. echo "Generic linux source patching and configuration ..."
  176. # grab extraversion from vanilla
  177. lx_grabextraversion
  178. hook_eval prepatch
  179. apply_patchfiles "lx_grabextraversion"
  180. hook_eval postpatch
  181. echo "Redefining some VERSION flags ..."
  182. lx_injectextraversion
  183. echo "Correcting user and permissions ..."
  184. chown -R root:root . * ; chmod -R u=rwX,go=rX .
  185. if [[ $treever = 24* ]] ; then
  186. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  187. eval $MAKE symlinks
  188. cp $base/package/base/linux24/autoconf.h include/linux/
  189. touch include/linux/modversions.h
  190. fi
  191. if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
  192. echo "Using \$base/config/\$config/linux.cfg."
  193. echo "Since automatic generation is disabled ..."
  194. cp -v $base/config/$config/linux.cfg .config
  195. else
  196. echo "Automatically creating default configuration ...."
  197. auto_config
  198. fi
  199. echo "... configuration finished!"
  200. if [[ $treever != 24* ]] ; then
  201. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  202. eval $MAKE include/asm
  203. yes '' | eval $MAKE oldconfig > /dev/null
  204. fi
  205. echo "Clean up the *.orig and *~ files ... "
  206. rm -f .config.old `find -name '*.orig' -o -name '*~'`
  207. echo "Generic linux source configuration finished."
  208. }
  209. pkg_linux_brokenfiles="$base/architecture/$arch/kernel-disable.lst \
  210. $base/architecture/$arch/kernel$treever-disable.lst \
  211. $base/package/*/linux$treever/disable-broken.lst \
  212. $pkg_linux_brokenfiles"