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.

337 lines
9.4 KiB

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