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.

59 lines
1.3 KiB

  1. # $conffiles is a list of patters of the form
  2. # ^[XO-] <pattern> [<value>]
  3. # X means enable, O disable, and - removes it
  4. # pattern can use '*' as a wildcard for [^ #]
  5. # optionaly can set a value different that y
  6. apply_conffiles() {
  7. local f x;
  8. rm -f /tmp/$$.sed
  9. for f in $conffiles; do if [ -f "$f" ]; then
  10. while read a c v; do
  11. x="${c//\\*/[^ #]*}"
  12. x="^\(# \)\?\($x\)[= ].*\$"
  13. # value
  14. if [ -z "$v" ]; then
  15. v='y'
  16. fi
  17. case "$a" in
  18. X) echo "apply_conffiles: rule $c=$v."
  19. echo "s,$x,\2=$v,g" >> /tmp/$$.sed
  20. ;;
  21. O) echo "apply_conffiles: rule unset $c."
  22. echo "s,$x,# \2 is not set,g" >> /tmp/$$.sed
  23. ;;
  24. -) echo "apply_conffiles: rule remove $c."
  25. echo "s,$x,,g" >> /tmp/$$.sed
  26. ;;
  27. *)
  28. echo "apply_conffiles: bad rule $a $c $v"
  29. ;;
  30. esac
  31. done < <( cat $f );
  32. fi ; done
  33. sed -f /tmp/$$.sed .config > $1
  34. rm /tmp/$$.sed
  35. }
  36. # get default config, and filter considering <n>
  37. # levels, because new options can appear and other disappear
  38. auto_config() {
  39. local j=1 n="${1:-1}"
  40. # defconfig
  41. eval "$MAKE defconfig $makeopt"
  42. cp -v .config .config.$j
  43. j=2 ; for (( i=1 ; i<n ; i++, j++ )) {
  44. apply_conffiles .config.$j
  45. cp -v .config.$j .config
  46. eval "$MAKE oldconfig $makeopt"
  47. (( j++ )) ; cp -v .config .config.$j
  48. }
  49. # second round
  50. apply_conffiles .config.$j
  51. cp -v .config.$j .config
  52. }