Skip to content
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

Allow to build packages on device #4149

Merged
2 commits merged into from
Aug 8, 2019
Merged

Allow to build packages on device #4149

2 commits merged into from
Aug 8, 2019

Conversation

ghost
Copy link

@ghost ghost commented Aug 6, 2019

Set of compatibility patches that makes our build system partially usable in Termux.

Related issue: #1756

Proof of concept:
asciicast


Behaviour changes for all builds:

  • Now will be stripped binaries located only in bin, lib or libexec.

  • When build-package.sh is called recursively, it won't pass TERMUX_ARCH with command line argument but will do this through exported environment variable.


Packages that delete stuff from TERMUX_PREFIX in build process. If for some packages that behaviour is acceptable, the others may delete user configuration files and critical runtime libraries.

These packages have stubs in their build.sh to prevent building on device. E.g. trying to build perl will result in following:

$ ./build-package.sh -f perl
termux - building perl for arch aarch64...
Downloading http://www.cpan.org/src/5.0/perl-5.30.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 17.0M  100 17.0M    0     0  9985k      0  0:00:01  0:00:01 --:--:-- 9985k
Downloading https://github.com/arsv/perl-cross/releases/download/1.3/perl-cross-1.3.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   611    0   611    0     0   1486      0 --:--:-- --:--:-- --:--:--  1486
100  103k  100  103k    0     0  60354      0  0:00:01  0:00:01 --:--:-- 79442
ERROR: Package 'perl' is not safe for on-device builds.
  • aapt
  • apache2
  • apt
  • boost
  • busybox
  • dialog
  • ecj
  • emacs
  • espeak
  • fzf
  • gawk
  • gcal
  • git
  • golang
  • jsoncpp
  • ldc
  • libbz2
  • librsync
  • libtalloc
  • libunwind
  • libvpx
  • mariadb
  • mpd
  • ncurses
  • nginx
  • openjpeg
  • openssh
  • openssl
  • pastebinit
  • perl
  • picolisp
  • pkg-config
  • postgresql
  • privoxy
  • proxychains-ng
  • radare2
  • texlive-tlmgr
  • vim
  • vim-python
  • xvidcore
  • zsh

@ghost ghost added the WIP Work in progress, do not close the issue (PR) label Aug 6, 2019
@ghost ghost mentioned this pull request Aug 6, 2019
@ghost ghost self-assigned this Aug 6, 2019
@ghost ghost force-pushed the termux-self-hosting branch 16 times, most recently from bd9fed1 to c94d57d Compare August 6, 2019 22:47
@finagolfin
Copy link
Member

Wow, great work, looking forward to trying this out. 😄

Any input on this old CMake issue also, #151? I can look into that and try submitting a patch to change it, if @fornwall and the Termux devs agree to change it.

I'll also test out this pull and help get it done.

@ghost ghost force-pushed the termux-self-hosting branch from 7b4bcc4 to 63441cc Compare August 6, 2019 23:19

CMAKE_ADDITIONAL_ARGS+=("-DCMAKE_CROSSCOMPILING=True")
CMAKE_ADDITIONAL_ARGS+=("-DCMAKE_LINKER=$TERMUX_STANDALONE_TOOLCHAIN/bin/$LD $LDFLAGS")
CMAKE_ADDITIONAL_ARGS+=("-DCMAKE_SYSTEM_NAME=Android")
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this ties into the issue I raised with #151, most packages that use this will likely require setting this on-device too.

Copy link
Author

@ghost ghost Aug 7, 2019

Choose a reason for hiding this comment

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

-DCMAKE_SYSTEM_NAME=Android seems require option for standalone toolchain.

File ./share/cmake-3.14/Modules/Platform/Android-Determine.cmake:

if(NOT IS_DIRECTORY "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}")
    message(FATAL_ERROR
      "Android: The standalone toolchain directory specified by CMAKE_ANDROID_STANDALONE_TOOLCHAIN:\n"
      "  ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}\n"
      "does not exist."
      )
...
  if(NOT EXISTS "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h")
    message(FATAL_ERROR
      "Android: The standalone toolchain directory specified by CMAKE_ANDROID_STANDALONE_TOOLCHAIN:\n"
      "  ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}\n"
      "does not contain a sysroot with a known layout.  The file:\n"
      "  ${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h\n"
      "does not exist."
      )

So having CMAKE_SYSTEM_NAME=Android on device will require patching CMake.

Copy link
Member

Choose a reason for hiding this comment

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

OK, someone mentioned that on that issue a couple years ago. I'm already proposing patching CMake to make sure CMake sets that variable to Android on Termux, I will look into what else is necessary, such as modifying that file you quote also.

Once that's done, this won't need to be repeated for the on-device build. I just want to know from you and @fornwall that you'd accept a CMake patch to change that, as Fredrik seemed to want it a couple years ago, before I look into submitting a pull for CMake here.

You mentioned earlier that some packages aren't building with the on-device clang, some of those could be because this CMake variable is not set on-device.

@ghost ghost force-pushed the termux-self-hosting branch 7 times, most recently from 8e05033 to f0c26a2 Compare August 7, 2019 15:31
@ghost ghost force-pushed the termux-self-hosting branch 5 times, most recently from cc33204 to e7f818e Compare August 7, 2019 23:24
@ghost ghost force-pushed the termux-self-hosting branch from 1a58d83 to 50e0efd Compare August 8, 2019 00:18
@finagolfin
Copy link
Member

Thanks for all the work on this, I will try this pull out in a fresh Termux install. Regarding all those packages that delete files, I looked at some of them and they mostly seem to delete files that were probably installed by a previous version of that same package, before updating to the new ones.

There's two ways I see to handle this:

  • Tell the dev to backup any files he wants in $TERMUX_PREFIX, as a newly built package may delete his config files or other changes.
  • Put in some way to deal with merging the old files with the new ones, possibly on a package-by-package basis and by checking for the new $TERMUX_ON_DEVICE_BUILD variable. We could push this for later and simply mass-label all those packages as non-buildable on device for now, and I can slowly fix them to work on-device over time.

Let me know what you think.

@ghost ghost force-pushed the termux-self-hosting branch 2 times, most recently from d5b59f7 to 8014bd0 Compare August 8, 2019 00:55
@ghost
Copy link
Author

ghost commented Aug 8, 2019

For now these packages can be just excluded from on-device build. If one of these packages is a dependency, it can be installed with apt and build-package.sh will skip it.

@ghost ghost force-pushed the termux-self-hosting branch from 8014bd0 to 4fa1f16 Compare August 8, 2019 01:07
@ghost ghost force-pushed the termux-self-hosting branch 5 times, most recently from f7d4f9a to 7d5d8f5 Compare August 8, 2019 12:33
@ghost ghost removed the WIP Work in progress, do not close the issue (PR) label Aug 8, 2019
@ghost ghost force-pushed the termux-self-hosting branch 2 times, most recently from ed7a0da to b81e4f4 Compare August 8, 2019 12:49
Leonid Plyushch added 2 commits August 8, 2019 16:17
Partial compatibility for on-device builds.

There is no guarantee that it will be possible to build all available
packages and built packages will have same reliability that cross-compiled
but should solve "self-hosting" problems as much as possible.
@ghost ghost force-pushed the termux-self-hosting branch from b81e4f4 to c2d7bbc Compare August 8, 2019 13:18
@ghost ghost merged commit 702d7ac into master Aug 8, 2019
@ghost ghost deleted the termux-self-hosting branch August 8, 2019 13:58
This pull request was closed.
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.

1 participant