diff options
author | Andrew Crerar | 2017-11-11 20:40:29 -0500 |
---|---|---|
committer | Andrew Crerar | 2017-11-11 20:40:29 -0500 |
commit | 4fb0f1cae4861110b21312b2b6cc5718e26e3e4a (patch) | |
tree | 35e7363e92d968159b449b104a4ccf59d83ef842 | |
parent | 4ded65011aa895de4e5ccb881d35b6bb21aed102 (diff) | |
download | aur-4fb0f1cae4861110b21312b2b6cc5718e26e3e4a.tar.gz |
Refactoring package()
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 67 |
2 files changed, 38 insertions, 31 deletions
@@ -1,7 +1,7 @@ pkgbase = ttf-google-fonts-git pkgdesc = TrueType fonts from the Google Fonts project (git version) pkgver = r1211.414832ad - pkgrel = 1 + pkgrel = 2 epoch = 1 url = https://github.com/google/fonts arch = any @@ -10,7 +10,7 @@ pkgname=ttf-google-fonts-git pkgver=r1211.414832ad -pkgrel=1 +pkgrel=2 epoch=1 pkgdesc="TrueType fonts from the Google Fonts project (git version)" arch=(any) @@ -45,49 +45,56 @@ provides=(adobe-source-code-pro-fonts adobe-source-sans-pro-fonts jsmath-fonts ttf-merriweather-sans ttf-nova ttf-opensans ttf-oswald ttf-oxygen ttf-oxygen-git ttf-pt-fonts ttf-quintessential ttf-roboto-mono ttf-signika ttf-sil-fonts ttf-source-code-pro-ibx ttf-source-sans-pro-ibx ttf-vollkorn-ibx) -source=("git+${url}.git") +source=(git+"${url}".git) sha512sums=('SKIP') pkgver() { - cd fonts + cd fonts - printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" } package() { - install -dm755 "$pkgdir/usr/share/fonts/TTF" - find . -type f -name \*.[Tt][Tt][Ff] -exec install -Dm644 '{}' ${pkgdir}/usr/share/fonts/TTF \; + # NOTE: These are the font families that already exist in the [extra] and [community] repos. + declare -A omitted_font_families=([cantarell]=1 [noto-sans-tamil]=1 [noto-serif]=1 + [noto-sans]=1 [fira-sans]=1 [fira-mono]=1 + [ubuntu]=1 [ubuntu-mono]=1 [tinos]=1 [arimo]=1 + [cousine]=1 [roboto]=1 [roboto-condensed]=1 + [inconsolata]=1) - # [fonts/ofl/cantarell] provided by extra/cantarell-fonts - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Cantarell-*.ttf" -delete + while IFS= read -rd '' file; do + font_family=$(fc-query -f '%{family[0]|downcase|translate( ,-)}\n' "$file" | sed -n '2p') - # [fonts/ofl/notosanstamil, fonts/ofl/notoserif] provided by extra/noto-fonts - find ${pkgdir}/usr/share/fonts/TTF -type f -name "NotoSansTamil-*.ttf" -delete - find ${pkgdir}/usr/share/fonts/TTF -type f -name "NotoSerif-*.ttf" -delete + # NOTE: Skip the rest of the loop if we're not supposed to be touching this family + ((omitted_font_families["$font_family"])) && continue - # [fonts/ofl/notosans] provided by extra/noto-fonts-extra - find ${pkgdir}/usr/share/fonts/TTF -type f -name "NotoSans-*.ttf" -delete + pkg_font_path="$pkgdir"/usr/share/fonts/"$font_family" + install -dm755 "$pkg_font_path" # Create the folder for the font (if it doesn't exist yet) + install -Dm644 "$file" -t "$pkg_font_path" # Install the font in the folder - # [fonts/ofl/firasans] provided by community/ttf-fira-sans - find ${pkgdir}/usr/share/fonts/TTF -type f -name "FiraSans-*.ttf" -delete + # NOTE: If the font's license path already exists, we don't need to copy the license into it again. + pkg_license_path="$pkgdir"/usr/share/licenses/"$pkgname"/"$font_family" + [[ -d "$pkg_license_path" ]] && continue - # [fonts/ofl/firamono] provided by community/ttf-fira-mono - find ${pkgdir}/usr/share/fonts/TTF -type f -name "FiraMono-*.ttf" -delete + # NOTE: We only care about copying over OFL licenses since Apache and Ubuntu are standard. + IFS=\/ read -ra path <<< "$file"; src_license_path="${srcdir}$(printf "/%s" "${path[@]:1:3}")"/OFL.txt + if [[ -f "$src_license_path" ]]; then + install -dm755 "$pkg_license_path" + install -Dm644 "$src_license_path" "$pkg_license_path"/OFL.txt + fi + done < <(find . -type f -iname \*.ttf -print0) - # [fonts/ufl/ubuntu, fonts/ufl/ubuntumono] provided by community/ttf-ubuntu-font-family - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Ubuntu-*.ttf" -delete - find ${pkgdir}/usr/share/fonts/TTF -type f -name "UbuntuMono-*.ttf" -delete + # NOTE: Since the cwtex* Chinese font family has special characters we need to change + # those folder names to prevent errors during package compression. + mv "$pkgdir"/usr/share/fonts/cwtex-仿宋體 "$pkgdir"/usr/share/fonts/cwtex-fangsong + mv "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-仿宋體 "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-fangsong - # [fonts/apache/tinos, fonts/apache/arimo, fonts/apache/cousine] provided by extra/ttf-croscore - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Tinos-*.ttf" -delete - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Arimo-*.ttf" -delete - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Cousine-*.ttf" -delete + mv "$pkgdir"/usr/share/fonts/cwtex-楷書 "$pkgdir"/usr/share/fonts/cwtex-kai + mv "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-楷書 "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-kai - # [fonts/apache/roboto, fonts/apache/robotocondensed] provided by community/ttf-roboto - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Roboto-*.ttf" -delete - find ${pkgdir}/usr/share/fonts/TTF -type f -name "RobotoCondensed-*.ttf" -delete - - # [fonts/ofl/inconsolata] provided by community/ttf-inconsolata - find ${pkgdir}/usr/share/fonts/TTF -type f -name "Inconsolata-*.ttf" -delete + mv "$pkgdir"/usr/share/fonts/cwtex-明體 "$pkgdir"/usr/share/fonts/cwtex-ming + mv "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-明體 "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-ming + mv "$pkgdir"/usr/share/fonts/cwtex-圓體 "$pkgdir"/usr/share/fonts/cwtex-yen + mv "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-圓體 "$pkgdir"/usr/share/licenses/"$pkgname"/cwtex-yen } |