Preface

This is a small post making some corrections about the previous. It is heavily recommended you read that one before coming to this one.

gnu-configure

In the previous article we just modified the pkg-config file to modify a few variables including vapidir, vapidir_versioned and datadir, sadly this had the side-effect of where the packages would install stuff their generated vala bindings.

Instead of installing to /usr/share/vala/vapi they would prefix them with the value of XBPS_CROSS_BASE, which is correct when searching for the vala bindings but not when installing them.

pkg-config

Let's take a look at the pkg-config file

/usr/lib/pkgconfig/vapigen-0.42.pc

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
bindir=/usr/bin
datarootdir=${prefix}/share
datadir=${datarootdir}
includedir=${prefix}/include

vapigen=${bindir}/vapigen-0.42
vapidir=${datadir}/vala/vapi
vapidir_versioned=${datadir}/vala-0.42/vapi

Name: vapigen
Description: Vala API Generator
Version: 0.42.5

wrapper

You can see it tries to use vapigen-0.42, if you remember our last wrapper it didn't account for packages using the versioned version of the executable directly. Let's fix that

diff --git a/common/hooks/pre-configure/02-script-wrapper.sh b/common/hooks/pre-configure/02-script-wrapper.sh
index 9eac4843ff..6b35ffffa2 100644
--- a/common/hooks/pre-configure/02-script-wrapper.sh
+++ b/common/hooks/pre-configure/02-script-wrapper.sh
@@ -91,6 +91,7 @@ exec /usr/bin/vapigen \\
     --girdir=${XBPS_CROSS_BASE}/usr/share/gir-1.0 "\$@"
 _EOF
    chmod 755 ${XBPS_WRAPPERDIR}/vapigen
+	ln -sf vapigen ${XBPS_WRAPPERDIR}/vapigen-0.42
 }
 
 install_wrappers() {

Now our wrapper will also install a symlink from vapigen to vapigen-0.42, and with that we can remove the pkg-config changes in the package:

cleanup

diff --git a/srcpkgs/vala/template b/srcpkgs/vala/template
index aa02d8a432..d0a40a2b24 100644
--- a/srcpkgs/vala/template
+++ b/srcpkgs/vala/template
@@ -1,7 +1,7 @@
 # Template file for 'vala'
 pkgname=vala
 version=0.42.5
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-graphviz"
 hostmakedepends="flex libxslt pkg-config automake libtool"
@@ -28,18 +28,6 @@ pre_configure() {
    autoreconf -fi
 }
 
-post_install() {
-	# Prefix the variables 'datadir' 'vapidir' and 'vapidir_versioned'
-	# with pc_sysrootdir so it gets expanded to the value of
-	# PKG_CONFIG_SYSROOT_DIR, this is necessary for packages that
-	# query pkg-config for the variables as we need to return the
-	# values from the cross environment not the native one.
-	vsed -e 's|^datadir=.*|datadir=${pc_sysrootdir}/${datarootdir}|g' \
-		 -e 's|^vapidir=.*|vapidir=${pc_sysrootdir}/${datadir}/vala/vapi|g' \
-		 -e 's|^vapidir_versioned=.*|vapidir_versioned=${pc_sysrootdir}/${datadir}/vala-0.42/vapi|g' \
-		 -i ${DESTDIR}/usr/lib/pkgconfig/vapigen-0.42.pc
-}
-
 libvala_package() {
    short_desc+=" - shared library"
    pkg_install() {

Closing

In the end we now have a single wrapper for both meson and gnu-configure, which is less code to worry about and doesn't mess with upstream packages.