rules 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/make -f
  2. # Uncomment to enable verbose debhelper output
  3. #export DH_VERBOSE = 1
  4. PACKAGE = squidstats
  5. DESTDIR = $(CURDIR)/debian/$(PACKAGE)
  6. INSTALL_ROOT = /opt/SquidStats
  7. OPT_DIR = $(DESTDIR)$(INSTALL_ROOT)
  8. VENV_BUILD = $(CURDIR)/debian/.build-venv
  9. VENV_FINAL = $(INSTALL_ROOT)/venv
  10. VENV_DEST = $(OPT_DIR)/venv
  11. APP_DEST = $(OPT_DIR)/app
  12. %:
  13. dh $@
  14. override_dh_auto_build:
  15. @echo "=== Building SquidStats Python virtual environment ==="
  16. python3 -m venv --copies $(VENV_BUILD)
  17. $(VENV_BUILD)/bin/pip3 install --upgrade pip setuptools wheel
  18. $(VENV_BUILD)/bin/pip3 install --no-cache-dir -r requirements.txt
  19. @echo "=== Build complete ==="
  20. override_dh_auto_install:
  21. # ── Application directories ───────────────────────────squid───────────────
  22. install -d $(APP_DEST)
  23. install -d $(VENV_DEST)
  24. install -d $(DESTDIR)/etc/$(PACKAGE)
  25. install -d $(DESTDIR)/var/log/$(PACKAGE)
  26. install -d $(DESTDIR)/var/lib/$(PACKAGE)
  27. # ── Copy application source files ────────────────────────────────────
  28. cp app.py config.py manage_db.py alembic.ini babel.cfg $(APP_DEST)/
  29. cp requirements.txt $(APP_DEST)/
  30. cp -r alembic/ $(APP_DEST)/
  31. cp -r database/ $(APP_DEST)/
  32. cp -r parsers/ $(APP_DEST)/
  33. cp -r routes/ $(APP_DEST)/
  34. cp -r services/ $(APP_DEST)/
  35. cp -r static/ $(APP_DEST)/
  36. cp -r templates/ $(APP_DEST)/
  37. cp -r tools/ $(APP_DEST)/
  38. cp -r translations/ $(APP_DEST)/
  39. cp -r utils/ $(APP_DEST)/
  40. # ── Copy virtual environment and relocate embedded paths ─────────────
  41. cp -a $(VENV_BUILD)/. $(VENV_DEST)/
  42. # Fix shebang lines only in text wrapper scripts, not binaries.
  43. find $(VENV_DEST)/bin -maxdepth 1 -type f \
  44. -exec grep -Iq . {} \; -exec sed -i "s|$(VENV_BUILD)|$(VENV_FINAL)|g" {} \;
  45. sed -i "s|home = $(VENV_BUILD)/bin|home = $(VENV_FINAL)/bin|g" \
  46. $(VENV_DEST)/pyvenv.cfg
  47. # Remove build-time __pycache__ to keep the package clean
  48. find $(VENV_DEST) -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
  49. find $(APP_DEST) -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
  50. # ── Configuration template ───────────────────────────────────────────
  51. install -m 0640 example.env $(DESTDIR)/etc/$(PACKAGE)/squidstats.env
  52. override_dh_auto_test:
  53. @echo "Tests are run in a separate CI stage; skipping here."
  54. # Prevent stripping of Python .so files (can break extensions)
  55. override_dh_strip:
  56. dh_strip --no-automatic-dbgsym
  57. # Exclude the bundled venv from ELF dependency scanning.
  58. # All native libraries (psycopg2-binary, cryptography, bcrypt, etc.) ship
  59. # as manylinux wheels inside the venv and carry their own shared libs,
  60. # so auto-detected system deps like libldap-2.5-0 / libpq5 / libssl are
  61. # wrong and break cross-distro portability.
  62. override_dh_shlibdeps:
  63. dh_shlibdeps -X$(INSTALL_ROOT)/venv/
  64. override_dh_dwz:
  65. # Skip DWZ compression for bundled venv modules.
  66. # The package contains many Python extension modules and no separate
  67. # debuginfo packages, so dwz can fail on bundled wheels.
  68. true
  69. override_dh_fixperms:
  70. dh_fixperms
  71. # Config file must not be world-readable (may contain secrets)
  72. chmod 0640 $(DESTDIR)/etc/$(PACKAGE)/squidstats.env 2>/dev/null || true