summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a677c079c357494db2448adb78cb7b96451f10e5 (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
# Maintainer: Aaron Bockelie <aaronsb@gmail.com>
pkgname=mmm
pkgver=1.0.9
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=('bc4aee08fc9540470d1688d30ef2cd869c15d0076a284137b23972276e659786')

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

    # 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

    # Remove puppeteer's chromium download to save space (PDF generation will need system chromium)
    rm -rf "$pkgdir/usr/lib/$pkgname/node_modules/puppeteer/.local-chromium" 2>/dev/null || true
    rm -rf "$pkgdir/usr/lib/$pkgname/node_modules/puppeteer-core/.local-chromium" 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"
}