Commit Graph

2494 Commits

Author SHA1 Message Date
Newbyte ced93fee7b
pmb.parse.kconfig: Raise NonBugError on invalid kernel config (MR 2279)
The intent of 9a74848f19 was to not print
a stacktrace when this happened. However, I still opted to raise an
exception, so you still get a stacktrace, just with a more helpful
message. There's no need to give the user a big stacktrace here, so
raise a NonBugError instead of a RuntimeError.
2024-03-27 21:50:28 +01:00
Newbyte 9723191fe5
pmb: Only log error if NonBugError is caught (MR 2279)
NonBugError means that the root cause originates from a bug outside of
pmbootstrap's code base. As such, no need to print a stacktrace or ask
the user to update pmbootstrap.
2024-03-27 21:50:28 +01:00
Newbyte 19b50a3deb
pmb.helpers.exceptions: Introduce (MR 2279)
Initially I thought of putting this in pmb/helpers/other.py, but this
resulted in a circular import, so I thought the easiest way to work
around that was to just create a new file.
2024-03-20 23:01:44 +01:00
Raymond Hackley 89117277d0
pmb.config: kconfig check: add USB mass storage devices to community (MR 2281)
Add USB mass storage devices to community, which is required for
USB booting.
2024-03-20 10:06:38 -07:00
methanal 259e6fba59
pmb.parse.bootimg: implement detection of QCDT types (MR 2276)
Implement a function to verify the type of QCDT image by comparing the
first four bytes of the file. This is represented in a deviceinfo
variable, used by boot-deploy for dt.img generation.
2024-03-17 18:45:51 +00:00
methanal 75dcab4405
pmb.aportgen: add deviceinfo_bootimg_qcdt_type (MR 2276) 2024-03-17 18:45:46 +00:00
Oliver Smith 416781d2c2
aportgen: shorten hasatrr checks with getattr (MR 2271) 2024-03-17 18:36:51 +00:00
Newbyte 883be0f119
aportgen: Add short forms of arguments (MR 2271)
With --fork-alpine-retain-branch the arguments are getting really long,
so let's add short forms for both to be consistent.
2024-03-17 18:36:45 +00:00
Newbyte d63ea90f2b
aportgen: Allow retaining current branch when forking Alpine (MR 2271)
Often I find myself confused and subsequently frustrated by the
behaviour of --fork-alpine as usually I apply whatever changes I want to
the aports package before forking. This is due to that in the proper
aports repo I can leverage the full power of git and apply patches or
revert commits, whereas after the package has been forked to pmaports
the context git needs to do this is lost.

To fix that, this commit introduces --fork-alpine-retain-branch which
works the same way as --fork-alpine except it doesn't change the aports
branch to match the current channel.
2024-03-17 18:36:36 +00:00
Oliver Smith 96da7f161a
logging: reset style at the end of log line (MR 2272)
Fix a regression from my recent patch that made text like the following
green:
	*** text ****
We also have log messages that only start with ***, but do not end with
***, coming from "pmbootstrap aportgen". They indicate that a new aport
has been generated, but are not a headline for the coming commands.

Fix that the aportgen messages don't reset the colors at the end of the
line, and so the next line would start with the color.

Fixes: 6ba138b6 ("logging: print text between *** in green (MR 2263)")
2024-03-17 16:24:30 +00:00
Oliver Smith 1020bd61ad
CI: ruff: fix "ruff <path>" warning (MR 2274)
Fix for:
warning: `ruff <path>` is deprecated. Use `ruff check <path>` instead.
2024-03-17 13:37:55 +01:00
Raymond Hackley b91b83afb7
pmb.flasher: fix C0303: Trailing whitespace (trailing-whitespace) (MR 2280)
************* Module pmb.flasher.run
pmb/flasher/run.py:53:0: C0303: Trailing whitespace (trailing-whitespace)
pmb/flasher/run.py:57:0: C0303: Trailing whitespace (trailing-whitespace)
************* Module pmb.flasher.variables
pmb/flasher/variables.py:64:0: C0303: Trailing whitespace (trailing-whitespace)
2024-03-17 13:36:19 +01:00
Oliver Smith 4478116379
Add sanity check for "systemd" config values (MR 2273)
Make sure users don't set systemd to "true" or other not allowed values
(allowed are "always", "default", "never").

Check for it:
* after loading the config
* when using 'pmbootstrap config systemd <newvalue>'
2024-03-12 23:53:47 +00:00
Oliver Smith de5e4c6962
is_systemd_selected: check for branch support (MR 2273)
Don't attempt to install postmarketos-base-systemd if the current branch
doesn't have a systemd section in pmaports.cfg.
2024-03-12 23:53:47 +00:00
Oliver Smith bfc64d1cb8
Support pmb:systemd-never option (MR 2273)
For UI packages that have pmb:systemd-never set:
* do not ask in "pmbootstrap init" whether to use systemd or not
* do not install systemd, even if the systemd option is set to "always"

The point of this is to not add maintenance burden to Sxmo (and possibly
other UIs who not wish to support systemd with postmarketOS), so users
don't install with this unsupported use case and report issues with it.
2024-03-12 23:53:47 +00:00
Oliver Smith ed9f70739a
install: add pmos-base-systemd if systemd enabled (MR 2273) 2024-03-12 23:53:47 +00:00
Oliver Smith 266bfc31cd
pmbootstrap build, install: require repo_bootstrap (MR 2273)
Make sure that if systemd is selected, the repo_bootstrap is done before
the "pmbootstrap build" and "pmbootstrap install" commands can be used.
2024-03-12 23:53:47 +00:00
Oliver Smith fafd4e7304
Add "pmbootstrap repo_bootstrap" (MR 2273)
Related: https://postmarketos.org/pmaports.cfg bootstrap_1 etc.
2024-03-12 23:53:47 +00:00
Oliver Smith dce459984e
pmb.chroot.init: upgrade pkgs at the end (MR 2273)
Upgrade packages in the chroot, in case alpine-base, apk etc. have been
built from source with pmbootstrap. We build it from source for systemd
currently, and sometimes it is useful to do that to debug apk.
2024-03-12 23:53:47 +00:00
Oliver Smith 9126d15452
pmb.chroot.init: add postmarketos_mirror argument (MR 2273)
Add this argument, so we can disable the pmOS repository during
"pmbootstrap repo_bootstrap" for the chroot we build in.

If building natively, it will be disabled in the "native" chroot.

If building for a foreign arch, it will be disabled in the
"buildroot_$arch" chroot, but still be enabled in the native chroot so
we have the cross compilers available.

The name of the argument is a bit long, but it is consistent with the
argument of the same name in pmb.helpers.repo.urls() (to which it gets
passed).
2024-03-12 23:53:47 +00:00
Oliver Smith 6f3ed45d49
systemd installs: merge /usr on chroot init (MR 2273) 2024-03-12 23:53:47 +00:00
Oliver Smith e96ca36376
init: ask whether to install systemd (MR 2273)
Add the following question to "pmbootstrap init":

[22:12:57] Based on your UI selection, 'default' will result in installing systemd.
[22:12:57] Install systemd? (default/always/never) [default]:

Determine whether the UI prefers to have systemd or not, based on
"pmb:systemd" in the UI package's APKBUILD.

Determine whether the currently selected branch supports systemd, by
checking for a "[repo:systemd]" section in pmaports.cfg. This section
will also contain bootstrap information, to be used in future patches.
2024-03-12 23:53:42 +00:00
Newbyte c6e8a89ea3
aportgen: Set pkgver for devices to 1 by default (MR 2275)
We have been discussing making device package versioning more
consistent and ended up settling on using integer versioning for device
packages[1]. As such, let's start by tackling this at the source and
start generating new device packages with 1 as the starting pkgver
instead of 0.1.

 [1]: https://gitlab.com/postmarketOS/pmaports/-/issues/2610#note_1796178414
2024-03-11 11:54:26 -07:00
Newbyte e812fafdee
pmb.helpers.frontend: Add some type hints (MR 2262) 2024-03-10 16:18:27 +00:00
Newbyte a78486e9e4
pmb.helpers.status: Add type hints (MR 2262) 2024-03-10 16:18:27 +00:00
Newbyte 5577495dc5
pmb.helpers.run: Add some type hints (MR 2262) 2024-03-10 16:18:27 +00:00
Newbyte 85f777073e
pyproject.toml: Fix deprecation warning (MR 2262)
Fixes this warning:

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
2024-03-10 16:18:23 +00:00
Clayton Craft a416e3ffae
pmb.config: kconfig check: add vfat to uefi check (MR 2269)
UEFI 2.0 spec requires FAT for the ESP[1], and we use the ESP for /boot so
let's make sure that the kernel always has support for mounting it.

1. https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#file-system-format-1
2024-03-08 16:31:25 -08:00
Clayton Craft 1352c658a5
pmb.config: kconfig check: mark some EFI config as specific to ARM (MR 2269)
This fixes an issue where the kconfig uefi check fails on x86_64
kernels, since these vars do not exist in the kconfig for this arch.
2024-03-08 16:31:20 -08:00
Alexander Martinz 7f271dd1cc
pmb: correct link after moving sources back to gitlab (MR 2270)
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2024-03-08 14:04:00 +01:00
Pablo Correa Gómez 762c725bb5
Remove unnecessary setup.cfg, non-universal is the default (MR 2265)
According to
https://wheel.readthedocs.io/en/stable/user_guide.html#building-wheels
universal = 1 is opt-in
2024-02-29 00:47:33 +01:00
Pablo Correa Gómez d2bcff3162
Drop support for python3.7 and python3.8 (MR 2265)
Even Debian oldstable is on python3.9 now, so should be safe, and
should also help the typing process that has now started
2024-02-29 00:47:33 +01:00
Pablo Correa Gómez d895f4a465
Migrate from setup.py to pyproject.toml (MR 2265)
In the process, drop the list of required python packages. This is
only needed for pip, as pmbootstrap checks by itself. This way we
avoid duplicating the minimum required version.

We also don't install the helpers anymore, as modern tooling does not
support installing things outside the python package dir
2024-02-29 00:47:33 +01:00
Newbyte 812a3e4a85
test: Test subpackages which set a different architecture (MR 2267) 2024-02-26 20:55:49 +01:00
Newbyte 71ac87e6af
pmb.parse._apkbuild: Fix subpackages with set arch but no custom function (MR 2267)
If there are multiple sections to a subpackage declaration, the middle one
(item 1 in the sequence in this case) is the custom function name which we
should use instead of the deduced one.

For example:
  $pkgname-something-separate:something_separate:noarch

Here, the subpackage is called $pkgname-something-separate, but function names
cannot contain hyphens, so it's instead given the custom name
something_separate where the hyphen is replaced by an underscore. At the end,
the architecture of the subpackage is also overriden as noarch instead of
whatever architecture the main package has.

However, it is also possible to only override architecture of a subpackage and
not the function name.

In such cases, we get this:
  $pkgname-something::noarch

We still have a "middle section" (item 1 in the sequence), but it will be
empty. As such, we not only need to check whether there are more than 1
subpackage part, but also whether that extra subpackage part is an empty string
or not.

This fixes an issue where pmbootstrap would not end up just setting the
properties of subpackages with a set arch but no custom function as
None instead of giving them proper depends, install, pkgdesc, et cetera
properties.
2024-02-26 20:55:49 +01:00
Raymond Hackley e0d5b49840
pmb/config: s/für/for/
Fix typo

Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20240226104630.5819-1-raymondhackley%40protonmail.com%3E
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-26 14:50:19 +00:00
Newbyte e6b6b73c0d
pmb.parse.arch: add armv8l -> armv7 mapping (MR 2259)
Supposedly this is the architecture reported by userspace when running
in 32-bit mode on aarch64.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2311
2024-02-22 19:47:32 +01:00
Oliver Smith 6ba138b6b2
logging: print text between *** in green (MR 2263)
Highlight messages like the following from pmbootstrap install:
  [19:45:59] *** (1/4) PREPARE NATIVE CHROOT ***

[ci:skip-build]: already built successfully in CI
2024-02-22 19:37:48 +01:00
Ferass El Hafidi 385fc2cfc1
README.md: mention parted bug in kernels between 5.8 and 6.0 (MR 2264)
Many have been unable to use pmbootstrap install on kernel versions
between 5.8 and 6.0 as parted was giving the following error:

	Error: Partition(s) 1, <...>, 64 on /dev/install have been
	       written, but we have been unable to inform the kernel
	       of the change, probably because it/they are in use.
	       As a result, the old partition(s) will remain in use.
	       You should reboot now before making further changes.

And pmb couldn't find /dev/loop0p1:

	ERROR: Unable to find the first partition of /dev/loop0,
	       expected it to be at /dev/loop0p1!

Related: pmbootstrap#2309

[ci:skip-build]: no code changes

Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2024-02-22 14:59:23 +01:00
Clayton Craft 8abd698cab pmb.install: fall back to a valid hostname if none set (MR 2260)
If the device name does not make a valid hostname, fall back to some
simple valid hostname. Some device names (e.g. 'generic-x86_64') are
valid names for apk packages and such, but are not valid host names. It
assumes that the user (real, or CI) doesn't care if it's unset and just
expects pmb to work and not conditionally crash based on the device they
selected.

Situations where the user sets an invalid hostname are still validated
separately and cause an exception so that they know their config was
wrong and to fit it.

This fixes an issue that came up in CI when doing `pmb config device
generic-x86_64` followed by `pmb install`.

I considered trying to convert invalid host names into valid ones, but I
didn't feel like it was worth the trouble of adding stuff to convert and
re-validate when we can just set a static, boring, but definitely valid
default if the device name is not valid.
2024-02-16 18:57:49 +00:00
Oliver Smith 2d90b558c1
CI: mypy: make compatible with "pmbootstrap ci" (MR 2258) 2024-02-16 10:04:25 +01:00
Newbyte c18bff1c67
CI: add Mypy check (MR 2258) 2024-02-16 10:04:25 +01:00
Newbyte 8835dd846c
pmb.parse._apkbuild: Disable attr-defined for entire module (MR 2258)
Due to that logging.verbose is "monkeypatched" into logging and not
present by default in the module, Mypy isn't able to pick up that it
exists. As such, just disable the check altogether in this file for
now.
2024-02-16 10:04:25 +01:00
Newbyte 40f3dddbfe
pmb.helpers.aportupgrade: Remove unused return values (MR 2258)
Neither the return value from upgrade_git_package nor
the one from upgrade_stable_package actually gets used anywhere, so
just remove it.
2024-02-16 10:04:25 +01:00
Newbyte bc530a107f
pmb.helpers.aportupgrade: Don't return any value from upgrade (MR 2258)
The return value of this function is never used. Additionally, the type
hint for it was incorrect as it may return None. As such, don't bother
returning anything both to appease Mypy and also to remove unused
and consequently presumably untested functionality.
2024-02-16 10:04:25 +01:00
Newbyte cb3807a9f6
pmb.helpers.aportupgrade: Check for none pkgver_match in upgrade_git_package (MR 2258)
Appeases Mypy.
2024-02-16 10:04:24 +01:00
Newbyte bcfab8cfc3
pmb.helpers.aportupgrade: Import urllib.parse explicitly (MR 2258)
Apparently importing urllib doesn't by itself import the urllib.parse
module, which mypy complains about.

Reference: https://stackoverflow.com/a/41502702/9315690
2024-02-16 10:04:24 +01:00
Newbyte 3aad061c68
pmb.parse.arguments: Check for argcomplete in sys.modules instead (MR 2258)
Repurposing argcomplete as a boolean telling whether the module
argcomplete was found results in a variable with two distinct purposes
and types, which is bad practice and confuses Mypy. As such, don't
assign False to argcomplete if the module is not found and instead just
check for whether it exists in sys.modules to determine whether it was
imported successfully.
2024-02-16 10:04:24 +01:00
Clayton Craft aa594b76fa
pmb.config: do not prompt for nonfree fw/userland (MR 2255)
This drops the prompt for using non-free firmware in images. The logic
for searching/installing non-free fw subpackages for devices is kept,
and will always be installed. This is to support the many device
packages in pmaports that still have nonfree-firmware subpackages. Going
forward, device packages can list firmware in `depends=` (for required
fw) or `pmb_recommends` (for optional fw).

nonfree-userland wasn't used in pmaports as far as I could find.
2024-02-15 16:00:56 -08:00
Oliver Smith 0bed6a0437
pmb.install…get_selected_providers: tweak comment (MR 2261) 2024-02-15 20:43:13 +00:00