Skip to content

Refactor pmb/build/package.py (make depends work like in abuild)

Administrator requested to merge refactor/pmb-build-package into master

Created by: ollieparanoid

This PR will fix #824 (closed) (wrong depends handling), which is the last blocker before merging the Plasma Mobile PR. And it will allow extending package code again, because the code is split up in small functions and these have test cases, with new features like native cross compilation for autoconf packages (see @zhuowei's proof of concept in #665). Needless to say, testing and reviewing is greatly appreciated.

EDIT: Test cases ran through locally, but fail with Travis. Fixed! 👍

Change of behavior

pmbootstrap build device-samsung-i9100 explains it all:

[01:18:04] Dependency handling in 'pmbootstrap build' has been changed.
[01:18:04] Previously we only built and installed the 'makedepends' from the APKBUILDs, now we use the 'depends', too.
[01:18:04]
[01:18:04] Your options:
[01:18:04] * Ignore depends (fast, old behavior, may cause problems with some packages):
[01:18:04]   pmbootstrap build device-samsung-i9100 -i
[01:18:04] * Build with depends (kernel!) and specify the right architecture:
[01:18:04]   pmbootstrap build device-samsung-i9100 --arch=armhf
[01:18:04]
[01:18:04] This change was necessary to be more compatible with Alpine's abuild.
[01:18:04] The default architecture is the native one (x86_64 in your case), so you need to overwrite
[01:18:04] it now to get the kernel dependency of your device package for the right architecture.
[01:18:04] Sorry for the inconvenience.
[01:18:04]
[01:18:04] ERROR: Missing -i or --arch parameter
[01:18:04] Run 'pmbootstrap log' for details.
[01:18:04] See also: <https://postmarketos.org/troubleshooting>

How to test (easy!)

  • Build packages like you would normally do
  • Do full installations

Detailed changes

  • Rename pmb/build/package.py to pmb/build/_package.py, so we can access the functions it contains in testcases, and still use pmb.build.package()
  • Refactor the entire file. Instead of one big function that does too many things, we have many small ones now, that are tested in the testsuite and easier to modify
  • Whenever building a package, pmbootstrap does not only build and install the "makedepends" (like we did before), now it does the same for the "depends". That's required to be compatible with abuild. The old behavior can still be used with 'pmbootstrap build --ignore-depends'.
  • Because of that change, noarch packages can no longer be built in the native chroot if we need them for a foreign chroot. A device- package depending on a kernel would pull in the same kernel for the native architecture otherwise.
  • Running 'pmbootstrap build device-...' without '--ignore-depends' and without a matching '--arch' displays a note that explains this change to the user and tells how to use it instead.
  • Noarch packages no longer get symlinked. That was only implemented for packages built in the native chroot, and now that is not always the case anymore. Symlinking these packages creates packages with broken dependencies anyway (e.g. device-samsung-i9100 can't be installed in x86_64, because linux-samsung-i9100 is armhf only).
  • Rename "carch" to "arch" wherever used. Naming it "carch" sometimes is confusing with no benefit.
  • Add a testcase for the aarch64 qemu workaround (because it failed first and I needed to know for sure if it is working again).
  • Improved some verbose logging, which helped with development of this feature.
  • Removed the old "build" test case (which was disabled in testcases_fast.sh) as the new "build_package" test case covers its functionallity.

Merge request reports

Loading