Skip to content

Commit

Permalink
scripts: use git+[...] instead of [...].git for git urls
Browse files Browse the repository at this point in the history
Not all source code hosters support the .git suffix (for example
sourcehut).  Use a git+ prefix instead to indicate that a url is a git
repo.
  • Loading branch information
Grimler91 committed Jan 1, 2023
1 parent c0f0f90 commit 20bd0f0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions scripts/bin/check-auto-update
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ check() {
local url="$2"
local return_code=0

if [[ ! $src_url =~ ^https?://${from_where}.com ]]; then
warn "Not a ${from_where} url: ${src_url}"
if [[ ! ${src_url#git+} =~ ^https?://${from_where}.com ]]; then
warn "Not a ${from_where} url: ${src_url#git+}"
return 1
fi

_check "$from_where" "$url" || return_code="$?"

if [[ "${url: -4}" != ".git" ]] && [[ "$return_code" == "2" ]]; then
if [[ "${url:0:4}" != "git+" ]] && [[ "$return_code" == "2" ]]; then
warn "No 'latest-release-tag' found. Checking for 'newest-tag'..."
return_code=3 # Set return code to 3 to indicate that TERMUX_PKG_UPDATE_TAG_TYPE='newest-tag'
# should also be written to build.sh if we find 'newest-tag' in next line.
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/get_source/termux_git_clone_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ termux_git_clone_src() {
rm -rf $TMP_CHECKOUT
git clone --depth 1 \
--branch $TERMUX_PKG_GIT_BRANCH \
$TERMUX_PKG_SRCURL \
${TERMUX_PKG_SRCURL:4} \
$TMP_CHECKOUT

pushd $TMP_CHECKOUT
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/get_source/termux_step_get_source.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
termux_step_get_source() {
: "${TERMUX_PKG_SRCURL:=""}"

if [ "${TERMUX_PKG_SRCURL: -4}" == ".git" ]; then
if [ "${TERMUX_PKG_SRCURL:0:4}" == "git+" ]; then
termux_git_clone_src
else
if [ -z "${TERMUX_PKG_SRCURL}" ] || [ "${TERMUX_PKG_SKIP_SRC_EXTRACT-false}" = "true" ] || [ "$TERMUX_PKG_METAPACKAGE" = "true" ]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/lint-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ lint_package() {
urls_ok=true
for url in "${TERMUX_PKG_SRCURL[@]}"; do
if [ -n "$url" ]; then
if ! grep -qP '^https://.+' <<< "$url"; then
if ! grep -qP '^git\+https://.+' <<< "$url" && ! grep -qP '^https://.+' <<< "$url"; then
echo "NON-HTTPS (acceptable)"
urls_ok=false
break
Expand Down Expand Up @@ -248,7 +248,7 @@ lint_package() {
echo "LENGTHS OF 'TERMUX_PKG_SRCURL' AND 'TERMUX_PKG_SHA256' ARE NOT EQUAL"
pkg_lint_error=true
fi
elif [ "${TERMUX_PKG_SRCURL: -4}" == ".git" ]; then
elif [ "${TERMUX_PKG_SRCURL:0:4}" == "git+" ]; then
echo "NOT SET (acceptable since TERMUX_PKG_SRCURL is git repo)"
else
echo "NOT SET"
Expand Down
4 changes: 2 additions & 2 deletions scripts/updates/api/termux_github_api_get_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ termux_github_api_get_tag() {

local project
project="$(echo "${PKG_SRCURL}" | cut -d'/' -f4-5)"
project="${project%.git}"
project="${project#git+}"

if [[ -z "${TAG_TYPE}" ]]; then # If not set, then decide on the basis of url.
if [[ "${PKG_SRCURL: -4}" == ".git" ]]; then
if [[ "${PKG_SRCURL:0:4}" == "git+" ]]; then
# Get newest tag.
TAG_TYPE="newest-tag"
else
Expand Down
4 changes: 2 additions & 2 deletions scripts/updates/api/termux_gitlab_api_get_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ termux_gitlab_api_get_tag() {

local project
project="$(echo "${PKG_SRCURL}" | cut -d'/' -f4-5)"
project="${project%.git}"
project="${project#git+}"

if [[ -z "${TAG_TYPE}" ]]; then # If not set, then decide on the basis of url.
if [[ "${PKG_SRCURL: -4}" == ".git" ]]; then
if [[ "${PKG_SRCURL:0:4}" == "git+" ]]; then
# Get newest tag.
TAG_TYPE="newest-tag"
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/updates/utils/termux_pkg_upgrade_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ termux_pkg_upgrade_version() {
"${TERMUX_PKG_BUILDER_DIR}/build.sh"

# Update checksum
if [[ "${TERMUX_PKG_SHA256[*]}" != "SKIP_CHECKSUM" ]] && [[ "${TERMUX_PKG_SRCURL: -4}" != ".git" ]]; then
if [[ "${TERMUX_PKG_SHA256[*]}" != "SKIP_CHECKSUM" ]] && [[ "${TERMUX_PKG_SRCURL:0:4}" != "git+" ]]; then
echo n | "${TERMUX_SCRIPTDIR}/scripts/bin/update-checksum" "${TERMUX_PKG_NAME}" || {
git checkout -- "${TERMUX_PKG_BUILDER_DIR}"
git pull --rebase
Expand Down

0 comments on commit 20bd0f0

Please sign in to comment.