#!/bin/bash # Prepares build environment # # Copyright (C) 2019 Mike Gerwitz # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # This will also download any necessary third-party files. Note that all # downloads are proxied over Tor (using `torify'). ## set -euo pipefail # Source fonts and license (SIL Open Font License 1.1) declare -ra fonts=( https://github.com/adobe-fonts/source-sans-pro/raw/c7ea228c8cd66f65dac985bef98fda12c9cfa713/WOFF/OTF/SourceSansPro-Light.otf.woff https://github.com/adobe-fonts/source-sans-pro/raw/c7ea228c8cd66f65dac985bef98fda12c9cfa713/WOFF/OTF/SourceSansPro-Regular.otf.woff https://github.com/adobe-fonts/source-sans-pro/raw/c7ea228c8cd66f65dac985bef98fda12c9cfa713/LICENSE.txt ) declare -r tpimagesdir=images/tp declare -r fontdir=fonts # Download third-party images. This not only keeps them out of the # repository, but explicitly states in a reproducible manner how the images # were manipulated (if at all). get-images() { echo 'retrieving third-party images...' ( cd "$tpimagesdir" && ./gen-makefile > Makefile ) make -C "$tpimagesdir" all check } # Download and verify fonts and license. get-fonts() { local font dest echo 'retrieving font files...' for font in "${fonts[@]}"; do dest="$fontdir/$( basename "$font" )" test ! -f "$dest" || continue torify wget "$font" -O "$dest" done # Verify that we haven't been served bad files. This should only happen # in the case of network failure or a malicious host, since the above URLs # reference the commit hash. echo 'verifying font files...' ( cd "$fontdir" && sha512sum -c SHA512SUM ) } # Bootstrap. main() { get-images get-fonts } main "$@"