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