From d3c130aaff40ec0556ab106466b2302ce9aef6c2 Mon Sep 17 00:00:00 2001 From: DingoBits <107956274+DingoBits@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:54:14 -0700 Subject: [PATCH 1/4] build(debian): use separate python3-dlib package --- howdy/debian/control | 4 +-- howdy/debian/postinst | 77 ------------------------------------------- howdy/debian/prerm | 3 -- 3 files changed, 2 insertions(+), 82 deletions(-) diff --git a/howdy/debian/control b/howdy/debian/control index d1648547..7d7258ac 100644 --- a/howdy/debian/control +++ b/howdy/debian/control @@ -9,9 +9,9 @@ Vcs-Git: https://github.com/boltgolt/howdy Package: howdy Homepage: https://github.com/boltgolt/howdy Architecture: amd64 -Depends: ${misc:Depends}, libc6, libgcc-s1, libpam0g, libstdc++6, curl | wget, python3, python3-pip, python3-dev, python3-setuptools, python3-numpy, python-opencv | python3-opencv, libopencv-dev, cmake, libinih-dev +PreDepends: python3:any | python3-minimal:any +Depends: ${misc:Depends}, libc6, libgcc-s1, libpam0g, libstdc++6, curl | wget, python3, python3-pip, python3-dev, python3-setuptools, python3-numpy, python-opencv | python3-opencv, libopencv-dev, cmake, libinih-dev, python3-dlib Recommends: libatlas-base-dev | libopenblas-dev | liblapack-dev, howdy-gtk -Suggests: nvidia-cuda-dev (>= 7.5) Description: Howdy: Windows Hello style authentication for Linux. Use your built-in IR emitters and camera in combination with face recognition to prove who you are. diff --git a/howdy/debian/postinst b/howdy/debian/postinst index 692c66fe..8afec338 100755 --- a/howdy/debian/postinst +++ b/howdy/debian/postinst @@ -106,83 +106,6 @@ if "upgrade" in sys.argv: sys.exit(0) -log("Downloading dlib") - -dlib_archive = "/tmp/v19.16.tar.gz" -loader = which("wget") -LOADER_CMD = None - -# If wget is installed, use that as the downloader -if loader: - LOADER_CMD = [loader, "--tries", "5", "--output-document"] -# Otherwise, fall back on curl -else: - loader = which("curl") - LOADER_CMD = [loader, "--retry", "5", "--location", "--output"] - -# Assemble and execute the download command -cmd = LOADER_CMD + [dlib_archive, "https://github.com/davisking/dlib/archive/v19.16.tar.gz"] -handleStatus(sc(cmd)) - -# The folder containing the dlib source -DLIB_DIR = None -# A regex of all files to ignore while unpacking the archive -excludes = re.compile( - "davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|" - "(docs|examples|python_examples)|" - "tools/(archive|convert_dlib_nets_to_caffe|htmlify|imglab|python/test|visual_studio_natvis))" -) - -# Open the archive -with tarfile.open(dlib_archive) as tf: - for item in tf: - # Set the destenation dir if unset - if not DLIB_DIR: - DLIB_DIR = "/tmp/" + item.name - - # extract only files sufficient for building - if not excludes.match(item.name): - tf.extract(item, "/tmp") - -# Delete the downloaded archive -os.unlink(dlib_archive) - -log("Building dlib") - -cmd = ["sudo", "python3", "setup.py", "install"] -cuda_used = False - -# Compile and link dlib -try: - sp = subprocess.Popen(cmd, cwd=DLIB_DIR, stdout=subprocess.PIPE) -except subprocess.CalledProcessError: - print("Error while building dlib") - raise - -# Go through each line from stdout -while sp.poll() is None: - line = sp.stdout.readline().decode("utf-8") - - if "DLIB WILL USE CUDA" in line: - cuda_used = True - - print(line, end="") - -log("Cleaning up dlib") - -# Remove the no longer needed git clone -del sp -rmtree(DLIB_DIR) - -print("Temporary dlib files removed") - -log("Configuring howdy") - -# Manually change the camera id to the one picked -for line in fileinput.input(["/etc/howdy/config.ini"], inplace=1): - line = line.replace("use_cnn = false", "use_cnn = " + str(cuda_used).lower()) - print(line, end="") - print("Camera ID saved") # Secure the howdy folder diff --git a/howdy/debian/prerm b/howdy/debian/prerm index f545bef6..8e0714f5 100755 --- a/howdy/debian/prerm +++ b/howdy/debian/prerm @@ -40,6 +40,3 @@ try: except Exception: # This error is normal pass - -# Remove dlib -subprocess.call(["pip3", "uninstall", "dlib", "-y", "--no-cache-dir"]) From f52674addbdcb2d62f05b999992135debc4a3bf2 Mon Sep 17 00:00:00 2001 From: DingoBits <107956274+DingoBits@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:55:32 -0700 Subject: [PATCH 2/4] fix(debian): do not install non-existent locales directory --- howdy/debian/install | 1 - 1 file changed, 1 deletion(-) diff --git a/howdy/debian/install b/howdy/debian/install index cc3c9eaf..965c6461 100644 --- a/howdy/debian/install +++ b/howdy/debian/install @@ -1,5 +1,4 @@ src/cli/. lib/security/howdy/cli -src/locales/. lib/security/howdy/locales src/recorders/. lib/security/howdy/recorders src/rubberstamps/. lib/security/howdy/rubberstamps src/cli.py lib/security/howdy From 175ed8f5856faeeb55056fa062ee6a8df5bd5beb Mon Sep 17 00:00:00 2001 From: DingoBits <107956274+DingoBits@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:57:41 -0700 Subject: [PATCH 3/4] fix(debian): relink howdy on upgrade --- howdy/debian/postinst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/howdy/debian/postinst b/howdy/debian/postinst index 8afec338..0df772a4 100755 --- a/howdy/debian/postinst +++ b/howdy/debian/postinst @@ -119,6 +119,8 @@ handleStatus(sc(["chmod 755 -R /lib/security/howdy/cli"], shell=True)) print("Permissions set") # Make the CLI executable as howdy +if os.path.exists("/usr/local/bin/howdy"): + os.unlink("/usr/local/bin/howdy") os.symlink("/lib/security/howdy/cli.py", "/usr/local/bin/howdy") os.chmod("/usr/local/bin/howdy", 0o755) print("Howdy command installed") From 7429dc450e8e196e5cd21a16b10301ca9677f152 Mon Sep 17 00:00:00 2001 From: DingoBits <107956274+DingoBits@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:57:56 -0700 Subject: [PATCH 4/4] fix(debian): import os in preinst --- howdy/debian/preinst | 1 + 1 file changed, 1 insertion(+) diff --git a/howdy/debian/preinst b/howdy/debian/preinst index 2318c920..e9718509 100755 --- a/howdy/debian/preinst +++ b/howdy/debian/preinst @@ -2,6 +2,7 @@ # Used to check cameras before committing to install # Executed before primary apt install of files +import os import subprocess import sys