From 406fb78bae89ec7c911a5ea9131503cf66f97a96 Mon Sep 17 00:00:00 2001 From: crpb Date: Tue, 8 Aug 2023 23:44:58 +0200 Subject: [PATCH 01/24] completion->search errors w/o Packages.xz --- fnt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fnt b/fnt index 7711617..baef660 100755 --- a/fnt +++ b/fnt @@ -172,7 +172,9 @@ case "$1" in echo "Feel free to send patches or dollars (see the sponsor link)" ;; search|-s) - unxz -c "$HOME/.fnt/Packages.xz" |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2" + if [ -f "$HOME/.fnt/Packages.xz" ]; then + unxz -c "$HOME/.fnt/Packages.xz" |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2" + fi curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" ;; From 31dfdc04cf634e13a91ce29bfb4be4e225a8d108 Mon Sep 17 00:00:00 2001 From: crpb Date: Wed, 9 Aug 2023 00:30:12 +0200 Subject: [PATCH 02/24] ar we only need data.X anyway --- fnt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fnt b/fnt index baef660..1e255da 100755 --- a/fnt +++ b/fnt @@ -161,10 +161,11 @@ case "$1" in echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}${url}]..." curl -s "${MIRROR}${url}" -o "${TMPDIR}/$f" cd "${TMPDIR}" || exit 1 - ar x "$f" - tar xJf data.tar.xz + data="$(ar t "$f" | grep data)" + ar x "$f" "$data" + tar xJf "$data" find "${TMPDIR}" . -name "*.?tf" -exec cp {} "$target" \; - rm "$f" control.tar* data.tar* debian-binary + rm "$f" "$data" rm -rf "${TMPDIR:?}/usr" ;; remove|-r) From 697809ef4b0018a47db1a5a3d23dcc5e15bba16a Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 20:04:36 +0200 Subject: [PATCH 03/24] global fastly mirror?! --- fnt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fnt b/fnt index 1e255da..f22acb4 100755 --- a/fnt +++ b/fnt @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e + # APT but only for fonts # alex@aiei.ch # @@ -8,10 +10,11 @@ #TMPDIR="${TMPDIR:-/tmp}" TMPDIR="${HOME}/.fnt" # debian sid index -INDEX="http://ftp.ch.debian.org/debian/dists/sid/main/binary-all/Packages.xz" +#INDEX="http://ftp.ch.debian.org/debian/dists/sid/main/binary-all/Packages.xz" +MIRROR="http://deb.debian.org/debian" +INDEX="${MIRROR}/dists/sid/main/binary-all/Packages.xz" # google fonts index GINDEX="https://sid.ethz.ch/debian/google-fonts/fonts-master/" -MIRROR="http://ftp.ch.debian.org/debian/" if ! command -v uname &>/dev/null; then s="Windows" @@ -34,7 +37,7 @@ case "$s" in i="apt" md5="md5sum" target="$HOME/.fonts/" - if [ 0 -eq `id -u` ]; then + if [ 0 -eq "$(id -u)" ]; then target="/usr/local/share/fonts/" mkdir -p $target fi @@ -103,7 +106,7 @@ case "$1" in # echo Listing... # macOS mainly comes with *.ttc (truetype font collections, that can not be processed by otfinfo) #ls -1 /System/Library/Fonts/*.?tf /usr/share/fonts/*type/*/*.?tf $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf 2>/dev/null | while read f; do - ls -1 $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf /usr/local/share/fonts/*.?tf 2>/dev/null | while read f; do + ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf /usr/local/share/fonts/*.?tf 2>/dev/null | while read f; do echo "$f" [$(otfinfo -u "$f" 2>/dev/null|wc -l|awk '{print $1}')] | sed s,.*/,, done ;; @@ -158,8 +161,8 @@ case "$1" in downsize=$(echo "$p" | awk '{print $NF}') url=$(echo "$p" | awk '{print $(NF-2)}') f=$(basename "$url") - echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}${url}]..." - curl -s "${MIRROR}${url}" -o "${TMPDIR}/$f" + echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}/${url}]..." + curl -s "${MIRROR}/${url}" -o "${TMPDIR}/$f" cd "${TMPDIR}" || exit 1 data="$(ar t "$f" | grep data)" ar x "$f" "$data" From fbb85f5fd4a78768c2d8b6147672727eb639b1e2 Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 22:32:19 +0200 Subject: [PATCH 04/24] deb822 / retab / stuff.. --- completions/_fnt | 2 +- fnt | 103 ++++++++++++++++++++++++++--------------------- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/completions/_fnt b/completions/_fnt index ab12928..43dae05 100755 --- a/completions/_fnt +++ b/completions/_fnt @@ -25,7 +25,7 @@ fonts) remove) local -a installed if [ "$(fnt list)" != "" ]; then - installed=("$(fnt list)") + installed=("$(fnt list |awk '{print$1}')") _values \ "installed" $installed fi diff --git a/fnt b/fnt index f22acb4..5ccf20a 100755 --- a/fnt +++ b/fnt @@ -1,5 +1,5 @@ #!/usr/bin/env bash - +# vim autoindent noexpandtab set -e # APT but only for fonts @@ -9,6 +9,7 @@ set -e #TMPDIR="${TMPDIR:-/tmp}" TMPDIR="${HOME}/.fnt" +PACKAGES="${TMPDIR}/Packages.xz" # debian sid index #INDEX="http://ftp.ch.debian.org/debian/dists/sid/main/binary-all/Packages.xz" MIRROR="http://deb.debian.org/debian" @@ -37,10 +38,10 @@ case "$s" in i="apt" md5="md5sum" target="$HOME/.fonts/" - if [ 0 -eq "$(id -u)" ]; then - target="/usr/local/share/fonts/" + if [ 0 -eq "$(id -u)" ]; then + target="/usr/local/share/fonts/" mkdir -p $target - fi + fi ;; FreeBSD) #echo FreeBSD @@ -68,10 +69,10 @@ case "$s" in esac for a in $check; do - if ! command -v "$a" &>/dev/null; then - echo "$a not found, please use $i to install it." - exit 1 - fi + if ! command -v "$a" &>/dev/null; then + echo "$a not found, please use $i to install it." + exit 1 + fi done if [ -z "$1" ]; then @@ -93,8 +94,8 @@ case "$1" in update|-u) echo Updating... mkdir -p "${TMPDIR}" - if [ -f "${TMPDIR}/Packages.xz" ]; then rm "${TMPDIR}/Packages.xz"; fi - curl -s "$INDEX" -o "${TMPDIR}/Packages.xz" + if [ -f "${PACKAGES}" ]; then rm "${PACKAGES}"; fi + curl -s "$INDEX" -o "${PACKAGES}" ;; info) @@ -106,23 +107,30 @@ case "$1" in # echo Listing... # macOS mainly comes with *.ttc (truetype font collections, that can not be processed by otfinfo) #ls -1 /System/Library/Fonts/*.?tf /usr/share/fonts/*type/*/*.?tf $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf 2>/dev/null | while read f; do - ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf /usr/local/share/fonts/*.?tf 2>/dev/null | while read f; do - echo "$f" [$(otfinfo -u "$f" 2>/dev/null|wc -l|awk '{print $1}')] | sed s,.*/,, + find "${HOME}"/{Library,.fonts}/ /usr/local/share/fonts -iname '*.?tf' | while read -r f; do + echo "$(basename "${f}") [ $(otfinfo -u "$f" 2>/dev/null | wc -l) ]" done + # ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf /usr/local/share/fonts/*.?tf 2>/dev/null | while read f; do + # echo "$f" [ $(otfinfo -u "$f" 2>/dev/null | wc -l | awk '{print $1}') ] | sed s,.*/,, + # done ;; preview|-p) # echo Previewing... mkdir -p "${TMPDIR}" - curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${TMPDIR}/preview.png" - md5s=$($md5 ${TMPDIR}/preview.png) - echo $md5s |grep b5765b390157e36eaf721c8848a4b04d >/dev/null && - curl -L -s "https://sid.ethz.ch/fonts/$2/preview.png" -o "${TMPDIR}/preview.png" + if curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${TMPDIR}/preview.png"; then + md5s=$($md5 "${TMPDIR}/preview.png") + if echo "$md5s" |grep b5765b390157e36eaf721c8848a4b04d >/dev/null; then + if curl -L -s "https://sid.ethz.ch/fonts/$2/preview.png" -o "${TMPDIR}/preview.png"; then + chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" + fi + fi + fi #chafa --invert -c none --symbols block+border-solid "${TMPDIR}/preview.png" chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" ;; install|-i) - if [ ! -f "${TMPDIR}/Packages.xz" ]; then - echo "Could not find ${TMPDIR}/Packages.xz" + if [ ! -f "${PACKAGES}" ]; then + echo "Could not find ${PACKAGES}" echo "Please run $0 update" # could also just run itself with update... exit 1 @@ -132,42 +140,45 @@ case "$1" in fi # cat $HOME/.fnt/Packages.xz |unxz|grep "^Package:\|^Homepage:\|^Size:\|^Installed-Size:\|^Description:" # cat $HOME/.fnt/Packages.xz |unxz| awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-" - p=$(unxz -c "$HOME/.fnt/Packages.xz" | grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep "fonts-$2"|head -1) + # p=$(unxz -c "${PACKAGES}" | grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep "fonts-$2"|head -1) + p="$(unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;exit;}')" # Package: fonts-agave Version: 37-1 Installed-Size: 364 Description: monospaces programming font Homepage: https://b.agaric.net/page/agave Filename: pool/main/f/fonts-agave/fonts-agave_37-1_all.deb Size: 103112 - if [ -z "$p" ]; then - q=$(curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) - s=$(curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) + if [ -z "$p" ]; then + q=$(curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) + s=$(curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) - if [ -z "$q" ] && [ -z "$s" ]; then - echo "Font \"$2\" not found" - exit 1 - else - echo "Installing google-${2}" - # here comes the google web font installer part using grep '\..tf' - curl -s "$GINDEX/ofl/${2}/" |grep "a href" |grep "\..tf" |sed 's,.*tf.>,,' | sed 's,,,' | sed 's,,,' | sed 's,,,' | sed 's,,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" From d5afd00905787af7263ba0cc320a51cd28b0550a Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 23:07:19 +0200 Subject: [PATCH 05/24] -rant --- fnt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fnt b/fnt index 5ccf20a..789a924 100755 --- a/fnt +++ b/fnt @@ -166,21 +166,21 @@ case "$1" in # get package infos name="$p" - infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}/,/^$/" |awk '/^(Version|Installed-Size|Description|Filename|Size): /')" - ver=$(echo "$infos" | awk '/^Version: /{print$2}') - instsize=$(echo "$infos" | awk '/^Installed-Size: /{print$2}') - downsize=$(echo "$infos" | awk '/^Size: /{print$2}') - fpath=$(echo "$infos" | awk '/^Filename: /{print$2}') + infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size): /')" + ver="$(echo "$infos" | awk '/^Version: /{print$2}')" + instsize="$(echo "$infos" | awk '/^Installed-Size: /{print$2}')" + downsize="$(echo "$infos" | awk '/^Size: /{print$2}')" + fpath="$(echo "$infos" | awk '/^Filename: /{print$2}')" f="$(basename "$fpath")" echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}/${fpath}]..." curl -s "${MIRROR}/${fpath}" -o "${TMPDIR}/$f" cd "${TMPDIR}" || exit 1 - data="$(ar t "$f" | grep data)" + data="$(ar t "$f" | grep '^data.')" ar x "$f" "$data" - tar xJf "$data" + tar xf "$data" find "${TMPDIR}" -name "*.?tf" -exec cp {} "$target" \; rm "$f" "$data" - rm -rf "${TMPDIR:?}/usr" + rm -rf "${TMPDIR:?}/"{usr,etc} ;; remove|-r) echo "Removing..." From d160551e386469644d485eee98ff09c756d554f8 Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 23:13:00 +0200 Subject: [PATCH 06/24] ... --- fnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fnt b/fnt index 789a924..b27a410 100755 --- a/fnt +++ b/fnt @@ -126,7 +126,7 @@ case "$1" in fi fi #chafa --invert -c none --symbols block+border-solid "${TMPDIR}/preview.png" - chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" + #chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" ;; install|-i) if [ ! -f "${PACKAGES}" ]; then From 631ee4c0ecc54f0621a0b41509f0069a5f9d36f1 Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 23:21:57 +0200 Subject: [PATCH 07/24] install should check if fontname is given --- fnt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fnt b/fnt index b27a410..494b14a 100755 --- a/fnt +++ b/fnt @@ -131,10 +131,15 @@ case "$1" in install|-i) if [ ! -f "${PACKAGES}" ]; then echo "Could not find ${PACKAGES}" - echo "Please run $0 update" + echo "Please run ${BASH_SOURCE[0]} update" # could also just run itself with update... exit 1 fi + if [ ! $# -eq 2 ]; then + echo "No fontname supplied." + echo "Example: ${BASH_SOURCE[0]} install agave" + exit 1 + fi if [ ! -d "${target}" ]; then mkdir -p "${target}" fi From 7cd7e70f0455230afc6657dfa37b32dca9757038 Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 23:31:28 +0200 Subject: [PATCH 08/24] search .. --- fnt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fnt b/fnt index 494b14a..0c8074e 100755 --- a/fnt +++ b/fnt @@ -115,6 +115,11 @@ case "$1" in # done ;; preview|-p) + if [ ! $# -eq 2 ]; then + echo "No fontname supplied." + echo "Example: ${BASH_SOURCE[0]} preview agave" + exit 1 + fi # echo Previewing... mkdir -p "${TMPDIR}" if curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${TMPDIR}/preview.png"; then @@ -193,7 +198,7 @@ case "$1" in ;; search|-s) if [ -f "${PACKAGES}" ]; then - unxz -c "${PACKAGES}" |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2" + unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;}' fi curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" From 8587934ce163ff6aca3daec8e317fed349b08dcf Mon Sep 17 00:00:00 2001 From: cb Date: Wed, 9 Aug 2023 23:36:22 +0200 Subject: [PATCH 09/24] quak --- fnt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fnt b/fnt index 0c8074e..2b2158b 100755 --- a/fnt +++ b/fnt @@ -210,6 +210,21 @@ case "$1" in echo ' _()< wak wak' echo '(__)' ;; + quak) + cat << 'EOF' + _______ +< QUAK? > + ------- + \ + \ + oO)-. .-(Oo + /__ _\ /_ __\ + \ \( | ()~() | )/ / + \__|\ | (-___-) | /|__/ + ' '--' ==`-'== '--' ' + +EOF + ;; *) echo "Nothing..." ;; From 7ac0d80174e6036b44ce24bdfc491eab06f92ebd Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 00:41:18 +0200 Subject: [PATCH 10/24] try before buy! --- fnt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fnt b/fnt index 2b2158b..ab51244 100755 --- a/fnt +++ b/fnt @@ -122,14 +122,21 @@ case "$1" in fi # echo Previewing... mkdir -p "${TMPDIR}" + rm "${TMPDIR}/preview.png" + PRINTED= if curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${TMPDIR}/preview.png"; then - md5s=$($md5 "${TMPDIR}/preview.png") - if echo "$md5s" |grep b5765b390157e36eaf721c8848a4b04d >/dev/null; then + # if we get nothing / "this picture is not available" pic + if [ "$($md5 "${TMPDIR}/preview.png" | awk '{print$1}')" = "b5765b390157e36eaf721c8848a4b04d" ]; then if curl -L -s "https://sid.ethz.ch/fonts/$2/preview.png" -o "${TMPDIR}/preview.png"; then - chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" + chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" 2>/dev/null && PRINTED=1 fi + else + chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" 2>/dev/null && PRINTED=1 fi fi + if [ "$PRINTED" != "1" ]; then + echo "Couldn't retrieve a preview." + fi #chafa --invert -c none --symbols block+border-solid "${TMPDIR}/preview.png" #chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" ;; From edebac8123b33e30b82cf63b063e8ee9bd32a268 Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 16:54:25 +0200 Subject: [PATCH 11/24] deaf by echo --- fnt | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/fnt b/fnt index ab51244..d788943 100755 --- a/fnt +++ b/fnt @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# vim autoindent noexpandtab +# vim: autoindent noexpandtab set -e # APT but only for fonts @@ -76,17 +76,19 @@ for a in $check; do done if [ -z "$1" ]; then - echo "Syntax: fnt [ update | list | info ]" - echo " fnt [ install | remove | preview | search ] font" - echo - echo "update|-u updates the font package index of debian sid" - echo "list|-l lists installed fonts with glyphcount per font" - echo "info information about how many fonts can be installed" - echo "install|-i install a font" - echo "remove|-r remove a font" - echo "preview|-p preview a font" - echo "search|-s search for font" - echo + cat<< 'EOHELP' +Syntax: fnt [ update | list | info ] + fnt [ install | remove | preview | search ] font + +update|-u updates the font package index of debian sid +list|-l lists installed fonts with glyphcount per font +info information about how many fonts can be installed +install|-i install a font +remove|-r remove a font +preview|-p preview a font +search|-s search for font + +EOHELP exit 0 fi @@ -158,6 +160,7 @@ case "$1" in # cat $HOME/.fnt/Packages.xz |unxz|grep "^Package:\|^Homepage:\|^Size:\|^Installed-Size:\|^Description:" # cat $HOME/.fnt/Packages.xz |unxz| awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-" # p=$(unxz -c "${PACKAGES}" | grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep "fonts-$2"|head -1) + # look for first font match p="$(unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;exit;}')" # Package: fonts-agave Version: 37-1 Installed-Size: 364 Description: monospaces programming font Homepage: https://b.agaric.net/page/agave Filename: pool/main/f/fonts-agave/fonts-agave_37-1_all.deb Size: 103112 From 5399001b797d8e74002dc8b34ac20b3d1f8a8e30 Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 17:03:44 +0200 Subject: [PATCH 12/24] list: should only look into target where we install fonts --- fnt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fnt b/fnt index d788943..e46794c 100755 --- a/fnt +++ b/fnt @@ -40,7 +40,6 @@ case "$s" in target="$HOME/.fonts/" if [ 0 -eq "$(id -u)" ]; then target="/usr/local/share/fonts/" - mkdir -p $target fi ;; FreeBSD) @@ -109,7 +108,7 @@ case "$1" in # echo Listing... # macOS mainly comes with *.ttc (truetype font collections, that can not be processed by otfinfo) #ls -1 /System/Library/Fonts/*.?tf /usr/share/fonts/*type/*/*.?tf $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf 2>/dev/null | while read f; do - find "${HOME}"/{Library,.fonts}/ /usr/local/share/fonts -iname '*.?tf' | while read -r f; do + find "$target" /usr/local/share/fonts -iname '*.?tf' | while read -r f; do echo "$(basename "${f}") [ $(otfinfo -u "$f" 2>/dev/null | wc -l) ]" done # ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf /usr/local/share/fonts/*.?tf 2>/dev/null | while read f; do From c451fb54264ff98122a7c55e0222d85759499adf Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 19:54:03 +0200 Subject: [PATCH 13/24] cleanup --- fnt | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/fnt b/fnt index e46794c..7707791 100755 --- a/fnt +++ b/fnt @@ -105,15 +105,9 @@ case "$1" in ;; list|-l) - # echo Listing... - # macOS mainly comes with *.ttc (truetype font collections, that can not be processed by otfinfo) - #ls -1 /System/Library/Fonts/*.?tf /usr/share/fonts/*type/*/*.?tf $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf 2>/dev/null | while read f; do find "$target" /usr/local/share/fonts -iname '*.?tf' | while read -r f; do - echo "$(basename "${f}") [ $(otfinfo -u "$f" 2>/dev/null | wc -l) ]" + echo "$(basename "${f}") [$(otfinfo -u "$f" 2>/dev/null | wc -l)]" done - # ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf /usr/local/share/fonts/*.?tf 2>/dev/null | while read f; do - # echo "$f" [ $(otfinfo -u "$f" 2>/dev/null | wc -l | awk '{print $1}') ] | sed s,.*/,, - # done ;; preview|-p) if [ ! $# -eq 2 ]; then @@ -121,7 +115,6 @@ case "$1" in echo "Example: ${BASH_SOURCE[0]} preview agave" exit 1 fi - # echo Previewing... mkdir -p "${TMPDIR}" rm "${TMPDIR}/preview.png" PRINTED= @@ -138,14 +131,13 @@ case "$1" in if [ "$PRINTED" != "1" ]; then echo "Couldn't retrieve a preview." fi - #chafa --invert -c none --symbols block+border-solid "${TMPDIR}/preview.png" - #chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" ;; install|-i) if [ ! -f "${PACKAGES}" ]; then echo "Could not find ${PACKAGES}" echo "Please run ${BASH_SOURCE[0]} update" # could also just run itself with update... + # but apt doesn't do that either :) exit 1 fi if [ ! $# -eq 2 ]; then @@ -156,17 +148,11 @@ case "$1" in if [ ! -d "${target}" ]; then mkdir -p "${target}" fi - # cat $HOME/.fnt/Packages.xz |unxz|grep "^Package:\|^Homepage:\|^Size:\|^Installed-Size:\|^Description:" - # cat $HOME/.fnt/Packages.xz |unxz| awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-" - # p=$(unxz -c "${PACKAGES}" | grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep "fonts-$2"|head -1) # look for first font match p="$(unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;exit;}')" - # Package: fonts-agave Version: 37-1 Installed-Size: 364 Description: monospaces programming font Homepage: https://b.agaric.net/page/agave Filename: pool/main/f/fonts-agave/fonts-agave_37-1_all.deb Size: 103112 - if [ -z "$p" ]; then q=$(curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) s=$(curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) - if [ -z "$q" ] && [ -z "$s" ]; then echo "Font \"$2\" not found" exit 1 @@ -182,7 +168,6 @@ case "$1" in exit 0 fi fi - # get package infos name="$p" infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size): /')" From d40b878a59aef1f3e2bd5b5880bdc45d61e8c3a0 Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 20:36:33 +0200 Subject: [PATCH 14/24] awk doesn't throw errors on no-match --- fnt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fnt b/fnt index 7707791..3aa1d07 100755 --- a/fnt +++ b/fnt @@ -1,6 +1,9 @@ #!/usr/bin/env bash # vim: autoindent noexpandtab set -e +#set -u +#set -o pipefail +#set -x # APT but only for fonts # alex@aiei.ch @@ -15,7 +18,7 @@ PACKAGES="${TMPDIR}/Packages.xz" MIRROR="http://deb.debian.org/debian" INDEX="${MIRROR}/dists/sid/main/binary-all/Packages.xz" # google fonts index -GINDEX="https://sid.ethz.ch/debian/google-fonts/fonts-master/" +GINDEX="https://sid.ethz.ch/debian/google-fonts/fonts-master" if ! command -v uname &>/dev/null; then s="Windows" @@ -110,7 +113,7 @@ case "$1" in done ;; preview|-p) - if [ ! $# -eq 2 ]; then + if [ $# -ne 2 ]; then echo "No fontname supplied." echo "Example: ${BASH_SOURCE[0]} preview agave" exit 1 @@ -194,8 +197,8 @@ case "$1" in if [ -f "${PACKAGES}" ]; then unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;}' fi - curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" - curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" |grep "$2" + curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" | awk "/$2/" + curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" | awk "/$2/" ;; moo) echo "This fnt does not have cow powers." From 544f76d554d325f03c8a5f2dbf64a9441c9641f2 Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 20:48:33 +0200 Subject: [PATCH 15/24] here string --- fnt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fnt b/fnt index 3aa1d07..1b03ce0 100755 --- a/fnt +++ b/fnt @@ -108,7 +108,7 @@ case "$1" in ;; list|-l) - find "$target" /usr/local/share/fonts -iname '*.?tf' | while read -r f; do + find "$target" /usr/local/share/fonts -iname '*.?tf' 2>/dev/null | while read -r f; do echo "$(basename "${f}") [$(otfinfo -u "$f" 2>/dev/null | wc -l)]" done ;; @@ -174,10 +174,10 @@ case "$1" in # get package infos name="$p" infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size): /')" - ver="$(echo "$infos" | awk '/^Version: /{print$2}')" - instsize="$(echo "$infos" | awk '/^Installed-Size: /{print$2}')" - downsize="$(echo "$infos" | awk '/^Size: /{print$2}')" - fpath="$(echo "$infos" | awk '/^Filename: /{print$2}')" + ver="$(awk '/^Version: /{print$2}' <<< "$infos")" + instsize="$(awk '/^Installed-Size: /{print$2}' <<< "$infos")" + downsize="$(awk '/^Size: /{print$2}' <<< "$infos")" + fpath="$(awk '/^Filename: /{print$2}' <<< "$infos")" f="$(basename "$fpath")" echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}/${fpath}]..." curl -s "${MIRROR}/${fpath}" -o "${TMPDIR}/$f" From 6e776dafac58788af50f945fe1617929fd6d5819 Mon Sep 17 00:00:00 2001 From: cb Date: Thu, 10 Aug 2023 20:49:35 +0200 Subject: [PATCH 16/24] escape --- fnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fnt b/fnt index 1b03ce0..891f605 100755 --- a/fnt +++ b/fnt @@ -182,7 +182,7 @@ case "$1" in echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}/${fpath}]..." curl -s "${MIRROR}/${fpath}" -o "${TMPDIR}/$f" cd "${TMPDIR}" || exit 1 - data="$(ar t "$f" | grep '^data.')" + data="$(ar t "$f" | grep '^data\.')" ar x "$f" "$data" tar xf "$data" find "${TMPDIR}" -name "*.?tf" -exec cp {} "$target" \; From 9f0cd781e2f26e6231ae37ecee9a975b7514fd8a Mon Sep 17 00:00:00 2001 From: cb Date: Sat, 12 Aug 2023 06:22:06 +0200 Subject: [PATCH 17/24] md5 --- fnt | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/fnt b/fnt index 891f605..61cdb6f 100755 --- a/fnt +++ b/fnt @@ -10,9 +10,9 @@ set -e # # selfupdate=https://raw.githubusercontent.com/alexmyczko/fnt/main/fnt -#TMPDIR="${TMPDIR:-/tmp}" -TMPDIR="${HOME}/.fnt" -PACKAGES="${TMPDIR}/Packages.xz" +#CACHEDIR="${CACHEDIR:-/tmp}" +CACHEDIR="${HOME}/.fnt" +PACKAGES="${CACHEDIR}/Packages.xz" # debian sid index #INDEX="http://ftp.ch.debian.org/debian/dists/sid/main/binary-all/Packages.xz" MIRROR="http://deb.debian.org/debian" @@ -97,7 +97,7 @@ fi case "$1" in update|-u) echo Updating... - mkdir -p "${TMPDIR}" + mkdir -p "${CACHEDIR}" if [ -f "${PACKAGES}" ]; then rm "${PACKAGES}"; fi curl -s "$INDEX" -o "${PACKAGES}" ;; @@ -118,17 +118,17 @@ case "$1" in echo "Example: ${BASH_SOURCE[0]} preview agave" exit 1 fi - mkdir -p "${TMPDIR}" - rm "${TMPDIR}/preview.png" + mkdir -p "${CACHEDIR}" + rm "${CACHEDIR}/preview.png" PRINTED= - if curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${TMPDIR}/preview.png"; then + if curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${CACHEDIR}/preview.png"; then # if we get nothing / "this picture is not available" pic - if [ "$($md5 "${TMPDIR}/preview.png" | awk '{print$1}')" = "b5765b390157e36eaf721c8848a4b04d" ]; then - if curl -L -s "https://sid.ethz.ch/fonts/$2/preview.png" -o "${TMPDIR}/preview.png"; then - chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" 2>/dev/null && PRINTED=1 + if [ "$($md5 "${CACHEDIR}/preview.png" | awk '{print$1}')" = "b5765b390157e36eaf721c8848a4b04d" ]; then + if curl -L -s "https://sid.ethz.ch/fonts/$2/preview.png" -o "${CACHEDIR}/preview.png"; then + chafa -c 240 -w 9 -O 9 -p on --symbols all "${CACHEDIR}/preview.png" 2>/dev/null && PRINTED=1 fi else - chafa -c 240 -w 9 -O 9 -p on --symbols all "${TMPDIR}/preview.png" 2>/dev/null && PRINTED=1 + chafa -c 240 -w 9 -O 9 -p on --symbols all "${CACHEDIR}/preview.png" 2>/dev/null && PRINTED=1 fi fi if [ "$PRINTED" != "1" ]; then @@ -152,7 +152,7 @@ case "$1" in mkdir -p "${target}" fi # look for first font match - p="$(unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;exit;}')" + p="$(unxz -c "${PACKAGES}" | awk '/^Package: (fonts-)?'"$2"'/ {gsub(/^Package: /,"");print;exit;}')" if [ -z "$p" ]; then q=$(curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) s=$(curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep "$2" | head -1) @@ -171,23 +171,32 @@ case "$1" in exit 0 fi fi - # get package infos + # retrive font from debian mirror + TMPDIR="$(mktemp --directory --suffix=fnt)" + trap 'rm -rf -- "$TMPDIR"' EXIT name="$p" - infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size): /')" + infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size|MD5sum): /')" ver="$(awk '/^Version: /{print$2}' <<< "$infos")" instsize="$(awk '/^Installed-Size: /{print$2}' <<< "$infos")" downsize="$(awk '/^Size: /{print$2}' <<< "$infos")" fpath="$(awk '/^Filename: /{print$2}' <<< "$infos")" - f="$(basename "$fpath")" + fname="$(basename "$fpath")" + md5sum="$(awk '/^MD5sum: /{print$2}' <<< "$infos") ${fname}" echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}/${fpath}]..." - curl -s "${MIRROR}/${fpath}" -o "${TMPDIR}/$f" cd "${TMPDIR}" || exit 1 - data="$(ar t "$f" | grep '^data\.')" - ar x "$f" "$data" - tar xf "$data" - find "${TMPDIR}" -name "*.?tf" -exec cp {} "$target" \; - rm "$f" "$data" - rm -rf "${TMPDIR:?}/"{usr,etc} + test -z "$(curl -s "${MIRROR}/${fpath}" -o "${TMPDIR}/$fname")" || { echo "Couldn't retrieve file." ; exit 1 ; } + echo "${md5sum}" > "${TMPDIR}/${fname}.md5" + if ${md5} --check --quiet "${TMPDIR}/${fname}.md5"; then + data="$(ar t "$fname" | grep '^data\.tar')" + ar x "${TMPDIR}/$fname" "$data" + tar xf "${TMPDIR}/$data" + find "${TMPDIR}" -name "*.?tf" -exec cp {} "$target" \; + else + echo "Can't verify md5sum!" + exit 1 + fi + #rm "$f" "$data" + #rm -rf "${CACHEDIR:?}/"{usr,etc} ;; remove|-r) echo "Removing..." From 232c4c5201e4581647698fb11f8708ecc3630a45 Mon Sep 17 00:00:00 2001 From: cb Date: Sat, 12 Aug 2023 07:16:50 +0200 Subject: [PATCH 18/24] md5 opts.. --- fnt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fnt b/fnt index 61cdb6f..558fb2b 100755 --- a/fnt +++ b/fnt @@ -183,10 +183,10 @@ case "$1" in fname="$(basename "$fpath")" md5sum="$(awk '/^MD5sum: /{print$2}' <<< "$infos") ${fname}" echo "Installing ${name} ${ver} [${downsize} ${instsize}000 ${MIRROR}/${fpath}]..." - cd "${TMPDIR}" || exit 1 + cd "${TMPDIR}" || { echo "Couldn't cd into ${TMPDIR}" ; exit 1 ; } test -z "$(curl -s "${MIRROR}/${fpath}" -o "${TMPDIR}/$fname")" || { echo "Couldn't retrieve file." ; exit 1 ; } echo "${md5sum}" > "${TMPDIR}/${fname}.md5" - if ${md5} --check --quiet "${TMPDIR}/${fname}.md5"; then + if ${md5} -c "${TMPDIR}/${fname}.md5" >/dev/null; then data="$(ar t "$fname" | grep '^data\.tar')" ar x "${TMPDIR}/$fname" "$data" tar xf "${TMPDIR}/$data" @@ -195,8 +195,6 @@ case "$1" in echo "Can't verify md5sum!" exit 1 fi - #rm "$f" "$data" - #rm -rf "${CACHEDIR:?}/"{usr,etc} ;; remove|-r) echo "Removing..." From 5f705d43945677215645e5d01eb8d9459528bec8 Mon Sep 17 00:00:00 2001 From: cb Date: Sat, 12 Aug 2023 07:55:08 +0200 Subject: [PATCH 19/24] fbsd: mktemp --- fnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fnt b/fnt index 558fb2b..b6517b1 100755 --- a/fnt +++ b/fnt @@ -172,7 +172,7 @@ case "$1" in fi fi # retrive font from debian mirror - TMPDIR="$(mktemp --directory --suffix=fnt)" + TMPDIR="$(mktemp -d)" trap 'rm -rf -- "$TMPDIR"' EXIT name="$p" infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size|MD5sum): /')" From 44858be53e743f5b933f7d7938f5939d0fbded0e Mon Sep 17 00:00:00 2001 From: cb Date: Sat, 12 Aug 2023 14:35:00 +0200 Subject: [PATCH 20/24] preview: rm -f --- fnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fnt b/fnt index b6517b1..1c51f9d 100755 --- a/fnt +++ b/fnt @@ -119,7 +119,7 @@ case "$1" in exit 1 fi mkdir -p "${CACHEDIR}" - rm "${CACHEDIR}/preview.png" + rm -f "${CACHEDIR}/preview.png" PRINTED= if curl -L -s "https://screenshots.debian.net/screenshot/fonts-$2" -o "${CACHEDIR}/preview.png"; then # if we get nothing / "this picture is not available" pic From 825dacd78f5de971e195a73fafe6d5bb435e0460 Mon Sep 17 00:00:00 2001 From: cb Date: Sat, 12 Aug 2023 14:35:35 +0200 Subject: [PATCH 21/24] man: fix preview / add install --- fnt.1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fnt.1 b/fnt.1 index c34a6ca..437638f 100644 --- a/fnt.1 +++ b/fnt.1 @@ -1,4 +1,4 @@ -.TH man 1 "01 Mar 2021" "1.1" "font downloader and manager" +.TH man 1 "12 Aug 2023" "1.1" "font downloader and manager" .SH NAME fnt \- download and install fonts .SH SYNOPSIS @@ -15,9 +15,12 @@ update font index. .I fnt search aga search for fonts named aga. .TP -.I fnt preview agave +.I fnt install agave install the font called agave. .TP +.I fnt preview agave +show a text-based preview of the font called agave. +.TP .I fnt list list installed fonts with glyphcount. .SH SEE ALSO From b6a1418726a408a08951c2f443d9c74be3cd7138 Mon Sep 17 00:00:00 2001 From: cb Date: Sat, 12 Aug 2023 21:31:16 +0200 Subject: [PATCH 22/24] tartar --- fnt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fnt b/fnt index 1c51f9d..654a87f 100755 --- a/fnt +++ b/fnt @@ -173,7 +173,10 @@ case "$1" in fi # retrive font from debian mirror TMPDIR="$(mktemp -d)" + chmod go-rwx "${TMPDIR}" trap 'rm -rf -- "$TMPDIR"' EXIT + PIT="${TMPDIR}/extract" + mkdir -m go-rwx "${PIT}" || { echo "Couldn't eat tartar." ; exit 1 ; } name="$p" infos="$(unxz -c "${PACKAGES}" | awk "/^Package: ${name}$/,/^$/" | awk '/^(Version|Installed-Size|Filename|Size|MD5sum): /')" ver="$(awk '/^Version: /{print$2}' <<< "$infos")" @@ -189,8 +192,9 @@ case "$1" in if ${md5} -c "${TMPDIR}/${fname}.md5" >/dev/null; then data="$(ar t "$fname" | grep '^data\.tar')" ar x "${TMPDIR}/$fname" "$data" + cd "${PIT}" || { echo "Couldn't munch any tartar in: ${PIT}" ; exit 1 ; } tar xf "${TMPDIR}/$data" - find "${TMPDIR}" -name "*.?tf" -exec cp {} "$target" \; + find "${PIT}" -name "*.?tf" -exec cp {} "$target" \; else echo "Can't verify md5sum!" exit 1 From 84b0303161aeb73ca20f8bc887f907efe975d3ec Mon Sep 17 00:00:00 2001 From: cb Date: Sun, 13 Aug 2023 06:52:10 +0200 Subject: [PATCH 23/24] typ --- fnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fnt b/fnt index 654a87f..60666b0 100755 --- a/fnt +++ b/fnt @@ -171,7 +171,7 @@ case "$1" in exit 0 fi fi - # retrive font from debian mirror + # retrieve font from debian mirror TMPDIR="$(mktemp -d)" chmod go-rwx "${TMPDIR}" trap 'rm -rf -- "$TMPDIR"' EXIT From a9cc2a77db3fd691c3397f19c709d2dcfde74f47 Mon Sep 17 00:00:00 2001 From: cb Date: Sun, 20 Aug 2023 06:07:40 +0200 Subject: [PATCH 24/24] search: missing cache-file --- fnt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fnt b/fnt index 60666b0..c6c8928 100755 --- a/fnt +++ b/fnt @@ -15,7 +15,7 @@ CACHEDIR="${HOME}/.fnt" PACKAGES="${CACHEDIR}/Packages.xz" # debian sid index #INDEX="http://ftp.ch.debian.org/debian/dists/sid/main/binary-all/Packages.xz" -MIRROR="http://deb.debian.org/debian" +MIRROR="https://deb.debian.org/debian" INDEX="${MIRROR}/dists/sid/main/binary-all/Packages.xz" # google fonts index GINDEX="https://sid.ethz.ch/debian/google-fonts/fonts-master" @@ -207,6 +207,8 @@ case "$1" in search|-s) if [ -f "${PACKAGES}" ]; then unxz -c "${PACKAGES}" | awk '/^Package: fonts-'"$2"'/ {gsub(/^Package: /,"");print;}' + else + echo "Skipping non-existant Packages cache. Consider running: ${BASH_SOURCE[0]} update" >&2 fi curl -s "$GINDEX/ofl/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" | awk "/$2/" curl -s "$GINDEX/apache/" |grep "a href" |sed 's,.*">,google-,;s,/.*,,' |grep -v "\.\.$" | awk "/$2/"