OpenSDE Packages Database (without history before r20070)
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.

324 lines
9.1 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../linux26/linux-conf.in
  5. # Copyright (C) 2006 - 2010 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. # Copyright (C) 1998 - 2003 Clifford Wolf
  8. #
  9. # More information can be found in the files COPYING and README.
  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; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. treever=$(echo $ver | cut -d. -f1-2 | tr -d .)
  17. lx_confdir=$(pkgdesc confdir linux26)
  18. lx_ver=0
  19. for x in $(echo "$ver" | cut -d. -f1-3 | tr '.' ' '); do
  20. lx_ver=$( expr $lx_ver \* 1000 + $x )
  21. done
  22. lx_cpu="$arch_machine"
  23. if [ -s "$lx_confdir/arch/$arch.in" ]; then
  24. . "$lx_confdir/arch/$arch.in"
  25. else
  26. . "$lx_confdir/arch/shared.in"
  27. fi
  28. lx_extraversion=
  29. lx_kernelrelease=
  30. lx_customconf="${SDECFG_PKG_LINUX_CONFIG_FILE:-config/$config/linux.cfg}"
  31. # $lx_confmerge list of config snaps gets merged to .config.3 on auto_config()
  32. #
  33. lx_confmerge=
  34. for x in $base/config/$config/linux.cfg \
  35. $( get_expanded $base/target/%/kernel${treever}.conf `get_reverted $targetchain` ) \
  36. $( get_expanded $base/target/%/kernel.conf `get_reverted $targetchain` ); do
  37. if [ -f "$x" ]; then
  38. var_append lx_confmerge ' ' "$x"
  39. fi
  40. done
  41. # $lx_confscripts list of scripts to alter .config.2 generating .config.3 on auto_config()
  42. lx_confscripts=
  43. for x in $base/target/$target/kernel$treever.conf.sh \
  44. $base/target/$target/kernel.conf.sh ; do
  45. if [ -f "$x" ]; then
  46. var_append lx_confscripts ' ' "$x"
  47. break
  48. fi
  49. done
  50. # inject a possible pre-/ post-release patch
  51. # we filter out .tar`s to avoid trouble with the linuxsh kernel drop-in trees
  52. var_insert patchfiles " " "`match_source_file patch-.* | grep -v '\.tar\.'`"
  53. #makeopt=`echo $makeopt | sed -n 's/.*\(-j[^ ]*\).*/\1/p'`
  54. makeopt=
  55. # we need +1 to really saturate the CPUs during the kernel build
  56. [ $SDECFG_PARALLEL_MAX -gt 1 ] &&
  57. var_append makeopt ' ' -j$(( $SDECFG_PARALLEL_MAX + 1 ))
  58. var_append makeopt ' ' "ARCH=$lx_cpu CROSS_COMPILE=$archprefix KCC=$KCC LOCALVERSION="
  59. makeinstopt="$makeopt"
  60. auto_config_merge() {
  61. local rules="$1" tag=
  62. echo " merging: '$rules'" >&2
  63. tag="$(sed '/CONFIG_/ ! d; s,.*CONFIG_\([^ =]*\).*,\1,' \
  64. "$rules" | tr '\n' '|')"
  65. egrep -v "\bCONFIG_($tag)\b" < .config
  66. sed 's,\(CONFIG_.*\)=n,# \1 is not set,' "$rules"
  67. }
  68. auto_config() {
  69. local x= loop=
  70. # get defconfig (.config.0)
  71. #
  72. echo "Creating linux default config"
  73. case "$SDECFG_PKG_LINUX_CONFIG_STYLE" in
  74. none)
  75. abort "auto_config: shouldn't reach this point."
  76. ;;
  77. defconfig|humble|nomodules)
  78. eval $MAKE $makeopt defconfig
  79. ;;
  80. allmodules)
  81. eval $MAKE $makeopt allmodconfig
  82. ;;
  83. esac
  84. cp .config{,.0}
  85. # architecture specific configuration (will be merged)
  86. if [ -f "$lx_confdir/arch/config.$arch.sh" ]; then
  87. sh "$lx_confdir/arch/config.$arch.sh" "$lx_ver" > .config.$arch
  88. else
  89. echo_warning "No config scripts found for this architecture ($arch)."
  90. echo > .config.$arch
  91. fi
  92. if [ -s .config.$arch ]; then
  93. # apply $arch specific rules
  94. #
  95. for loop in 1 2; do
  96. auto_config_merge .config.$arch > .config.1.$loop.0
  97. cp .config{.1.$loop.0,}
  98. # create a valid .config
  99. #
  100. yes '' | eval $MAKE $makeopt oldconfig > /dev/null ; cp .config{,.1.$loop}
  101. done
  102. fi
  103. if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" != "humble" ]; then
  104. # all modules needs to be first so modules can be disabled by i.e.
  105. # the targets later
  106. echo "Enabling all modules ..."
  107. yes '' | eval $MAKE $makeopt no2modconfig > /dev/null ; cp .config{,.2}
  108. fi
  109. # for "safety" we will apply the config twice, so hidden options have time
  110. # to appear
  111. #
  112. for loop in 1 2; do
  113. # call scripts to tweak the config file
  114. #
  115. for x in $lx_confscripts ; do
  116. echo " running: $x"
  117. sh $x .config
  118. done
  119. cp .config{,.3.$loop}
  120. # merge various text/plain config files
  121. #
  122. for x in $lx_confmerge; do
  123. if [ -f $x ] ; then
  124. auto_config_merge "$x" > .config.4.$loop
  125. cp .config{.4.$loop,}
  126. else
  127. echo_warning "Can't find '${x#$base/}' for merging."
  128. fi
  129. done
  130. # create a valid .config
  131. #
  132. yes '' | eval $MAKE $makeopt oldconfig > /dev/null ; cp .config{,.5.$loop}
  133. done
  134. # last disable broken stuff
  135. #
  136. rm -f /tmp/$$.sed
  137. list="CONFIG_THIS_DOES_NOT_EXIST"
  138. for x in $pkg_linux_brokenfiles ; do
  139. if [ -f "$x" ] ; then
  140. echo "Disable broken file: $x"
  141. list="$list `tr ' ' '\t' < $x | cut -f1 | grep '^CONFIG_'`"
  142. fi
  143. done
  144. for x in $list ; do
  145. echo "s,^$x=.\$,# $x is not set,;" >> /tmp/$$.sed
  146. done
  147. sed -f /tmp/$$.sed < .config > .config.6
  148. rm -f /tmp/$$.sed
  149. cp .config{.6,}
  150. # create a valid .config (dependencies might need to be disabled)
  151. yes '' | eval $MAKE $makeopt oldconfig > /dev/null
  152. # save final config (with modules)
  153. cp .config{,_modules}
  154. echo "Creating config without modules ...."
  155. sed "s,\(CONFIG_.*\)=m,# \1 is not set," .config > .config_new
  156. mv .config_new .config
  157. # create a valid .config (dependencies might need to be disabled)
  158. yes '' | eval $MAKE $makeopt oldconfig > /dev/null
  159. mv .config .config_nomods
  160. # which .config to use?
  161. if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" != "nomodules" ] ; then
  162. cp .config{_modules,}
  163. else
  164. cp .config{_nomods,}
  165. fi
  166. }
  167. lx_grabextraversion () {
  168. local ev
  169. ev=$( sed -n -e 's,^[ \t]*EXTRAVERSION[ \t]*=[ \t]*\([^ \t]*\),\1,p' Makefile | tail -n 1 )
  170. if [ "$ev" ]; then
  171. lx_extraversion="${lx_extraversion}${ev}"
  172. # keep intact but commented since the second EXTRAVERSION
  173. # definition, and clean the first.
  174. sed -i -e 's,^\([ \t]*EXTRAVERSION[ \t]*=.*\),#\1,g' \
  175. -e 's,^#\(EXTRAVERSION =\).*,\1,' Makefile
  176. fi
  177. }
  178. lx_injectextraversion () {
  179. local version_header=linux/version.h
  180. local rerun=
  181. if [ -f include/linux/utsrelease.h ]; then
  182. version_header=linux/utsrelease.h
  183. fi
  184. if [ -f include/generated/utsrelease.h ]; then
  185. version_header=generated/utsrelease.h
  186. fi
  187. # inject final EXTRAVERSION into Makefile
  188. sed -i -e "s,^\([ \t]*EXTRAVERSION[ \t]*\)=.*,\1= ${lx_extraversion},g" Makefile
  189. # update version.h - we only do this, because some other freaky
  190. # projects like rsbac change EXTRAVERSION in other Makefiles ...
  191. eval $MAKE $makeopt include/$version_header | grep -q "is up to date" && rerun=1
  192. if [ "$rerun" ] ; then
  193. echo "WARNING: Your system's timer resolution is too low ..."
  194. sleep 1 ; touch Makefile
  195. eval $MAKE $makeopt include/$version_header
  196. fi
  197. # get kernel_release
  198. rerun=1
  199. while true; do
  200. lx_kernelrelease="$( echo -e "#include <$version_header>\nUTS_RELEASE" |
  201. gcc -E -I./include - | tail -n 1 | cut -d '"' -f 2 )"
  202. if [ -z "$lx_kernelrelease" -a "$rerun" ]; then
  203. $MAKE $makeopt .kernelrelease include/$version_header
  204. rerun= ; continue
  205. fi
  206. break
  207. done
  208. [ $lx_kernelrelease ] || abort "Could not grab final kernel version!"
  209. }
  210. lx_filter_patch ()
  211. {
  212. pref=`sed -n '/^-EXTRAVERSION =/ {
  213. s/^-EXTRAVERSION =//p
  214. q }' $1`
  215. sed -e "s/^-EXTRAVERSION =.*/-EXTRAVERSION =/" \
  216. -e "s/^+EXTRAVERSION = *$pref/+EXTRAVERSION = /" $1
  217. }
  218. lx_patch ()
  219. {
  220. # validate ARCH
  221. [ -d "arch/$lx_cpu/" ] || abort "architecture ($lx_cpu) not known by this kernel."
  222. echo "Generic linux patching ..."
  223. # grab extraversion from vanilla
  224. lx_grabextraversion
  225. hook_eval prepatch
  226. apply_patchfiles lx_grabextraversion lx_filter_patch
  227. hook_eval postpatch
  228. # some arches (sh64 at the time of writing) have a "defect" Makefile
  229. # and do not work without a .config ...
  230. touch .config
  231. echo "Redefining VERSION ..."
  232. lx_extraversion="${lx_extraversion}-dist"
  233. lx_injectextraversion
  234. echo "... linux source patching for ${lx_extraversion} finished."
  235. echo "Correcting user and permissions ..."
  236. chown -R root:root . ; chmod -R u=rwX,go=rX .
  237. if [ "$lx_kernelrelease" != "UTS_RELEASE" ]; then
  238. echo "Create symlinks and a few headers for <$lx_cpu> ... "
  239. eval $MAKE $makeopt include/asm
  240. fi
  241. echo "Clean up the *.orig and *~ files ... "
  242. rm -f .config.old
  243. find -name '*.orig' -o -name '*~' | xargs rm -f
  244. }
  245. lx_config() {
  246. echo "Generic linux configuration ..."
  247. hook_eval preconf
  248. if [ "$SDECFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
  249. echo_status "Using only ${lx_customconf}."
  250. if expr "$lx_customconf" : '/*' > /dev/null; then
  251. cp -vf "$lx_customconf" .config
  252. else
  253. cp -vf "$base/$lx_customconf" .config
  254. fi
  255. eval $MAKE $makeopt oldconfig
  256. else
  257. echo "Automatically creating default configuration ...."
  258. auto_config
  259. fi
  260. if [ "$lx_kernelrelease" == "UTS_RELEASE" ]; then
  261. # we have to run make prepare
  262. eval $MAKE $makeopt prepare
  263. fi
  264. # regrab the version
  265. lx_injectextraversion
  266. [ "$lx_kernelrelease" != "UTS_RELEASE" ] ||
  267. abort "Unable to detect kernel release version!"
  268. echo "... configuration of $lx_kernelrelease finished!"
  269. }
  270. pkg_linux_brokenfiles="$base/architecture/$arch/kernel$treever-disable.lst \
  271. $base/package/*/linux$treever/disable-broken.lst \
  272. $pkg_linux_brokenfiles"
  273. # if the fhs package is enabled, remove 'lib/firmware' from file list because
  274. # then this directory belongs to the fhs package
  275. if pkginstalled fhs; then
  276. var_append flistdel "|" "lib/firmware"
  277. fi