summaryrefslogtreecommitdiff
path: root/tweaks/base
blob: 9a2c9a6c0466441c373c5de7b57ed4507275cbdd (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 -Wf=',${Pre-Depends},${Depends},${Recommends}\n' $* 2>/dev/null|sed -r -e 's/[,|] *([a-z0-9.+-]+)?(:\s+)?( *[^|,]*)?/\1\n/g'|sed '/^$/d'|sort -u; }
  6. _pkg2re(){ set -e
  7. echo $*|sed -r -e 's/\s+/\|/g;s/^\|//;s/([.+-])/\\\1/g;s/\|$//'; }
  8. _pkgreal(){ set -e
  9. chroot /target dpkg-query -Wf='${Package},${Provides},\n'|sed -r "/,,/d;s/^([a-z0-9.+-]+).*[,|] *($(_pkg2re $*))[ :,]/\1/;/,/d"; }
  10. _pkganddeepdeps(){ set -e
  11. local rest=$*
  12. local all=$rest
  13. for i in 1 2 3 4 5
  14. do local deps=$(_pkgdeps $rest)
  15. rest="$deps $(_pkgreal $deps)"
  16. all="$all $rest"
  17. done
  18. echo $all|sed -r 's/\s+/\n/g'|sort -u; }
  19. essentials=$(chroot /target dpkg-query -Wf='${Package}%${Essential}\n'|sed -r 's/(.*)%yes/\1/;/%/d')
  20. chroot /target apt-mark auto $(_pkganddeepdeps $essentials apt linux-image-*)
  21. # fix mark auto-installed d-i installed packages unusable on their own
  22. chroot /target apt-mark auto aptitude-common grub-common isc-dhcp-common tasksel-data vim-common
  23. # keep backup of any tweaked (i.e. edited or created) config file
  24. _backup(){ set -e
  25. [ -e "$1.orig" ] || if [ -e "$1" ]; then cp -a "$1" "$1.orig"
  26. else touch "$1.orig"
  27. fi; }
  28. _clone(){ set -e
  29. _backup "$2"
  30. cp -a "$1" "$2"; }
  31. _setvar(){ set -e
  32. _backup "$1"
  33. sed -i -r -e "s,^#?($2)=.*,\\1=$3," "$1"; }
  34. ## improve autonomy
  35. # auto-repair inconsistent filesystems during boot
  36. _setvar /target/etc/default/rcS FSCKFIX yes