Skip to content

Commit

Permalink
addpkg(x11/rnote): 0.11.0
Browse files Browse the repository at this point in the history
temporary commit, refactor build script
  • Loading branch information
TomJo2000 committed Sep 21, 2024
1 parent a029cc2 commit 3945e03
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
63 changes: 41 additions & 22 deletions x11-packages/rnote/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -49,19 +66,21 @@ 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."
local target
for target in 'rnote-cli' 'rnote'; do
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 "${target}" \
--release
done
}

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-cli" -t "$TERMUX_PREFIX/bin"
install -Dm755 "${TERMUX_PKG_SRCDIR}/target/$CARGO_TARGET_NAME/release/rnote" -t "$TERMUX_PREFIX/bin"
}
File renamed without changes.

0 comments on commit 3945e03

Please sign in to comment.