summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 286cb5f739afe976943bce9ab661fbdcb876c03b (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Maintainer: Carl Smedstad <carl.smedstad at protonmail dot com>
# Contributor: Hao Long <aur@esd.cc>

pkgname=archivebox
_pkgname=ArchiveBox
pkgver=0.7.2
pkgrel=4
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
  python-setuptools
  python-wheel
)
checkdepends=(
  python-bottle
  python-pytest
)
_commit=315c9f3844d63f897e1c73c3bbbab7bf9f3e0c11
_django_version=3.1.14
_django_extensions_version=3.1.5
source=(
  "git+$url.git#commit=$_commit"
  "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=(
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'fe5a93c64d37f4dec49b7535ae405c0b87c1eb3d40979a33955a3631b5a6a00a'
  'a29b022fb6728678ec5f769d78eff4d8b0c0f4beb15f9b8392726d4f0bda9031'
)

_archive="$_pkgname"

pkgver() {
  cd "$_archive"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$_archive"

  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 -rf venv
  python -m venv --system-site-packages --without-pip venv
}

build() {
  cd "$srcdir/django-$_django_version"
  python -m build --wheel --no-isolation
  python -m installer --destdir="$srcdir/$_archive/venv" --prefix=/ dist/*.whl

  cd "$srcdir/django-extensions-$_django_extensions_version"
  python -m build --wheel --no-isolation
  python -m installer --destdir="$srcdir/$_archive/venv" --prefix=/ dist/*.whl

  cd "$srcdir/$_archive"
  python -m build --wheel --no-isolation
  python -m installer --destdir=venv --prefix=/ dist/*.whl
}

check() {
  cd "$_archive"

  rm -rf test_venv
  cp -a venv test_venv
  sed -i "s|#!/bin/python|#!$PWD/test_venv/bin/python|" test_venv/bin/archivebox
  export PATH="$PWD/test_venv/bin:$PATH"
  export PYTHONPATH="$PWD/test_venv/lib/python3.11/site-packages:$PYTHONPATH"

  pytest tests
}

package() {
  cd "$_archive"

  install -dm755 "$pkgdir/opt/archivebox"
  cp -a -t "$pkgdir/opt/archivebox" venv/*
  sed -i 's|#!/usr/bin/python|#!/opt/archivebox/bin/python|' "$pkgdir/opt/archivebox/bin/archivebox"

  install -dm755 "$pkgdir/usr/bin"
  ln -s /opt/archivebox/bin/archivebox "$pkgdir/usr/bin/archivebox"

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

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