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.

60 lines
1.3 KiB

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