avivace / iosevka-docker

Docker containers to build custom (or upstream) versions of the Iosevka typeface and package them for Debian
https://hub.docker.com/r/avivace/iosevka-build
Creative Commons Zero v1.0 Universal
29 stars 12 forks source link

Silently aborts without FONT_VERSION #10

Closed OnkelTem closed 2 years ago

OnkelTem commented 2 years ago

Running docker container w/o FONT_VERSION now leads to command abortion. See: https://github.com/be5invis/Iosevka/issues/1340#issuecomment-1115994078

The problem is that this code from https://github.com/avivace/iosevka-docker/blob/master/run.sh:

if [ ! -n "$FONT_VERSION" ]; then
    FONT_VERSION=$(curl -s https://github.com/be5invis/Iosevka/releases/latest \
        | grep -Po '(?<=tag/v)[0-9.]*')
fi

isn't doing what it's expected to.

First, https://github.com/be5invis/Iosevka/releases/latest returns HTTP 302 (redirect) and hence the output of curl -s https://github.com/be5invis/Iosevka/releases/latest is an empty string. With this empty string as version it then tries to download the release here

    curl -sSLO --proto '=https' --tlsv1.2 https://github.com/be5invis/Iosevka/archive/v${FONT_VERSION}.tar.gz

Adding -L flag to the curl invocation would lead us to a page like https://github.com/be5invis/Iosevka/releases/tag/v15.2.0. Applying the regexp to which gives:

$ curl -s -L https://github.com/be5invis/Iosevka/releases/latest | grep -Po '(?<=tag/v)[0-9.]*'
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0
15.2.0

as FONT_VERSION variable.

The most simple workaround would be to use FONT_VERSION set to "dev", e.g.:

$ docker run -e FONT_VERSION="dev" -it -v $(pwd):/build avivace/iosevka-build ttf::iosevka-custom
OnkelTem commented 2 years ago

As for a fix, the easiest way to repair is perhaps just to take the first match. E.g

if [ ! -n "$FONT_VERSION" ]; then
    FONT_VERSION=$(curl -s https://github.com/be5invis/Iosevka/releases/latest \
        | grep -Po '(?<=tag/v)[0-9.]*' | head -1)
fi
avivace commented 2 years ago

Thanks @OnkelTem !