-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPKGBUILD
More file actions
59 lines (51 loc) · 2.22 KB
/
PKGBUILD
File metadata and controls
59 lines (51 loc) · 2.22 KB
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
pkgname=code-writer
pkgver=0.1.0
pkgrel=1
pkgdesc="AI-powered code solver — Code Writer"
arch=(x86_64)
url="https://github.com/youruser/code-writer"
license=('MIT')
depends=('python')
makedepends=('python-pip' 'python-virtualenv')
# We leave source empty because we are building from the local directory
source=()
package() {
# 1. Prepare directories
install -dm755 "$pkgdir/opt/$pkgname/src"
install -dm755 "$pkgdir/usr/bin"
# 2. Copy the project files from your current directory ($startdir)
# We copy 'src', 'resources', and any config folders
# Using $startdir ensures we get files outside the (empty) srcdir
cp -rp "$startdir/src"/* "$pkgdir/opt/$pkgname/src"
# Copy config and resources if they exist
[ -d "$startdir/config" ] && cp -rp "$startdir/config" "$pkgdir/opt/$pkgname/"
[ -d "$startdir/resources" ] && cp -rp "$startdir/resources" "$pkgdir/opt/$pkgname/"
[ -d "$startdir/CodeWriter" ] && cp -rp "$startdir/CodeWriter" "$pkgdir/opt/$pkgname/src"
# 3. Set up the Virtual Environment inside the package
# This keeps your system python clean!
python -m venv "$pkgdir/opt/$pkgname/venv"
# We must use the venv's python to install to the right path
# We use --no-warn-script-location because we are in a "fake" root
"$pkgdir/opt/$pkgname/venv/bin/python" -m pip install --upgrade pip
"$pkgdir/opt/$pkgname/venv/bin/pip" install \
'requests>=2.32' \
'rich>=13.5.0' \
'google-genai>=0.1.0' \
'argparse' \
'websockets'
# 4. Create the Wrapper Script
# This script will live in /usr/bin/code-writer
cat > "$pkgdir/usr/bin/code-writer" <<EOF
#!/bin/sh
# Navigate to the app dir so relative paths for configs work
cd /opt/$pkgname
# Run using the isolated venv python
exec /opt/$pkgname/venv/bin/python /opt/$pkgname/src/main.py "\$@"
EOF
chmod 755 "$pkgdir/usr/bin/code-writer"
# 5. Fix permissions (Ensure the venv is usable by all users)
find "$pkgdir/opt/$pkgname" -type d -exec chmod 755 {} +
find "$pkgdir/opt/$pkgname" -type f -exec chmod 644 {} +
chmod 755 "$pkgdir/opt/$pkgname/venv/bin/python"
[ -f "$pkgdir/opt/$pkgname/src/main.py" ] && chmod 755 "$pkgdir/opt/$pkgname/src/main.py"
}