PKGBUILD
67 lines · 1868 bytes
1# Maintainer: Wraient <rushikeshwastaken@gmail.com>
2pkgname='curd'
3pkgver=r92.d2c2c15
4pkgrel=5
5pkgdesc="Watch anime in cli with Anilist Tracking, Discord RPC, Intro Outro Skipping, etc."
6arch=("x86_64")
7url="https://github.com/Wraient/curd"
8license=('GPL')
9depends=('python' 'mpv' 'socat')
10makedepends=('git' 'python-pip')
11source=("git+$url.git")
12sha256sums=('SKIP')
13
14pkgver() {
15 cd "$srcdir/$pkgname"
16 # Use the number of commits and the short hash as the version number
17 printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
18}
19
20build() {
21 # No compilation needed for a Python script
22 return 0
23}
24
25package() {
26 # Create the directory for the virtual environment and script
27 install -dm755 "$pkgdir/usr/share/$pkgname"
28
29 # Check if the virtual environment already exists, if not, create it
30 if [ ! -d "$pkgdir/usr/share/$pkgname/venv" ]; then
31 python -m venv "$pkgdir/usr/share/$pkgname/venv"
32 fi
33
34 # Install or update packages in the virtual environment
35 "$pkgdir/usr/share/$pkgname/venv/bin/pip" install --upgrade pypresence requests
36
37 # Install the Python script
38 install -Dm755 "$srcdir/$pkgname/curd.py" "$pkgdir/usr/share/$pkgname/curd.py"
39
40 install -Dm755 /dev/null "$pkgdir/usr/bin/curd"
41 # Create the run script
42 cat << 'EOF' > "$pkgdir/usr/bin/curd"
43#!/bin/bash
44
45# Path to the virtual environment
46VENV_DIR="/usr/share/curd/venv"
47
48# Check if the virtual environment exists, create if not
49if [ ! -d "$VENV_DIR" ]; then
50 python -m venv "$VENV_DIR"
51 "$VENV_DIR/bin/pip" install pypresence requests
52fi
53
54# Activate the virtual environment
55source "$VENV_DIR/bin/activate"
56
57# Run the Python script
58python /usr/share/curd/curd.py "$@"
59
60# Deactivate the virtual environment after running
61deactivate
62EOF
63
64 # Make the run script executable
65 chmod +x "$pkgdir/usr/bin/curd"
66}
67