From d4b97ba153d319019241ade993d58e8d7c7bf178 Mon Sep 17 00:00:00 2001 From: TomIO Date: Sat, 21 Sep 2024 01:44:53 +0200 Subject: [PATCH] addpkg(x11/rnote): 0.11.0 temporary commit, refactor build script --- x11-packages/rnote/build.sh | 59 ++++++++++++------- ...crate-patch.diff => gettext-rs-crate.diff} | 0 2 files changed, 37 insertions(+), 22 deletions(-) rename x11-packages/rnote/{gettext-rs-crate-patch.diff => gettext-rs-crate.diff} (100%) diff --git a/x11-packages/rnote/build.sh b/x11-packages/rnote/build.sh index 005d249347c6e10..b10132e09c3c1e8 100644 --- a/x11-packages/rnote/build.sh +++ b/x11-packages/rnote/build.sh @@ -8,25 +8,42 @@ TERMUX_PKG_SHA256=b133d4331963d3c09d3a7477f60fc4c5072471dcbf459379a593ca1724164a TERMUX_PKG_AUTO_UPDATE=true TERMUX_PKG_DEPENDS="gdk-pixbuf, gettext, glib, graphene, gtk4, hicolor-icon-theme, libadwaita, libcairo, pipewire, pango, poppler" TERMUX_PKG_BUILD_DEPENDS="libiconv" +TERMUX_PKG_PYTHON_BUILD_DEPS="toml2json" __fetch_gettext_rs() { - # This version is relative to gettext-sys provided by the gettext-rs crate - local _version="0.21.4" - local _url="https://github.com/gettext-rs/gettext-rs/archive/refs/tags/gettext-sys-$_version.tar.gz" - local _path="$TERMUX_PKG_CACHEDIR/gettext-v$_version.tar.gz" - termux_download "$_url" "$_path" SKIP_CHECKSUM - tar xf "$_path" -C "$TERMUX_PKG_SRCDIR" - mv "gettext-rs-gettext-sys-$_version" "gettext-source" + # This version is relative to gettext-sys provided by the gettext-rs crate + local crate_version + crate_version="$(curl -s https://crates.io/api/v1/crates/gettext-sys | jq --raw-output '.crate.max_stable_version')" + grep -qP '\d+\.\d+\.\d+' <<< "$crate_version" || { + termux_error_exit "Unable to fetch latest version for \`gettext-sys\` crate" + } + local -a crate=( + "https://github.com/gettext-rs/gettext-rs/archive/refs/tags/gettext-sys-$crate_version.tar.gz" # Upstream URL + "$TERMUX_PKG_CACHEDIR/gettext-v$crate_version.tar.gz" # Local save path + '211773408ab61880b94a0ea680785fc21fad307cd42594d547cf5a056627fcda' # SHA256 checksum + ) + local gettext_version + gettext_version="$(. "$TERMUX_SCRIPTDIR/packages/gettext/build.sh"; echo ${TERMUX_PKG_VERSION})" # Fetch latest and greatest gettext from upstream and place it inside gettext-source/gettext-sys - local _upstream_source_version="0.22.5" - wget "https://mirrors.kernel.org/gnu/gettext/gettext-${_upstream_source_version}.tar.xz" -P "$TERMUX_PKG_SRCDIR/gettext-source/gettext-sys" + local -a upstream=( + "$(. "$TERMUX_SCRIPTDIR/packages/gettext/build.sh"; echo ${TERMUX_PKG_SRCURL})" # Upstream URL (from gettext's build script) + "$TERMUX_PKG_SRCDIR/gettext-source/gettext-sys/gettext-${gettext_version}.tar.xz" # Local save path + "$(. "$TERMUX_SCRIPTDIR/packages/gettext/build.sh"; echo ${TERMUX_PKG_SHA256})" # SHA256 checksum (from gettext's build script) + ) + + termux_download "${crate[@]}" + + tar xf "${crate[1]}" -C "$TERMUX_PKG_SRCDIR" + mv "gettext-rs-gettext-sys-$crate_version" "gettext-source" + + termux_download "${upstream[@]}" } __patch_gettext_rs() { - # Patch gettext-rs crate to use a newer gettext version because the old one doesn't compile properly with clang - patch -p1 -d "$TERMUX_PKG_SRCDIR/gettext-source" < "$TERMUX_PKG_BUILDER_DIR"/gettext-rs-crate-patch.diff + # Patch gettext-rs crate to use a newer gettext version because the old one doesn't compile properly with clang + patch -p1 -d "$TERMUX_PKG_SRCDIR/gettext-source" -i "$TERMUX_PKG_BUILDER_DIR"/gettext-rs-crate.diff } termux_step_pre_configure() { @@ -49,19 +66,17 @@ termux_step_pre_configure() { } termux_step_make() { - termux_setup_rust - - cd "${TERMUX_PKG_SRCDIR}" + termux_setup_rust - RUSTFLAGS="-C link-arg=-Wl,-rpath=${TERMUX_PREFIX}/lib -C link-arg=-L${TERMUX_PREFIX}/lib -C link-arg=-liconv" \ - cargo build \ - --jobs "${TERMUX_PKG_MAKE_PROCESSES}" \ - --target "${CARGO_TARGET_NAME}" \ - --package rnote \ - --release + cd "${TERMUX_PKG_SRCDIR}" || termux_error_exit "Failed to enter source directory, aborting build." + RUSTFLAGS="-C link-arg=-Wl,-rpath=${TERMUX_PREFIX}/lib -C link-arg=-L${TERMUX_PREFIX}/lib -C link-arg=-liconv" \ + cargo build \ + --jobs "${TERMUX_PKG_MAKE_PROCESSES}" \ + --target "${CARGO_TARGET_NAME}" \ + --package rnote \ + --release } termux_step_post_make_install() { - cd "${TERMUX_PKG_SRCDIR}" - install -Dm755 "target/$CARGO_TARGET_NAME/release/rnote" -t "$TERMUX_PREFIX/bin" + install -Dm755 "${TERMUX_PKG_SRCDIR}/target/$CARGO_TARGET_NAME/release/rnote" -t "$TERMUX_PREFIX/bin" } diff --git a/x11-packages/rnote/gettext-rs-crate-patch.diff b/x11-packages/rnote/gettext-rs-crate.diff similarity index 100% rename from x11-packages/rnote/gettext-rs-crate-patch.diff rename to x11-packages/rnote/gettext-rs-crate.diff