fix(clone): ssh connection may require user input (key unlocking etc)
Anything that requires user input (such as a key unlock or hostkey verify) will block the terminal and wait for input which will never come. When cloning or configuring a repo via ssh we therefore initially connect to gitlab to warm the connection. Afterwards users are expected to either have setup a ssh ControlMaster or use something like a ssh agent. Fixes #148 Component: pkgctl repo clone/configure Co-Authored-by: Christian Heusel <christian@heusel.eu> Signed-off-by: Christian Heusel <christian@heusel.eu> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
parent
7e41adf00b
commit
f632659563
|
@ -12,6 +12,8 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/api/gitlab.sh
|
||||
# shellcheck source=src/lib/repo/configure.sh
|
||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/configure.sh
|
||||
# shellcheck source=src/lib/util/git.sh
|
||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
||||
|
||||
source /usr/share/makepkg/util/message.sh
|
||||
|
||||
|
@ -52,6 +54,7 @@ pkgctl_repo_clone() {
|
|||
fi
|
||||
|
||||
# options
|
||||
local protocol=ssh
|
||||
local GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_SSH}
|
||||
local CLONE_ALL=0
|
||||
local MAINTAINER=
|
||||
|
@ -72,6 +75,7 @@ pkgctl_repo_clone() {
|
|||
;;
|
||||
--protocol=https)
|
||||
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_HTTPS}
|
||||
protocol=https
|
||||
CONFIGURE_OPTIONS+=("$1")
|
||||
shift
|
||||
;;
|
||||
|
@ -82,6 +86,7 @@ pkgctl_repo_clone() {
|
|||
else
|
||||
die "unsupported protocol: %s" "$2"
|
||||
fi
|
||||
protocol="$2"
|
||||
CONFIGURE_OPTIONS+=("$1" "$2")
|
||||
shift 2
|
||||
;;
|
||||
|
@ -171,6 +176,12 @@ pkgctl_repo_clone() {
|
|||
if [[ -n "${VERSION}" ]]; then
|
||||
command+=" --switch '${VERSION}'"
|
||||
fi
|
||||
|
||||
# warm up ssh connection as it may require user input (key unlock, hostkey verification etc)
|
||||
if [[ ${protocol} == ssh ]]; then
|
||||
git_warmup_ssh_connection
|
||||
fi
|
||||
|
||||
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${pkgbases[@]}"; then
|
||||
die 'Failed to clone some packages, please check the output'
|
||||
exit 1
|
||||
|
|
|
@ -10,6 +10,8 @@ _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
||||
# shellcheck source=src/lib/api/gitlab.sh
|
||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/api/gitlab.sh
|
||||
# shellcheck source=src/lib/util/git.sh
|
||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/git.sh
|
||||
|
||||
source /usr/share/makepkg/util/config.sh
|
||||
source /usr/share/makepkg/util/message.sh
|
||||
|
@ -188,6 +190,12 @@ pkgctl_repo_configure() {
|
|||
if [[ -n ${BOLD} ]]; then
|
||||
export DEVTOOLS_COLOR=always
|
||||
fi
|
||||
|
||||
# warm up ssh connection as it may require user input (key unlock, hostkey verification etc)
|
||||
if [[ ${proto} == ssh ]]; then
|
||||
git_warmup_ssh_connection
|
||||
fi
|
||||
|
||||
if ! parallel --bar --jobs "${jobs}" "${command}" ::: "${paths[@]}"; then
|
||||
die 'Failed to configure some packages, please check the output'
|
||||
exit 1
|
||||
|
|
|
@ -7,6 +7,9 @@ DEVTOOLS_INCLUDE_UTIL_GIT_SH=1
|
|||
|
||||
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
||||
|
||||
# shellcheck source=src/lib/common.sh
|
||||
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
||||
|
||||
|
||||
git_diff_tree() {
|
||||
local commit=$1
|
||||
|
@ -22,3 +25,10 @@ git_diff_tree() {
|
|||
"${commit}" \
|
||||
-- "${path}"
|
||||
}
|
||||
|
||||
git_warmup_ssh_connection() {
|
||||
msg 'Establishing ssh connection to git@%s' "${GITLAB_HOST}"
|
||||
if ! ssh -T "git@${GITLAB_HOST}" >/dev/null; then
|
||||
die 'Failed to establish ssh connection to git@%s' "${GITLAB_HOST}"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue