aboutsummaryrefslogtreecommitdiff
path: root/tools/cpm/fetch.sh
blob: 684fc1107aabd29c91729a948796b1df6baa1bb3 (plain) (blame)
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
#!/bin/sh -e

# SPDX-FileCopyrightText: 2025 crueter
# SPDX-License-Identifier: GPL-3.0-or-later

[ -z "$CPM_SOURCE_CACHE" ] && CPM_SOURCE_CACHE=$PWD/.cache/cpm

mkdir -p "$CPM_SOURCE_CACHE"

# shellcheck disable=SC1091
. tools/cpm/common.sh

# shellcheck disable=SC1091
. tools/cpm/download.sh

# shellcheck disable=SC2034
ROOTDIR="$PWD"

TMP=$(mktemp -d)

usage() {
	cat << EOF
Usage: $0 [PACKAGE]...
Fetch the specified package or packages from their defined download locations.
If the package is already cached, it will not be re-fetched.

This project has defined the following as valid cpmfiles:
EOF

	for file in $CPMFILES; do
		echo "- $file"
	done

	exit 0
}

while true; do
	case "$1" in
		(-h) usage ;;
		("$0") break ;;
		("") break ;;
	esac

	PACKAGE="$1"

	shift

	export PACKAGE
	# shellcheck disable=SC1091
	. tools/cpm/package.sh

    if [ "$CI" = "true" ]; then
        ci_package
	else
		echo "-- Downloading regular package $PACKAGE, with key $KEY, from $DOWNLOAD"
	    download_package
    fi
done

rm -rf "$TMP"