summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ee3f69ec55d8ec1e22c2c55db45f049ccb7f1413 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Hao Long <aur@esd.cc>

pkgname=archivebox
_pkgname=ArchiveBox
pkgver=0.7.3
pkgrel=1
pkgdesc="Open source self-hosted web archiving"
arch=(any)
url="https://github.com/ArchiveBox/ArchiveBox"
license=(MIT)
depends=(
  chromium
  curl
  git
  nodejs
  postlight-parser
  python
  python-asgiref
  python-chardet
  python-dateparser
  python-mypy_extensions
  python-python-crontab
  python-pytz
  python-requests
  python-sqlparse
  python-urllib3
  python-w3lib
  readability-extractor
  ripgrep
  single-file
  wget
  yt-dlp
)
makedepends=(
  python-build
  python-installer
  python-pdm-backend
  python-setuptools
  python-wheel
)
checkdepends=(
  python-bottle
  python-pytest
)
_django_version=3.1.14
_django_extensions_version=3.1.5
source=(
  "git+$url.git#tag=v$pkgver"
  "git+https://github.com/jbittel/base32-crockford.git"
  "git+https://github.com/jazzband/django-taggit.git"
  "git+https://github.com/tapanpandita/pocket.git"
  "git+https://github.com/untitaker/python-atomicwrites.git"
  "django-$_django_version::https://github.com/django/django/archive/$_django_version.tar.gz"
  "django-extensions-$_django_extensions_version::https://github.com/django-extensions/django-extensions/archive/$_django_extensions_version.tar.gz"
)
sha256sums=(
  '5a530b3e86332db33b24b675e98d9b8b3d0bd9148095aa3025495952c1d16834'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'fe5a93c64d37f4dec49b7535ae405c0b87c1eb3d40979a33955a3631b5a6a00a'
  'a29b022fb6728678ec5f769d78eff4d8b0c0f4beb15f9b8392726d4f0bda9031'
)

prepare() {
  cd "$_pkgname"
  git submodule init
  git config --remove-section submodule.docs
  git config --remove-section submodule.deb_dist
  git config --remove-section submodule.brew_dist
  git config --remove-section submodule.pip_dist
  git config --remove-section submodule.docker
  git config submodule.archivebox/vendor/base32-crockford.url "$srcdir/base32-crockford"
  git config submodule.archivebox/vendor/pocket.url "$srcdir/pocket"
  git config submodule.archivebox/vendor/django-taggit.url "$srcdir/django-taggit"
  git config submodule.archivebox/vendor/python-atomicwrites.url "$srcdir/python-atomicwrites"
  git -c protocol.file.allow=always submodule update -- \
    archivebox/vendor/base32-crockford \
    archivebox/vendor/pocket \
    archivebox/vendor/django-taggit \
    archivebox/vendor/python-atomicwrites

  {
    echo '[tool.pdm.build]'
    echo 'excludes = ['
    echo '  "archivebox/vendor/base32-crockford",'
    echo '  "archivebox/vendor/django-taggit",'
    echo '  "archivebox/vendor/pocket",'
    echo '  "archivebox/vendor/python-atomicwrites",'
    echo ']'
  } >> pyproject.toml

  rm -vrf venv
  python -m venv --system-site-packages --without-pip venv
}

build() {
  cd "$_pkgname"
  python -m build --wheel --no-isolation ../django-$_django_version
  ./venv/bin/python -m installer ../django-$_django_version/dist/*.whl

  python -m build --wheel --no-isolation ../django-extensions-$_django_extensions_version
  ./venv/bin/python -m installer ../django-extensions-$_django_extensions_version/dist/*.whl

  python -m build --wheel --no-isolation
  ./venv/bin/python -m installer dist/*.whl
}

check() {
  cd "$_pkgname"
  rm -vrf venv-test
  cp -va venv venv-test
  sed -i "s|#!/bin/python|#!$PWD/venv-test/bin/python|" venv-test/bin/archivebox
  PATH="$PWD/venv-test/bin:$PATH" ./venv-test/bin/python -m pytest tests
}

package() {
  cd "$_pkgname"
  install -vdm755 "$pkgdir/opt/archivebox"
  cp -va -t "$pkgdir/opt/archivebox" venv/*
  sed -i 's|#!/usr/bin/python|#!/opt/archivebox/bin/python|' "$pkgdir/opt/archivebox/bin/archivebox"

  install -vdm755 "$pkgdir/usr/bin"
  ln -vs /opt/archivebox/bin/archivebox "$pkgdir/usr/bin/archivebox"

  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  # Silence namcap warning
  rm -vr "$pkgdir/opt/archivebox/include"
}