mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 20:16:35 +00:00
fix(deploy): run cargo build under a login shell
sudo -u <user> cargo fails when cargo lives in ~/.cargo/bin and root's PATH doesn't carry it. Switch to sudo -u <user> -i sh -c so the user's .profile / cargo env is sourced.
This commit is contained in:
parent
f320b680a1
commit
5656d430ff
1 changed files with 3 additions and 6 deletions
|
|
@ -62,10 +62,6 @@ BIN_DST_DIR="/opt/betterframe/kiosk"
|
||||||
BIN_DST="${BIN_DST_DIR}/betterframe-kiosk"
|
BIN_DST="${BIN_DST_DIR}/betterframe-kiosk"
|
||||||
|
|
||||||
if [ "${SKIP_BUILD:-0}" != "1" ]; then
|
if [ "${SKIP_BUILD:-0}" != "1" ]; then
|
||||||
if ! command -v cargo >/dev/null 2>&1; then
|
|
||||||
echo "error: cargo not found. Install rustup or set SKIP_BUILD=1." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
libgtk-4-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
|
libgtk-4-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
|
||||||
libwebkitgtk-6.0-dev pkg-config build-essential \
|
libwebkitgtk-6.0-dev pkg-config build-essential \
|
||||||
|
|
@ -73,10 +69,11 @@ if [ "${SKIP_BUILD:-0}" != "1" ]; then
|
||||||
gstreamer1.0-plugins-bad gstreamer1.0-libav
|
gstreamer1.0-plugins-bad gstreamer1.0-libav
|
||||||
|
|
||||||
# Build as the invoking user (typically the dev/admin user), not root,
|
# Build as the invoking user (typically the dev/admin user), not root,
|
||||||
# so cargo registry caches stay in their home.
|
# so cargo registry caches stay in their home and rustup PATH applies.
|
||||||
|
# -i runs a login shell so ~/.cargo/env gets sourced from .profile/.bashrc.
|
||||||
BUILD_USER="${SUDO_USER:-root}"
|
BUILD_USER="${SUDO_USER:-root}"
|
||||||
echo " building as ${BUILD_USER}"
|
echo " building as ${BUILD_USER}"
|
||||||
sudo -u "${BUILD_USER}" cargo build --release --manifest-path "${REPO_ROOT}/kiosk/Cargo.toml"
|
sudo -u "${BUILD_USER}" -i sh -c "cd '${REPO_ROOT}' && cargo build --release --manifest-path kiosk/Cargo.toml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${BIN_SRC}" ]; then
|
if [ ! -f "${BIN_SRC}" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue