Skip to content

Conversation

@IntinteDAO
Copy link
Contributor

Please test @robertkirkman

@robertkirkman
Copy link
Member

@IntinteDAO I am able to cross-compile this without using the tur-on-device folder by doing this:

TERMUX_PKG_HOMEPAGE=https://xmoto.tuxfamily.org/
TERMUX_PKG_DESCRIPTION="A challenging 2D motocross platform game"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="0.6.3"
TERMUX_PKG_SRCURL=https://github.com/xmoto/xmoto/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=64cb29934660456ec82cebdaa0d3d273a862e10760e8ee80443928d317242484
TERMUX_PKG_DEPENDS="libx11, libjpeg-turbo, libpng, lua54, sdl2, sdl2-mixer, sdl2-net, libcurl, bzip2, libxdg-basedir, sdl2-ttf, glu, game-music-emu, libwavpack"
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_HOSTBUILD=true

# Function to obtain the .deb URL
obtain_deb_url() {
	local url attempt retries wait PAGE deb_url
	url="https://packages.ubuntu.com/noble/amd64/$1/download"
	retries=50
	wait=50
	>&2 echo "url: $url"
	for ((attempt=1; attempt<=retries; attempt++)); do
		PAGE="$(curl -s "$url")"
		deb_url="$(grep -oE 'https?://.*\.deb' <<< "$PAGE" | head -n1)"
		if [[ -n "$deb_url" ]]; then
				echo "$deb_url"
				return 0
		else
			>&2 echo "Attempt $attempt: Failed to obtain deb URL. Retrying in $wait seconds..."
		fi
		sleep "$wait"
	done
	termux_error_exit "Failed to obtain URL after $retries attempts."
}

_install_ubuntu_packages() {
	# install Ubuntu packages, like in the aosp-libs build.sh
	export HOSTBUILD_ROOTFS="${TERMUX_PKG_HOSTBUILD_DIR}/ubuntu_packages"
	mkdir -p "${HOSTBUILD_ROOTFS}"
	local URL DEB_NAME DEB_LIST
	DEB_LIST="$@"
	for i in $DEB_LIST; do
		echo "deb: $i"
		URL="$(obtain_deb_url "$i")"
		DEB_NAME="${URL##*/}"
		termux_download "$URL" "${TERMUX_PKG_CACHEDIR}/${DEB_NAME}" SKIP_CHECKSUM
		mkdir -p "${TERMUX_PKG_TMPDIR}/${DEB_NAME}"
		ar x "${TERMUX_PKG_CACHEDIR}/${DEB_NAME}" --output="${TERMUX_PKG_TMPDIR}/${DEB_NAME}"
		tar xf "${TERMUX_PKG_TMPDIR}/${DEB_NAME}"/data.tar.* \
			-C "${HOSTBUILD_ROOTFS}"
	done
}

_load_ubuntu_packages() {
	export HOSTBUILD_ROOTFS="${TERMUX_PKG_HOSTBUILD_DIR}/ubuntu_packages"
	export LD_LIBRARY_PATH="${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu"
	LD_LIBRARY_PATH+=":${HOSTBUILD_ROOTFS}/usr/lib"
	LD_LIBRARY_PATH+=":${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu/pulseaudio"
	export PATH="${HOSTBUILD_ROOTFS}/usr/games:$PATH"
}

termux_step_host_build() {
	if [[ "$TERMUX_ON_DEVICE_BUILD" == "true" ]]; then
		return
	fi

	_install_ubuntu_packages \
		fonts-arphic-bkai00mp \
		fonts-dejavu-core \
		fonts-dejavu-mono \
		libasyncns0 \
		libccd2 \
		libchipmunk7 \
		libdecor-0-0 \
		libdecor-0-plugin-1-gtk \
		libflac12t64 \
		libfluidsynth3 \
		libinstpatch-1.0-2 \
		libjack-jackd2-0 \
		libmodplug1 \
		libmp3lame0 \
		libmpg123-0t64 \
		libode8t64 \
		libogg0 \
		libopus0 \
		libopusfile0 \
		libpipewire-0.3-0t64 \
		libpipewire-0.3-common \
		libpulse0 \
		libsamplerate0 \
		libsdl2-2.0-0 \
		libsdl2-mixer-2.0-0 \
		libsdl2-net-2.0-0 \
		libsdl2-ttf-2.0-0 \
		libsndfile1 \
		libspa-0.2-modules \
		libvorbis0a \
		libvorbisenc2 \
		libvorbisfile3 \
		libwebrtc-audio-processing1 \
		libxdg-basedir1 \
		libxss1 \
		timgm6mb-soundfont \
		xmoto \
		xmoto-data
}

termux_step_pre_configure() {
	if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then
		_load_ubuntu_packages
	fi
}

this prevents the cross-compiling error and the resulting xmoto Termux package still works properly on my device when I test it.

however, understandably, as you can see, this is one of those kinds of softwares which requires a big mess of weird stuff to technically cross-compile properly.

Since you would like this to be in TUR, I guess you can decide whether you prefer to build in tur-on-device, or cross-compile using my method.

@IntinteDAO
Copy link
Contributor Author

@IntinteDAO I am able to cross-compile this without using the tur-on-device folder by doing this:

TERMUX_PKG_HOMEPAGE=https://xmoto.tuxfamily.org/
TERMUX_PKG_DESCRIPTION="A challenging 2D motocross platform game"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="0.6.3"
TERMUX_PKG_SRCURL=https://github.com/xmoto/xmoto/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=64cb29934660456ec82cebdaa0d3d273a862e10760e8ee80443928d317242484
TERMUX_PKG_DEPENDS="libx11, libjpeg-turbo, libpng, lua54, sdl2, sdl2-mixer, sdl2-net, libcurl, bzip2, libxdg-basedir, sdl2-ttf, glu, game-music-emu, libwavpack"
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_HOSTBUILD=true

# Function to obtain the .deb URL
obtain_deb_url() {
	local url attempt retries wait PAGE deb_url
	url="https://packages.ubuntu.com/noble/amd64/$1/download"
	retries=50
	wait=50
	>&2 echo "url: $url"
	for ((attempt=1; attempt<=retries; attempt++)); do
		PAGE="$(curl -s "$url")"
		deb_url="$(grep -oE 'https?://.*\.deb' <<< "$PAGE" | head -n1)"
		if [[ -n "$deb_url" ]]; then
				echo "$deb_url"
				return 0
		else
			>&2 echo "Attempt $attempt: Failed to obtain deb URL. Retrying in $wait seconds..."
		fi
		sleep "$wait"
	done
	termux_error_exit "Failed to obtain URL after $retries attempts."
}

_install_ubuntu_packages() {
	# install Ubuntu packages, like in the aosp-libs build.sh
	export HOSTBUILD_ROOTFS="${TERMUX_PKG_HOSTBUILD_DIR}/ubuntu_packages"
	mkdir -p "${HOSTBUILD_ROOTFS}"
	local URL DEB_NAME DEB_LIST
	DEB_LIST="$@"
	for i in $DEB_LIST; do
		echo "deb: $i"
		URL="$(obtain_deb_url "$i")"
		DEB_NAME="${URL##*/}"
		termux_download "$URL" "${TERMUX_PKG_CACHEDIR}/${DEB_NAME}" SKIP_CHECKSUM
		mkdir -p "${TERMUX_PKG_TMPDIR}/${DEB_NAME}"
		ar x "${TERMUX_PKG_CACHEDIR}/${DEB_NAME}" --output="${TERMUX_PKG_TMPDIR}/${DEB_NAME}"
		tar xf "${TERMUX_PKG_TMPDIR}/${DEB_NAME}"/data.tar.* \
			-C "${HOSTBUILD_ROOTFS}"
	done
}

_load_ubuntu_packages() {
	export HOSTBUILD_ROOTFS="${TERMUX_PKG_HOSTBUILD_DIR}/ubuntu_packages"
	export LD_LIBRARY_PATH="${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu"
	LD_LIBRARY_PATH+=":${HOSTBUILD_ROOTFS}/usr/lib"
	LD_LIBRARY_PATH+=":${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu/pulseaudio"
	export PATH="${HOSTBUILD_ROOTFS}/usr/games:$PATH"
}

termux_step_host_build() {
	if [[ "$TERMUX_ON_DEVICE_BUILD" == "true" ]]; then
		return
	fi

	_install_ubuntu_packages \
		fonts-arphic-bkai00mp \
		fonts-dejavu-core \
		fonts-dejavu-mono \
		libasyncns0 \
		libccd2 \
		libchipmunk7 \
		libdecor-0-0 \
		libdecor-0-plugin-1-gtk \
		libflac12t64 \
		libfluidsynth3 \
		libinstpatch-1.0-2 \
		libjack-jackd2-0 \
		libmodplug1 \
		libmp3lame0 \
		libmpg123-0t64 \
		libode8t64 \
		libogg0 \
		libopus0 \
		libopusfile0 \
		libpipewire-0.3-0t64 \
		libpipewire-0.3-common \
		libpulse0 \
		libsamplerate0 \
		libsdl2-2.0-0 \
		libsdl2-mixer-2.0-0 \
		libsdl2-net-2.0-0 \
		libsdl2-ttf-2.0-0 \
		libsndfile1 \
		libspa-0.2-modules \
		libvorbis0a \
		libvorbisenc2 \
		libvorbisfile3 \
		libwebrtc-audio-processing1 \
		libxdg-basedir1 \
		libxss1 \
		timgm6mb-soundfont \
		xmoto \
		xmoto-data
}

termux_step_pre_configure() {
	if [[ "$TERMUX_ON_DEVICE_BUILD" == "false" ]]; then
		_load_ubuntu_packages
	fi
}

this prevents the cross-compiling error and the resulting xmoto Termux package still works properly on my device when I test it.

however, understandably, as you can see, this is one of those kinds of softwares which requires a big mess of weird stuff to technically cross-compile properly.

Since you would like this to be in TUR, I guess you can decide whether you prefer to build in tur-on-device, or cross-compile using my method.

Sorry for not replying, but Github broke something and I don't know who is writing in my threads, and I noticed it by accident.

As for Xmoto, I would prefer your version if possible, but what I would like is for the package to be moved to Termux-Packages (if possible). TUR currently seems to be the best for games, but if the developers want to move the code to the main branch, that's fine.

I wonder if your version of build.sh would be accepted by termux-packages or not.

Anyway, good job, I don't understand much when I look at it, but how it works... :D

@robertkirkman
Copy link
Member

robertkirkman commented Nov 3, 2025

As for Xmoto, I would prefer your version if possible, but what I would like is for the package to be moved to Termux-Packages (if possible). TUR currently seems to be the best for games, but if the developers want to move the code to the main branch, that's fine.

Main repository can also have games, TUR repository seems to mainly have four kinds of packages:

  • packages that are not very popular and not very many people need them (like openjdk-11)
  • packages that have too may bugs and which don't work very well and nobody knows how to fix them yet (like pacutils)
  • packages that are too difficult to cross-compile and must be compiled on-device (tur-on-device folder)
  • packages which are related to pentesting so are not allowed in the official repository (tur-hacking folder)

Thank you for making the packages of these games, because I think examples of game ports are very important for Termux (for one reason because they are, all at once, valuable tech demos and integration tests and benchmarks of the graphics and input capabilities of Termux), if you want then you can make PRs for the games to the main repository but, like I have mentioned in some places, I don't have time to maintain the games much myself but I try to help with them when I can

I wonder if your version of build.sh would be accepted by termux-packages or not.

you can copy any of my code and submit it to the main repository and if you did then I would approve it, but I'm not sure if I have time to submit it myself right now since I am prioritizing other more popular packages, if you wait a while then I might eventually

Sorry for not replying, but Github broke something and I don't know who is writing in my threads, and I noticed it by accident.

that's ok, if you check your other PRs here then you can see my other new comments in them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants