feature(clone): add protocol option to force cloning over HTTPS

This is a rather quick and simple implementation to override the current
logic and force clone with HTTPS. Allowing to explicitly clone over HTTPS
is currently required to unblock reproducible builds where no ssh keys
and GitLab user accounts are set up as of now. Hence this quick solution
comes into play to mitigate the regression on reproducible builds
builders.

Revisit the overall auto detection and protocol logic approach for a
later release related to some ideas floating around in pending
merge-requests.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Levente Polyak 2023-05-24 02:40:52 +02:00
parent f11cb9018e
commit a08bc2acf4
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
6 changed files with 47 additions and 4 deletions

View File

@ -265,6 +265,7 @@ _pkgctl_repo_cmds=(
_pkgctl_repo_clone_args=( _pkgctl_repo_clone_args=(
-m --maintainer -m --maintainer
--protocol
--switch --switch
-u --unprivileged -u --unprivileged
--universe --universe
@ -273,6 +274,7 @@ _pkgctl_repo_clone_args=(
) )
_pkgctl_repo_clone_args__maintainer_opts() { :; } _pkgctl_repo_clone_args__maintainer_opts() { :; }
_pkgctl_repo_clone_args_m_opts() { _pkgctl_repo_clone_args__maintainer_opts; } _pkgctl_repo_clone_args_m_opts() { _pkgctl_repo_clone_args__maintainer_opts; }
_pkgctl_repo_clone_args__protocol_opts() { _devtools_completions_protocol; }
_pkgctl_repo_clone_args__switch_opts() { :; } _pkgctl_repo_clone_args__switch_opts() { :; }
_pkgctl_repo_clone_args__jobs_opts() { :; } _pkgctl_repo_clone_args__jobs_opts() { :; }
_pkgctl_repo_clone_args_j_opts() { _pkgctl_repo_clone_args__jobs_opts; } _pkgctl_repo_clone_args_j_opts() { _pkgctl_repo_clone_args__jobs_opts; }
@ -280,9 +282,11 @@ _pkgctl_repo_clone_opts() { _devtools_completions_all_packages; }
_pkgctl_repo_configure_args=( _pkgctl_repo_configure_args=(
--protocol
-j --jobs -j --jobs
-h --help -h --help
) )
_pkgctl_repo_configure_args__protocol_opts() { _devtools_completions_protocol; }
_pkgctl_repo_configure_args__jobs_opts() { :; } _pkgctl_repo_configure_args__jobs_opts() { :; }
_pkgctl_repo_configure_args_j_opts() { _pkgctl_repo_clone_args__jobs_opts; } _pkgctl_repo_configure_args_j_opts() { _pkgctl_repo_clone_args__jobs_opts; }
_pkgctl_repo_configure_opts() { _filedir -d; } _pkgctl_repo_configure_opts() { _filedir -d; }
@ -363,6 +367,9 @@ _devtools_completions_build_repo() {
_devtools_completions_all_packages() { _devtools_completions_all_packages() {
mapfile -t COMPREPLY < <(compgen -W "$(pacman -Sql)" -- "$cur") mapfile -t COMPREPLY < <(compgen -W "$(pacman -Sql)" -- "$cur")
} }
_devtools_completions_protocol() {
mapfile -t COMPREPLY < <(compgen -W "https" -- "$cur")
}
__devtools_complete() { __devtools_complete() {
local service=$1 local service=$1

View File

@ -108,6 +108,7 @@ _pkgctl_repo_switch_args=(
_pkgctl_repo_clone_args=( _pkgctl_repo_clone_args=(
'(-m --maintainer=)'{-m,--maintainer=}'[Clone all packages of the named maintainer]:maintainer:' '(-m --maintainer=)'{-m,--maintainer=}'[Clone all packages of the named maintainer]:maintainer:'
'--protocol[Clone the repository over https]:proto:(https)'
'--switch=[Switch the current working tree to a specified version]' '--switch=[Switch the current working tree to a specified version]'
'--universe[Clone all existing packages, useful for cache warming]' '--universe[Clone all existing packages, useful for cache warming]'
'(-j --jobs)'{-j,--jobs}'[Run up to N jobs in parallel (default: number of processing units)]:jobs:' '(-j --jobs)'{-j,--jobs}'[Run up to N jobs in parallel (default: number of processing units)]:jobs:'
@ -116,6 +117,7 @@ _pkgctl_repo_clone_args=(
) )
_pkgctl_repo_configure_args=( _pkgctl_repo_configure_args=(
'--protocol[Configure remote url to use https]:proto:(https)'
'(-j --jobs)'{-j,--jobs}'[Run up to N jobs in parallel (default: number of processing units)]:jobs:' '(-j --jobs)'{-j,--jobs}'[Run up to N jobs in parallel (default: number of processing units)]:jobs:'
'(-h --help)'{-h,--help}'[Display usage]' '(-h --help)'{-h,--help}'[Display usage]'
'*:git_dir:_files -/' '*:git_dir:_files -/'

View File

@ -25,6 +25,9 @@ Options
*-m, --maintainer* 'NAME':: *-m, --maintainer* 'NAME'::
Clone all packages of the named maintainer Clone all packages of the named maintainer
*--protocol* 'https'::
Clone the repository over https
*--universe*:: *--universe*::
Clone all existing packages, useful for cache warming Clone all existing packages, useful for cache warming

View File

@ -25,6 +25,9 @@ read-only HTTPS otherwise.
Options Options
------- -------
*--protocol* 'https'::
Configure remote url to use https
*-j, --jobs* 'N':: *-j, --jobs* 'N'::
Run up to N jobs in parallel. By default the number of jobs is equal to the Run up to N jobs in parallel. By default the number of jobs is equal to the
number of available processing units. For sequential processing this option number of available processing units. For sequential processing this option

View File

@ -26,12 +26,13 @@ pkgctl_repo_clone_usage() {
Clone Git packaging repositories from the canonical namespace. Clone Git packaging repositories from the canonical namespace.
The configure command is subsequently invoked to synchronize the distro The configure command is subsequently invoked to synchronize the distro
specs and makepkg.conf settings. The unprivileged option can be used specs and makepkg.conf settings. The protocol option can be used
for cloning packaging repositories without SSH access using read-only for cloning packaging repositories without SSH access using read-only
HTTPS. HTTPS.
OPTIONS OPTIONS
-m, --maintainer=NAME Clone all packages of the named maintainer -m, --maintainer=NAME Clone all packages of the named maintainer
--protocol https Clone the repository over https
--switch VERSION Switch the current working tree to a specified version --switch VERSION Switch the current working tree to a specified version
--universe Clone all existing packages, useful for cache warming --universe Clone all existing packages, useful for cache warming
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
@ -69,11 +70,21 @@ pkgctl_repo_clone() {
pkgctl_repo_clone_usage pkgctl_repo_clone_usage
exit 0 exit 0
;; ;;
-u|--unprivileged) --protocol=https)
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS} GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS}
CONFIGURE_OPTIONS+=("$1") CONFIGURE_OPTIONS+=("$1")
shift shift
;; ;;
--protocol)
(( $# <= 1 )) && die "missing argument for %s" "$1"
if [[ $2 == https ]]; then
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS}
else
die "unsupported protocol: %s" "$2"
fi
CONFIGURE_OPTIONS+=("$1" "$2")
shift 2
;;
-m|--maintainer) -m|--maintainer)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
MAINTAINER="$2" MAINTAINER="$2"

View File

@ -33,6 +33,7 @@ pkgctl_repo_configure_usage() {
read-only HTTPS otherwise. read-only HTTPS otherwise.
OPTIONS OPTIONS
--protocol https Configure remote url to use https
-j, --jobs N Run up to N jobs in parallel (default: $(nproc)) -j, --jobs N Run up to N jobs in parallel (default: $(nproc))
-h, --help Show this help text -h, --help Show this help text
@ -94,6 +95,7 @@ pkgctl_repo_configure() {
local GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS} local GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS}
local official=0 local official=0
local proto=https local proto=https
local proto_force=0
local jobs= local jobs=
jobs=$(nproc) jobs=$(nproc)
local paths=() local paths=()
@ -109,6 +111,19 @@ pkgctl_repo_configure() {
pkgctl_repo_configure_usage pkgctl_repo_configure_usage
exit 0 exit 0
;; ;;
--protocol=https)
proto_force=1
shift
;;
--protocol)
(( $# <= 1 )) && die "missing argument for %s" "$1"
if [[ $2 == https ]]; then
proto_force=1
else
die "unsupported protocol: %s" "$2"
fi
shift 2
;;
-j|--jobs) -j|--jobs)
(( $# <= 1 )) && die "missing argument for %s" "$1" (( $# <= 1 )) && die "missing argument for %s" "$1"
jobs=$2 jobs=$2
@ -152,8 +167,10 @@ pkgctl_repo_configure() {
fi fi
if is_packager_email_official "${packager_email}"; then if is_packager_email_official "${packager_email}"; then
official=1 official=1
proto=ssh if (( ! proto_force )); then
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_SSH} proto=ssh
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_SSH}
fi
fi fi
fi fi