summaryrefslogtreecommitdiff
path: root/misc/makezip2.sh
blob: 19d04857d5e024e81694b6a95873e5426f222697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
set -e
cd "$(dirname "$0")/.."

OPT_HELP=
OPT_REVEAL_IN_FINDER=false
OUTFILE=

# parse args
while [[ $# -gt 0 ]]; do
  case "$1" in
  -h|-help|--help)   OPT_HELP=0; shift;;
  -reveal-in-finder) OPT_REVEAL_IN_FINDER=true; shift;;
  -*)
    echo "$0: Unknown option $1" >&2
    OPT_HELP=1
    shift
    ;;
  *)
    if [[ "$OUTFILE" != "" ]] && ! $OPT_HELP; then
      echo "$0: Extra unexpected argument(s) after <outfile>" >&2
      OPT_HELP=1
    fi
    OUTFILE=$1
    shift
    ;;
  esac
done
if [ -n "$OPT_HELP" ]; then
  echo "Usage: $0 [options] <outfile>"
  echo "Options:"
  echo "  -h, -help          Show help."
  echo "  -reveal-in-finder  After creating the zip file, show it in Finder"
  exit $OPT_HELP
fi

# tmp dir
ZIPDIR=build/tmp/zip

# convert relative path to absolute if needed
OUTFILE_ABS=$OUTFILE
if [[ "$OUTFILE_ABS" != /* ]]; then
  OUTFILE_ABS="$PWD/$OUTFILE_ABS"
fi

rm -rf "$ZIPDIR"
mkdir -p "$(dirname "$OUTFILE_ABS")" "$ZIPDIR"

cp LICENSE.txt "$ZIPDIR/LICENSE.txt"


mkdir -p "$ZIPDIR/web"

cp misc/dist/help.txt                         "$ZIPDIR/help.txt"
cp build/fonts/static-hinted/Inter.ttc        "$ZIPDIR/Inter.ttc"
cp build/fonts/var/InterVariable.ttf          "$ZIPDIR/InterVariable.ttf"
cp build/fonts/var/InterVariable-Italic.ttf   "$ZIPDIR/InterVariable-Italic.ttf"
cp build/fonts/static/Inter*.woff2            "$ZIPDIR/web/" &
cp build/fonts/var/InterVariable.woff2        "$ZIPDIR/web/InterVariable.woff2"
cp build/fonts/var/InterVariable-Italic.woff2 "$ZIPDIR/web/InterVariable-Italic.woff2"
cp misc/dist/inter.css                         "$ZIPDIR/web/"

. build/venv/bin/activate
python misc/tools/patch-version.py "$ZIPDIR/web/inter.css"

mkdir -p "$ZIPDIR/extras/otf" \
         "$ZIPDIR/extras/ttf" \
         "$ZIPDIR/extras/woff-hinted"

cp build/fonts/static/Inter*.otf          "$ZIPDIR/extras/otf/" &
cp build/fonts/static-hinted/Inter*.ttf   "$ZIPDIR/extras/ttf/" &
cp build/fonts/static-hinted/Inter*.woff2 "$ZIPDIR/extras/woff-hinted/" &



mkdir -p "$(dirname "$OUTFILE_ABS")"
wait

rm -rf "$OUTFILE_ABS"
pushd "$ZIPDIR" >/dev/null
zip -q -X -r "$OUTFILE_ABS" *
popd >/dev/null
rm -rf "$ZIPDIR"

echo "Created $OUTFILE"
if $OPT_REVEAL_IN_FINDER && [ "$(uname -s)" = Darwin ] && [ -f /usr/bin/open ]; then
  /usr/bin/open --reveal "$OUTFILE"
fi