aboutsummaryrefslogtreecommitdiff
path: root/tools/cpm/package.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/cpm/package.sh')
-rwxr-xr-xtools/cpm/package.sh63
1 files changed, 50 insertions, 13 deletions
diff --git a/tools/cpm/package.sh b/tools/cpm/package.sh
index bf2f3feaa7..8246222d50 100755
--- a/tools/cpm/package.sh
+++ b/tools/cpm/package.sh
@@ -12,17 +12,17 @@ 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
+ 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
+ url 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 Add a patch to a package in the cpmfile
EOF
@@ -30,11 +30,48 @@ EOF
}
SCRIPTS=$(CDPATH='' cd -- "$(dirname -- "$0")/package" && pwd)
-export SCRIPTS
+CMAKE="$CMAKE/package"
+
+export SCRIPTS CMAKE
+
+filter_args() {
+ print_usage=false
+ all_flag=false
+ commit_flag=false
+ filtered=""
+
+ for arg in "$@"; do
+ case "$arg" in
+ -h | --help) print_usage=true ;;
+ -a | --all) all_flag=true ;;
+ -c | --commit) commit_flag=true ;;
+ -ac | -ca)
+ commit_flag=true
+ all_flag=true
+ ;;
+ *) filtered="$filtered $arg" ;;
+ esac
+ done
+}
while :; do
case "$1" in
- hash | update | fetch | add | rm | version | which | download | reset | patch | dir)
+ dir | fetch | hash | reset | rm | url | version | which | update)
+ cmd="$1"
+ shift
+
+ filter_args "$@"
+ cmake_defines=""
+
+ if $print_usage; then cmake_defines="$cmake_defines -DPRINT_USAGE=TRUE"; fi
+ if $all_flag; then cmake_defines="$cmake_defines -DALL_PACKAGES=TRUE"; fi
+ if $commit_flag; then cmake_defines="$cmake_defines -DMAKE_COMMIT=TRUE"; fi
+
+ # shellcheck disable=SC2086
+ cmake $cmake_defines -P "$CMAKE/$cmd.cmake" -- $filtered
+ break
+ ;;
+ add | patch)
cmd="$1"
shift
"$SCRIPTS/$cmd".sh "$@"