forked from ToyKeeper/tktsto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-zip.sh
More file actions
executable file
·74 lines (63 loc) · 1.88 KB
/
Copy pathmake-zip.sh
File metadata and controls
executable file
·74 lines (63 loc) · 1.88 KB
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
#!/bin/sh
# make-zip.sh: make the extension .zip file for browsers to load
# Copyright (C) 2025 Selene ToyKeeper & Ignat Remizov
# SPDX-License-Identifier: AGPL-3.0-or-later
BROWSER=${1:-chromium}
PROGRAM="ignatremizov-tabs"
# Load optional build overrides from .env.
if [ -f ./.env ]; then
set -a
. ./.env
set +a
fi
# get version from the appropriate manifest file
if [ 'firefox' = "$BROWSER" ]; then
VERSION=$(grep '"version"' manifest-ff.json | sed -rn 's/.*: "(.*)".*/\1/p')
else
VERSION=$(grep '"version"' manifest.json | sed -rn 's/.*: "(.*)".*/\1/p')
fi
# clean the build area
mkdir -p build
rm -rf build/*
# copy root-level files
for f in LICENSE LICENSE.* Makefile *.js *.md *.html ; do
[ -e "$f" ] && cp -v "$f" build
done
# manifest differs per browser
if [ 'firefox' = "$BROWSER" ]; then
cp -v manifest-ff.json build/manifest.json
else
cp -v manifest.json build/manifest.json
fi
# Apply optional overrides to the build manifest.
if [ -n "${EXT_NAME:-}" ]; then
if sed --version >/dev/null 2>&1; then
sed -i "s/\"name\": \"[^\"]*\"/\"name\": \"$EXT_NAME\"/" build/manifest.json
else
sed -i '' "s/\"name\": \"[^\"]*\"/\"name\": \"$EXT_NAME\"/" build/manifest.json
fi
fi
if [ 'firefox' = "$BROWSER" ] && [ -n "${FF_EXT_ID:-}" ]; then
if sed --version >/dev/null 2>&1; then
sed -i "s/\"id\": \"[^\"]*\"/\"id\": \"$FF_EXT_ID\"/" build/manifest.json
else
sed -i '' "s/\"id\": \"[^\"]*\"/\"id\": \"$FF_EXT_ID\"/" build/manifest.json
fi
fi
# copy subdirs
SUBDIRS="bkgd common docs img options themes view"
for d in $SUBDIRS ; do
mkdir -p "build/$d"
for ext in js html css md png ; do
for f in "$d"/*.$ext ; do
[ -e "$f" ] && cp "$f" "build/$d"
done
done
done
# Remove developer-only docs from packaged builds.
rm -rf build/docs/dev
mkdir -p dist
cd build
ZIPFILE=../dist/"$PROGRAM"-"$VERSION"-"$BROWSER".zip
rm -f "$ZIPFILE"
zip -r "$ZIPFILE" *