build_deb.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. ### Bash Environment Setup
  3. # http://redsymbol.net/articles/unofficial-bash-strict-mode/
  4. # https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
  5. # set -o xtrace
  6. set -o errexit
  7. set -o errtrace
  8. set -o nounset
  9. set -o pipefail
  10. IFS=$'\n'
  11. CURRENT_PLAFORM="$(uname)"
  12. REQUIRED_PLATFORM="Linux"
  13. if [[ "$CURRENT_PLAFORM" != "$REQUIRED_PLATFORM" ]]; then
  14. echo "[!] Skipping the Debian package build on $CURRENT_PLAFORM (it can only be run on $REQUIRED_PLATFORM)."
  15. exit 0
  16. fi
  17. REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
  18. VERSION="$(jq -r '.version' < "$REPO_DIR/package.json")"
  19. DEBIAN_VERSION="${DEBIAN_VERSION:-1}"
  20. cd "$REPO_DIR"
  21. if [[ -f "$REPO_DIR/.venv/bin/activate" ]]; then
  22. source "$REPO_DIR/.venv/bin/activate"
  23. else
  24. echo "[!] Warning: No virtualenv presesnt in $REPO_DIR.venv"
  25. fi
  26. # Build python package lists
  27. # https://pdm-project.org/latest/usage/lockfile/
  28. echo "[+] Generating requirements.txt and pdm.lock from pyproject.toml..."
  29. pdm lock --group=':all' --production --lockfile pdm.lock --strategy="cross_platform"
  30. pdm sync --group=':all' --production --lockfile pdm.lock --clean || pdm sync --group=':all' --production --lockfile pdm.lock --clean
  31. pdm export --group=':all' --production --lockfile pdm.lock --without-hashes -o requirements.txt
  32. pdm lock --group=':all' --dev --lockfile pdm.dev.lock --strategy="cross_platform"
  33. pdm sync --group=':all' --dev --lockfile pdm.dev.lock --clean || pdm sync --group=':all' --dev --lockfile pdm.dev.lock --clean
  34. pdm export --group=':all' --dev --lockfile pdm.dev.lock --without-hashes -o requirements-dev.txt
  35. # cleanup build artifacts
  36. rm -Rf build deb_dist dist archivebox-*.tar.gz
  37. # build source and binary packages
  38. # make sure the stdeb.cfg file is up-to-date with all the dependencies
  39. python3 setup.py --command-packages=stdeb.command \
  40. sdist_dsc --debian-version=$DEBIAN_VERSION \
  41. bdist_deb
  42. # should output deb_dist/archivebox_0.5.4-1.{deb,changes,buildinfo,tar.gz}