1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-21 20:33:00 +00:00

remove pipenv dependency

This commit is contained in:
Jörn-Michael Miehe 2021-09-30 16:49:12 +02:00
parent b38145e3cd
commit 9cdd41927d

68
kiwi
View file

@ -7,10 +7,10 @@
# base config filename # base config filename
KIWI_CONF_NAME="kiwi.yml" KIWI_CONF_NAME="kiwi.yml"
# version tag filename # version tag filename
KIWI_VERSION_TAG="etc/version_tag" KIWI_VERSION_TAG="kiwi_scp/data/etc/version_tag"
# dependencies to run kiwi-scp # dependencies to run kiwi-scp
KIWI_DEPENDENCIES="python3 pipenv less docker docker-compose" KIWI_DEPENDENCIES="python3 less docker docker-compose"
# base install dir # base install dir
KIWI_BASEDIR="${HOME}/.cache/kiwi-scp" KIWI_BASEDIR="${HOME}/.cache/kiwi-scp"
# per-user env setup script # per-user env setup script
@ -32,12 +32,9 @@ CANARY_MAX_AGE=600
# DYNAMIC STRINGS # # DYNAMIC STRINGS #
################### ###################
# cache current work directory
WORKDIR="$(pwd)"
# uri of correct kiwi-scp archive # uri of correct kiwi-scp archive
kiwi_archive_uri() { kiwi_archive_uri() {
echo "${KIWI_REPO}/archive/${KIWI_VERSION}.tar.gz" echo "${KIWI_REPO}/archive/refs/heads/${KIWI_VERSION}.tar.gz"
} }
# directory of correct installation # directory of correct installation
@ -45,14 +42,9 @@ kiwi_install_dir() {
echo "${KIWI_BASEDIR}/${KIWI_VERSION}" echo "${KIWI_BASEDIR}/${KIWI_VERSION}"
} }
# src directory in installed version
kiwi_root() {
echo "$(kiwi_install_dir)/src"
}
# main script in installed version # main script in installed version
kiwi_executable() { kiwi_executable() {
echo "$(kiwi_root)/kiwi-scp.py" echo "$(kiwi_install_dir)/bin/kiwi"
} }
############# #############
@ -175,54 +167,32 @@ fi
if [ ! -x "$(kiwi_executable)" ]; then if [ ! -x "$(kiwi_executable)" ]; then
printf "Installing kiwi-scp v%s into %s ... " "${KIWI_VERSION}" "${KIWI_BASEDIR}" printf "Installing kiwi-scp v%s into %s ... " "${KIWI_VERSION}" "${KIWI_BASEDIR}"
# switch to temp dir # read version tag
tmp_dir=$(mktemp -d) KIWI_VERSION="$( \
cd "${tmp_dir}" || : curl \
--proto '=https' \
# download archive --tlsv1.2 \
curl --proto '=https' --tlsv1.2 -sSfL "$(kiwi_archive_uri)" | tar xz -sSfL \
"https://raw.githubusercontent.com/ldericher/kiwi-scp/${KIWI_VERSION}/${KIWI_VERSION_TAG}" \
# read archive version tag )"
cd "kiwi-scp-${KIWI_VERSION}" || :
KIWI_VERSION=$(cat "./src/${KIWI_VERSION_TAG}")
if [ -x "$(kiwi_executable)" ]; then if [ -x "$(kiwi_executable)" ]; then
# after version update: no need to install # after version tag update: no need to install
echo "v${KIWI_VERSION} already installed!" echo "v${KIWI_VERSION} already installed!"
else else
# install archive # install archive
mkdir -p "$(kiwi_install_dir)" python3 -m virtualenv "$(kiwi_install_dir)" >/dev/null 2>/dev/null
mv "src" "Pipfile" "Pipfile.lock" "$(kiwi_install_dir)/" . "$(kiwi_install_dir)/bin/activate"
python3 -m pip install "git+${KIWI_REPO}@${KIWI_VERSION}" >/dev/null 2>/dev/null
echo "OK" echo "OK"
fi fi
# discard temp dir
cd "${WORKDIR}" || :
rm -rf "${tmp_dir}"
fi fi
# setup main environment # setup main environment
KIWI_ROOT="$(kiwi_root)"
PIPENV_VERBOSITY=-1
PIPENV_PIPFILE="$(kiwi_install_dir)/Pipfile"
export KIWI_CONF_NAME export KIWI_CONF_NAME
export KIWI_ROOT . "$(kiwi_install_dir)/bin/activate"
export PIPENV_VERBOSITY
export PIPENV_PIPFILE
# check virtualenv
cd "$(kiwi_install_dir)" || :
if ! pipenv --venv >/dev/null 2>/dev/null; then
# install virtualenv
printf "Preparing virtualenv ... "
pipenv sync >/dev/null 2>/dev/null
echo "OK"
fi
# go back to the original work directory
cd "${WORKDIR}" || :
# run main script # run main script
exec pipenv run "$(kiwi_executable)" "${@}" exec "$(kiwi_executable)" "${@}"