v0.23.0: Routine, first public version
This commit is contained in:
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build Routine.app and a drag-to-install Routine-<version>.dmg, on a Mac, from a checkout.
|
||||
# UNTESTED ON A MAC so far: see docs/building-the-mac-app.md (what to run, what to send back).
|
||||
#
|
||||
# scripts/build-mac-app.sh → dist/Routine.app and dist/Routine-<version>.dmg
|
||||
#
|
||||
# Needs: macOS 13+, curl, an internet connection. No Xcode, no Homebrew, no admin password: like
|
||||
# install-mac.sh it fetches uv, which fetches its own Python and the pinned packages, all under
|
||||
# build/mac/. PyInstaller freezes the app (Python and Qt inside the bundle), the bundle is signed
|
||||
# ad hoc (codesign -s -: no Apple developer account, so not notarized: macOS asks once before the
|
||||
# first open, see the doc), and the .dmg holds the app beside a shortcut to /Applications.
|
||||
# The app is for the build machine's kind of Mac: built on Apple silicon it runs on Apple silicon.
|
||||
#
|
||||
# BUILD_TEST=1 lets the PyInstaller part run off a Mac (to test the freezing; no .app, no .dmg).
|
||||
set -euo pipefail
|
||||
|
||||
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
UV_VERSION="0.10.4"
|
||||
PYTHON_VERSION="3.13"
|
||||
PINS=(PySide6-Essentials==6.11.0 pyinstaller==6.22.3)
|
||||
OUT="$REPO/dist"
|
||||
WORK="$REPO/build/mac"
|
||||
|
||||
die() { printf 'build-mac-app: %s\n' "$*" >&2; exit 1; }
|
||||
MAC=0
|
||||
[ "$(uname -s)" = Darwin ] && MAC=1
|
||||
[ "$MAC" = 1 ] || [ "${BUILD_TEST:-}" = 1 ] || die "run this on a Mac (BUILD_TEST=1 to try the freezing elsewhere)"
|
||||
|
||||
VERSION="$(sed -n 's/^__version__ = "\(.*\)"/\1/p' "$REPO/routine/__init__.py")"
|
||||
[ -n "$VERSION" ] || die "no __version__ in routine/__init__.py"
|
||||
rm -rf "$WORK/work" "$WORK/dist" "$WORK/dmg"
|
||||
mkdir -p "$WORK" "$OUT"
|
||||
|
||||
# ── uv → Python → PySide6 + PyInstaller, all under build/mac ──
|
||||
export UV_PYTHON_INSTALL_DIR="$WORK/python" UV_CACHE_DIR="$WORK/cache" UV_PYTHON_PREFERENCE=only-managed UV_NO_CONFIG=1
|
||||
UV="${ROUTINE_UV:-$WORK/uv/uv}"
|
||||
if [ ! -x "$UV" ]; then
|
||||
echo "Downloading uv $UV_VERSION …"
|
||||
curl -LsSf "https://astral.sh/uv/$UV_VERSION/install.sh" |
|
||||
env UV_UNMANAGED_INSTALL="$WORK/uv" INSTALLER_NO_MODIFY_PATH=1 sh >/dev/null || die "couldn't download uv"
|
||||
fi
|
||||
[ -x "$WORK/venv/bin/python" ] || "$UV" venv --quiet --python "$PYTHON_VERSION" "$WORK/venv"
|
||||
"$UV" pip install --quiet --python "$WORK/venv/bin/python" "${PINS[@]}"
|
||||
PY="$WORK/venv/bin/python"
|
||||
|
||||
# ── freeze ──
|
||||
echo "Freezing Routine $VERSION …"
|
||||
ICON=()
|
||||
[ "$MAC" = 1 ] && ICON=(--icon "$REPO/shared/icon.icns" --osx-bundle-identifier me.teafry.routine)
|
||||
(cd "$REPO" && "$PY" -m PyInstaller --noconfirm --clean --log-level WARN --windowed --name Routine \
|
||||
"${ICON[@]}" \
|
||||
--add-data "$REPO/shared:shared" \
|
||||
--exclude-module PyQt6 --exclude-module PyQt5 --exclude-module tkinter \
|
||||
--paths "$REPO" \
|
||||
--distpath "$WORK/dist" --workpath "$WORK/work" --specpath "$WORK" \
|
||||
"$REPO/routine/__main__.py")
|
||||
|
||||
if [ "$MAC" != 1 ]; then
|
||||
echo "BUILD_TEST: frozen into $WORK/dist/Routine (no .app or .dmg off a Mac)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
APP="$WORK/dist/Routine.app"
|
||||
[ -d "$APP" ] || die "PyInstaller made no Routine.app"
|
||||
PLIST="$APP/Contents/Info.plist"
|
||||
plutil -replace CFBundleName -string Routine "$PLIST"
|
||||
plutil -replace CFBundleDisplayName -string Routine "$PLIST"
|
||||
plutil -replace CFBundleShortVersionString -string "$VERSION" "$PLIST"
|
||||
plutil -replace CFBundleVersion -string "$VERSION" "$PLIST"
|
||||
plutil -replace LSMinimumSystemVersion -string 13.0 "$PLIST"
|
||||
plutil -replace NSHighResolutionCapable -bool true "$PLIST"
|
||||
plutil -replace LSApplicationCategoryType -string public.app-category.productivity "$PLIST"
|
||||
|
||||
echo "Signing (ad hoc) …"
|
||||
codesign --force --deep --sign - "$APP"
|
||||
codesign --verify --deep --strict "$APP" || die "the signature doesn't verify"
|
||||
|
||||
echo "Making the .dmg …"
|
||||
STAGE="$WORK/dmg"
|
||||
mkdir -p "$STAGE"
|
||||
cp -R "$APP" "$STAGE/"
|
||||
ln -s /Applications "$STAGE/Applications"
|
||||
DMG="$OUT/Routine-$VERSION.dmg"
|
||||
rm -f "$DMG"
|
||||
hdiutil create -quiet -volname "Routine $VERSION" -srcfolder "$STAGE" -ov -format UDZO "$DMG"
|
||||
rm -rf "$OUT/Routine.app"
|
||||
cp -R "$APP" "$OUT/"
|
||||
|
||||
echo
|
||||
echo "Done: $DMG ($(du -h "$DMG" | cut -f1)), for $(uname -m) Macs."
|
||||
echo "Try it: open the .dmg, drag Routine to Applications, open it from there."
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# Deploy routine-server (server/) to a machine you can ssh into, and (re)start it in a screen session.
|
||||
#
|
||||
# scripts/deploy-server.sh HOST copy the code and restart the server
|
||||
# scripts/deploy-server.sh HOST --stop stop it
|
||||
# scripts/deploy-server.sh HOST --token print the bearer token for the apps' Settings → Sync
|
||||
#
|
||||
# HOST is an ssh destination (user@host, or an alias from ~/.ssh/config); DEPLOY_HOST works too.
|
||||
# The rest comes from the environment:
|
||||
# DEPLOY_DIR folder on HOST, relative to its home or absolute (default routine-server)
|
||||
# ROUTINE_SERVER_HOST address the server listens on (default 127.0.0.1: only HOST itself;
|
||||
# use an address your devices reach privately, e.g. a VPN one)
|
||||
# ROUTINE_SERVER_PORT port (default 8070)
|
||||
# It needs ssh, rsync, and on HOST python3, screen and curl. To start it at boot, have HOST run
|
||||
# DEPLOY_DIR/app/run.sh (it reads the settings this script leaves in DEPLOY_DIR/app/server.env).
|
||||
set -euo pipefail
|
||||
HOST=${DEPLOY_HOST:-}
|
||||
ACTION=deploy
|
||||
for a in "$@"; do
|
||||
case "$a" in
|
||||
--stop) ACTION=stop ;;
|
||||
--token) ACTION=token ;;
|
||||
-h|--help) sed -n '2,16p' "$0"; exit 0 ;;
|
||||
*) HOST=$a ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$HOST" ] || { echo "usage: $0 HOST [--stop|--token] (or set DEPLOY_HOST)" >&2; exit 2; }
|
||||
DIR=${DEPLOY_DIR:-routine-server}
|
||||
BIND=${ROUTINE_SERVER_HOST:-127.0.0.1}
|
||||
PORT=${ROUTINE_SERVER_PORT:-8070}
|
||||
NAME=routine-server
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
case "$ACTION" in
|
||||
token) ssh "$HOST" "cat '$DIR/data/token'"; echo; exit 0 ;;
|
||||
stop) ssh "$HOST" "screen -S $NAME -X quit || true"; echo "stopped"; exit 0 ;;
|
||||
esac
|
||||
|
||||
ssh "$HOST" "mkdir -p '$DIR/app' '$DIR/data' && chmod 700 '$DIR/data'"
|
||||
rsync -a server/routine_server.py server/run.sh routine/model.py "$HOST:$DIR/app/"
|
||||
printf 'ROUTINE_SERVER_HOST=%q\nROUTINE_SERVER_PORT=%q\n' "$BIND" "$PORT" | ssh "$HOST" "cat > '$DIR/app/server.env'"
|
||||
CHECK=$BIND
|
||||
[ "$CHECK" = "0.0.0.0" ] && CHECK=127.0.0.1
|
||||
ssh "$HOST" bash -s <<REMOTE
|
||||
set -e
|
||||
cd '$DIR'
|
||||
screen -S $NAME -X quit 2>/dev/null || true
|
||||
sleep 1
|
||||
screen -dmS $NAME bash -c "bash '\$PWD/app/run.sh' 2>&1 | tee '\$PWD/server.log'"
|
||||
sleep 2
|
||||
for pid in \$(pgrep -f routine_server.py); do echo 1000 > /proc/\$pid/oom_score_adj 2>/dev/null || true; done # first to go if memory runs out
|
||||
curl -s -m 5 http://$CHECK:$PORT/health; echo
|
||||
REMOTE
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# Put Routine in the app grid so it can be pinned to the dash. Re-run after moving the repo.
|
||||
# (Runs this checkout as it is: for a copy of its own, updated by re-running, see install-linux.sh.)
|
||||
set -euo pipefail
|
||||
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
APPS=~/.local/share/applications
|
||||
HICOLOR=~/.local/share/icons/hicolor
|
||||
ICON="$HICOLOR/scalable/apps/me.teafry.routine.svg"
|
||||
mkdir -p "$APPS" "$HICOLOR/scalable/apps"
|
||||
cp "$REPO/shared/icon.svg" "$ICON"
|
||||
# fixed sizes too, for whatever doesn't read SVG (rendered with Qt, which the app needs anyway)
|
||||
for n in 48 64 128 256; do
|
||||
mkdir -p "$HICOLOR/${n}x${n}/apps"
|
||||
QT_QPA_PLATFORM=offscreen PYTHONPATH="$REPO" python3 -c "
|
||||
import sys
|
||||
from routine.qt.QtGui import QGuiApplication, QIcon
|
||||
a = QGuiApplication(sys.argv)
|
||||
QIcon(sys.argv[1]).pixmap(int(sys.argv[2]), int(sys.argv[2])).save(sys.argv[3])" \
|
||||
"$REPO/shared/icon.svg" "$n" "$HICOLOR/${n}x${n}/apps/me.teafry.routine.png" 2>/dev/null
|
||||
done
|
||||
cat > "$APPS/me.teafry.routine.desktop" <<DESKTOP
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Routine
|
||||
Comment=The day's routine, ticked off as you go
|
||||
Exec=python3 -m routine
|
||||
Path=$REPO
|
||||
Icon=$ICON
|
||||
Terminal=false
|
||||
Categories=Utility;
|
||||
StartupWMClass=me.teafry.routine
|
||||
StartupNotify=true
|
||||
DESKTOP
|
||||
update-desktop-database "$APPS" 2>/dev/null || true
|
||||
gtk-update-icon-cache -q -t -f "$HICOLOR" 2>/dev/null || true
|
||||
echo "Installed: search for Routine in Activities, then right-click → Pin to Dash."
|
||||
Reference in New Issue
Block a user