summaryrefslogtreecommitdiff
path: root/tweaks/base
blob: 2e2ceeebbd4842b6a46473ba977d557c85841a39 (plain)
  1. ## tidy loose ends
  2. set -e;
  3. # fix mark auto-installed essential packages + dependencies (bug#742977)
  4. _pkgdeps(){ set -e;
  5. chroot /target dpkg-query
  6. -Wf=',${Pre-Depends},${Depends},${Recommends}\n' $* 2>/dev/null
  7. | sed -r
  8. -e 's/[,|] *([a-z0-9.+-]+)?(:\s+)?( *[^|,]*)?/\1\n/g'
  9. | sed '/^$/d'|sort -u; };
  10. _pkg2re(){ set -e;
  11. echo $*
  12. | sed -r
  13. -e 's/\s+/\|/g;'
  14. -e 's/^\|//;'
  15. -e 's/([.+-])/\\\1/g;'
  16. -e 's/\|$//'; };
  17. _pkgreal(){ set -e;
  18. chroot /target dpkg-query
  19. -Wf='${Package},${Provides},\n'
  20. | sed -r
  21. -e '/,,/d;'
  22. -e 's/^([a-z0-9.+-]+).*[,|] *('"$(_pkg2re $*)"')[ :,]/\1/;'
  23. -e '/,/d'; };
  24. _pkganddeepdeps(){ set -e;
  25. rest=$*;
  26. all=$rest;
  27. for i in 1 2 3 4 5; do
  28. deps=$(_pkgdeps $rest);
  29. rest="$deps $(_pkgreal $deps)";
  30. all="$all $rest";
  31. done;
  32. echo $all
  33. | sed -r
  34. -e 's/\s+/\n/g'
  35. | sort -u; };
  36. _pkgessentials(){ set -e;
  37. chroot /target dpkg-query
  38. -Wf='${Package}%${Essential}\n'
  39. | sed -r
  40. -e 's/(.*)%yes/\1/;'
  41. -e '/%/d'; };
  42. chroot /target apt-mark auto
  43. $(_pkganddeepdeps $(_pkgessentials) apt linux-image-*);
  44. # fix mark auto-installed misc. packages relevant only as dependencies
  45. chroot /target apt-mark auto
  46. apt-utils aptitude-common grub-common isc-dhcp-common tasksel-data vim-common;
  47. # keep backup of any tweaked (i.e. edited or created) config file
  48. _backup(){ set -e;
  49. if [ -e "$1.orig" ]; then
  50. :;
  51. elif [ -e "$1" ]; then
  52. cp -a "$1" "$1.orig";
  53. else
  54. touch "$1.orig";
  55. fi; };
  56. _clone(){ set -e;
  57. _backup "$2";
  58. cp -a "$1" "$2"; };
  59. _setvar(){ set -e;
  60. _backup "$1";
  61. sed -i -r
  62. -e "s,^#?($2)=.*,\\1=$3," "$1"; };
  63. ## improve autonomy
  64. # auto-repair inconsistent filesystems during boot
  65. _setvar /target/etc/default/rcS FSCKFIX yes;