Project

General

Profile

Download (1.63 KB) Statistics
| Branch: | Tag: | Revision:

haketilo / build.sh @ 4c6a2323

1
#!/bin/sh
2

    
3
# This file is part of Haketilo
4
#
5
# Copyright (C) 2021, Wojtek Kosior
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the CC0 1.0 Universal License as published by
9
# the Creative Commons Corporation.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# CC0 1.0 Universal License for more details.
15

    
16
set -e
17

    
18
. ./shell_utils.sh
19

    
20
print_usage() {
21
    printf 'usage:  %s mozilla|chromium [source directory] [update url]\n' \
22
	   "$0" >&2
23
}
24

    
25
call_awk() {
26
    local BROWSER_UPCASE="$(printf %s "$BROWSER" | tr '[:lower:]' '[:upper:]')"
27
    awk -f compute_scripts.awk -- -M manifest.json -D "$BROWSER_UPCASE" \
28
	-D MV2 --output=files-to-copy --write-js-deps --write-html-deps \
29
	--output-dir="$BUILDDIR"
30
}
31

    
32
main() {
33
    if [ "x$1" = "xmozilla" -o "x$1" = "xchromium" ]; then
34
	BROWSER=$1
35
    else
36
	print_usage
37
	exit 1
38
    fi
39

    
40
    SRCDIR="${2:-.}"
41
    if [ -d "$SRCDIR" ]; then
42
	BUILDDIR="$(realpath $BROWSER-unpacked)"
43
	rm -rf "$BUILDDIR"
44
	mkdir "$BUILDDIR"
45
	cd "$SRCDIR"
46
    else
47
	print_usage
48
	exit 2
49
    fi
50

    
51
    UPDATE_URL="$3"
52
    if [ -n "$3" ]; then
53
	printf 'possibility of using an update url is currently unimplemented' \
54
	       >&2
55
	exit 1
56
    fi
57

    
58
    FILES_TO_COPY="$(call_awk)"
59
    for FILE in $FILES_TO_COPY; do
60
	FILEDIR="$(printf %s "$FILE" | sed 's_[^/]*$_/_')"
61
	if [ -n "$FILEDIR" -a ! -d "$BUILDDIR/$FILEDIR" ]; then
62
	    mkdir -p "$BUILDDIR/$FILEDIR"
63
	fi
64
	cp "$FILE" "$BUILDDIR/$FILE"
65
    done
66

    
67
    cp -r README.md copyright licenses/ "$BUILDDIR"
68
}
69

    
70
main "$@"
(4-4/16)