|
| 1 | +TERMUX_PKG_HOMEPAGE=https://hnefatafl.org/ |
| 2 | +# It's suspected that the discord URL being in the description of packages makes the upstream developer happy |
| 3 | +# (speculatively, because it might increase their bug report coverage) |
| 4 | +# is something like that acceptable to Termux? |
| 5 | +TERMUX_PKG_DESCRIPTION="Copenhagen Hnefatafl client. Discord: https://discord.gg/h56CAHEBXd" |
| 6 | +TERMUX_PKG_LICENSE="AGPL-V3" |
| 7 | +TERMUX_PKG_MAINTAINER="@termux" |
| 8 | +TERMUX_PKG_VERSION="5.6.1-2" |
| 9 | +TERMUX_PKG_SRCURL="https://codeberg.org/dcampbell/hnefatafl/archive/v$TERMUX_PKG_VERSION.tar.gz" |
| 10 | +TERMUX_PKG_SHA256=ce9f494eea0a3e92360efa96cec6251c1fa7a011864096804d073f8560e15ea0 |
| 11 | +TERMUX_PKG_DEPENDS="alsa-lib, libc++, hicolor-icon-theme, libxi, libxcursor, libxrandr, hicolor-icon-theme, openssl" |
| 12 | +TERMUX_PKG_BUILD_IN_SRC=true |
| 13 | +TERMUX_PKG_AUTO_UPDATE=true |
| 14 | +TERMUX_PKG_HOSTBUILD=true |
| 15 | + |
| 16 | +_install_ubuntu_packages() { |
| 17 | + termux_download_ubuntu_packages "$@" |
| 18 | + |
| 19 | + export HOSTBUILD_ROOTFS="${TERMUX_PKG_HOSTBUILD_DIR}/ubuntu_packages" |
| 20 | + |
| 21 | + find "${HOSTBUILD_ROOTFS}" -type f -name '*.pc' | \ |
| 22 | + xargs -n 1 sed -i -e "s|/usr|${HOSTBUILD_ROOTFS}/usr|g" |
| 23 | + |
| 24 | + find "${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu" -xtype l \ |
| 25 | + -exec sh -c "ln -snvf /usr/lib/x86_64-linux-gnu/\$(readlink \$1) \$1" sh {} \; |
| 26 | + |
| 27 | + export LD_LIBRARY_PATH="${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu" |
| 28 | + LD_LIBRARY_PATH+=":${HOSTBUILD_ROOTFS}/usr/lib" |
| 29 | + |
| 30 | + export PKG_CONFIG_LIBDIR="${HOSTBUILD_ROOTFS}/usr/lib/x86_64-linux-gnu/pkgconfig" |
| 31 | + PKG_CONFIG_LIBDIR+=":/usr/lib/x86_64-linux-gnu/pkgconfig" |
| 32 | +} |
| 33 | + |
| 34 | +termux_step_host_build() { |
| 35 | + # build man page |
| 36 | + |
| 37 | + if [[ "$TERMUX_ON_DEVICE_BUILD" == "true" ]]; then |
| 38 | + return |
| 39 | + fi |
| 40 | + |
| 41 | + _install_ubuntu_packages libasound2-dev |
| 42 | + |
| 43 | + termux_setup_rust |
| 44 | + pushd "$TERMUX_PKG_SRCDIR" |
| 45 | + rm -f .cargo/config.toml |
| 46 | + cargo build \ |
| 47 | + --jobs "$TERMUX_PKG_MAKE_PROCESSES" \ |
| 48 | + --release |
| 49 | + target/release/hnefatafl-ai --man --username "" |
| 50 | + target/release/hnefatafl-client --man |
| 51 | + target/release/hnefatafl-server --man |
| 52 | + target/release/hnefatafl-server-full --man |
| 53 | + target/release/hnefatafl-text-protocol --man |
| 54 | + cp hnefatafl-ai.1 "$TERMUX_PKG_HOSTBUILD_DIR"/ |
| 55 | + cp hnefatafl-server.1 "$TERMUX_PKG_HOSTBUILD_DIR"/ |
| 56 | + cp hnefatafl-server-full.1 "$TERMUX_PKG_HOSTBUILD_DIR"/ |
| 57 | + cp hnefatafl-text-protocol.1 "$TERMUX_PKG_HOSTBUILD_DIR"/ |
| 58 | + cp hnefatafl-client.1 "$TERMUX_PKG_HOSTBUILD_DIR"/ |
| 59 | + popd |
| 60 | +} |
| 61 | + |
| 62 | +termux_step_pre_configure() { |
| 63 | + termux_setup_rust |
| 64 | + |
| 65 | + rm -f .cargo/config.toml |
| 66 | + |
| 67 | + : "${CARGO_HOME:=$HOME/.cargo}" |
| 68 | + export CARGO_HOME |
| 69 | + |
| 70 | + cargo vendor |
| 71 | + find ./vendor \ |
| 72 | + -mindepth 1 -maxdepth 1 -type d \ |
| 73 | + ! -wholename ./vendor/cpal \ |
| 74 | + ! -wholename ./vendor/smithay-client-toolkit \ |
| 75 | + ! -wholename ./vendor/smithay-client-toolkit-0.19.2 \ |
| 76 | + ! -wholename ./vendor/softbuffer \ |
| 77 | + ! -wholename ./vendor/wayland-cursor \ |
| 78 | + ! -wholename ./vendor/wgpu-hal \ |
| 79 | + ! -wholename ./vendor/winit \ |
| 80 | + ! -wholename ./vendor/x11rb-protocol \ |
| 81 | + ! -wholename ./vendor/xkbcommon-dl \ |
| 82 | + -exec rm -rf '{}' \; |
| 83 | + |
| 84 | + # currently, there is only one relevant version of "iced winit", but most likely, |
| 85 | + # if this winit fork ever changes, the version necessary for hnefatafl-copenhagen |
| 86 | + # will be connected to the version of hnefatafl-copenhagen, i.e. older versions of |
| 87 | + # hnefatafl-copenhagen will require this commit, but future versions of hnefatafl-copenhagen |
| 88 | + # could require a different commit. |
| 89 | + local _ICED_WINIT_COMMIT=2e28820207080f4499382df3a4fedb0da81562d3 |
| 90 | + git clone https://github.com/iced-rs/winit.git vendor/winit-iced |
| 91 | + git -C vendor/winit-iced checkout "$_ICED_WINIT_COMMIT" |
| 92 | + |
| 93 | + find vendor/{cpal,smithay-client-toolkit,smithay-client-toolkit-0.19.2,softbuffer,wgpu-hal,winit,winit-iced,x11rb-protocol,xkbcommon-dl} -type f | \ |
| 94 | + xargs -n 1 sed -i \ |
| 95 | + -e 's|target_os = "android"|target_os = "disabling_this_because_it_is_for_building_an_apk"|g' \ |
| 96 | + -e 's|target_os = "linux"|target_os = "android"|g' \ |
| 97 | + -e "s|libxkbcommon.so.0|libxkbcommon.so|g" \ |
| 98 | + -e "s|libxkbcommon-x11.so.0|libxkbcommon-x11.so|g" \ |
| 99 | + -e "s|libxcb.so.1|libxcb.so|g" \ |
| 100 | + -e "s|/tmp|$TERMUX_PREFIX/tmp|g" |
| 101 | + |
| 102 | + for crate in wayland-cursor softbuffer; do |
| 103 | + local patch="$TERMUX_PKG_BUILDER_DIR/$crate-no-shm.diff" |
| 104 | + local dir="vendor/$crate" |
| 105 | + echo "Applying patch: $patch" |
| 106 | + patch -p1 -d "$dir" < "${patch}" |
| 107 | + done |
| 108 | + |
| 109 | + local patch="$TERMUX_PKG_BUILDER_DIR/smithay-client-toolkit-0.19.2-no-shm.diff" |
| 110 | + local dir="vendor/smithay-client-toolkit-0.19.2" |
| 111 | + echo "Applying patch: $patch" |
| 112 | + patch -p1 -d "$dir" < "${patch}" |
| 113 | + |
| 114 | + local patch="$TERMUX_PKG_BUILDER_DIR/smithay-client-toolkit-0.20.0-no-shm.diff" |
| 115 | + local dir="vendor/smithay-client-toolkit" |
| 116 | + echo "Applying patch: $patch" |
| 117 | + patch -p1 -d "$dir" < "${patch}" |
| 118 | + |
| 119 | + echo "" >> Cargo.toml |
| 120 | + echo '[patch.crates-io]' >> Cargo.toml |
| 121 | + for crate in cpal smithay-client-toolkit softbuffer wayland-cursor wgpu-hal winit x11rb-protocol xkbcommon-dl; do |
| 122 | + echo "$crate = { path = \"./vendor/$crate\" }" >> Cargo.toml |
| 123 | + done |
| 124 | + echo "smithay-client-toolkit2 = { package = \"smithay-client-toolkit\", path = \"./vendor/smithay-client-toolkit-0.19.2\" }" >> Cargo.toml |
| 125 | + echo "" >> Cargo.toml |
| 126 | + echo '[patch."git+https://github.com/iced-rs/winit.git"]' >> Cargo.toml |
| 127 | + echo 'winit = { path = "./vendor/winit-iced" }' >> Cargo.toml |
| 128 | +} |
| 129 | + |
| 130 | +termux_step_make() { |
| 131 | + cargo build \ |
| 132 | + --jobs "$TERMUX_PKG_MAKE_PROCESSES" \ |
| 133 | + --target "$CARGO_TARGET_NAME" \ |
| 134 | + --release |
| 135 | + |
| 136 | + if [[ "$TERMUX_ON_DEVICE_BUILD" == "true" ]]; then |
| 137 | + target/"$CARGO_TARGET_NAME"/release/hnefatafl-ai --man --username "" |
| 138 | + target/"$CARGO_TARGET_NAME"/release/hnefatafl-client --man |
| 139 | + target/"$CARGO_TARGET_NAME"/release/hnefatafl-server --man |
| 140 | + target/"$CARGO_TARGET_NAME"/release/hnefatafl-server-full --man |
| 141 | + target/"$CARGO_TARGET_NAME"/release/hnefatafl-text-protocol --man |
| 142 | + else |
| 143 | + cp "$TERMUX_PKG_HOSTBUILD_DIR"/hnefatafl-ai.1 "$TERMUX_PKG_BUILDDIR"/ |
| 144 | + cp "$TERMUX_PKG_HOSTBUILD_DIR"/hnefatafl-server.1 "$TERMUX_PKG_BUILDDIR"/ |
| 145 | + cp "$TERMUX_PKG_HOSTBUILD_DIR"/hnefatafl-server-full.1 "$TERMUX_PKG_BUILDDIR"/ |
| 146 | + cp "$TERMUX_PKG_HOSTBUILD_DIR"/hnefatafl-text-protocol.1 "$TERMUX_PKG_BUILDDIR"/ |
| 147 | + cp "$TERMUX_PKG_HOSTBUILD_DIR"/hnefatafl-client.1 "$TERMUX_PKG_BUILDDIR"/ |
| 148 | + fi |
| 149 | +} |
| 150 | + |
| 151 | +termux_step_make_install() { |
| 152 | + install -Dm755 target/"$CARGO_TARGET_NAME"/release/hnefatafl-ai -t "$TERMUX_PREFIX"/bin |
| 153 | + install -Dm755 target/"$CARGO_TARGET_NAME"/release/hnefatafl-client -t "$TERMUX_PREFIX"/bin |
| 154 | + install -Dm755 target/"$CARGO_TARGET_NAME"/release/hnefatafl-server -t "$TERMUX_PREFIX"/bin |
| 155 | + install -Dm755 target/"$CARGO_TARGET_NAME"/release/hnefatafl-server-full -t "$TERMUX_PREFIX"/bin |
| 156 | + install -Dm755 target/"$CARGO_TARGET_NAME"/release/hnefatafl-text-protocol -t "$TERMUX_PREFIX"/bin |
| 157 | + install -Dm644 website/src/images/helmet.svg "$TERMUX_PREFIX"/share/icons/hicolor/scalable/apps/org.hnefatafl.hnefatafl_client.svg |
| 158 | + install -Dm644 hnefatafl-ai.1 "$TERMUX_PREFIX"/share/man/man1/hnefatafl-ai.1 |
| 159 | + install -Dm644 hnefatafl-client.1 "$TERMUX_PREFIX"/share/man/man1/hnefatafl-client.1 |
| 160 | + install -Dm644 hnefatafl-server.1 "$TERMUX_PREFIX"/share/man/man1/hnefatafl-server.1 |
| 161 | + install -Dm644 hnefatafl-server-full.1 "$TERMUX_PREFIX"/share/man/man1/hnefatafl-server-full.1 |
| 162 | + install -Dm644 hnefatafl-text-protocol.1 "$TERMUX_PREFIX"/share/man/man1/hnefatafl-text-protocol.1 |
| 163 | + install -Dm644 packages/hnefatafl-client.desktop "$TERMUX_PREFIX"/share/applications/hnefatafl-client.desktop |
| 164 | +} |
0 commit comments