Warning: there may be occasional oddness due to css and blog edits. **KNOWN ISSUE: possible hidden text**

Wednesday, March 31, 2021

Minetest better

minetest game example screenshot
Minetest gallery pic

This post has been revisited a couple times but I feel it is in its final form as I chose to continue with the development version instead of worrying about something I cannot control.

October 2020

There is a game in our ports collection which I spent far too many hours playing due to being temporarily out of work (but not jobless) beyond my control beginning mid March 2020.  It gave me something to do, to fill the empty, and I played it from a vanilla ports install.  When I say "vanilla ports install" what I mean is that I did not modify anything about it except for the configuration exposed by the person who ported it to FreeBSD.  This 'vanilla install' became customized when I saw that a newer version was available to the wider gamer community but had not yet been updated for FreeBSD.

I did my best to get it to work but discovered that some of the patches automatically applied did not need to be used, they failed to be applied to the newer version.  This was just the beginning of my tinkering to get minetest to function as well as possible.  I am sure that using a bundled, abbreviated, adequately functional component would be less efficient than to use the full version which may be available from ports.  I discovered this by investigating the various exposed options I could tick to know what they were about, and seeing others described by the Linux devs which were not.

The overview of the change, the left is how it appeared on October 3, 2020 at svnweb.freebsd.org and the right is how the Makefile was on my box then, the changes emphasized with highlighting.

# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>						# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>
# $FreeBSD$											# $FreeBSD$

PORTNAME=	minetest									PORTNAME=	minetest
PORTVERSION=    5.3.0										PORTVERSION=    5.3.0
CATEGORIES=     games										CATEGORIES=     games

MAINTAINER=	amdmi3@FreeB									MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Near-infinite-world block sandbox game						COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+										LICENSE=	LGPL21+
LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt							LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt

LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \						LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \
		libgmp.so:math/gmp				|       					libgmp.so:math/gmp \
								>       					libjsoncpp.so:devel/jsoncpp

USE_GITHUB=	yes										USE_GITHUB=	yes
GH_ACCOUNT=	minetest									GH_ACCOUNT=	minetest

USES=		cmake compiler:c11 iconv:wchar_t						USES=		cmake compiler:c11 iconv:wchar_t
CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \						CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc"	|       					-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
								>       					-DENABLE_SYSTEM_JSONCPP=ON \
								>       					-DJSON_INCLUDE_DIR=/usr/local/include/json \
								>       					-DCMAKE_BUILD_TYPE=MinSizeRel \
								>       					-DOPENGL_GL_PREFERENCE=LEGACY \
								>       					-DENABLE_SYSTEM_GMP=ON

LDFLAGS_i386=	-Wl,-znotext									LDFLAGS_i386=	-Wl,-znotext

PORTDATA=	*										PORTDATA=	*
PORTDOCS=	*										PORTDOCS=	*

OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \						OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \
		DOCS EXAMPLES NLS										DOCS EXAMPLES NLS
OPTIONS_MULTI=	COMP										OPTIONS_MULTI=	COMP
OPTIONS_GROUP=	DATABASE									OPTIONS_GROUP=	DATABASE

COMP_DESC=		Software components							COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER								OPTIONS_MULTI_COMP=	CLIENT SERVER

DATABASE_DESC=		Database support							DATABASE_DESC=		Database support
OPTIONS_GROUP_DATABASE=	PGSQL LEVELDB REDIS SPATIAL						OPTIONS_GROUP_DATABASE=	PGSQL LEVELDB REDIS SPATIAL

OPTIONS_DEFAULT=	CLIENT SERVER \								OPTIONS_DEFAULT=	CLIENT SERVER \
			CURL SOUND FREETYPE NCURSES LUAJIT								CURL SOUND FREETYPE NCURSES LUAJIT
OPTIONS_EXCLUDE_powerpc64=	LUAJIT								OPTIONS_EXCLUDE_powerpc64=	LUAJIT
OPTIONS_SUB=		yes									OPTIONS_SUB=		yes

CLIENT_DESC=		Build client								CLIENT_DESC=		Build client
CLIENT_CMAKE_BOOL=	BUILD_CLIENT								CLIENT_CMAKE_BOOL=	BUILD_CLIENT
CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \						CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \
			libIrrlicht.so:x11-toolkits/irrlicht					libIrrlicht.so:x11-toolkits/irrlicht
CLIENT_USES=		gl jpeg xorg								CLIENT_USES=		gl jpeg xorg
CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm						CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm
SERVER_DESC=		Build server								SERVER_DESC=		Build server
SERVER_CMAKE_BOOL=	BUILD_SERVER								SERVER_CMAKE_BOOL=	BUILD_SERVER

CURL_DESC=		Enable cURL support for fetching media					CURL_DESC=		Enable cURL support for fetching media
CURL_CMAKE_BOOL=	ENABLE_CURL								CURL_CMAKE_BOOL=	ENABLE_CURL
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl							CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
SOUND_DESC=		Enable sound								SOUND_DESC=		Enable sound
SOUND_CMAKE_BOOL=	ENABLE_SOUND								SOUND_CMAKE_BOOL=	ENABLE_SOUND
FREETYPE_DESC=		Support for TrueType fonts with unicode					FREETYPE_DESC=		Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE								FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2						FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2
NCURSES_DESC=		Enable ncurses console							NCURSES_DESC=		Enable ncurses console
NCURSES_CMAKE_BOOL=	ENABLE_CURSES								NCURSES_CMAKE_BOOL=	ENABLE_CURSES
NCURSES_USES=		ncurses									NCURSES_USES=		ncurses

LUAJIT_DESC=		LuaJIT support								LUAJIT_DESC=		LuaJIT support
LUAJIT_CMAKE_BOOL=	ENABLE_LUAJIT REQUIRE_LUAJIT						LUAJIT_CMAKE_BOOL=	ENABLE_LUAJIT REQUIRE_LUAJIT
LUAJIT_LIB_DEPENDS=	libluajit-5.1.so:lang/luajit						LUAJIT_LIB_DEPENDS=	libluajit-5.1.so:lang/luajit

PGSQL_USES=		pgsql									PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL							PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL
LEVELDB_DESC=		Enable LevelDB backend							LEVELDB_DESC=		Enable LevelDB backend
LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB								LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb						LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
REDIS_DESC=		Enable Redis backend							REDIS_DESC=		Enable Redis backend
REDIS_CMAKE_BOOL=	ENABLE_REDIS								REDIS_CMAKE_BOOL=	ENABLE_REDIS
REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis						REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis
SPATIAL_DESC=		Enable SpatialIndex AreaStore backend					SPATIAL_DESC=		Enable SpatialIndex AreaStore backend
SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex					SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL								SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL

NLS_CMAKE_BOOL=		ENABLE_GETTEXT								NLS_CMAKE_BOOL=		ENABLE_GETTEXT
NLS_USES=		gettext									NLS_USES=		gettext
NLS_LDFLAGS=		-L${LOCALBASE}/lib							NLS_LDFLAGS=		-L${LOCALBASE}/lib

.include <bsd.port.options.mk>									.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}						.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}
USES+=		openal										USES+=		openal
LIB_DEPENDS+=	libvorbis.so:audio/libvorbis \							LIB_DEPENDS+=	libvorbis.so:audio/libvorbis \
		libogg.so:audio/libogg										libogg.so:audio/libogg
.endif												.endif

.if ${PORT_OPTIONS:MSERVER}									.if ${PORT_OPTIONS:MSERVER}
USE_RC_SUBR=	${PORTNAME}									USE_RC_SUBR=	${PORTNAME}
USERS=		${PORTNAME}									USERS=		${PORTNAME}
GROUPS=		${PORTNAME}									GROUPS=		${PORTNAME}
.endif												.endif

# hacky way to not bring irrlicht and X11 depends for server only				# hacky way to not bring irrlicht and X11 depends for server only
.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}					.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch					BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch
IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include	IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include
CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"				CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend						EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend
.endif												.endif

post-extract:											post-extract:
# make sure no bundled gmp is used								# make sure no bundled gmp is used
	@${RM} -rf ${WRKSRC}/lib/gmp									@${RM} -rf ${WRKSRC}/lib/gmp
# bundled jsoncpp is OK, see comment in cmake/Modules/FindJson.cmake				# bundled jsoncpp is OK, see comment in cmake/Modules/FindJson.cmake
#	(not sure if it affects FreeBSD, but too lazy to investigate)				#	(not sure if it affects FreeBSD, but too lazy to investigate)
# bundled lua is OK, there's no option to use system one					# bundled lua is OK, there's no option to use system one

post-patch:											post-patch:
	@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \						@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \
		${WRKSRC}/cmake/Modules/*.cmake									${WRKSRC}/cmake/Modules/*.cmake

.include <bsd.port.mk>										.include <bsd.port.mk>


In addition to the above adjustments to the Makefile, there may be a patch file which must be removed or hidden in order for my modified build to succeed.  The file is /usr/ports/games/files/patch-src_CMakeLists.txt

As you can see, my preference is for those things installed within the system as opposed to those which may be bundled as part of the tarball.  As yet I have not absolutely verified or conclusively tested whether the changes I made actually result in a speedier or more efficient minetest executable.  Take the above as you wish, choose to use it as described but I suggest caution if you further adjust the modifications.  Specifically, the LIB_DEPENDS should in most cases have a matching CMAKE_ARGS equivalent.

I believe the iconv:wchar_t which I removed relates to languages which would need wide characters, and this allows for conversions which may be necessary for that situation.  I will not be needing wide characters for my singleplayer or client gameplay, so that is safe for me to excise.  I do not know exactly how the cmake compiler:c++11-lang definition changes the way it is built but it is the one that works for me and my other adjustments.  The other CMAKE_ARGS item, -DCMAKE_BUILD_TYPE=MinSizeRel is there because I believe it is an improvement, it builds with it but I do not know exactly what its function or change is.

I would like to make a proper comparison between the vanilla install and my modification but this needs a bit more research and possibly additional software tools for testing.

Had I used portlint in the minetest directory at any time during my modification, I would have discovered a mistake in the original Makefile.  A report from portlint indicates that the USES= line should appear before any USE_ lines which in this specific example is USE_GITHUB=yes so if poudriere is used with portlint=yes, it may deny building.  Change this in the Makefile unless it gets fixed by the port maintainer first, but then make note that my Makefile had the flaw and so do not restore that flaw by copying it from above.

Update - March 2021

The port maintainer has since adopted some changes with recent updates to minetest by upstream causing this port to be reexamined.  I have also decided to look over my changes and how they relate to the current Makefile and try to make any possible improvements for myself which would enhance performance.  I am also going to submit a few bug reports for this port so that my changes can be affected officially.  The primary one being that the patch I remove is not necessary because it canbe accomplished properly by cmake arguements.  I may have missed some things or made slightly incorrect adjustments my first time through, even though the changes may have been appropriate and correct aside from syntax. So lets see how the current modified Makefile looks as the comparison below illustrates today, March 30, 2021.

First the hard-coded default method which is similar to my previous modification from back in October.

# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>						# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>
# $FreeBSD$												# $FreeBSD$

PORTNAME=	minetest										PORTNAME=	minetest
PORTVERSION=	5.4.0											PORTVERSION=	5.4.0
PORTREVISION=	1											PORTREVISION=	1
CATEGORIES=	games											CATEGORIES=	games

MAINTAINER=	amdmi3@FreeBSD.org									MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Near-infinite-world block sandbox game							COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+											LICENSE=	LGPL21+
LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt								LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt

LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \						|       LIB_DEPENDS=	libgmp.so:math/gmp \
		libgmp.so:math/gmp \								|       		libjsoncpp.so:devel/jsoncpp \
		libjsoncpp.so:devel/jsoncpp							|       		libsqlite3.so:databases/sqlite3

USE_GITHUB=	yes										<
GH_ACCOUNT=	minetest									<
												<
USES=		cmake compiler:c11 iconv:wchar_t							USES=		cmake compiler:c11 iconv:wchar_t
CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \						|       CMAKE_ARGS=	-DBUILD_UNITTESTS="FALSE" \
												>       		-DCMAKE_BUILD_TYPE="MinSizeRel" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \								-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
		-DENABLE_SYSTEM_JSONCPP=ON							|       		-DCUSTOM_MANDIR="${PREFIX}/man" \
												>       		-DENABLE_SYSTEM_GMP="ON" \
												>       		-DENABLE_SYSTEM_JSONCPP="ON" \
												>       		-DJSON_INCLUDE_DIR="${PREFIX}/include/jsoncpp" \
												>       		-DOPENGL_GL_PREFERENCE="GLVND" \
												>       		-DREQUIRE_LUAJIT="ON"
												>       #		-DVERSION_EXTRA="_${PORTREVISION}"
												>       # OpenGL_GL_PREFERENCE Allowed values are 'GLVND' and 'LEGACY'
												>       # See CMake Policy CMP0072 for reference. GLVND is broken on some nvidia setups, so use LEGACY instead.

												>       USE_GITHUB=	yes
												>       GH_ACCOUNT=	minetest
												>
LDFLAGS_i386=	-Wl,-znotext										LDFLAGS_i386=	-Wl,-znotext

PORTDATA=	*											PORTDATA=	*
PORTDOCS=	*											PORTDOCS=	*

OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \						|       OPTIONS_DEFINE=	CURL DOCS EXAMPLES FREETYPE LUAJIT NCURSES NLS SOUND
		DOCS EXAMPLES NLS								<
OPTIONS_MULTI=	COMP											OPTIONS_MULTI=	COMP
OPTIONS_GROUP=	DATABASE										OPTIONS_GROUP=	DATABASE

COMP_DESC=		Software components								COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER									OPTIONS_MULTI_COMP=	CLIENT SERVER

DATABASE_DESC=		Database support								DATABASE_DESC=		Database support
OPTIONS_GROUP_DATABASE=	PGSQL LEVELDB REDIS SPATIAL						|       OPTIONS_GROUP_DATABASE=	LEVELDB PGSQL REDIS SPATIAL

OPTIONS_DEFAULT=	CLIENT SERVER \								|       OPTIONS_DEFAULT=	CLIENT CURL FREETYPE LUAJIT NCURSES SERVER SOUND
			CURL SOUND FREETYPE NCURSES LUAJIT					<
OPTIONS_SUB=		yes										OPTIONS_SUB=		yes

CLIENT_DESC=		Build client									CLIENT_DESC=		Build client
CLIENT_CMAKE_BOOL=	BUILD_CLIENT									CLIENT_CMAKE_BOOL=	BUILD_CLIENT
CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \						|       CLIENT_LIB_DEPENDS=	libIrrlicht.so:x11-toolkits/irrlicht \
			libIrrlicht.so:x11-toolkits/irrlicht					|       			libpng.so:graphics/png
CLIENT_USES=		gl jpeg xorg									CLIENT_USES=		gl jpeg xorg
CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm						|       CLIENT_USE=		GL=gl \
												>       			XORG=x11,xext,xxf86vm
SERVER_DESC=		Build server									SERVER_DESC=		Build server
SERVER_CMAKE_BOOL=	BUILD_SERVER									SERVER_CMAKE_BOOL=	BUILD_SERVER

CURL_DESC=		Enable cURL support for fetching media						CURL_DESC=		Enable cURL support for fetching media
CURL_CMAKE_BOOL=	ENABLE_CURL									CURL_CMAKE_BOOL=	ENABLE_CURL
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl								CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
SOUND_DESC=		Enable sound									SOUND_DESC=		Enable sound
SOUND_CMAKE_BOOL=	ENABLE_SOUND									SOUND_CMAKE_BOOL=	ENABLE_SOUND
FREETYPE_DESC=		Support for TrueType fonts with unicode						FREETYPE_DESC=		Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE									FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2							FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2
NCURSES_DESC=		Enable ncurses console								NCURSES_DESC=		Enable ncurses console
NCURSES_CMAKE_BOOL=	ENABLE_CURSES									NCURSES_CMAKE_BOOL=	ENABLE_CURSES
NCURSES_USES=		ncurses										NCURSES_USES=		ncurses

LUAJIT_DESC=		LuaJIT support									LUAJIT_DESC=		LuaJIT support
LUAJIT_CMAKE_BOOL=	ENABLE_LUAJIT REQUIRE_LUAJIT							LUAJIT_CMAKE_BOOL=	ENABLE_LUAJIT REQUIRE_LUAJIT
LUAJIT_LIB_DEPENDS=	libluajit-5.1.so:lang/luajit-openresty						LUAJIT_LIB_DEPENDS=	libluajit-5.1.so:lang/luajit-openresty

PGSQL_USES=		pgsql										PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL								PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL
LEVELDB_DESC=		Enable LevelDB backend								LEVELDB_DESC=		Enable LevelDB backend
LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB									LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb							LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb
REDIS_DESC=		Enable Redis backend								REDIS_DESC=		Enable Redis backend
REDIS_CMAKE_BOOL=	ENABLE_REDIS									REDIS_CMAKE_BOOL=	ENABLE_REDIS
REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis							REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis
SPATIAL_DESC=		Enable SpatialIndex AreaStore backend						SPATIAL_DESC=		Enable SpatialIndex AreaStore backend
SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex						SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL									SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL

NLS_CMAKE_BOOL=		ENABLE_GETTEXT								|       NLS_CMAKE_BOOL=	ENABLE_GETTEXT
NLS_USES=		gettext									|       NLS_USES=	gettext
NLS_LDFLAGS=		-L${LOCALBASE}/lib							|       NLS_LDFLAGS=	-L${LOCALBASE}/lib

.include <bsd.port.options.mk>										.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}							.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}
USES+=		openal											USES+=		openal
LIB_DEPENDS+=	libvorbis.so:audio/libvorbis \							|       LIB_DEPENDS+=	libogg.so:audio/libogg \
		libogg.so:audio/libogg								|       		libvorbis.so:audio/libvorbis
.endif													.endif

.if ${PORT_OPTIONS:MSERVER}										.if ${PORT_OPTIONS:MSERVER}
USE_RC_SUBR=	${PORTNAME}										USE_RC_SUBR=	${PORTNAME}
USERS=		${PORTNAME}										USERS=		${PORTNAME}
GROUPS=		${PORTNAME}										GROUPS=		${PORTNAME}
.endif													.endif

# hacky way to not bring irrlicht and X11 depends for server only					# hacky way to not bring irrlicht and X11 depends for server only
.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}						.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch					|       BUILD_DEPENDS+=		${NONEXISTENT}:x11-toolkits/irrlicht:patch
IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include		IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include
CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"				|       CMAKE_ARGS+=		-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend						|       EXTRA_PATCHES+=		${FILESDIR}/extra-patch-irrlichtdepend
.endif													.endif

post-extract:												post-extract:
# make sure no bundled gmp is used									# make sure no bundled gmp is used
	@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp							@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp
# bundled lua is OK, there's no option to use system one						# bundled lua is OK, there's no option to use system one

post-patch:												post-patch:
	@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \							@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \
		${WRKSRC}/cmake/Modules/*.cmake										${WRKSRC}/cmake/Modules/*.cmake

.include <bsd.port.mk>											.include <bsd.port.mk>

Sometime after deciding that the above was perfected, I realized that if I am to eventually submit a bug report to the maintainer for improvement, that I might attempt a more rococo version which will have all the option configs that interest me exposed to the light of day rather than hiding in the shadows of a developer's documentation.  This much more complex version will take a bit of effort to perfect and I still may flub something.  My makefile (below) permits the user to choose bundled gmp or jsoncpp rather than deciding that either is not desirable.

# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>							# Created by: Dmitry Marakasov <amdmi3@FreeBSD.org>
# $FreeBSD$												# $FreeBSD$

PORTNAME=	minetest										PORTNAME=	minetest
PORTVERSION=	5.4.0											PORTVERSION=	5.4.0
PORTREVISION=	1											PORTREVISION=	1
CATEGORIES=	games											CATEGORIES=	games

MAINTAINER=	amdmi3@FreeBSD.org									MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Near-infinite-world block sandbox game							COMMENT=	Near-infinite-world block sandbox game

LICENSE=	LGPL21+											LICENSE=	LGPL21+
LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt								LICENSE_FILE=	${WRKSRC}/doc/lgpl-2.1.txt

LIB_DEPENDS=	libsqlite3.so:databases/sqlite3 \						|       LIB_DEPENDS=	libsqlite3.so:databases/sqlite3
		libgmp.so:math/gmp \								<
		libjsoncpp.so:devel/jsoncpp							<

USE_GITHUB=	yes										<
GH_ACCOUNT=	minetest									<
												<
USES=		cmake compiler:c11 iconv:wchar_t							USES=		cmake compiler:c11 iconv:wchar_t
CMAKE_ARGS=	-DCUSTOM_MANDIR="${PREFIX}/man" \						|       CMAKE_ARGS=	-DBUILD_UNITTESTS="FALSE" \
												>       		-DCMAKE_BUILD_TYPE="MinSizeRel" \
		-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \								-DCUSTOM_EXAMPLE_CONF_DIR="${PREFIX}/etc" \
		-DENABLE_SYSTEM_JSONCPP=ON							|       		-DCUSTOM_MANDIR="${PREFIX}/man"
												>       #               -DVERSION_EXTRA="_${PORTREVISION}"  # Except that there is an automatic added dash seperator.
												>       # OpenGL_GL_PREFERENCE Allowed values are 'GLVND' and 'LEGACY'
												>       # See CMake Policy CMP0072 for reference: cmake --help-policy CMP0072. GLVND is broken on some nvidia setups, so use LEGACY instead.

												>       USE_GITHUB=	yes
												>       GH_ACCOUNT=	minetest
												>
LDFLAGS_i386=	-Wl,-znotext										LDFLAGS_i386=	-Wl,-znotext

PORTDATA=	*											PORTDATA=	*
PORTDOCS=	*											PORTDOCS=	*

OPTIONS_DEFINE=	CURL SOUND FREETYPE NCURSES LUAJIT \						|       OPTIONS_DEFINE=	CURL DOCS EXAMPLES FREETYPE LUAJIT NCURSES NLS SOUND SYSTEM_GMP \
		DOCS EXAMPLES NLS								|       		SYSTEM_JSONCPP
OPTIONS_MULTI=	COMP											OPTIONS_MULTI=	COMP
												>       OPTIONS_RADIO=	GRAPHICS
OPTIONS_GROUP=	DATABASE										OPTIONS_GROUP=	DATABASE

COMP_DESC=		Software components								COMP_DESC=		Software components
OPTIONS_MULTI_COMP=	CLIENT SERVER									OPTIONS_MULTI_COMP=	CLIENT SERVER

												>       OPTIONS_RADIO_GRAPHICS=	GLVND LEGACY
												>
												>       SYSTEM_GMP_DESC=		Use gmp from ports (ENABLE_SYSTEM_GMP)
												>       SYSTEM_GMP_CMAKE_BOOL=		ENABLE_SYSTEM_GMP
												>       SYSTEM_GMP_CMAKE_ON=		-DGMP_INCLUDE_DIR="${PREFIX}/include"
												>       SYSTEM_GMP_LIB_DEPENDS=		libgmp.so:math/gmp
												>
												>       SYSTEM_JSONCPP_DESC=		Use jsoncpp from ports (ENABLE_SYSTEM_JSONCPP)
												>       SYSTEM_JSONCPP_CMAKE_BOOL=	ENABLE_SYSTEM_JSONCPP
												>       SYSTEM_JSONCPP_CMAKE_ON=	-DJSON_INCLUDE_DIR="${PREFIX}/include/jsoncpp"
												>       SYSTEM_JSONCPP_LIB_DEPENDS=	libjsoncpp.so:devel/jsoncpp
												>
												>       GRAPHICS_DESC=		Graphics support
												>       GLVND_DESC=		Use libOpenGL or libGLX
												>       LEGACY_DESC=		Use libGL - where GLVND may be broken on nvidia
												>
												>       GLVND_CMAKE_ON=		-DOPENGL_GL_PREFERENCE="GLVND"
												>       LEGACY_CMAKE_ON=	-DOPENGL_GL_PREFERENCE="LEGACY"
												>
DATABASE_DESC=		Database support								DATABASE_DESC=		Database support
OPTIONS_GROUP_DATABASE=	PGSQL LEVELDB REDIS SPATIAL						|       OPTIONS_GROUP_DATABASE=	LEVELDB PGSQL REDIS SPATIAL

OPTIONS_DEFAULT=	CLIENT SERVER \								|       OPTIONS_DEFAULT=	CLIENT CURL FREETYPE GLVND LUAJIT NCURSES SERVER SOUND \
			CURL SOUND FREETYPE NCURSES LUAJIT					|       			SYSTEM_GMP SYSTEM_JSONCPP
OPTIONS_SUB=		yes										OPTIONS_SUB=		yes

CLIENT_DESC=		Build client									CLIENT_DESC=		Build client
CLIENT_CMAKE_BOOL=	BUILD_CLIENT									CLIENT_CMAKE_BOOL=	BUILD_CLIENT
CLIENT_LIB_DEPENDS=	libpng.so:graphics/png \						|       CLIENT_LIB_DEPENDS=	libIrrlicht.so:x11-toolkits/irrlicht \
			libIrrlicht.so:x11-toolkits/irrlicht					|       			libpng.so:graphics/png
CLIENT_USES=		gl jpeg xorg									CLIENT_USES=		gl jpeg xorg
CLIENT_USE=		GL=gl XORG=x11,xext,xxf86vm						|       CLIENT_USE=		GL=gl \
												>       			XORG=x11,xext,xxf86vm
SERVER_DESC=		Build server									SERVER_DESC=		Build server
SERVER_CMAKE_BOOL=	BUILD_SERVER									SERVER_CMAKE_BOOL=	BUILD_SERVER

CURL_DESC=		Enable cURL support for fetching media						CURL_DESC=		Enable cURL support for fetching media
CURL_CMAKE_BOOL=	ENABLE_CURL									CURL_CMAKE_BOOL=	ENABLE_CURL
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl								CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
SOUND_DESC=		Enable sound									SOUND_DESC=		Enable sound
SOUND_CMAKE_BOOL=	ENABLE_SOUND									SOUND_CMAKE_BOOL=	ENABLE_SOUND
FREETYPE_DESC=		Support for TrueType fonts with unicode						FREETYPE_DESC=		Support for TrueType fonts with unicode
FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE									FREETYPE_CMAKE_BOOL=	ENABLE_FREETYPE
FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2							FREETYPE_LIB_DEPENDS=	libfreetype.so:print/freetype2
NCURSES_DESC=		Enable ncurses console								NCURSES_DESC=		Enable ncurses console
NCURSES_CMAKE_BOOL=	ENABLE_CURSES									NCURSES_CMAKE_BOOL=	ENABLE_CURSES
NCURSES_USES=		ncurses										NCURSES_USES=		ncurses

LUAJIT_DESC=		LuaJIT support									LUAJIT_DESC=		LuaJIT support
LUAJIT_CMAKE_BOOL=	ENABLE_LUAJIT REQUIRE_LUAJIT							LUAJIT_CMAKE_BOOL=	ENABLE_LUAJIT REQUIRE_LUAJIT
LUAJIT_LIB_DEPENDS=	libluajit-5.1.so:lang/luajit-openresty						LUAJIT_LIB_DEPENDS=	libluajit-5.1.so:lang/luajit-openresty

PGSQL_USES=		pgsql										PGSQL_USES=		pgsql
PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL								PGSQL_CMAKE_BOOL=	ENABLE_POSTGRESQL
LEVELDB_DESC=		Enable LevelDB backend								LEVELDB_DESC=		Enable LevelDB backend
LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB									LEVELDB_CMAKE_BOOL=	ENABLE_LEVELDB
LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb							LEVELDB_LIB_DEPENDS=	libleveldb.so:databases/leveldb
REDIS_DESC=		Enable Redis backend								REDIS_DESC=		Enable Redis backend
REDIS_CMAKE_BOOL=	ENABLE_REDIS									REDIS_CMAKE_BOOL=	ENABLE_REDIS
REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis							REDIS_LIB_DEPENDS=	libhiredis.so:databases/hiredis
SPATIAL_DESC=		Enable SpatialIndex AreaStore backend						SPATIAL_DESC=		Enable SpatialIndex AreaStore backend
SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex						SPATIAL_LIB_DEPENDS=	libspatialindex.so:devel/spatialindex
SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL									SPATIAL_CMAKE_BOOL=	ENABLE_SPATIAL

NLS_CMAKE_BOOL=		ENABLE_GETTEXT								|       NLS_CMAKE_BOOL=	ENABLE_GETTEXT
NLS_USES=		gettext									|       NLS_USES=	gettext
NLS_LDFLAGS=		-L${LOCALBASE}/lib							|       NLS_LDFLAGS=	-L${LOCALBASE}/lib

.include <bsd.port.options.mk>										.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}							.if ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSOUND}
USES+=		openal											USES+=		openal
LIB_DEPENDS+=	libvorbis.so:audio/libvorbis \							|       LIB_DEPENDS+=	libogg.so:audio/libogg \
		libogg.so:audio/libogg								|       		libvorbis.so:audio/libvorbis
.endif													.endif

.if ${PORT_OPTIONS:MSERVER}										.if ${PORT_OPTIONS:MSERVER}
USE_RC_SUBR=	${PORTNAME}										USE_RC_SUBR=	${PORTNAME}
USERS=		${PORTNAME}										USERS=		${PORTNAME}
GROUPS=		${PORTNAME}										GROUPS=		${PORTNAME}
.endif													.endif

# hacky way to not bring irrlicht and X11 depends for server only					# hacky way to not bring irrlicht and X11 depends for server only
.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}						.if ! ${PORT_OPTIONS:MCLIENT} && ${PORT_OPTIONS:MSERVER}
BUILD_DEPENDS+=	${NONEXISTENT}:x11-toolkits/irrlicht:patch					|       BUILD_DEPENDS+=		${NONEXISTENT}:x11-toolkits/irrlicht:patch
IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include		IRRLICHT_INCLUDE_DIR=	`${MAKE} -C ${PORTSDIR}/x11-toolkits/irrlicht -V WRKSRC`/include
CMAKE_ARGS+=	-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"				|       CMAKE_ARGS+=		-DIRRLICHT_INCLUDE_DIR:STRING="${IRRLICHT_INCLUDE_DIR}"
EXTRA_PATCHES+=	${FILESDIR}/extra-patch-irrlichtdepend						|       EXTRA_PATCHES+=		${FILESDIR}/extra-patch-irrlichtdepend
.endif													.endif
												>       # From wiki:
												>       #  Building without Irrlicht / X dependency
												>       # You can build the Minetest server without library dependencies to Irrlicht or any graphical stuff.
												>       # You still need the Irrlicht headers for this, so first, download the irrlicht source to somewhere.
												>       #
												>       # When invoking CMake, use -DBUILD_CLIENT=0 -DIRRLICHT_SOURCE_DIR=/wherever/you/unzipped/the/source.

post-extract:											|       #post-extract:
# make sure no bundled gmp is used									# make sure no bundled gmp is used
	@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp					|       #	@${RM} -rf ${WRKSRC}/lib/gmp ${WRKSRC}/lib/jsoncpp
# bundled lua is OK, there's no option to use system one						# bundled lua is OK, there's no option to use system one

post-patch:												post-patch:
	@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \							@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' \
		${WRKSRC}/cmake/Modules/*.cmake										${WRKSRC}/cmake/Modules/*.cmake

.include <bsd.port.mk>											.include <bsd.port.mk>

As before and with any of my modifications above, in addition to the above adjustments to the Makefile, there may be a patch file which must be removed or hidden in order for my modified build to succeed.  The file is /usr/ports/games/files/patch-src_CMakeLists.txt

The final result comparison of the ncurses configuration menu for default (as it is in ports now) on the left and my new rococo version on the right.

 

It should be noted that while these modifications are not yet made official (and I cannot say for certain if they will be since my philosophy/understanding may be different than the maintainer) this port is also not set to be built locally by poudriere.  Poudriere handles updates to the ports tree in a manner which any local changes would become an extra hassle as it wishes to maintain an exact duplicate, and so instead I will be adding games/minetest to the blacklist, keeping it out of the poudriere repo.  I will build it "manually" from ports and use gitup to keep a seperate /usr/ports tree updated without repairing (wiping out) my changes or at least not complaining when it does so.  This seems to be the most reasonable method to have local modified Makefiles for any relatively small subset of ports.  I thought I might periodically revisit this port for any improvements I can make to its Makefile which meant this blog post could become rather long over time and be re-published but have since decided against this.  Bug report for games/minetest to propose my revised Makefile.

Sunday, March 28, 2021

umix for TV volume control

I use a separate miccus bluetooth transmitter connected by a headphone cable and RCA adapter so that I can listen to my television or pc.  Presently I have adapted a bit of magic that modified my original setup which had two outputs reaching the transmitter but that had a side-effect (60-cycle?) hum and was a mild hassle in general.

Instead of connecting the output of the headphone jack of my 4k PiP-capable monitor to the transmitter, I attach it to the mic port on my PC.  The line out port of my motherboard remains attached to the transmitter by way of an RCA adapter as it had originally. The final piece of the puzzle is a very cool utility called umix which is a simple non-graphical audio mixer.

The manual page gives the necessary information on how to use this application, including what I used as the mute toggle key (x).
UMIX(1)                         Sound Utilities                        UMIX(1)

NAME
       umix - adjust soundcard mixers

SYNOPSIS
       umix [channel volume|left:right][R|P][+|-] device] [-r driver] [-f
       configpath] [-ghilqsv]

DESCRIPTION
       umix is a program for adjusting soundcard mixers.  With it you can
       adjust your soundcard volumes, balances and recording sources.  It can
       be used flexibly from the command-line, or from an interactive user
       interface.

       You can save your soundcard volumes to a file, and load them
       afterwards, for example when when booting the machine.

       Channel names are used to specify the volume you want to adjust. You
       can check what channels are supported with the -q option. Channel names
       can also be shortened if they have enough distinctive letters to
       identify the channel, eg. 'volume' can be shortened to 'vol'. If
       channel name is specified as all , all available channels are set to
       the specified value.

       For each channel specified, volume is the volume you want to set, with
       both left and right specified as the same, or in left:right format.

       You can also specify optional + or - after the volume for increasing or
       decreasing the volume for channel, with amount volume.  The optional
       R or P at the end of the channel argument sets the channel as a current
       recording source or normal play, respectively.  You can use both upper-
       and lowercase letters.

       You can slide volumes smoothly in steps from one point to another.  The
       format is following: startvol,endvol,steps,delay.  Here startvol is the
       volume you want to slide the volume from, and endvol is the volume you
       want to increase or decrease in steps to.  Optional parameter steps
       specifies the number of steps between the two volumes, and delay the
       delay between two steps. Default values for steps is 20, and 20ms for
       delay.  The optional + or - have no effect when sliding volumes.

       The delay can be between 0 and 5 seconds, specified in milliseconds.
       Maximum value for steps is the difference between the starting and
       destination volume, so that the minimum raise or decrease in one step
       is always 1.

       All volume settings are parsed the same, so you can use sliding in your
       config file too, you just have to edit the config manually.  For
       example the line

       pcm 0,100,25,50

       in your config file would slide the volume of 'pcm' from 0 to 100 in 25
       steps and with a 50 ms delay when loading settings.

       Umix needs read and write permissions to the mixer device. I suggest
       that you create a group for this and change permissions so that group
       has write and read access to the devices, then add necessary users to
       that group.

OPTIONS
       -q, --query
              Query and print all active channel volumes and stats from all
              available devices. Interactive UI is not started.

       -l, --load
              Load previously saved settings from configpath.  If configpath
              is specified as '-', settings are loaded from standard input.
              Clears the -i option.

       -s, --save
              Save current mixer settings to configpath.  If configpath is
              specified as '-', settings are printed to standard output.
              Clears the -i option.

       -f configpath, --file=configpath
              Specify the file used to read and save settings.  Defaults to
              /etc/umixrc.  Sets the -i option.

       -d device, --device=device
              Specify the device used. Defaults to /dev/mixer.  Sets the -i
              option.

       -r driver, --driver=driver
              Specify the driver used. Defaults to OSS.  Sets the -i option.

       -i, --interactive
              Start interactive user interface after processing non-
              interactive command-line options.

       -g, --globals
              Print current global options. This is useful for finding out
              what is the default device etc.

       -h, --help
              Display help and exit.

       -v, --version
              Display version information and exit.

EXAMPLES
       umix -q
              Prints all volumes of active channels and their stats.  The
              output should be self-explanatory.

       umix volume 100 bass 88 treble 80 pcm 94
              Sets the volume to 100, bass to 88, treble to 80 and PCM to 94.

       umix vol 100:80 syn 90:30
              Here channel names are shortened and stereo settings are used.
              Sets volume`s left to 100, right to 80 and synth`s left to 90
              and right to 30.

       umix bass 20- pcm 20:10+ ogain 40:45-
              Here volumes are incremented or decremented from their original
              values. Decreases bass by 20, increases PCM`s left by 20 and
              right by 10 and the last one decreases output gain`s left by 40
              and right by 45.

       umix mic R synth 20P line 10p-
              This sets the mic as a recording source, synth as normal play
              with volume 20 and line as normal play with volume decreased by
              10.

       umix pcm 0,60,30,25 vol 100,70 synth 50:50,25:50
              Here sliding is demonstrated. The first slides pcm from 0 to 60
              with 30 steps and a 25 ms delay, then slides vol from 100 to 70
              with default steps and delay and the last one slides synth from
              50:50 to 25:50.

       umix -f /some/path/umixrc -l
              Here the config path is specified as /some/path/umixrc and
              settings are loaded from that file.

       umix -d /dev/mixer2 -f /somepath/umsettings
              The device that is used for mixing is specified as /dev/mixer2,
              config path is set as /somepath/umsettings and the interactive
              user interface is automatically started, because.  -f and -d set
              the -i option.

NCURSES USER INTERFACE
       The (n)curses based user interface. Designed to be used from a console
       or x-terminal.

   USAGE
       On the left side is the channel menu, which consists of channel names,
       stats and volumes.  On the right side is the balance menu.  The
       currently chosen channel is indicated with highlighting its name and
       drawing arrows around the chosen menu.  You can move around with
       default vi/emacs/arrow keys.

       Moving up and down selects the current channel, moving left and right
       adjusts the volume or balance, depending on which menu you are in.  Tab
       toggles between volume and balance menus.

       If the channel does not support stereo mixing (it`s left and right
       values cannot differ), then a '|' at center of the balance is drawn.

   KEY BINDINGS
       j / ^n / arrow down
              Move down.

       k / ^p / arrow up
              Move up.

       h / ^b / arrow left
              Decrease volume / balance left.

       l / ^f / arrow right
              Increase volume / balance right.

       ] / .  Increase volume by fifth of maximum amount.

       [ / ,  Decrease volume by fifth of maximum amount.

       Tab    Toggle between volume and balance menus.

       Space  Toggle play / record source.

       L      Load settings.

       S      Save settings.

       f      Specify the config path. This presents a dialog in the lower
              border. If no string is given, the path remains unchanged.

       e      Enter channel volume manually for the current channel.  Same
              rules apply as with command-line channel settings, so you can
              set balances and recording sources too.

       n      Cycles through available mixer devices. You can see the
              currently active mixer and the total number of initialized
              mixers in the top border.

       m      Mutes all those channels that are not already mute. If pressed
              again, returns volumes back to the state before muting.

       x      Excludes the current channel. Same as m but only with the
              current channel.

       H      Displays the help.

       q      Exit the program.

       ^l     Refresh the screen.

CONFIG FILE
       The config consists of global options and mixer settings.  Global
       options come after the keyword [global].  Global options are read
       before loading any mixer settings or parsing command-line options.
       Global options are the defaults to use if no command-line options are
       given.

       Mixer settings come after the keyword [mixers].  The mixer device that
       settings are loaded for is specified with the keyword mixer.  The
       string after mixer= is the path of the mixer device. Then comes the
       settings for that mixer. These are parsed like command-line options.

       Comments and all other characters are ignored.

FILES
       /etc/umixrc
              The default configuration file.

       $HOME/.umixrc
              Used as the config file if exists.

BUGS
       When used with terminals that have columns below 35, the output is not
       optimal with the ncurses UI.

       If the number of channels is greater than number of lines on screen,
       you cannot adjust channels that exceed the number of lines in the
       ncurses UI (rare, but to be fixed soon)

AUTHOR
       Sakari Lehtonen <sakari@ionstream.fi>

                                  08 Jun 2002                          UMIX(1)

Now if I switch sources entirely on my monitor, or use the picture-in-picture function to watch a TV show (or hockey game) in the smaller window, I can hear both the TV and my PC if I so choose, as long as I set the audio source of my monitor properly such as to tell it to use the source port for the small picture as audio source.  This also allows me a much easier method to silence (or adjust the volume) of the television program while in a commercial break by use of the mixer application instead of needing to toggle it on the monitor itself which I might move slightly out of reach.  Additionally, I can easily mute all of my application sound when I choose to only view a TV program.

Tool without fanfare

Due to our fairly recent VCS change and impending portsnap retirement, it is somewhat surprising that gitup was released to seemingly very little or no fanfare.  It might be used to solve the issue of svn being replaced by git for obtaining source, and both portsnap and svn for maintaining one's local ports tree.  It also is apparently even smaller or less dependency encumbered than git@tiny which should be a rather large positive for the average consumer as well as being quite simple to configure and use.

Firstly, the configuration file provided with the port when installed might need to be updated or modified to suit your needs.

# $FreeBSD$
#
# Default configuration options for gitup.conf.
# github.com/freebsd/freebsd-ports
#
# ${repo} can be replaced by doc, ports and src. (*)
#
# https://git.freebsd.org/${repo}.git
# ssh://anongit@git.freebsd.org/${repo}.git
# (*) In subversion, base is used for FreeBSD src repository (src).
{
        "defaults" : {
                "host"                  : "github.com",
                "port"                  : "443",
                "verbosity"             : "1",
                "work_directory"        : "/var/db/gitup",
        },

        "ports" : {
                "repository"            : "/freebsd/freebsd-ports.git",
                "branch"                : "main",
                "target"                : "/usr/ports",
                "ignores"               : [
                        "distfiles",
                        "packages",
                ],
        },

        "quarterly" : {
                "host"                  : "git.freebsd.org",
                "repository"            : "/freebsd/freebsd-ports.git",
                "branch"                : "quarterly",
                "target"                : "/usr/ports",
                "ignores"               : [
                        "distfiles",
                        "packages",
                ],
        },

        "release" : {
                "repository"            : "/src.git",
                "branch"                : "releng/12.2",
                "target"                : "/usr/src",
                "ignores"               : [
                        "sys/arm64/conf",
                        "sys/i386/conf",
                        "sys/pc98/conf",
                        "sys/powerpc/conf",
                        "sys/riscv/conf",
                        "sys/sparc64/conf",
                ],
        },

        "stable" : {
                "repository"            : "/src.git",
                "branch"                : "stable/13",
                "target"                : "/usr/src",
                "ignores"               : [
                        "sys/arm64/conf",
                        "sys/i386/conf",
                        "sys/pc98/conf",
                        "sys/powerpc/conf",
                        "sys/riscv/conf",
                        "sys/sparc64/conf",
                ],
        },
}

This is because, as we can see above, the defined aliases are no longer appropriate.  The present pending release is 13.0, and current is now 14, while stable is also 13.x, so this should be an easy adjustment.

There does not seem to be an option to simply show what the configured sections are but if one tries to initiate gitup with a bit of nonsense, the message will tell you and so now we can see how the above configuration works.

gitup blargh
gitup:
Cannot find a matching section in the command line arguments.  These are the configured sections:
         * ports
         * quarterly
         * release
         * stable
         * current
: Invalid argument

The short manpage gives further insight and tells of how it can be used to repair a repo and other things.

NAME
     gitup – A minimalist, dependency-free program to clone/pull Git
     repositories.

SYNOPSIS
     gitup section [-ckrV] [-C configuration file] [-h commit checksum]
           [-t tag] [-u pack file] [-v verbosity] [-w commit checksum]

DESCRIPTION
     gitup is a minimalist, dependency-free program used to clone or
     synchronize a local copy of a Git repository.  It is not intended to be a
     full-featured replacement for the devel/git port, but rather, is intended
     to provide a convenient way for users to update FreeBSD source files
     without having to install devel/git (and all of its related dependencies)
     and without the substantial disk overhead that normally accompany local
     Git repositories.

     gitup currently only supports anonymous, encrypted transfers via the
     "Smart HTTP" protocol.

OPTIONS
     Configuration options are stored in /usr/local/etc/gitup.conf and are
     grouped into commonly used sections (additional custom sections can be
     added to this file).  The following command line options can be used to
     override the default and/or section values:

     -C          The location of the configuration file to use.

     -c          Force gitup to clone the repository.

     -h          The "have" commit checksum of the repository to use.  Only
                 needed when importing a pack file generated by the official
                 Git client.

     -k          Save a copy of the pack data.

     -r          Repair the local repository, replacing any files that are
                 missing or have been modified.

     -t          Fetch the commit referenced by the specified tag.

     -u          Skip the download of the pack data and use the specified file
                 instead.

     -v          How verbose the output should be (0 = no output, 1 = show
                 only names of the updated files, 2 = also show commands sent
                 to the server and additional debugging information).

     -V          Display the version number and exit.

     -w          The "want" commit checksum of the repository to retrieve.

FILES
     /usr/local/etc/gitup.conf  Default location of the gitup configuration
                                file.

     /var/db/gitup              Default location where gitup stores its lists
                                of known files.  The files stored here are
                                used during subsequent runs to reconstruct the
                                local repository state and confirm that the
                                local tree is intact.

CAVEATS
     Because gitup neither uses nor updates the .git directory, it is not a
     drop-in replacement for the official Git client.  gitup should only be
     used on repositories originally cloned with the official Git client if
     there is no intention to ever use the official Git client on that local
     repository again.

     To keep its footprint as small as possible, gitup does not retain pack
     files downloaded from the repository (unless explicitly instructed to do
     so) and does not use a saved pack file (unless explicitly instructed to
     do so).  gitup relies on the known remote files lists stored in
     /var/db/gitup and the current state of the local repository to
     reconstruct data that would normally be stored in the pack file.
     Discrepancies in the local repository will be flagged as errors and gitup
     will attempt to any restore any missing or modified files from the
     server, returning the local repository to a clean state.

     Extra care should be given when specifying a commit to pull as gitup only
     performs shallow clones and does not have access to a repository's full
     commit history.  If a commit is passed in via the -w command line
     argument and that commit exists on a different branch, the Git server
     will neither object nor inform gitup of the branch change and will send a
     pack file that will convert the local repository.  If the change of
     branches is intentional, the relevant section in
     /usr/local/etc/gitup.conf will need to be manually updated.

EXAMPLES
     Using the configuration options for commonly used repositories/branches
     stored in /usr/local/etc/gitup.conf, to clone/pull a copy of the most
     recent revision of stable/12:

           gitup stable

     To retrieve a copy of freebsd-ports at commit
     0123456789abcdef0123456789abcdef01234567:

           gitup ports -w 0123456789abcdef0123456789abcdef01234567

SEE ALSO
     gitup.conf(5)

AUTHORS
     John Mehr  is the author of gitup and this man page.


What I like most about this tool is that by default it avoids repairs to the ports tree where I may have made modifications to Makefiles or hidden patch files or any other similar adjustments.  This way I can keep a slightly modified local ports tree which I can use to build individual ports (such as minetest) which I then explicitly blacklist for the poudriere repo pkg builds.  This requires that any pkg built and part of the poudriere repo is removed or a pkg upgrade will still see it.

The initial run, regardless of whether the repair option is used or a clean fresh ports tree is constructed by it, offers no feedback from this tool that it is doing anything and the processes or file transfers involved take quite a bit of time. I did enable maximum verbosity but that did not help, I would strongly recommend to the author that a spinning cursor or some other indication that the tool is doing something be added so that we know that our configuration is correct and we know everything is okay.  I am fine with things taking time to function (in this case about 14 minutes), to produce results, but silence is a killer as it makes me wonder and may cause me to end a process which is less than a second away from finally doing something visible.  The level of verbosity does not affect the 14 minutes of silence, only the output that follows it.  If this is used as part of an unattended script, I would recommend watching for results once outside of the script to be certain it acts as it should before hiding everything, or you may never know if anything is wrong such as an error in the configuration file.

FYI:

When the branch gets changed, which it has twice recently, first it shifted to main, and now its back to master once more, you may end up with an error should you have verbosity enabled for that repo. If you use poudriere, the message may appear similar to below, simply change it to what you might find is used at github/freebsd.

# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd-ports.git
# Target: /usr/ports
# Have: 4010f7bbc03638d71781ce091bf40a0907fa12fe
# Want: 4010f7bbc03638d71781ce091bf40a0907fa12fe
# Branch: main
[00:00:00] Updating portstree "default" with git...fatal: couldn't find remote ref refs/heads/master

The solution for poudriere seems to be a bit overkill, but it is as follows below.

Delete the "default" ports tree:

poudriere ports -d

Re-create the "default" ports tree using branch=main by method=git. poudriere ports -c -B main -m git

Friday, March 12, 2021

Poudriere blacklist filter

Remember when I mentioned in a previous blog post how it seemed strange that the blacklist was not applied to the input file at the outset?  I have finally perfected a script which will do this with only minor adjustment to the poudriere commandline invocation.  Of course, file names, script names, may need adjustment to suit your environment or tastes.  Below is the relatively simple sh script named p-keg-deblack which does the work.

#!/bin/sh
rm /var/tmp/cleaned_blacklist 2>/dev/null
grep -v \# ~/Symbolic_Links/13amd64-blacklist | sort -d -u >> /var/tmp/cleaned_blacklist

diff $1 /var/tmp/cleaned_blacklist | grep \< |sed  -e 's/^<\ //g' -e 's/---//g' -e '1d' > ~/$1-deblack

echo $1-deblack

First, it removes any temporary files it had created, if none exist the error is silenced.  Your blacklist file for poudriere may include comment lines which would begin with # and so those are excluded by an inverted grep.  Since my build lists are all sorted in dictionary order with only unique lines, we treat the blacklist the same way, regardless of how it is actually organized, the output is placed in a temporary file.  Now we compare the build list with the cleaned blacklist.  Diff will place all the lines unique to each file preceded with a < or > depending upon which file, the first is on the left "<" and the second is on the right ">".  We want those lines which are only in the build list, so we grep all lines beginning with "<" then we remove "< " to prepare the list for poudriere.  The first line of the diff indicates where in the file that section begins, and there is another line "---" which we do not want.  We create a file with your input file name adding a suffix of -deblack.  When this script is used, all that poudriere will see is this filename with suffix we just created.

How do we use this script when we invoke poudriere?  This makes the process as unobtrusive as possible, we add one more word and two characters.  Normally we would do something like the following:

poudriere bulk -f installed-pkgs-Gross -j 13amd64 -J 2:16
However, to include the script we use the line below:
poudriere bulk -f `p-keg-deblack installed-pkgs-Gross` -j 13amd64 -J 2:16

Essential caveat: Use this script at your own risk, I make no promises.

Frequently viewed this week