Commit Graph

31 Commits

Author SHA1 Message Date
Oliver Smith 6f6a3b0408
Happy new year 2022! 2022-01-02 22:39:14 +01:00
BO41 3f2bd03d33
remove unused args argument (MR 2136) 2021-11-27 14:13:33 +01:00
BO41 99bed38272
pmb.parse.apkbuild: remove unused args argument (MR 2136) 2021-11-27 14:13:33 +01:00
BO41 ce0f1c2d4a
args.cache: remove (MR 2136)
Replace "args.cache" with a global variable in order to
avoid passing "args" to all functions. This is a step to get rid of this
args-passed-to-all-functions pattern in pmbootstrap.
2021-11-27 14:13:27 +01:00
Minecrell 8ace36113c
pmb.config/install: add flexible provider selection for "pmbootstrap init" (MR 2132)
The provider selection for "pmbootstrap init" added in this commit
is a flexible way to offer UI/device-specific configuration options
in "pmbootstrap init", without hardcoding them in pmbootstrap.
Instead, the options are defined entirely in pmaports using APK's
virtual package provider mechanism. The code in pmbootstrap searches
for available providers and displays them together with their pkgdesc.

There are many possible use cases for this but I have tested two so far:

  1. Selecting root provider (sudo vs doas). This can be defined entirely
     in postmarketos-base, without having to handle this specifically in
     pmbootstrap.

     $ pmbootstrap init
     [...]
     Available providers for postmarketos-root (2):
      * sudo: Use sudo to run root commands (**default**)
      * doas: Use doas (minimal replacement for sudo) to run root commands
              (Note: Does not support all functionality of sudo)
     Provider [default]: doas

  2. Device-specific options. My main motivation for working on this
     feature is a new configuration option for the MSM8916-based devices.
     It allows more control about which firmware to enable:

     $ pmbootstrap init
     [...]
     Available providers for soc-qcom-msm8916-rproc (3):
      * all: Enable all remote processors (audio goes through modem) (default)
      * no-modem: Disable only modem (audio bypasses modem, ~80 MiB more RAM)
      * none: Disable all remote processors (no WiFi/BT/modem, ~90 MiB more RAM)
     Provider [default]: no-modem

The configuration prompts show up dynamically by defining
_pmb_select="<virtual packages>" in postmarketos-base, a UI PKGBUILD
or the device APKBUILD. Selecting "default" (just pressing enter)
means that no provider is selected. This allows APK to choose it
automatically based on the "provider_priority". It also provides
compatibility with existing installation; APK will just choose the
default provider when upgrading. The selection can still be changed
after installation by installing another provider using "apk".

Note that at the end this is just a more convenient interface for the
already existing "extra packages" prompt. When using pmbootstrap in
automated scripts the providers (e.g. "postmarketos-root-doas") can be
simply selected through the existing "extra_packages" option.
2021-11-06 15:04:34 +01:00
Minecrell 19b232969d
pmb.helpers.pmaports: search for provides in both root and subpackages (MR 2132)
At the moment, "provides" are only checked in the root package and not
in subpackages of APKBUILDs. Fix this by looking through the subpackages
as well.
2021-11-06 15:04:25 +01:00
Minecrell 5ed807c064
pmb.helpers.pmaports: parse guessed APKBUILD first for speed up (MR 2132)
At the moment we have to parse all APKBUILDs to find subpackages,
even if they are guessed easily shortly after. To speed this up,
let's guess first but verify the guess by only parsing that particular
APKBUILD. If the subpackage/provides is in there we seem to have found it.
2021-11-06 15:04:25 +01:00
Minecrell eb3e38d15c
pmb.helpers.pmaports: separate finding pkg in APKBUILD to function (MR 2132)
Make it possible to call this in a different place as well by placing
it in a separate function.
2021-11-06 15:04:25 +01:00
Newbyte 2d23849aa3
pmb, test: remove redundant commas (MR 2115) 2021-09-26 17:58:40 +02:00
Caio Fontes 039552f5b7
enforce E501 in pmb/helpers (MR 2058) 2021-06-06 19:21:30 +02:00
Oliver Smith 278dfced61
Replace pmaports channels stable, stable-next (MR 2032)
Translate the pmaports channels "stable" to "v20.05" and "stable-next"
to "v21.03", so these have the same channel name as the pmaports.git
branch name.

The original plan was to switch the "stable" channel from the "v20.05"
branch to the "v21.03" branch when the release is done. However, now
that we are close to that, I'm realizing that this would not be useful.
It would lead to conflicts in the dir with locally built packages
(default: ~/.local/var/pmbootstrap/packages/$CHANNEL). And it would make
it awkward to go back to a previous branch (we may name it old-stable
for the time being, but what after that, old-old-stable?).
2021-03-18 18:58:13 +01:00
Oliver Smith 1c791da482
treewide: bump copyright to 2021 2021-01-07 23:30:47 +01:00
Oliver Smith 2f018c44ef
pmb.helpers.{package,pmaports,repo}: fix comments (MR 1928)
Make the comments on top of the three files less confusing and more
consistent.
2020-04-25 13:17:21 +03:00
Minecrell add39d1a57
pmb.config.init: fix perf regression when selecting "none" UI (MR 1913)
The ui-extras questions will attempt to find a postmarketos-ui-<ui>
package in pmaports. If the package does not exist as "root" APKBUILD
it currently attempts to parse all APKBUILDs in case it is somewhere
defined as a subpackage. This is really slow (up to 2-3 seconds),
which feels weird during "pmbootstrap init".

For the UI packages we specifically look for the root UI package,
not the subpackage, so let's skip searching for subpackages in this
case. This makes selecting the "none" UI nice and fast again.
2020-04-13 21:52:06 +03:00
Minecrell 9249f36f16
pmb.helpers.pmaports: change some frequent messages to .verbose() (!1898) 2020-03-31 23:58:44 +02:00
Minecrell cd630edf25
pmb.helpers.pmaports: glob just once (!1898) 2020-03-31 23:58:38 +02:00
Daniele Debernardi 11c36fcf65
pmb.helpers.pmaports: cache get_list results (!1896) 2020-03-29 20:19:58 +02:00
Daniele Debernardi 20de238ff6
pmb.helpers.pmaports: search apkbuild path only if package exists (!1896) 2020-03-29 20:19:58 +02:00
Daniele Debernardi 0c179a5cf9
pmb.helpers.pmaports: cache _glob_apkbuilds results (!1896) 2020-03-29 20:19:48 +02:00
Minecrell fb8de5a553
pmb: Look for device/* files in device/*/... instead (!1879)
In the future, device ports will be located in a subdirectory
below device/... (e.g. device/testing/device-...).
Replace all occurrences of device/* with a glob that checks the
subdirectories instead.

Note: To ensure that this always works properly we should also add some
checks that all devices are indeed located under one of the supported
subdirectories (i.e. testing/community/main).

Change the glob for pmaports to <aports>/**/APKBUILD.
This allows using subdirectories for organization outside of device/
as well.
2020-03-14 08:44:16 +01:00
Oliver Smith f1cfd029d6
pmb/helpers/pmaports: fix finding subpackages (!1890)
Fix finding subpackages in pmaports, if no binary repo exists (-mp "" makes
pmbootstrap not use a binary packages mirror for pmOS packages). Discovered
with failing "test_depends_SLOW_40s" in bpo.

$ pmbootstrap -v -mp "" repo_missing --built --arch x86_64
[18:40:51] Calculate packages that need to be built (all packages, x86_64)
[18:40:56] ERROR: Package 'musl-dev-aarch64': Could not find aport, and could not find this package in any APKINDEX!
2020-03-09 18:49:59 +01:00
Oliver Smith f21c216a26
Cosmetic: use SPDX license header (!1877)
While at it, also remove unnecessary "#!/usr/bin/env python3" in files
that only get imported, and adjust other empty/comment lines in the
beginnings of the files for consistency.

This makes files easier to read, and makes the pmbootstrap codebase more
consistent with the build.postmarketos.org codebase.
2020-02-24 03:11:10 +03:00
Minecrell 0e27713512
pmb.parse._apkbuild: Extend APKBUILD parser to work for subpackages (!1866)
At the moment we have a simple subpkgdesc() function that can only
parse "pkgdesc" from subpackages, without support for any variables.
But we have a quite nice variable parser now that can be extended
to work for subpackages.

Simply put this works by:
  - Finding the lines that belong to the subpackage function
  - Stripping indentation (tab)
  - Parsing relevant attributes similar to the apkbuild() function

The "subpackages" in the parsed APKBUILD are replaced by a dict
of subpkgname: {"pkgdesc": "...", "depends": "..."} which are
parsed from the subpackage function (if found).
This makes it possible to get the "depends" of a subpackage.
2020-02-19 14:56:57 +03:00
Oliver Smith 948e3f931f
Change copyright to 2020 2020-01-06 02:43:00 +01:00
Oliver Smith ae1b3fc38c
pmb/helpers/pmaports: ignore provides without ver (!1851)
The APKBUILD reference for "provides" [1] is not worded clearly; but
after reading it over and over again, my understanding is:

* package with provides='foo=1.2' will be automatically installed if
  user requests installing "foo"
* package with provides='foo' (without version) will NOT get
  automatically installed if user requests installing "foo"

For pmbootstrap, this means, that we must not attempt to build a package
where the pkgname mentioned in provides matches what we are currently
resolving, unless there is an equals sign in the provides entry.

Fixes: #1862, pmaports#404

[1] https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#provides says:

"List of package names (and optionally version info) this package
provides.

If package with a version is provided (provides='foo=1.2') apk will
consider it as an alternate name and it will automatically consider the
package for installation by the alternate name, and conflict with other
packages having the same name, or provides.

If version is not provided (provides='foo'), apk will consider it as
virtual package name. Several package with same non-versioned provides
can be installed simultaneously. However, none of them will be installed
by default when requested by the virtual name - instead, error message
is given and user is asked to choose which package providing the virtual
name should be installed."
2020-01-02 17:16:05 +01:00
Oliver Smith cf9d648ac9
pmaports.guess_main: new assumption for -dev pkgs (!1827)
Packages ending in -dev: just assume that the originating aport has the
same pkgname, except for the -dev at the end. Otherwise we may end up
with the wrong package.

For example, if something depends on plasma-framework-dev, and
plasma-framework is in Alpine, but plasma is in pmaports, then the
regular guess_main() algorithm below would pick plasma instead of
plasma-framework.

Fixes: build.postmarketos.org#52
2019-10-20 20:03:56 +02:00
Oliver Smith 99e7ae3019
pmb.helpers.package.check_arch(): split (!1776)
Split the part that actually checks the arch against the arches list
into pmb.helpers.pmaports.check_arches(arches, arch), and call it
from pmb.helpers.package.check_arch(args, pkgname, arch, binary).

This will be used in a follow up commit, where we have already resolved
the package data and only need to check the architecture.
2019-04-20 01:58:20 +02:00
Oliver Smith f16bdaf0ca
Update copyright to 2019
Happy new year \o/
2019-01-02 09:31:20 +01:00
Oliver Smith d6f7571cb9
repo_missing: properly find subpackages, provides (!1724)
Do not fail anymore when attempting to start a new binary repository
build without any existing binary packages:
	pmbootstrap -mp="" repo_missing

Find subpackages defined with subpackage functions:
	subpackages="dev:mydevfunc"

Find provides defined with specific versions:
	provides="mkbootimg=1.0.0"
2018-12-10 21:00:04 +01:00
Oliver Smith 933c4d0f0d new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.

This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.

For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.

Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.

Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
  aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
  in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
  distinguish it from the other check_arch function
2018-12-01 21:30:59 +00:00
Oliver Smith a44b80b31d build.find_aport() -> helpers.pmaports.find()
Move find_aport() and find_aport_guess_main() from pmb/build/other.py
to the new file pmb/helpers/pmaports.py.

Finding aports is not only needed when building packages, hence it
makes sense to move it out of pmb.build. The pmb/helpers/pmaports.py
file will have more pmaports related functions in a follow up commit.
2018-12-01 21:30:59 +00:00