|
|
@ -3,8 +3,6 @@ |
|
|
# SPDX-FileCopyrightText: Copyright 2026 crueter |
|
|
# SPDX-FileCopyrightText: Copyright 2026 crueter |
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later |
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later |
|
|
|
|
|
|
|
|
# TODO(crueter): Fix this pls |
|
|
|
|
|
|
|
|
|
|
|
# This reads a single-line input from the user and also gives them |
|
|
# This reads a single-line input from the user and also gives them |
|
|
# help if needed. |
|
|
# help if needed. |
|
|
# $1: The prompt itself, without any trailing spaces or whatever |
|
|
# $1: The prompt itself, without any trailing spaces or whatever |
|
|
@ -88,6 +86,18 @@ optional "Additional find_package arguments, space-separated" \ |
|
|
|
|
|
|
|
|
FIND_ARGS="$reply" |
|
|
FIND_ARGS="$reply" |
|
|
|
|
|
|
|
|
|
|
|
optional "Git host (default: github.com)" \ |
|
|
|
|
|
"The hostname of the Git server, if not GitHub (e.g. codeberg.org, git.crueter.xyz)" |
|
|
|
|
|
|
|
|
|
|
|
GIT_HOST="$reply" |
|
|
|
|
|
|
|
|
|
|
|
required "Numeric version of the bundled package" \ |
|
|
|
|
|
"The semantic version of the bundled package. This is only used for package identification, |
|
|
|
|
|
and if you use tag/artifact fetching. Do not input the entire tag here; for example, if you're using |
|
|
|
|
|
tag v1.3.0, then set this to 1.3.0 and set the tag to v%VERSION%." |
|
|
|
|
|
|
|
|
|
|
|
VERSION="$reply" |
|
|
|
|
|
|
|
|
optional "Is this a CI package? [y/N]" \ |
|
|
optional "Is this a CI package? [y/N]" \ |
|
|
"Yes if the package is a prebuilt binary distribution (e.g. crueter-ci), |
|
|
"Yes if the package is a prebuilt binary distribution (e.g. crueter-ci), |
|
|
no if the package is built from source if it's bundled." |
|
|
no if the package is built from source if it's bundled." |
|
|
@ -98,27 +108,31 @@ case "$reply" in |
|
|
esac |
|
|
esac |
|
|
|
|
|
|
|
|
if [ "$CI" = "false" ]; then |
|
|
if [ "$CI" = "false" ]; then |
|
|
optional "Git host (default: github.com)" \ |
|
|
|
|
|
"The hostname of the Git server, if not GitHub (e.g. codeberg.org, git.crueter.xyz)" |
|
|
|
|
|
|
|
|
|
|
|
GIT_HOST="$reply" |
|
|
|
|
|
|
|
|
while :; do |
|
|
|
|
|
required "Use tag or commit sha versioning? [tag/sha]" \ |
|
|
|
|
|
"Tag versioning is compatible with auto-updating. |
|
|
|
|
|
Use sha versioning for projects with improper tagging practices" |
|
|
|
|
|
|
|
|
|
|
|
if [ "$reply" = "tag" ]; then |
|
|
|
|
|
TAG=1 |
|
|
|
|
|
break |
|
|
|
|
|
elif [ "$reply" = "sha" ]; then |
|
|
|
|
|
SHA=1 |
|
|
|
|
|
break |
|
|
|
|
|
else |
|
|
|
|
|
echo "-- Invalid choice $reply" |
|
|
|
|
|
fi |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
if [ "$TAG" = "1" ]; then |
|
|
if [ "$TAG" = "1" ]; then |
|
|
required "Numeric version of the bundled package" \ |
|
|
|
|
|
"The semantic version of the bundled package. This is only used for package identification, |
|
|
|
|
|
and if you use tag/artifact fetching. Do not input the entire tag here; for example, if you're using |
|
|
|
|
|
tag v1.3.0, then set this to 1.3.0 and set the tag to v%VERSION%." |
|
|
|
|
|
|
|
|
|
|
|
GIT_VERSION="$reply" |
|
|
|
|
|
|
|
|
|
|
|
optional "Name of the upstream tag. %VERSION% is replaced by the numeric version (default: %VERSION%)" \ |
|
|
|
|
|
|
|
|
optional "Name of the upstream tag. %VERSION% is replaced by the numeric version ($VERSION) (default: %VERSION%)" \ |
|
|
"Most commonly this will be something like v%VERSION% or release-%VERSION%, or just %VERSION%." |
|
|
"Most commonly this will be something like v%VERSION% or release-%VERSION%, or just %VERSION%." |
|
|
|
|
|
|
|
|
TAGNAME="$reply" |
|
|
TAGNAME="$reply" |
|
|
[ -n "$TAGNAME" ] || TAGNAME="%VERSION%" |
|
|
[ -n "$TAGNAME" ] || TAGNAME="%VERSION%" |
|
|
|
|
|
|
|
|
optional "Name of the release artifact to download, if applicable. |
|
|
optional "Name of the release artifact to download, if applicable. |
|
|
-- %VERSION% is replaced by the numeric version and %TAG% is replaced by the tag name" \ |
|
|
|
|
|
|
|
|
-- %VERSION% is replaced by the numeric version ($VERSION) and %TAG% is replaced by the tag name" \ |
|
|
"Download the specified artifact from the release with the previously specified tag. |
|
|
"Download the specified artifact from the release with the previously specified tag. |
|
|
If unspecified, the source code at the specified tag will be used instead." |
|
|
If unspecified, the source code at the specified tag will be used instead." |
|
|
|
|
|
|
|
|
@ -136,11 +150,6 @@ should be set in CMake with AddJsonPackage's OPTIONS parameter." |
|
|
|
|
|
|
|
|
OPTIONS="$reply" |
|
|
OPTIONS="$reply" |
|
|
else |
|
|
else |
|
|
required "Version of the CI package (e.g. 3.6.0-9eff87adb1)" \ |
|
|
|
|
|
"CI artifacts are stored as <name>-<platform>-<version>.tar.zst. This option controls the version." |
|
|
|
|
|
|
|
|
|
|
|
VERSION="$reply" |
|
|
|
|
|
|
|
|
|
|
|
required "Name of the CI artifact" \ |
|
|
required "Name of the CI artifact" \ |
|
|
"CI artifacts are stored as <name>-<platform>-<version>.tar.zst. This option controls the name." |
|
|
"CI artifacts are stored as <name>-<platform>-<version>.tar.zst. This option controls the name." |
|
|
|
|
|
|
|
|
@ -164,11 +173,15 @@ jq_input='{repo: "'"$REPO"'"}' |
|
|
[ -z "$PACKAGE" ] || jq_input="$jq_input + {package: \"$PACKAGE\"}" |
|
|
[ -z "$PACKAGE" ] || jq_input="$jq_input + {package: \"$PACKAGE\"}" |
|
|
[ -z "$MIN_VERSION" ] || jq_input="$jq_input + {min_version: \"$MIN_VERSION\"}" |
|
|
[ -z "$MIN_VERSION" ] || jq_input="$jq_input + {min_version: \"$MIN_VERSION\"}" |
|
|
[ -z "$FIND_ARGS" ] || jq_input="$jq_input + {find_args: \"$FIND_ARGS\"}" |
|
|
[ -z "$FIND_ARGS" ] || jq_input="$jq_input + {find_args: \"$FIND_ARGS\"}" |
|
|
|
|
|
jq_input="$jq_input + {version: \"$VERSION\"}" |
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$GIT_HOST" ] && [ "$GIT_HOST" != "github.com" ]; then |
|
|
|
|
|
jq_input="$jq_input + {git_host: \"$GIT_HOST\"}" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if [ "$CI" = "true" ]; then |
|
|
if [ "$CI" = "true" ]; then |
|
|
jq_input="$jq_input + { |
|
|
jq_input="$jq_input + { |
|
|
ci: true, |
|
|
ci: true, |
|
|
version: \"$VERSION\", |
|
|
|
|
|
artifact: \"$ARTIFACT\" |
|
|
artifact: \"$ARTIFACT\" |
|
|
}" |
|
|
}" |
|
|
|
|
|
|
|
|
@ -187,32 +200,29 @@ else |
|
|
jq_input="$jq_input + {options: $options_json}" |
|
|
jq_input="$jq_input + {options: $options_json}" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# Git host |
|
|
|
|
|
if [ -n "$GIT_HOST" ] && [ "$GIT_HOST" != "github.com" ]; then |
|
|
|
|
|
jq_input="$jq_input + {git_host: \"$GIT_HOST\"}" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# versioning stuff |
|
|
# versioning stuff |
|
|
if [ -n "$GIT_VERSION" ]; then |
|
|
|
|
|
jq_input="$jq_input + {git_version: \"$GIT_VERSION\"}" |
|
|
|
|
|
[ -z "$TAGNAME" ] || jq_input="$jq_input + {tag: \"$TAGNAME\"}" |
|
|
|
|
|
|
|
|
if [ "$TAG" = 1 ]; then |
|
|
|
|
|
jq_input="$jq_input + {tag: \"$TAGNAME\"}" |
|
|
[ -z "$ARTIFACT" ] || jq_input="$jq_input + {artifact: \"$ARTIFACT\"}" |
|
|
[ -z "$ARTIFACT" ] || jq_input="$jq_input + {artifact: \"$ARTIFACT\"}" |
|
|
else |
|
|
else |
|
|
jq_input="$jq_input + {sha: \"$SHA\"}" |
|
|
jq_input="$jq_input + {sha: \"$SHA\"}" |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
new_json=$(jq -n "$jq_input") |
|
|
|
|
|
|
|
|
JSON=$(jq -n "$jq_input") |
|
|
|
|
|
|
|
|
jq --arg key "$PKG" --argjson new "$new_json" \ |
|
|
|
|
|
'.[$key] = $new' "$CPMFILE" --indent 4 >"${CPMFILE}.tmp" && |
|
|
|
|
|
mv "${CPMFILE}.tmp" "$CPMFILE" |
|
|
|
|
|
|
|
|
# shellcheck disable=SC1091 |
|
|
|
|
|
. "$SCRIPTS"/vars.sh |
|
|
|
|
|
|
|
|
# now correct the hash |
|
|
|
|
|
if [ "$CI" != true ]; then |
|
|
if [ "$CI" != true ]; then |
|
|
# shellcheck disable=SC1091 |
|
|
|
|
|
. "$ROOTDIR"/common.sh |
|
|
|
|
|
QUIET=true UPDATE=true "$SCRIPTS"/util/fix-hash.sh "$PKG" |
|
|
|
|
|
|
|
|
HASH=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD") |
|
|
|
|
|
JSON=$(echo "$JSON" | jq ".hash = \"$HASH\"") |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
echo "Added package $PKG to $CPMFILE. Include it in your project with AddJsonPackage($PKG)" |
|
|
|
|
|
|
|
|
jq --arg key "$PKG" --argjson new "$JSON" \ |
|
|
|
|
|
'.[$key] = $new' "cpmfile.json" --indent 4 >"cpmfile.json.tmp" && |
|
|
|
|
|
mv "cpmfile.json.tmp" cpmfile.json |
|
|
|
|
|
|
|
|
|
|
|
"$SCRIPTS"/format.sh |
|
|
|
|
|
|
|
|
|
|
|
echo "Added package $PKG to cpmfile.json. Include it in your project with AddJsonPackage($PKG)" |