diff --git a/scripts/apt-clean.sh b/scripts/apt-clean.sh index 4365a7c..270b574 100755 --- a/scripts/apt-clean.sh +++ b/scripts/apt-clean.sh @@ -23,24 +23,28 @@ find /var/cache/debconf/ ! -type d -wholename '/var/cache/debconf/*-old' -delete __t=$(mktemp) ; : "${__t:?}" debconf_trim_i18n() { - mawk 'BEGIN { m = 0 } - $0 == "" { print } - /^[^[:space:]]/ { - if ($1 ~ "\.[Uu][Tt][Ff]-?8:") { m = 1; next; } - m = 0; print $0; - } - /^[[:space:]]/ { - if (m == 1) next; - print $0; - }' < "$1" > "${__t}" - cat < "${__t}" > "$1" + mawk 'BEGIN { m = 0; } + $0 == "" { print; } + /^[^[:space:]]/ { + if ($1 ~ "\.[Uu][Tt][Ff]-?8:") { + m = 1; + next; + } + m = 0; + print $0; + } + /^[[:space:]]/ { + if (m == 1) next; + print $0; + }' < "$1" > "${__t}" + cat < "${__t}" > "$1" } debconf_trim_i18n /var/cache/debconf/templates.dat while read -r tmpl ; do - [ -n "${tmpl}" ] || continue - [ -s "${tmpl}" ] || continue - debconf_trim_i18n "${tmpl}" + [ -n "${tmpl}" ] || continue + [ -s "${tmpl}" ] || continue + debconf_trim_i18n "${tmpl}" done < 0) { print i_begin,NR ; i_begin = 0 ; } } - ' "$1" + mawk 'BEGIN { OFS = ","; i_begin = 0; } + $0 == "-----BEGIN CERTIFICATE-----" { + i_begin = NR; + } + $0 == "-----END CERTIFICATE-----" { + if (i_begin > 0) { + print i_begin, NR; + i_begin = 0; + } + }' "$1" } bundle_fingerprints() { diff --git a/scripts/python-rm-cache.sh b/scripts/python-rm-cache.sh index 039b846..a1b887e 100755 --- a/scripts/python-rm-cache.sh +++ b/scripts/python-rm-cache.sh @@ -1,7 +1,9 @@ #!/bin/sh set -f for i ; do - find "$i/" -name __pycache__ -exec rm -rf {} + - find "$i/" ! -type d -name '*.py[co]' -exec rm -f {} + + [ -n "$i" ] || continue + [ -d "$i" ] || continue + find "$i/" -name __pycache__ -exec rm -rf {} + + find "$i/" ! -type d -name '*.py[co]' -exec rm -f {} + done exit 0 diff --git a/scripts/static-compress.sh b/scripts/static-compress.sh index 5b8c829..a5ac425 100755 --- a/scripts/static-compress.sh +++ b/scripts/static-compress.sh @@ -1,52 +1,41 @@ #!/bin/sh set -f -COMPRESS_MIN_RATIO=90 - if command -V gzip >/dev/null ; then has_gzip=1 ; fi if command -V brotli >/dev/null ; then has_brotli=1 ; fi if command -V zstd >/dev/null ; then has_zstd=1 ; fi -do_gzip() { [ -s "$1.gz" ] || gzip -1kf "$1" ; comp_fixup "$1" "$1.gz" ; } -do_brotli() { [ -s "$1.br" ] || brotli -1kf "$1" ; comp_fixup "$1" "$1.br" ; } -do_zstd() { [ -s "$1.zst" ] || zstd -q1kf "$1" ; comp_fixup "$1" "$1.zst" ; } +do_gzip() { [ -s "$1.gz" ] || gzip -1kf "$1" || return ; comp_fixup "$1" "$1.gz" || rm -f "$1.gz" ; } +do_brotli() { [ -s "$1.br" ] || brotli -1kf "$1" || return ; comp_fixup "$1" "$1.br" || rm -f "$1.br" ; } +do_zstd() { [ -s "$1.zst" ] || zstd -q1kf "$1" || return ; comp_fixup "$1" "$1.zst" || rm -f "$1.zst" ; } + +float_div() { + mawk -v "a=$1" -v "b=$2" 'BEGIN{print a/b;exit;}'