Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·109 lines (97 loc) · 4.47 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·109 lines (97 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2026 Daniele Pighin
#
# One-line installer for the darktable -> IOPaint integration (macOS / Linux).
#
# curl -fsSL https://raw.githubusercontent.com/masterpiga/darktable-iopaint/main/install.sh | bash
#
# It clones this fork, builds it (virtualenv + dependencies + web frontend),
# wires the Lua script into darktable, and optionally pre-downloads the model.
# Afterwards just start darktable - the "IOPaint" panel appears in lighttable and
# darkroom, ready to use.
#
# Non-interactive overrides (env vars):
# IOPAINT_DT_REPO git URL to clone (default: this fork)
# IOPAINT_DT_INSTALL_DIR where to install (default: ~/.local/share/darktable-iopaint)
# IOPAINT_DT_CONFIG_DIR darktable config directory (default: ~/.config/darktable)
# IOPAINT_DT_PREDOWNLOAD y|n, pre-download lama (default: y)
# PYTHON python interpreter for setup (3.8-3.11)
#
set -euo pipefail
REPO_URL="${IOPAINT_DT_REPO:-https://github.com/masterpiga/darktable-iopaint.git}"
DEFAULT_INSTALL="${XDG_DATA_HOME:-$HOME/.local/share}/darktable-iopaint"
DEFAULT_CONFIG="$HOME/.config/darktable"
say() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33mwarning:\033[0m %s\n' "$*" >&2; }
die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
need() { command -v "$1" >/dev/null 2>&1 || die "'$1' is required but not found on PATH."; }
# prompt VAR "message" "default" - reads from the terminal even when piped via curl.
# Falls back to the default if no usable terminal is available (never aborts).
prompt() {
local _var="$1" _msg="$2" _def="$3" _ans=""
if { exec 3<>/dev/tty; } 2>/dev/null; then
printf '%s [%s]: ' "$_msg" "$_def" >&3
IFS= read -r _ans <&3 || _ans=""
exec 3>&- 3<&-
fi
[ -n "$_ans" ] || _ans="$_def"
printf -v "$_var" '%s' "$_ans"
}
say "darktable-iopaint installer"
warn "Experimental software - use at your own risk. Tested only on macOS."
need git
INSTALL_DIR="${IOPAINT_DT_INSTALL_DIR:-}"
CONFIG_DIR="${IOPAINT_DT_CONFIG_DIR:-}"
PREDOWNLOAD="${IOPAINT_DT_PREDOWNLOAD:-}"
[ -n "$INSTALL_DIR" ] || prompt INSTALL_DIR "Install darktable-iopaint to" "$DEFAULT_INSTALL"
[ -n "$CONFIG_DIR" ] || prompt CONFIG_DIR "darktable config directory" "$DEFAULT_CONFIG"
[ -n "$PREDOWNLOAD" ] || prompt PREDOWNLOAD "Pre-download the lama model now? (y/n)" "y"
# expand a leading ~
INSTALL_DIR="${INSTALL_DIR/#\~/$HOME}"
CONFIG_DIR="${CONFIG_DIR/#\~/$HOME}"
# 1. clone or update
if [ -d "$INSTALL_DIR/.git" ]; then
say "Updating existing checkout in $INSTALL_DIR"
git -C "$INSTALL_DIR" pull --ff-only
else
say "Cloning $REPO_URL -> $INSTALL_DIR"
mkdir -p "$(dirname "$INSTALL_DIR")"
git clone "$REPO_URL" "$INSTALL_DIR"
fi
# 2. build (virtualenv + deps + frontend); setup.sh chooses a supported Python
say "Running setup (virtualenv, dependencies, web frontend)…"
"$INSTALL_DIR/darktable/setup.sh"
VENV_PY="$INSTALL_DIR/.venv/bin/python"
[ -x "$VENV_PY" ] || die "setup did not produce a virtualenv at $VENV_PY"
# 3. install a loader into darktable's lua scripts dir so the script appears in the
# "lua scripts" (script manager) panel. The shim loads the real script from the
# checkout via dofile, so it auto-detects its repo and tracks git updates (and
# avoids a require-name clash with itself).
CONTRIB_DIR="$CONFIG_DIR/lua/contrib"
mkdir -p "$CONTRIB_DIR"
SHIM="$CONTRIB_DIR/iopaint.lua"
{
echo '-- darktable-iopaint loader (generated by install.sh)'
echo '-- Loads the script from the source checkout so it auto-detects its location'
echo '-- and picks up git updates. Enable/disable it from the lua scripts panel.'
echo "return dofile(\"$INSTALL_DIR/darktable/iopaint.lua\")"
} > "$SHIM"
say "Installed script-manager loader: $SHIM"
# 4. optional model pre-download
case "$PREDOWNLOAD" in
[Yy]*)
say "Pre-downloading the lama model…"
"$VENV_PY" -m iopaint download --model lama || warn "model pre-download failed; it will download on first use"
;;
*) say "Skipping model pre-download (it downloads automatically on first use)" ;;
esac
say "Done!"
echo
echo " Next, in darktable:"
echo " 1. Open the 'lua scripts' panel, find 'iopaint' under 'contrib', and enable it."
echo " 2. The 'IOPaint' panel then appears in lighttable (right) and darkroom (left)."
echo " 3. Select images (or open one in darkroom) and click 'send selection to IOPaint'."
echo
echo " Installed at : $INSTALL_DIR"
echo " darktable cfg: $CONFIG_DIR"