diff options
author | Jonas Smedegaard <dr@jones.dk> | 2014-07-30 14:02:46 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2014-07-30 16:10:24 +0200 |
commit | 6f85dac676ef4bb4871272cc2499cb321e32c302 (patch) | |
tree | d3d6a64ceeda391bb6bca5c6ca979b743febc66d /tweaks/base | |
parent | f7ea0e336396a21bee6f16a33be14c8b798c512f (diff) |
Wrap tweaks.
Diffstat (limited to 'tweaks/base')
-rw-r--r-- | tweaks/base | 89 |
1 files changed, 59 insertions, 30 deletions
diff --git a/tweaks/base b/tweaks/base index 9c2811d..2e2ceee 100644 --- a/tweaks/base +++ b/tweaks/base @@ -1,38 +1,67 @@ ## tidy loose ends -set -e +set -e; # fix mark auto-installed essential packages + dependencies (bug#742977) -_pkgdeps(){ set -e - 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; } -_pkg2re(){ set -e - echo $*|sed -r -e 's/\s+/\|/g;s/^\|//;s/([.+-])/\\\1/g;s/\|$//'; } -_pkgreal(){ set -e - chroot /target dpkg-query -Wf='${Package},${Provides},\n'|sed -r "/,,/d;s/^([a-z0-9.+-]+).*[,|] *($(_pkg2re $*))[ :,]/\1/;/,/d"; } -_pkganddeepdeps(){ set -e - rest=$* - all=$rest - for i in 1 2 3 4 5 - do deps=$(_pkgdeps $rest) - rest="$deps $(_pkgreal $deps)" - all="$all $rest" - done - echo $all|sed -r 's/\s+/\n/g'|sort -u; } -essentials=$(chroot /target dpkg-query -Wf='${Package}%${Essential}\n'|sed -r 's/(.*)%yes/\1/;/%/d') -chroot /target apt-mark auto $(_pkganddeepdeps $essentials apt linux-image-*) + _pkgdeps(){ set -e; + 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; }; + _pkg2re(){ set -e; + echo $* + | sed -r + -e 's/\s+/\|/g;' + -e 's/^\|//;' + -e 's/([.+-])/\\\1/g;' + -e 's/\|$//'; }; + _pkgreal(){ set -e; + chroot /target dpkg-query + -Wf='${Package},${Provides},\n' + | sed -r + -e '/,,/d;' + -e 's/^([a-z0-9.+-]+).*[,|] *('"$(_pkg2re $*)"')[ :,]/\1/;' + -e '/,/d'; }; + _pkganddeepdeps(){ set -e; + rest=$*; + all=$rest; + for i in 1 2 3 4 5; do + deps=$(_pkgdeps $rest); + rest="$deps $(_pkgreal $deps)"; + all="$all $rest"; + done; + echo $all + | sed -r + -e 's/\s+/\n/g' + | sort -u; }; + _pkgessentials(){ set -e; + chroot /target dpkg-query + -Wf='${Package}%${Essential}\n' + | sed -r + -e 's/(.*)%yes/\1/;' + -e '/%/d'; }; + chroot /target apt-mark auto + $(_pkganddeepdeps $(_pkgessentials) apt linux-image-*); # fix mark auto-installed misc. packages relevant only as dependencies -chroot /target apt-mark auto apt-utils aptitude-common grub-common isc-dhcp-common tasksel-data vim-common + chroot /target apt-mark auto + apt-utils aptitude-common grub-common isc-dhcp-common tasksel-data vim-common; # keep backup of any tweaked (i.e. edited or created) config file -_backup(){ set -e - [ -e "$1.orig" ] || if [ -e "$1" ]; then cp -a "$1" "$1.orig" - else touch "$1.orig" - fi; } -_clone(){ set -e - _backup "$2" - cp -a "$1" "$2"; } -_setvar(){ set -e - _backup "$1" - sed -i -r -e "s,^#?($2)=.*,\\1=$3," "$1"; } + _backup(){ set -e; + if [ -e "$1.orig" ]; then + :; + elif [ -e "$1" ]; then + cp -a "$1" "$1.orig"; + else + touch "$1.orig"; + fi; }; + _clone(){ set -e; + _backup "$2"; + cp -a "$1" "$2"; }; + _setvar(){ set -e; + _backup "$1"; + sed -i -r + -e "s,^#?($2)=.*,\\1=$3," "$1"; }; ## improve autonomy # auto-repair inconsistent filesystems during boot -_setvar /target/etc/default/rcS FSCKFIX yes + _setvar /target/etc/default/rcS FSCKFIX yes; |