summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c47ea7ea79e031d9007385234b89035ebdea2bf3 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Maintainer: jinzhongjia <mail@nvimer.org>
pkgname=dbx
pkgver=0.6.4
pkgrel=1
pkgdesc="Open-source database management tool (Tauri-based)"
arch=('x86_64')
url="https://github.com/t8y2/dbx"
license=('AGPL-3.0-only')
depends=(
    'webkit2gtk-4.1'
    'gtk3'
    'sqlite'
    'unixodbc'
    'openssl'
    'hicolor-icon-theme'
)
makedepends=(
    'rust'
    'cargo'
    'nodejs'
    'pnpm'
    'pkgconf'
    'git'
)
provides=("$pkgname")
conflicts=("$pkgname-bin")
# makepkg's global LTO option injects -flto=auto / -C linker-plugin-lto, which
# breaks final-link symbol resolution against several bundled native static
# archives in our dep tree (ring, aws-lc-sys). Disable for this package.
# !debug: rust release profile strips symbols, so the auto-split debug pkg is
# empty and gdb-add-index errors out. Skip the debug subpackage entirely.
options=('!lto' '!debug')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('6dbb1945af1b471d1801675bbe06c6dfa5c6ee35222ef4d41b66b2a4f2069a8d')

prepare() {
    cd "$pkgname-$pkgver"

    # Keep all build state inside $srcdir, never touch user $HOME
    export CARGO_HOME="$srcdir/.cargo"
    export npm_config_cache="$srcdir/.npm"
    pnpm config --location project set store-dir "$srcdir/.pnpm-store"

    # pnpm v10 blocks postinstall scripts unless the package is listed in
    # package.json#pnpm.onlyBuiltDependencies. Upstream allows esbuild only;
    # vue-demi also needs its postinstall to pick the right Vue 2/3 shim.
    node -e '
      const fs = require("fs");
      const p = JSON.parse(fs.readFileSync("package.json", "utf8"));
      p.pnpm = p.pnpm || {};
      const cur = p.pnpm.onlyBuiltDependencies || [];
      p.pnpm.onlyBuiltDependencies = [...new Set([...cur, "vue-demi"])];
      fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
    '
    # Upstream opts into openssl's vendored feature. Use the declared system
    # dependency instead: vendoring embeds its temporary $srcdir install path
    # in the final binary.
    sed -i 's/openssl = { version = "0.10", features = \["vendored"\] }/openssl = "0.10"/' \
        crates/dbx-core/Cargo.toml
    # The release binary must not retain a build-workspace fallback path.
    # It is only useful to upstream developers and contains $srcdir via
    # env!("CARGO_MANIFEST_DIR").
    sed -i '/CARGO_MANIFEST_DIR/,+2d' crates/dbx-core/src/agent_service.rs
    # Pre-fetch JS and Rust deps so build() can run without network.
    pnpm install --frozen-lockfile
    (
        cd src-tauri
        cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
    )
}

build() {
    cd "$pkgname-$pkgver"

    export CARGO_HOME="$srcdir/.cargo"
    export RUSTUP_TOOLCHAIN=stable
    # Disable LTO. With lto="thin" (set in workspace Cargo.toml) plus rust-lld,
    # native static libs from build scripts (aws-lc-sys, ring, etc.) end up
    # with undefined symbols at final link. Disabling LTO restores normal
    # static-archive resolution.
    export CARGO_PROFILE_RELEASE_LTO=false

    # Strip $srcdir from panic-message file paths embedded by rustc; otherwise
    # makepkg warns "package contains reference to $srcdir". Also remap the
    # cargo registry to a stable path so the binary is reproducible regardless
    # of where it was built.
    export RUSTFLAGS="${RUSTFLAGS} --remap-path-prefix=$srcdir/$pkgname-$pkgver=/build/$pkgname --remap-path-prefix=$srcdir/.cargo/registry=/cargo-registry --remap-path-prefix=$srcdir/.cargo/git=/cargo-git"

    # Frontend + backend in one step; skip bundling, we install files ourselves
    pnpm exec tauri build --no-bundle
}

package() {
    cd "$pkgname-$pkgver"

    # Binary (workspace target dir is at repo root, not under src-tauri/)
    install -Dm755 "target/release/dbx" \
        "$pkgdir/usr/bin/dbx"

    # Icons (hicolor)
    install -Dm644 "src-tauri/icons/32x32.png" \
        "$pkgdir/usr/share/icons/hicolor/32x32/apps/dbx.png"
    install -Dm644 "src-tauri/icons/128x128.png" \
        "$pkgdir/usr/share/icons/hicolor/128x128/apps/dbx.png"
    install -Dm644 "src-tauri/icons/128x128@2x.png" \
        "$pkgdir/usr/share/icons/hicolor/256x256/apps/dbx.png"
    install -Dm644 "src-tauri/icons/icon.png" \
        "$pkgdir/usr/share/pixmaps/dbx.png"

    # Desktop entry
    install -dm755 "$pkgdir/usr/share/applications"
    cat > "$pkgdir/usr/share/applications/dbx.desktop" <<EOF
[Desktop Entry]
Name=DBX
Comment=$pkgdesc
Exec=dbx %U
Icon=dbx
Terminal=false
Type=Application
Categories=Development;Database;
StartupWMClass=DBX
EOF

    # License
    install -Dm644 LICENSE \
        "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}