Project

General

Profile

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

haketilo / build.sh @ fd9f2fc4

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
print_usage() {
19
    printf 'usage:  %s mozilla|chromium [source directory] [update url]\n' \
20
	   "$0" >&2
21
}
22

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

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

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

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

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

    
65
    cp -r README.md copyright licenses/ "$BUILDDIR"
66
}
67

    
68
main "$@"
(4-4/18)