Newer
Older
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
# Common functions for generate_lists and generate_medkit functions
# (C) 2018 CZ.NIC, z.s.p.o.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
USIGN_VERSION=ef6419142a3b0fbcddcccf536e3c1880302c6f89
SRC_USIGN="https://git.openwrt.org/project/usign.git"
# Git puller helper function (git_pull output_path source_url target)
git_get() {
local REPO="$1"
local OUTPUT="$2"
local BRANCH="${3:-master}"
if [ ! -d "$OUTPUT/.git" ]; then
mkdir -p "$(dirname "$OUTPUT")"
git clone "$REPO" "$OUTPUT"
(
cd "$OUTPUT"
git checkout "$BRANCH"
git submodule update --init --recursive
git clean -Xdf
)
return 1
else
(
cd "$OUTPUT"
git fetch
local REF="origin/$BRANCH"
git show-ref -q "$REF" || REF="$BRANCH" # Is this reference on remote or object
if ! git diff --quiet HEAD "$REF"; then
git reset --hard "$REF"
git submodule update --init --recursive
git clean -Xdf
return 1
fi
)
fi
}
# Wget puller helper function (wget_pull output_file source_url)
wget_get() {
local HREF="$1"
local OUTPUT="$2"
if [ ! -e "$OUTPUT" ] || [ $(expr $(date -u +%s) - $(stat -c %Z "$OUTPUT")) -gt 86400 ]; then
wget "$HREF" -O "$OUTPUT"
fi
}
get_usign() {
if ! git_get "$SRC_USIGN" turris-tools/usign "$USIGN_VERSION"; then
( cd turris-tools/usign && cmake . )
make -C turris-tools/usign
fi
export USIGN="$(pwd)/turris-tools/usign/usign"
}