just install now builds as you, then asks for root once and installs the whole thing: the login session (wasm compositor on the MoonBit host, modules, chandra-ctl, KDE colors, portal) and face unlock (helper, PAM module, config, models). The alternatives are flags instead of recipes: --link (was install-dev), --rust (install-rust), --native (install-native), --pam (install-face --pam), --no-face, --no-models. The PAM module is compiled as you into build/, so root only copies it; without a compiler or libpam headers face unlock is skipped with a warning. just uninstall removes face unlock too (--purge: enrolled faces). Removed: install-dev, install-rust, install-native, install-face, uninstall-face and the old install-session* / uninstall-session aliases. New docs/install.md; README, docs and installer hints updated. Also drops a committed __pycache__ file and ignores __pycache__/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hkA52AocBmJHipFRqb
This commit is contained in:
16 files changed
+171
-108
No files matched your search
+2
-2
@@ -248,7 +248,7 @@ class OpenCVRecognizer:
|
||||
import cv2 # noqa
|
||||
import numpy # noqa
|
||||
except ImportError:
|
||||
raise Fail("OpenCV is missing: run just install-face", 2)
|
||||
raise Fail("OpenCV is missing: run just install", 2)
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
@@ -622,7 +622,7 @@ def cmd_status(cfg, user, out):
|
||||
try:
|
||||
import cv2 # noqa
|
||||
except ImportError:
|
||||
problem = "OpenCV is missing: run just install-face"
|
||||
problem = "OpenCV is missing: run just install"
|
||||
if not problem:
|
||||
for m in MODELS:
|
||||
if not os.path.exists(os.path.join(cfg.models, m)):
|
||||
|
||||
+29
-18
@@ -1,11 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install (or remove) face unlock. Run as root (`just install-face` does this through
|
||||
scripts/as-root):
|
||||
"""Install (or remove) face unlock. `just install` runs this (through session/install.py, as
|
||||
root) along with the rest of Chandra; `just install --pam` adds --pam, `just uninstall` --remove.
|
||||
By hand, as root:
|
||||
|
||||
run0 python3 face/install.py # install, fetch the face models
|
||||
run0 python3 face/install.py --pam # ... and use it for polkit-1 and sudo
|
||||
run0 python3 face/install.py --no-models
|
||||
run0 python3 face/install.py --pixi PATH # the pixi binary (`just install-face` passes it)
|
||||
run0 python3 face/install.py --pixi PATH # the pixi binary (`just install` passes it)
|
||||
run0 python3 face/install.py --remove # take it out of every PAM service, uninstall
|
||||
run0 python3 face/install.py --remove --purge # ... and delete the enrolled faces
|
||||
|
||||
@@ -14,7 +15,8 @@ Installs:
|
||||
face/pixi.toml + pixi.lock (root's; nothing from the distro)
|
||||
/usr/local/lib/chandra/chandra-face the helper (enroll, compare, ...), root's
|
||||
/usr/local/bin/chandra-face -> the helper
|
||||
<PAM module dir>/pam_chandra_face.so the PAM module (built here with cc; needs libpam headers)
|
||||
<PAM module dir>/pam_chandra_face.so the PAM module (`just install` builds it as you into
|
||||
build/; else it's built here with cc and the libpam headers)
|
||||
/etc/chandra/face.conf settings (kept when it exists)
|
||||
/var/lib/chandra-face/ enrolled faces
|
||||
/usr/local/share/chandra/face/*.onnx the YuNet and SFace models (downloaded, checksummed)
|
||||
@@ -61,7 +63,7 @@ def make_env():
|
||||
pixi = find_pixi()
|
||||
if not pixi:
|
||||
sys.exit("pixi not found: install it (https://pixi.sh) or pass --pixi PATH; "
|
||||
"`just install-face` passes the one on your PATH")
|
||||
"`just install` passes the one on your PATH")
|
||||
os.makedirs(env_dir, 0o755, exist_ok=True)
|
||||
for f in ("pixi.toml", "pixi.lock"):
|
||||
shutil.copyfile(os.path.join(here, f), os.path.join(env_dir, f))
|
||||
@@ -85,7 +87,7 @@ def pam_dir():
|
||||
|
||||
|
||||
if os.geteuid() != 0:
|
||||
sys.exit("run as root: run0 python3 face/install.py (or sudo), or `just install-face`")
|
||||
sys.exit("run as root: run0 python3 face/install.py (or sudo), or `just install`")
|
||||
|
||||
mod = os.path.join(pam_dir(), "pam_chandra_face.so")
|
||||
|
||||
@@ -104,6 +106,10 @@ if "--remove" in sys.argv:
|
||||
if os.path.isdir(models):
|
||||
shutil.rmtree(models)
|
||||
print("removed", models)
|
||||
try:
|
||||
os.rmdir(os.path.dirname(helper)) # /usr/local/lib/chandra, if nothing else is in it
|
||||
except OSError:
|
||||
pass
|
||||
if "--purge" in sys.argv:
|
||||
for p in (store,):
|
||||
if os.path.isdir(p):
|
||||
@@ -112,6 +118,10 @@ if "--remove" in sys.argv:
|
||||
if os.path.exists(conf):
|
||||
os.remove(conf)
|
||||
print("removed", conf)
|
||||
try:
|
||||
os.rmdir(os.path.dirname(conf)) # /etc/chandra, if nothing else is in it
|
||||
except OSError:
|
||||
pass
|
||||
sys.exit(0)
|
||||
|
||||
os.umask(0o022)
|
||||
@@ -130,13 +140,17 @@ if os.path.lexists(link):
|
||||
os.symlink(helper, link)
|
||||
print("linked", link, "->", helper)
|
||||
|
||||
cc = shutil.which("cc") or shutil.which("gcc") or shutil.which("clang")
|
||||
if not cc:
|
||||
sys.exit("no C compiler: install gcc (and the libpam headers: libpam0g-dev / pam-devel)")
|
||||
subprocess.check_call([cc, "-O2", "-Wall", "-shared", "-fPIC", "-o", mod + ".new",
|
||||
"-DCHANDRA_FACE_HELPER=\"%s\"" % helper,
|
||||
"-DCHANDRA_FACE_PYTHON=\"%s\"" % py,
|
||||
os.path.join(here, "pam_chandra_face.c"), "-lpam"])
|
||||
src = os.path.join(here, "pam_chandra_face.c")
|
||||
built = os.path.join(os.path.dirname(here), "build", "pam_chandra_face.so") # from `just install` (same helper and python paths)
|
||||
if os.path.exists(built) and os.path.getmtime(built) >= os.path.getmtime(src):
|
||||
shutil.copyfile(built, mod + ".new")
|
||||
else:
|
||||
cc = shutil.which("cc") or shutil.which("gcc") or shutil.which("clang")
|
||||
if not cc:
|
||||
sys.exit("no C compiler: install gcc (and the libpam headers: libpam0g-dev / pam-devel)")
|
||||
subprocess.check_call([cc, "-O2", "-Wall", "-shared", "-fPIC", "-o", mod + ".new",
|
||||
"-DCHANDRA_FACE_HELPER=\"%s\"" % helper,
|
||||
"-DCHANDRA_FACE_PYTHON=\"%s\"" % py, src, "-lpam"])
|
||||
os.chmod(mod + ".new", 0o644)
|
||||
os.replace(mod + ".new", mod)
|
||||
print("installed", mod)
|
||||
@@ -153,8 +167,5 @@ if "--no-models" not in sys.argv:
|
||||
subprocess.check_call([py, "-I", helper, "--no-elevate", "fetch-models"])
|
||||
if "--pam" in sys.argv:
|
||||
subprocess.check_call([py, "-I", helper, "--no-elevate", "pam", "enable"])
|
||||
print("""
|
||||
Settings > Session > Face unlock comes with the session itself (the compositor, its host and the
|
||||
Settings module), not with this install: if Settings doesn't show it yet, run `just install`
|
||||
(or `just install-dev`) and log out and in again. Or enroll now from a terminal:
|
||||
`chandra-face enroll`, then `chandra-face pam enable`.""")
|
||||
print("face unlock: add a face in Settings > Session > Face unlock (after logging in to the new "
|
||||
"session), or now with `chandra-face enroll`, then `chandra-face pam enable`")
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Face unlock's Python environment (docs/face-unlock.md): `just install-face` installs it, as
|
||||
# Face unlock's Python environment (docs/face-unlock.md): `just install` installs it, as
|
||||
# root, into /usr/local/lib/chandra/face-env from this manifest and pixi.lock, so neither
|
||||
# python3-opencv nor any other distro package is needed. It is root's on purpose: the PAM module
|
||||
# runs this Python as root, so it must not live anywhere a user can write (like this checkout).
|
||||
|
||||
Reference in new issue
Block a user