Skip to content

Commit

Permalink
Fix broken install.sh install from Release archives.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovette committed Sep 18, 2024
1 parent baa7d21 commit 62897bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Dockerfile-install
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM docker.io/library/debian:latest

RUN set -eux; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends man python3 python3-venv python3-systemd; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends man python3 python3-venv python3-systemd curl; \
rm -rf /var/lib/apt/lists/*

COPY . /opt/jsonlogalert
Expand All @@ -16,7 +16,7 @@ RUN set -eux; \
ENV PYTHONPYCACHEPREFIX=/tmp/pycache

# Set to install from source; unset to install from latest GitHub release
ENV SRCDIR=/opt/jsonlogalert
# ENV SRCDIR=/opt/jsonlogalert

RUN set -eux; \
./install.sh
Expand Down
11 changes: 5 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ install_venv()
log_info "Installing requirements to ${VENVDIR} (editable)..."
arg_editable="-e"
fi
"${VENVDIR}"/bin/python -m pip install --require-virtualenv --upgrade -r requirements.txt $arg_editable "${srcdir}" 2>&1 | sed "s/^/$LOGPREFIX info > /"
"${VENVDIR}"/bin/python -m pip install --require-virtualenv --upgrade -r "$srcdir"/requirements.txt $arg_editable "${srcdir}" 2>&1 | sed "s/^/$LOGPREFIX info > /"
if ! test -f "${jsonlogalert_bin}"; then
log_err "${jsonlogalert_bin}: Failed to install"
exit 1
Expand Down Expand Up @@ -360,6 +360,7 @@ install_binaries()
install_local()
{
srcdir=$(readlink -f "$1")
log_debug "install srcdir is '${srcdir}'"
install_venv "${srcdir}"
install_binaries "${srcdir}"
install_etc "${srcdir}"
Expand All @@ -369,17 +370,16 @@ install_local()
install_release()
{
release_ver="$1"
tarball_untar_dir="${GITHUB_REPO}-${release_ver}"
tarball_name="${tarball_untar_dir}.${TARBALL_FORMAT}"
tarball_name="${GITHUB_REPO}-${release_ver}.${TARBALL_FORMAT}"
tarball_url="${GITHUB_DOWNLOAD}/${release_ver}.${TARBALL_FORMAT}"
# mktemp will create a subdirectory of '$TMPDIR' if set
tarball_untar_dir="${GITHUB_REPO}-${release_ver#v}"
tmpdir=$(mktemp -d)
trap 'rm -rf -- "${tmpdir}"' EXIT
if ! test -d "${tmpdir}"; then
log_err "${tmpdir}: No such directory"
exit 1
fi
log_debug "downloading files into ${tmpdir}"
log_debug "downloading file as '${tmpdir}/${tarball_name}'"
http_download "${tmpdir}/${tarball_name}" "${tarball_url}"
(cd "${tmpdir}" && untar "${tarball_name}")
install_local "${tmpdir}/${tarball_untar_dir}"
Expand Down Expand Up @@ -415,7 +415,6 @@ main()
parse_args "$@"
VENVDIR="${VENVROOT}/${GITHUB_REPO}"
if test -n "${TMPDIR}"; then
# mktemp fails if '$TMPDIR' is set but does not exist
if ! test -d "${TMPDIR}"; then
log_err "TMPDIR=${TMPDIR}: No such directory"
exit 1
Expand Down
16 changes: 12 additions & 4 deletions makeinstallsh/install_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ install_venv()
arg_editable="-e"
fi

"${VENVDIR}"/bin/python -m pip install --require-virtualenv --upgrade -r requirements.txt $arg_editable "${srcdir}" 2>&1 | sed "s/^/$LOGPREFIX info > /"
"${VENVDIR}"/bin/python -m pip install --require-virtualenv --upgrade -r "${srcdir}"/requirements.txt $arg_editable "${srcdir}" 2>&1 | sed "s/^/$LOGPREFIX info > /"

if ! test -f "${jsonlogalert_bin}"; then
log_err "${jsonlogalert_bin}: Failed to install"
Expand Down Expand Up @@ -157,6 +157,8 @@ install_local()
{
srcdir=$(readlink -f "$1")

log_debug "install srcdir is '${srcdir}'"

install_venv "${srcdir}"
install_binaries "${srcdir}"
install_etc "${srcdir}"
Expand All @@ -167,10 +169,16 @@ install_local()
install_release()
{
release_ver="$1"
tarball_untar_dir="${GITHUB_REPO}-${release_ver}"
tarball_name="${tarball_untar_dir}.${TARBALL_FORMAT}"

# jsonlogalert-v0.1.0.tar.gz
tarball_name="${GITHUB_REPO}-${release_ver}.${TARBALL_FORMAT}"

# .../jsonlogalert/archive/refs/tags/v0.1.0.tar.gz
tarball_url="${GITHUB_DOWNLOAD}/${release_ver}.${TARBALL_FORMAT}"

# jsonlogalert-0.1.0.tar.gz (without the 'v' prefix!)
tarball_untar_dir="${GITHUB_REPO}-${release_ver#v}"

# mktemp will create a subdirectory of '$TMPDIR' if set
tmpdir=$(mktemp -d)
trap 'rm -rf -- "${tmpdir}"' EXIT
Expand All @@ -180,7 +188,7 @@ install_release()
exit 1
fi

log_debug "downloading files into ${tmpdir}"
log_debug "downloading file as '${tmpdir}/${tarball_name}'"
http_download "${tmpdir}/${tarball_name}" "${tarball_url}"

(cd "${tmpdir}" && untar "${tarball_name}")
Expand Down
4 changes: 2 additions & 2 deletions makeinstallsh/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ echo "# DO NOT EDIT THIS FILE DIRECTLY!"
echo "# IT IS THE COMBINATION OF 'makeinstall.sh/*.sh' and functions from"
echo "# https://github.com/client9/shlib.git"

grep -v '^#' makeinstallsh/install_head.sh
grep -v '^\s*#' makeinstallsh/install_head.sh

(
cd "$BUILD_DIR/shlib"
Expand All @@ -51,4 +51,4 @@ grep -v '^#' makeinstallsh/install_head.sh
grep -v '^#' | grep -v ' #' | tr -s '\n'
)

grep -v '^#' makeinstallsh/install_main.sh | tr -s '\n'
grep -v '^\s*#' makeinstallsh/install_main.sh | tr -s '\n'

0 comments on commit 62897bb

Please sign in to comment.