这是indexloc提供的服务,不要输入任何密码
Skip to content

addpkg(main/hledger-cli): 1.43.2 #25265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2025
Merged

addpkg(main/hledger-cli): 1.43.2 #25265

merged 2 commits into from
Jul 18, 2025

Conversation

erplsf
Copy link
Contributor

@erplsf erplsf commented Jul 5, 2025

Greetings,

This is a PR in an attempt to package hledger for Termux. I'm not very accustomed with the way that Haskell programs are built, and even less so with Termux-specific process. I've tried to follow the general steps where I could - added dependencies and other small tweaks.

I've decided to adjust common build steps make and make_install to also detect other naming convention for Cabal projects.

But the build fails now on compiling exe:alex and I'm out of luck. Any help or pointers are very welcome.

Here I also attach the full build log when running ./scripts/run-docker.sh ./build-package.sh -f -I hledger.

Ideally this closes #3803 and simonmichael/hledger#398.

build.log

This was referenced Jul 5, 2025
@erplsf erplsf changed the title Package hledger for termux addpkg(main/hledger): 1.43.2 Jul 5, 2025
@erplsf erplsf force-pushed the master branch 2 times, most recently from 62e4add to 235c3a6 Compare July 5, 2025 11:04
@erplsf erplsf requested a review from thunder-coding July 5, 2025 11:05
@robertkirkman
Copy link
Contributor

It says that the first error that will need to be solved is File permission check: FAILED (executable bit is set),

this can happen because of using chmod +x packages/hledger/build.sh. Try using these commands to resolve this, then the build in CI could proceed to other errors:

chmod -x packages/hledger/build.sh
git add packages/hledger/build.sh
git commit --amend
# try "downstream" first, later "origin" or whatever shows to the left of your fork repository
# URL in the output from the command "git remote -v"
git push -f downstream master

build.sh files in Termux are, I guess, special because they are not directly executed immediately; instead, they are sourced and their functions are run later at separate times.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 5, 2025

Thank you, I'll try that.

But while the build fails in CI, could you take a look at the local build result or you trust CI only?

@robertkirkman
Copy link
Contributor

I could soon sure, but also, I have requested for MrAdityaAlok to check if they know any way to build this software for Android and resolve the error, because they are very great with Haskell for Android and also they will know the best changes to make to cabal commands in termux_step_make.sh and termux_step_make_install.sh.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 5, 2025

I see other linting failures meanwhile, will get on to fixing them.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 5, 2025

got up to dlopen failed: "/data/data/com.termux/files/usr/lib/libpthread.so" is too small to be an ELF executable: only found 11 bytes error on x86_64 build locally.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 5, 2025

I've tried also to build the package for aarch64 without bundled in Cabal config (by overriding termux_step_make with just cabal build all). this gets me to a mysterious <no location info>: error: External interpreter terminated (255) when building brick-2.9.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 6, 2025

I get much further when reverting a config change to Cabal - so I think indeed, something got fixed for shellcheck but broken for all other packages.
I'll attach a build log in a bit, when the new run finishes.

@MrAdityaAlok
Copy link
Member

@erplsf #25273 should fix your issue.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 6, 2025 via email

@erplsf
Copy link
Contributor Author

erplsf commented Jul 6, 2025

@MrAdityaAlok Sadly it still fails on trying to build alex


Failed to build exe:alex from alex-3.5.3.0. The failure occurred during the
final install step.
Build log (
/home/builder/.cache/cabal/logs/ghc-9.12.2/alex-3.5.3.0-e-alex-d1443fbd9aa2cec73dd8a93fa45696bbad14c9c7e8868d2d41a42cbbf121a2bf.log
):
Configuring executable 'alex' for alex-3.5.3.0...
Preprocessing executable 'alex' for alex-3.5.3.0...
Building executable 'alex' for alex-3.5.3.0...
[ 1 of 19] Compiling DFS              ( src/DFS.hs, dist/build/alex/alex-tmp/DFS.o )
[ 2 of 19] Compiling Data.Ranged.Boundaries ( src/Data/Ranged/Boundaries.hs, dist/build/alex/alex-tmp/Data/Ranged/Boundaries.o )
[ 3 of 19] Compiling Data.Ranged.Ranges ( src/Data/Ranged/Ranges.hs, dist/build/alex/alex-tmp/Data/Ranged/Ranges.o )
[ 4 of 19] Compiling Data.Ranged.RangedSet ( src/Data/Ranged/RangedSet.hs, dist/build/alex/alex-tmp/Data/Ranged/RangedSet.o )
[ 5 of 19] Compiling Data.Ranged      ( src/Data/Ranged.hs, dist/build/alex/alex-tmp/Data/Ranged.o )
[ 6 of 19] Compiling Paths_alex       ( dist/build/alex/autogen/Paths_alex.hs, dist/build/alex/alex-tmp/Paths_alex.o )
[ 7 of 19] Compiling UTF8             ( src/UTF8.hs, dist/build/alex/alex-tmp/UTF8.o )
[ 8 of 19] Compiling CharSet          ( src/CharSet.hs, dist/build/alex/alex-tmp/CharSet.o )
[ 9 of 19] Compiling Util             ( src/Util.hs, dist/build/alex/alex-tmp/Util.o )
[10 of 19] Compiling AbsSyn           ( src/AbsSyn.hs, dist/build/alex/alex-tmp/AbsSyn.o )
[11 of 19] Compiling ParseMonad       ( src/ParseMonad.hs, dist/build/alex/alex-tmp/ParseMonad.o )
[12 of 19] Compiling Scan             ( src/Scan.hs, dist/build/alex/alex-tmp/Scan.o )
[13 of 19] Compiling Parser           ( src/Parser.hs, dist/build/alex/alex-tmp/Parser.o )
[14 of 19] Compiling Output           ( src/Output.hs, dist/build/alex/alex-tmp/Output.o )
[15 of 19] Compiling NFA              ( src/NFA.hs, dist/build/alex/alex-tmp/NFA.o )
[16 of 19] Compiling Info             ( src/Info.hs, dist/build/alex/alex-tmp/Info.o )
[17 of 19] Compiling DFAMin           ( src/DFAMin.hs, dist/build/alex/alex-tmp/DFAMin.o )
[18 of 19] Compiling DFA              ( src/DFA.hs, dist/build/alex/alex-tmp/DFA.o )
[19 of 19] Compiling Main             ( src/Main.hs, dist/build/alex/alex-tmp/Main.o )
[20 of 20] Linking dist/build/alex/alex
Installing executable alex in /home/builder/.local/state/cabal/store/ghc-9.12.2-inplace/incoming/new-32151/home/builder/.local/state/cabal/store/ghc-9.12.2-inplace/alex-3.5.3.0-e-alex-d1443fbd9aa2cec73dd8a93fa45696bbad14c9c7e8868d2d41a42cbbf121a2bf/bin
Warning: The directory
/home/builder/.local/state/cabal/store/ghc-9.12.2-inplace/incoming/new-32151/home/builder/.local/state/cabal/store/ghc-9.12.2-inplace/alex-3.5.3.0-e-alex-d1443fbd9aa2cec73dd8a93fa45696bbad14c9c7e8868d2d41a42cbbf121a2bf/bin
is not in the system search path.
/usr/bin/strip: Unable to recognise the format of the input file `/home/builder/.local/state/cabal/store/ghc-9.12.2-inplace/incoming/new-32151/home/builder/.local/state/cabal/store/ghc-9.12.2-inplace/alex-3.5.3.0-e-alex-d1443fbd9aa2cec73dd8a93fa45696bbad14c9c7e8868d2d41a42cbbf121a2bf/bin/alex'
Error: [Cabal-7125]
Failed to build exe:alex from alex-3.5.3.0 (which is required by exe:hledger-web from hledger-web-1.43.2). See the build log above for details.

EDIT: Sorry, I think I forgot to try a "clean build".

Copy link
Member

@MrAdityaAlok MrAdityaAlok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like you to split this package into three:

  • hledger (Cli)
  • hledger-ui (Ncurses interface)
  • hledger-web (Web interface)

This would reduce package sizes as well give user more choices. Also, this aligns with rest of the Linux distribution packaging (Arch, Fedora).

Use hackage archives for building.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 6, 2025

will do, thanks for reviewing.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 6, 2025

how would you suggest selecting what to build if upstream package contains multiple packages in one? by manually specifying cabal build hledger-cli?

@MrAdityaAlok
Copy link
Member

MrAdityaAlok commented Jul 6, 2025

how would you suggest selecting what to build if upstream package contains multiple packages in one? by manually specifying cabal build hledger-cli?

cabal build exe:hledger-cli

@robertkirkman
Copy link
Contributor

robertkirkman commented Jul 7, 2025

if we want we can drop work on the on-device build for now and accept the win that we already have - we can try to package and distribute it as a binary for now.

This is acceptable, since there is already a very large amount of preexisting packages that cannot be built on-device. However, if you find any easy way to fix the problem for on-device building, it is still good to apply it.

Ideally, all packages would be great if buildable fully on-device, and I would like to get close to that goal some day, but this challenge is very difficult and can take many years, so some new packages being added that cannot be built on-device doesn't really slow it down that much, relatively.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 7, 2025 via email

@robertkirkman
Copy link
Contributor

I started testing the aarch64 binary artifact a little bit, I have noticed some things that might be possible to tweak to polish the experience,

  • the command hledger demo 2 shows asciinema: callProcess: execvp: does not exist (No such file or directory), but pkg install asciinema resolves this. so, asciinema should be in TERMUX_PKG_DEPENDS of this package.
  • most distros name the package of this software "hledger" rather than "hledger-cli", so maybe the name of the folder should be changed here to "hledger" https://repology.org/project/hledger/versions

@erplsf
Copy link
Contributor Author

erplsf commented Jul 7, 2025

thanks! i assume you got the binary from the ci results?

@robertkirkman
Copy link
Contributor

thanks! i assume you got the binary from the ci results?

Correct

@MrAdityaAlok
Copy link
Member

Got this at the moment:

dlopen failed: cannot locate symbol "stg_upd_frame_info" referenced by
"/data/data/com.termux/files/home/.cabal/store/ghc-9.12.2-inplace/quote-quot-0.2.1.0-f00e68c33f055879f54c456f833b4501b64ee4bacfccebfd737ffe8b47b82052/lib/
libHSquote-quot-0.2.1.0-f00e68c33f055879f54c456f833b4501b64ee4bacfccebfd737ffe8b47b82052-ghc9.12.2.so
"...

[ 8 of 10] Compiling Data.Text.Builder.Linear.Char (
src/Data/Text/Builder/Linear/Char.hs,
dist/build/Data/Text/Builder/Linear/Char.o,
dist/build/Data/Text/Builder/Linear/Char.dyn_o )
Error: [Cabal-7125]
Failed to build text-builder-linear-0.1.3 (which is required by exe:hledger
from hledger-1.43.2). See the build log above for details.

"stg_upd_frame_info"
I have many times tried to solve this or even find what causes it, but never succeeded. It has occurred many a times during on device build.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 7, 2025 via email

@erplsf
Copy link
Contributor Author

erplsf commented Jul 8, 2025

copying over a response from there:

geekosaur
does Android's dlopen not allow referencing already-loaded objects? every Haskell program (compiled by ghc) has libHSrts linked into it
(typically you dlopen NULL to access symbols already loaded into the program)
(I know you used 9.12.2 but that shared object goes back at least to ghc 6.0)

@MrAdityaAlok
Copy link
Member

copying over a response from there:

geekosaur
does Android's dlopen not allow referencing already-loaded objects? every Haskell program (compiled by ghc) has libHSrts linked into it
(typically you dlopen NULL to access symbols already loaded into the program)
(I know you used 9.12.2 but that shared object goes back at least to ghc 6.0)

Maybe it has something do with this: android/ndk#201

@erplsf
Copy link
Contributor Author

erplsf commented Jul 9, 2025

@MrAdityaAlok let's get this reviewed as change without on-device build - I'm making a pause on it now, as I won't have time to debug on-device builds anymore soon, so I want users to at least get the prebuilt version ready to use.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 14, 2025

@robertkirkman and other folks (as @MrAdityaAlok is busy) - can we get this reviewed properly to be merged with what we have?

@robertkirkman
Copy link
Contributor

I can merge the current version if @MrAdityaAlok approves of this, but it was working for basic commands when I tested the cross-compiled version, so it should be acceptable!

@MrAdityaAlok
Copy link
Member

Sorry! For being late. I am currently busy with my semester exams.

@erplsf Split non-hledger changes to different commit and also squash the commits. And what is the need for removing CONFIG for on device build? Did it cause any error? I added it to seperate from the user's config.
Everything else looks good.

@robertkirkman would you please merge the PR #24952? I am currently away from my system.

@robertkirkman
Copy link
Contributor

I am confused about what I should do, on my screen, the PR that shows on that number looks like it has already been merged?

image

@MrAdityaAlok
Copy link
Member

I am confused about what I should do, on my screen, the PR that shows on that number looks like it has already been merged?

image

I'm really sorry!! It was #25273

@erplsf
Copy link
Contributor Author

erplsf commented Jul 17, 2025

And what is the need for removing CONFIG for on device build? Did it cause any error? I added it to seperate from the user's config.

trying to use --config=$TERMUX_CABAL_CONFIG for both regular and on-device builds, breaks on-device, because in setup/configure scripts we don't generate (and write) the $CABAL_CONFIG_FILE. so the variable expands to empty string and cabal tries to use nothing as a config. what I did to solve it is a crude workaround, just to try to get on-device builds working. if you want, I can revert it and we'll handle on-device builds some other day, so this is easier to review.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 17, 2025

@MrAdityaAlok I've split my commits in three parts:

  1. add support for build scripts to detect more kinds of cabal projects
  2. add the package itself
  3. (optionally) proposed fixes for on-device builds - this doesn't get the package built on device, only changes things so we can try building packages on device, because without them, the build errors out early without even getting to cabal build phase.

EDIT: I'm fine with dropping the last commit.

@erplsf erplsf requested a review from robertkirkman July 17, 2025 10:46
@@ -63,9 +63,16 @@ termux_step_configure_cabal() {
AVOID_GNULIB+=" gl_cv_header_working_fcntl_h=yes"
AVOID_GNULIB+=" gl_cv_C_locale_sans_EILSEQ=yes"

if [[ "$TERMUX_ON_DEVICE_BUILD" == false ]]; then
CONFIG="--config=$TERMUX_CABAL_CONFIG"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think on-device building support for Haskell should be fixed in scripts/build/setup/termux_setup_cabal.sh because that's where TERMUX_CABAL_CONFIG is only being set inside a block that has if [[ "${TERMUX_ON_DEVICE_BUILD}" == "false" ]].

That should probably be rewritten in a way that makes it so that TERMUX_CABAL_CONFIG exists while TERMUX_ON_DEVICE_BUILD=true, right?

This is one of the things that made me assume that on-device building with GHC wasn't really ready yet.

@MrAdityaAlok
Copy link
Member

@erplsf Drop the last comment. I'll work on making on-device build work in some other PR.

@erplsf
Copy link
Contributor Author

erplsf commented Jul 18, 2025

@MrAdityaAlok done.

@MrAdityaAlok
Copy link
Member

@MrAdityaAlok done.

Thanks!

@MrAdityaAlok MrAdityaAlok merged commit 7b58288 into termux:master Jul 18, 2025
11 checks passed
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.

Hledger
5 participants