summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ec75e50b2377e8bcad449f68b926d485d2bbac2f (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
# Maintainer: Aaron Bockelie <aaronsb@gmail.com>
pkgname=mmm
pkgver=1.1.0
pkgrel=1
pkgdesc="Markdown Mixed Media - A powerful terminal markdown viewer with image support, Mermaid diagrams, and PDF/ODT export"
arch=('any')
url="https://github.com/aaronsb/markdown-mixed-media"
license=('MIT')
depends=('nodejs>=20')
optdepends=(
    'chafa: Terminal image rendering support'
    'mermaid-cli: Mermaid diagram rendering'
    'chromium: PDF generation support'
)
makedepends=('npm' 'git')
options=('!strip')  # Don't strip binaries to avoid fakeroot issues
source=("$pkgname-$pkgver.tar.gz::https://github.com/aaronsb/markdown-mixed-media/archive/v$pkgver.tar.gz")
sha256sums=('cb68b908a65e609d956ac71c068b8c291bbd5fd8eb42862051260b2d3ad8eb0c')

build() {
    cd "$srcdir/markdown-mixed-media-$pkgver"

    # puppeteer is an optionalDependency (runtime-detected). Skip its bundled
    # Chromium download — users install system chromium (see optdepends).
    # This also makes the build work on architectures where puppeteer has no
    # prebuilt Chrome binary (e.g. aarch64).
    export PUPPETEER_SKIP_DOWNLOAD=true

    # Install dependencies (.npmrc sets legacy-peer-deps for marked-emoji compat)
    npm install --production=false

    # Build the project
    npm run build

    # Create the executable
    npm run build:simple
}

package() {
    cd "$srcdir/markdown-mixed-media-$pkgver"

    # Create directories
    install -dm755 "$pkgdir/usr/lib/$pkgname"
    install -dm755 "$pkgdir/usr/bin"

    # Copy built files
    cp -r dist "$pkgdir/usr/lib/$pkgname/"
    cp package.json "$pkgdir/usr/lib/$pkgname/"

    # Copy node_modules but exclude problematic binaries
    cp -r node_modules "$pkgdir/usr/lib/$pkgname/"

    # Remove problematic binary files that cause fakeroot issues
    find "$pkgdir/usr/lib/$pkgname/node_modules" -type f -name "*.node" -delete 2>/dev/null || true
    find "$pkgdir/usr/lib/$pkgname/node_modules" -type f -name "*.so" -delete 2>/dev/null || true
    find "$pkgdir/usr/lib/$pkgname/node_modules" -type f -name "*.dylib" -delete 2>/dev/null || true

    # Create wrapper script
    cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/usr/bin/env node
import '/usr/lib/$pkgname/dist/index-direct.js';
EOF

    # Make executable
    chmod 755 "$pkgdir/usr/bin/$pkgname"

    # Install license
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

    # Install documentation
    install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}