diff --git a/LinuxMint/create_local_venv.sh b/LinuxMint/create_local_venv.sh new file mode 100644 index 0000000..daba959 --- /dev/null +++ b/LinuxMint/create_local_venv.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -e + +# create_local_venv.sh +# Dev helper: create a local venv for running meshtastic_client.py +# directly from the project folder (e.g. in VS Code). + +PROJECT_DIR="/home/knud/Desktop/Meshtastic/Meshtastic_client" +VENV_DIR="${PROJECT_DIR}/.venv" + +echo "Project dir : $PROJECT_DIR" +echo "Local venv : $VENV_DIR" +cd "$PROJECT_DIR" || exit 1 + +if [ -d "$VENV_DIR" ]; then + echo "Local venv already exists at $VENV_DIR" + echo "If you want a fresh one, delete it first:" + echo " rm -rf "$VENV_DIR"" + exit 0 +fi + +echo "Creating virtualenv..." +python3 -m venv "$VENV_DIR" + +echo "Upgrading pip inside venv..." +"$VENV_DIR/bin/pip" install --upgrade pip + +echo "Installing dev dependencies into local venv..." +"$VENV_DIR/bin/pip" install meshtastic pyserial pypubsub protobuf bleak + +echo "Writing requirements.txt (for reference)..." +cat > "$PROJECT_DIR/requirements.txt" << EOF +meshtastic +pyserial +pypubsub +protobuf +bleak +EOF + +echo +echo "====================================================" +echo " Local dev venv ready." +echo " Path: $VENV_DIR" +echo +echo " In VS Code, select this interpreter:" +echo " $VENV_DIR/bin/python" +echo +echo " To run locally from terminal:" +echo " source "$VENV_DIR/bin/activate"" +echo " python meshtastic_client.py" +echo "====================================================" diff --git a/LinuxMint/meshtastic-client_1.0.202512101218_amd64.deb b/LinuxMint/meshtastic-client_1.0.202512101218_amd64.deb new file mode 100644 index 0000000..918658d Binary files /dev/null and b/LinuxMint/meshtastic-client_1.0.202512101218_amd64.deb differ diff --git a/LinuxMint/meshtastic_client.py b/LinuxMint/meshtastic_client.py index f966759..e5f5f6a 100644 --- a/LinuxMint/meshtastic_client.py +++ b/LinuxMint/meshtastic_client.py @@ -833,7 +833,8 @@ class MeshtasticGUI: shortname = user.get("shortName") or "" longname = user.get("longName") or "" hwmodel = user.get("hwModel") or "" - role = user.get("role") or "" + role_raw = user.get("role") or "" + role = role_raw if role_raw.strip() else "CLIENT" macaddr = user.get("macaddr") or "" publickey = user.get("publicKey") or "" unmsg = user.get("isUnmessagable") or user.get("isUnmessageable") or False @@ -1641,4 +1642,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/LinuxMint/rebuilddeb.sh b/LinuxMint/rebuilddeb.sh index 792add3..abbc83f 100644 --- a/LinuxMint/rebuilddeb.sh +++ b/LinuxMint/rebuilddeb.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e ### CONFIG ############################################################ @@ -8,72 +9,132 @@ PROJECT_DIR="/home/knud/Desktop/Meshtastic/Meshtastic_client" BUILD_DIR="$PROJECT_DIR/build" ICON_NAME="meshtastic.png" +APP_INSTALL_DIR="/opt/${APP_NAME}" + +# Logging +LOG_DIR="$PROJECT_DIR/build_logs" +mkdir -p "$LOG_DIR" +LOG_FILE="$LOG_DIR/rebuild_$(date +\"%Y%m%d_%H%M%S\").log" + +# Send all stdout/stderr to both terminal and log +exec > >(tee -a "$LOG_FILE") 2>&1 + +echo "Logging to: $LOG_FILE" + ###################################################################### echo "=== Building $APP_NAME version $APP_VERSION ===" -cd "$PROJECT_DIR" || exit +cd "$PROJECT_DIR" || exit 1 -### CLEAN OLD DEB FILES ############################################## +### CLEAN OLD BUILD OUTPUT ########################################### -echo "[1/9] Removing old .deb packages..." -rm -f ${APP_NAME}_*.deb +echo "[1/5] Cleaning old build dir..." +rm -rf "$BUILD_DIR" +mkdir -p "$BUILD_DIR" -### CLEAN BUILD FOLDER ############################################### +### CREATE FILE LAYOUT ################################################ +# We do **NOT** bundle a pre-built venv in the .deb anymore. +# Instead we install the app code + a small launcher that creates +# a per-user venv on first run under ~/.local/share/${APP_NAME}/venv. -echo "[2/9] Cleaning build directory..." -rm -rf build +echo "[2/5] Creating directory structure in build tree..." + +# App code location on target system (read-only, root-owned) +mkdir -p "$BUILD_DIR${APP_INSTALL_DIR}" + +# Launcher + desktop file + icon mkdir -p "$BUILD_DIR/usr/local/bin" -mkdir -p "$BUILD_DIR/usr/share/$APP_NAME" mkdir -p "$BUILD_DIR/usr/share/applications" mkdir -p "$BUILD_DIR/usr/share/icons/hicolor/48x48/apps" -### CREATE VENV ###################################################### +### COPY APPLICATION CODE ############################################ -echo "[3/9] Creating Python virtual environment..." -python3 -m venv venv +echo "[3/5] Copying application code..." -echo "[4/9] Installing Python dependencies..." -./venv/bin/python -m pip install --upgrade pip -./venv/bin/python -m pip install meshtastic pyserial bleak protobuf +cp "$PROJECT_DIR/meshtastic_client.py" "$BUILD_DIR${APP_INSTALL_DIR}/meshtastic_client.py" -### COPY PROGRAM FILES ############################################## - -echo "[5/9] Copying program files to build folder..." -cp meshtastic_client.py "$BUILD_DIR/usr/share/$APP_NAME/" -cp meshtastic-client.desktop "$BUILD_DIR/usr/share/applications/" - -if [ -f "$ICON_NAME" ]; then - echo "[6/9] Copying icon..." - cp "$ICON_NAME" "$BUILD_DIR/usr/share/icons/hicolor/48x48/apps/$ICON_NAME" +if [ -f "$PROJECT_DIR/$ICON_NAME" ]; then + cp "$PROJECT_DIR/$ICON_NAME" "$BUILD_DIR/usr/share/icons/hicolor/48x48/apps/${APP_NAME}.png" else - echo "[6/9] WARNING: Icon file '$ICON_NAME' not found!" + echo " (Warning: $ICON_NAME not found, skipping icon copy)" fi -### COPY VENV ######################################################## +### CREATE LAUNCHER SCRIPT ########################################### -echo "[7/9] Copying virtual environment..." -cp -r venv "$BUILD_DIR/usr/share/$APP_NAME/" +echo "[4/5] Generating launcher script /usr/local/bin/${APP_NAME}..." -### CREATE LAUNCHER ################################################## +LAUNCHER="$BUILD_DIR/usr/local/bin/${APP_NAME}" -echo "[8/9] Creating launcher..." -cat < "$BUILD_DIR/usr/local/bin/$APP_NAME" +cat > "$LAUNCHER" << 'EOF' #!/bin/bash -/usr/share/$APP_NAME/venv/bin/python /usr/share/$APP_NAME/meshtastic_client.py +set -e + +APP_NAME="meshtastic-client" +APP_DIR="/opt/${APP_NAME}" + +# Per-user venv location (no root needed) +USER_DATA_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}" +USER_APP_DIR="${USER_DATA_ROOT}/${APP_NAME}" +VENV_DIR="${USER_APP_DIR}/venv" + +PY_BIN="${VENV_DIR}/bin/python" +PIP_BIN="${VENV_DIR}/bin/pip" + +# Create venv + install deps on first start +if [ ! -x "$PY_BIN" ]; then + mkdir -p "$USER_APP_DIR" + echo "[${APP_NAME}] Creating virtualenv in $VENV_DIR ..." + python3 -m venv "$VENV_DIR" + + echo "[${APP_NAME}] Upgrading pip..." + "$PIP_BIN" install --upgrade pip + + echo "[${APP_NAME}] Installing Python dependencies..." + "$PIP_BIN" install \ + meshtastic \ + pyserial \ + pypubsub \ + protobuf \ + bleak + + echo "[${APP_NAME}] Virtualenv ready." +fi + +exec "$PY_BIN" "${APP_DIR}/meshtastic_client.py" "$@" EOF -chmod +x "$BUILD_DIR/usr/local/bin/$APP_NAME" +chmod +x "$LAUNCHER" + +### CREATE .DESKTOP FILE ############################################# + +echo "[5/5] Creating .desktop file..." + +DESKTOP_FILE="$BUILD_DIR/usr/share/applications/${APP_NAME}.desktop" + +cat > "$DESKTOP_FILE" << EOF +[Desktop Entry] +Type=Application +Name=Meshtastic Client +Comment=Meshtastic Desktop Client GUI +Exec=${APP_NAME} +Icon=${APP_NAME} +Terminal=false +Categories=Network;Utility; +EOF ### BUILD .DEB PACKAGE ############################################### echo "[9/9] Building .deb using fpm..." fpm -s dir -t deb -n "$APP_NAME" -v "$APP_VERSION" \ --description "Meshtastic Desktop Client" \ + -d python3 \ + -d python3-venv \ + -d python3-pip \ -C "$BUILD_DIR" \ . echo "======================================================" echo " Build finished!" echo " Created package: ${APP_NAME}_${APP_VERSION}_amd64.deb" +echo " Log file: $LOG_FILE" echo "======================================================" - diff --git a/LinuxMint/requirements.txt b/LinuxMint/requirements.txt index b83ef87..81fd945 100644 --- a/LinuxMint/requirements.txt +++ b/LinuxMint/requirements.txt @@ -1,4 +1,5 @@ meshtastic pyserial -bleak +pypubsub protobuf +bleak