You are not logged in.

#1 2017-11-18 11:52:48

htfy96
Member
Registered: 2015-10-22
Posts: 11

How to handle bundled libclang4 binaries in a package?

Hi,
I am writing PKGBUILD for cquery. Build scripts from upstream downloads prebuilt libclang4.0.0 binaries and links the executable against them with absolute rpath.

Currently, I patched the build scripts to change rpath from an absolute value to lib/, and copy libraries and the executable to /opt/cquery. Then I put a script named cquery under /usr/bin:

#!/usr/bin/bash
cd /opt/cquery
./cquery $@

The complete PKGBUILD is attached below. Is it the correct way to handle these binaries?

# Maintainer: Vic Luo <vicluo96 at gmail.com>

pkgname=cquery-git
_pkgname=cquery
pkgver=662.a60f93b
pkgrel=3
pkgdesc='Low-latency vscode language server for large C++ code-bases, powered by libclang.'
arch=('any')
url='https://github.com/jacobdufault/cquery/'
license=('MIT')
depends=('clang')
makedepends=("git" "python2")
source=('git+https://github.com/jacobdufault/cquery.git' 'cquery-sh')
md5sums=(
    'SKIP'
    'cdefbd32658ab9c6a531deb64c512c5d'
)

pkgver() {
    cd $_pkgname
    echo $(git rev-list --count master).$(git rev-parse --short master)
}

prepare() {
    cd $_pkgname
    git submodule update --init --recursive
    sed -e "s/, '-Werror'//g" -i ./wscript
    sed -e "s/rpath=\[CLANG_LIB_DIR\]/rpath=\['lib'\]/g" -i ./wscript
}

build() {
    cd $_pkgname
    python2 waf configure
    python2 waf build
    cd build
    ln -s clang+llvm*/lib lib
}

check() {
    cd $_pkgname/build
    yes | ./app --test
}

package() {
    cd $_pkgname/build
    install -m 755 -d "${pkgdir}/opt/cquery/"
    install -m 755 ./app "${pkgdir}/opt/cquery/cquery"
    install -m 755 -d "${pkgdir}/opt/cquery/lib"
    install -m 755 -t "${pkgdir}/opt/cquery/lib" lib/*.so*
    install -m 755 -d "${pkgdir}/usr/bin"
    install -D -m 755 "${srcdir}/cquery-sh" "${pkgdir}/usr/bin/cquery"
}

Offline

#2 2017-11-19 00:48:13

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: How to handle bundled libclang4 binaries in a package?

Actually, the correct way to handle this case (standalone executables bundled with dependencies) is to store the whole thing in /opt, which you did, and symlink the executable to /usr/bin

RPATH is evaluated in the context of the executable file itself, after the symlink is resolved to /opt/cquery/cquery and therefore there is no need for a wrapper script to run the executable with a different working directory.

...

That being said, why does it depend on clang if it uses a prebuilt copy of clang, and would you be able to convince it to use system libraries instead?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB