summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 20ae19ccac663d98f4da25f85940b987ccd8d922 (plain)
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
# Maintainer: Amir Husayn Panahifar <Panahifar.ah@outlook.com>

pkgname=tractor-rc-git
pkgver=x.y.z
pkgrel=1
pkgdesc="Setup an onion routing proxy (latest Git version)"
arch=('any')
url="https://framagit.org/tractor/tractor/"
license=('GPL-3.0-or-later')
depends=(
  'python'
  'python-gobject'
  'python-fire'
  'python-pysocks'
  'python-stem'
  'tor'
  'dconf'
)
makedepends=(
  'python-build'
  'python-setuptools'
  'python-installer'
  'python-wheel'
  'git'
)
checkdepends=('python-nose')
optdepends=('carburetor-git: Graphical settings app using GTK')
source=("git+https://framagit.org/tractor/tractor.git")
sha256sums=('SKIP')

_check_python_environment() {
  echo "๐Ÿ” Validating Python environment..."
  local modules=('build' 'setuptools' 'wheel')
  for module in "${modules[@]}"; do
    if ! /usr/bin/python -c "import $module" &>/dev/null; then
      echo "โŒ Error: Missing Python module '$module'."
      echo "   ๐Ÿ’ก Please install 'python-$module' using your package manager."
      exit 1
    fi
  done
  echo "โœ… Python environment is correctly configured."
}

pkgver() {
  cd "$srcdir/tractor" || exit 1
  git describe --tags --long --always | sed -E 's/^v//;s/-/./g;s/[^a-zA-Z0-9.]/_/g'
}

build() {
  echo "๐Ÿ”ง Starting the build process..."
  _check_python_environment
  cd "$srcdir/tractor" || exit 1
  /usr/bin/python -m build --wheel --no-isolation || {
    echo "โŒ Build failed. Please review the error output above."
    exit 1
  }
  echo "โœ… Build completed successfully."
}

check() {
  echo "๐Ÿงช Running test cases..."
  cd "$srcdir/tractor" || exit 1
  /usr/bin/python -m nose || {
    echo "โš ๏ธ Warning: Test cases failed. Proceeding with caution."
    return 0
  }
  echo "โœ… All tests passed successfully."
}

package() {
  echo "๐Ÿ“ฆ Installing the package..."
  cd "$srcdir/tractor" || exit 1
  /usr/bin/python -m installer --destdir="$pkgdir" dist/*.whl || {
    echo "โŒ Installation failed. Please check the error output above."
    exit 1
  }
  install -Dm0644 src/tractor/tractor.gschema.xml \
    "$pkgdir/usr/share/glib-2.0/schemas/tractor.gschema.xml"
  install -Dm0644 data/tractor.1 \
    "$pkgdir/usr/share/man/man1/tractor.1"
  install -Dm0644 data/completion/bash/tractor \
    "$pkgdir/usr/share/bash-completion/completions/tractor"
  echo "๐ŸŽ‰ Package installation completed successfully!"
}