aboutsummaryrefslogtreecommitdiff
path: root/tools/cpm/package.sh
blob: bf2f3feaa7f0943a521779052c9a5e6c5ad50f94 (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
#!/bin/sh -e

# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later

RETURN=0

usage() {
	cat <<EOF
Usage: cpmutil.sh package [command]

Operate on a package or packages.

Commands:
    hash    	Verify the hash of a package, and update it if needed
    update  	Check for updates for a package
    fetch   	Fetch a package and place it in the cache
    add     	Add a new package
    rm      	Remove a package
    version 	Change the version of a package
    which   	Check if a package is defined
    download 	Get the download URL for a package
    dir     	Get the local directory for a package
    reset   	Reset a fetched package to its original state
    patch   	Create an in-tree patch based on local modifications

EOF

	exit $RETURN
}

SCRIPTS=$(CDPATH='' cd -- "$(dirname -- "$0")/package" && pwd)
export SCRIPTS

while :; do
	case "$1" in
	hash | update | fetch | add | rm | version | which | download | reset | patch | dir)
		cmd="$1"
		shift
		"$SCRIPTS/$cmd".sh "$@"
		break
		;;
	*) usage ;;
	esac

	shift
done