You are not logged in.

#1 2022-05-15 03:43:47

Bink
Member
Registered: 2022-05-15
Posts: 16

[SOLVED] PKGBUILD review request: Dynamic path to build dependency

I'm working on updating what had been an orphaned AUR package.  A new make dependency was needed (docbook-xsl) and to produce a successful build, I needed to specify build flags pointing to two specific files from that dependency (illustrated below with html/chunk.xsl and fo/docbook.xsl)

makedepends=('cmake' 'git' 'docbook-xsl=1.79.2-7')
build() {
	mkdir -p "$srcdir/$_gitname/build_dir"
	cd "$srcdir/$_gitname/build_dir"

	CXXFLAGS+=" -fpermissive"
	cmake -DCMAKE_INSTALL_PREFIX=/usr \
	      -DCMAKE_BUILD_TYPE=RELEASE \
	      -DBT_DOCBOOK_XSL_HTML_CHUNK_XSL=/usr/share/xml/docbook/xsl-stylesheets-1.79.2/html/chunk.xsl \
	      -DBT_DOCBOOK_XSL_PDF_DOCBOOK_XSL=/usr/share/xml/docbook/xsl-stylesheets-1.79.2/fo/docbook.xsl \
	      ..
	make
}

It's working, but I'm not convinced it's the most elegant solution.  I'd prefer not to have to require a specific version of docbook-xsl, or specify a static path to the necessary files, for updatability sake and avoiding the possibility the files are not where I've specified.

Any thoughts on how to elegantly handle this?

Last edited by Bink (2025-01-31 03:26:38)

Offline

#2 2022-05-15 07:58:03

mpan
Member
Registered: 2012-08-01
Posts: 1,583
Website

Re: [SOLVED] PKGBUILD review request: Dynamic path to build dependency

I do not know docbook-xsl.

Arch Wiki suggests using pacman to get docbook-xsl version. Perhaps that helps.


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2022-05-15 10:17:20

Bink
Member
Registered: 2022-05-15
Posts: 16

Re: [SOLVED] PKGBUILD review request: Dynamic path to build dependency

Thanks @mpan.  That reference provides a nice simple means to dynamically point to the files, with a bit of tweaking:

/usr/share/xml/docbook/xsl-stylesheets-$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)/html/chunk.xsl
/usr/share/xml/docbook/xsl-stylesheets-$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)/fo/docbook.xsl

If using pacman within PKGBUILD is fine, then this looks like it'll do the trick.

Last edited by Bink (2022-05-15 10:17:55)

Offline

#4 2022-05-15 10:39:06

Bink
Member
Registered: 2022-05-15
Posts: 16

Re: [SOLVED] PKGBUILD review request: Dynamic path to build dependency

This has worked in testing.  Thanks again @mpan.

makedepends=('cmake' 'git' 'docbook-xsl')
build() {
	_xslstylespath="/usr/share/xml/docbook/xsl-stylesheets-"$(pacman -Q docbook-xsl | cut -d ' ' -f 2 | cut -d '-' -f 1)

	mkdir -p "$srcdir/$_gitname/build_dir"
	cd "$srcdir/$_gitname/build_dir"

	CXXFLAGS+=" -fpermissive"
	cmake -DCMAKE_INSTALL_PREFIX=/usr \
	      -DCMAKE_BUILD_TYPE=RELEASE \
	      -DBT_DOCBOOK_XSL_HTML_CHUNK_XSL=$_xslstylespath/html/chunk.xsl \
	      -DBT_DOCBOOK_XSL_PDF_DOCBOOK_XSL=$_xslstylespath/fo/docbook.xsl \
	      ..
	make
}

Offline

Board footer

Powered by FluxBB