parlay

yet another gentoo overlay
git clone https://git.parazyd.org/parlay
Log | Files | Refs | README

generate-google-fonts.sh (1898B)


      1 #!/bin/sh
      2 
      3 usage() {
      4 	echo "usage: $(basename "$0") /path/to/google-fonts-git"
      5 	exit 1
      6 }
      7 
      8 [ -n "$1" ] || usage
      9 
     10 if ! [ -d "$1/ofl" ] || ! [ -d "$1/apache" ]; then
     11 	echo "error: Google fonts repo is missing apache/ofl directory."
     12 	exit 1
     13 fi
     14 
     15 gitdir="$1"
     16 
     17 get_pretty_name() {
     18 	if ! [ -f "$1/METADATA.pb" ]; then
     19 		#echo "error: Missing $1/METADATA.pb"
     20 		echo "$(basename "$1")"
     21 		return
     22 	fi
     23 	awk -F ': ' '/^name: / {print $2}' "$1/METADATA.pb" \
     24 		| tr -d '"' | tr ' ' '+'
     25 }
     26 
     27 for i in "$gitdir/apache/"*/ "$gitdir/ofl/"*/; do
     28 	font="$(basename "$i")"
     29 
     30 	case "$i" in
     31 	*/apache/*)
     32 		license="Apache-2.0"
     33 		shlicense="apache"
     34 		;;
     35 	*/ofl/*)
     36 		license="OFL-1.1"
     37 		shlicense="ofl"
     38 		;;
     39 	*)
     40 		echo "Internal error"
     41 		exit 1
     42 		;;
     43 	esac
     44 
     45 	if [ -d "/usr/portage/media-fonts/$font" ]; then
     46 		echo "Skipping: $shlicense/$font"
     47 		continue
     48 	fi
     49 
     50 	existed=0
     51 	echo "Generating: $shlicense/$font"
     52 	if [ -d "$font" ]; then
     53 		existed=1
     54 	fi
     55 	mkdir -p "$font"
     56 	cd "$font" || exit 1
     57 
     58 	font_pretty="$(get_pretty_name $i)"
     59 
     60 	cat <<EOF > "${font}-9999.ebuild"
     61 # Copyright 2019 Gentoo Authors
     62 # Distributed under the terms of the GNU General Public License v2
     63 
     64 EAPI=6
     65 
     66 inherit font git-r3
     67 
     68 DESCRIPTION="Google Fonts $(echo "$font_pretty" | tr '+' ' ') font"
     69 HOMEPAGE="https://fonts.google.com/specimen/$font_pretty"
     70 EGIT_REPO_URI="https://github.com/google/fonts"
     71 
     72 LICENSE="$license"
     73 SLOT="0"
     74 KEYWORDS=""
     75 IUSE=""
     76 
     77 DEPEND=""
     78 RDEPEND="\${DEPEND}"
     79 BDEPEND=""
     80 
     81 RESTRICT="binchecks strip"
     82 FONT_SUFFIX="ttf"
     83 
     84 src_install() {
     85 	FONT_S="\$WORKDIR/\${P}/$shlicense/$font" font_src_install
     86 }
     87 EOF
     88 
     89 	cat <<EOF > metadata.xml
     90 <?xml version="1.0" encoding="UTF-8"?>
     91 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
     92 <pkgmetadata>
     93 	<maintainer type="person">
     94 		<email>parazyd@dyne.org</email>
     95 	</maintainer>
     96 </pkgmetadata>
     97 EOF
     98 
     99 	if [ "$existed" = 0 ]; then
    100 		ebuild "${font}-9999.ebuild" digest
    101 	fi
    102 	cd - >/dev/null
    103 done