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.

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