Commit graph

2602 commits

Author SHA1 Message Date
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
Clayton Craft
3f390303b3
pmb.install: discover selected providers in dependencies too (MR 2261)
Sometimes dependencies of packages we are explicitly adding to world
define selected providers that we should account for. This improves
get_selected_providers to discover/add these selected providers in
dependencies too, recursively.

Fixes #2306
2024-02-15 20:43:13 +00:00
Pablo Correa Gómez
f893cd3081
config: add note on why mirrors are http and not https (MR 2256)
It has been a confusion point in the past:

https://gitlab.com/postmarketOS/pmbootstrap/-/merge_requests/2128

https://gitlab.com/postmarketOS/pmbootstrap/-/merge_requests/2094
2024-02-15 20:02:51 +00:00
Pablo Correa Gómez
57701084de
config: organize defaults matching config_keys and order alphabetically (MR 2256)
Makes it much easier to read
2024-02-15 20:02:39 +00:00
Newbyte
cc3a7eb2ff
b4-config: Remove (MR 2257)
We no longer use SourceHut for pmbootstrap development, so this is no
longer relevant.
2024-02-14 17:50:56 +01:00
Oliver Smith
7102157bf1
Prepare 2.2.1 release 2024-02-11 21:37:39 +00:00
xtex
ea107170d9
envkernel: Install envkernel.fish (MR 2249) 2024-02-10 01:29:05 +00:00
xtex
5df2ef234e
envkernel.fish: Support out-of-tree usage of envkernel.fish (MR 2249) 2024-02-10 01:29:05 +00:00
xtex
3609a68aaf
envkernel: only export alias when defined (MR 2249)
MR !2229 make pmbootstrap optional and break fish compat
2024-02-10 01:29:05 +00:00
Andras Sebok
0c8b9c805f
pmb.aportgen: drop deviceinfo_screen_* (MR 2253) 2024-02-09 20:13:59 +01:00
Oliver Smith
18698ab251
install: get_recommends: fix infinite recursion (MR 2250)
Keep track of the packages visited and skip them if they are passed
again.

Fixes: 19f8a3b8 ("pmb.install: support pmb_recommends for any package")
2024-02-07 09:47:12 +00:00
Oliver Smith
7f61262ae8
Prepare 2.2.0 release 2024-02-06 23:43:54 +00:00
Oliver Smith
a890b2cd26
pmb.build.init: fix apk wrapper for x86 on x86_64 (MR 2247)
Only install the abuild-apk wrapper if cpu emulation is required. This
fixes building for x86 on x86_64.

Fix for:
  >>> postmarketos-base-ui-gnome: Analyzing dependencies...
  /usr/local/bin/abuild-apk: line 11: /native/usr/bin/abuild-apk: not found

Fixes: c5ca06d5 ("pmb: only enable abuild-apk wrapper for buildroot (MR 2246)")
2024-02-06 20:03:50 +00:00
Luca Weiss
54a616621f
kconfig check: Enable more options for community (MR 2245)
Enable some configs that were collected over the last year(s) and enable
them for the community kconfig check.
2024-02-06 19:02:34 +00:00
jane400
178486a64e
kconfig check: enable NFT_COMPAT for iptables-nft wrapper (MR 2245)
we're not in the nftables only world yet, things like docker and
tailscale only work with the `iptables` command. those programs
expect iptable-modules, which we make available to nftables over
the nftables/iptables compat layer.
2024-02-06 19:02:30 +00:00
Caleb Connolly
7e3ce1ef14
build.envkernel: simplify and fix unhandled error path (MR 2243)
Drop the weird flag file stuff for state management, and just always
mount the source code in, and always unmount it on exit - including in
the error path.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 18:22:37 +00:00
Caleb Connolly
384c843a25
pmb.build: ensure all specified packages are built with --force (MR 2244)
When running build --force, if a later package is a dependency of an
earlier package, it will be "visited" by the dependency resolver,
erroneously causing it to be skipped when later in the session it's
visited to force build. This is because previously visited packages are
marked as such in a hashmap, but skip_already_built() assumes that a
package which has been visited would have already been built.

Fix this by overriding skip_already_built() if doing a force build. This
works because package dependencies are only built if the APKBUILD
version is newer than the binary repo, even when --force is specified.
So there is no risk of an infinite loop here.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 18:07:07 +00:00
Caleb Connolly
c5ca06d502
pmb: only enable abuild-apk wrapper for buildroot (MR 2246)
Some packages like kernels are cross compiled from the native chroot.
the apk_wrapper won't work here! So only enable it for buildroot chroots

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 16:15:09 +01:00
Jacob Ludvigsen
2bd1eb26d8
install: more comprehensive subdivision of btrfs subvols (MR 2233)
Why
Btrfs has some goodness (snapshots, switching between different rw snapshot)
which plays particularly well with certain "subvolume layouts".

What
This MR seeks to implement such a layout, namely a flat btrfs layout,
where the top level subvolume (i.e. the btrfs filesystem/partition itself)
remains unmounted in all situations,
except when making changes to direct child subvolumes of the filesystem.

- rename all subvols to follow the common @* btrfs subvol naming scheme.
- add subvol @root, because roots home directory shouldn't be rolled back.
- make subvol @var not Copy-on-Write (nodatacow) to avoid write
- multiplication on logs, VMs, databases, containers and flatpaks.
- add subvol @snapshots because that lets us change the root subvol to a
read-write snapshot of @ without affecting snapshots.
- add subvol @srv because it contains data for Web and FTP servers,
which shouldn't roll back together with root subvol.
- add subvol @tmp because we don't want to snapshot temporary files.
This subvol remains unmounted on the device,
unless conditions as laid out in pmaports!4737 are met.
- add check and error for btrfs when using rsync installation.
2024-02-06 12:04:20 +00:00
Clayton Craft
e139a34472
pmb.install: honor -y, don't prompt when target disk is >100GiB (MR 2239)
fixes #2303
2024-02-06 03:51:42 -08:00
Clayton Craft
b06d751822
pmb.install: include dependencies when searching for pmb_recommends (MR 2238) 2024-02-06 03:35:55 -08:00
Clayton Craft
0722e962d0
pmb.install: fix crash on empty subpackage in get_recommends (MR 2238) 2024-02-06 03:35:54 -08:00
Caleb Connolly
a72b21de0c
build: use native abuild-apk (MR 2242)
Speed up using abuild to install build dependencies by introducing a
wrapper which invokes abuild-apk in the native chroot with
LD_PRELOAD_PATH

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 00:26:13 +01:00
Caleb Connolly
9526a9d437
build: use host native gzip (MR 2242)
Instead of installing a gzip wrapper, run gzip from the native chroot
which we bind mount in.

Signed-off-by: Caleb Connolly <kc@postmarketos.org>
2024-02-06 00:23:19 +01:00
Oliver Smith
37a7f3924d
Fix preserving proxy variables (MR 2237)
Fix "pmbootstrap chroot" and others not passing the proxy environment
variables correctly. Thanks to notfound405 for pointing this out!

Instead of only preserving proxy environment variables in
pmb.helpers.run_core, which should never be called directly, do it in
the calling functions:

* pmb.helpers.run.user
* pmb.helpers.run.root
* pmb.chroot.root
* pmb.chroot.user

This fixes that the environment variables were only really passed by
pmb.helpers.run.user, because the other functions would result in
something like:
  HTTP_PROXY=mytestproxy sudo env -i /usr/bin/sh -c '…'
This is needed to either elevate to root, or to elevate to root first
and then enter the chroot as root or user. Due to the "env -i", the
environment intentionally gets cleaned, but unintentionally also removes
the proxy environment variables that were explicitly set.

By adjusting the functions, they now run a variant of:
  sudo env -i /usr/bin/sh -c 'HTTP_PROXY=mytestproxy …'

The escaping is simplified in this example, run "pmbootstrap -v" to see
the not very readable, but proper escaping with shutil.quote().

Remove the previous test for preserving the environment variables in
pmb.helpers.run_core (as it should never be called directly), and test
instead the new behavior.

Fixes: issue 2299
Fixes: 13c4ac42 ("pmb.helpers.run_core: fix proxy env var logic")
2024-01-25 20:12:53 +00:00
Fiona Klute
23a8d14d4a
Don't drop parameters in run-script (MR 2230)
Note that the parameters aren't included directly in the sh -c command
string, but instead as additional parameters after. That avoids having
to find a cross-shell approach for quoting them in a way that works
inside the string (there doesn't seem to be one).

That's also the reason for the additional "sh" parameter: The first
parameter after the command string becomes the command name ($0), the
ones after positional parameters.
2024-01-23 23:11:55 +00:00
Oliver Smith
7dd565f7f3
CONTRIBUTING: modernize (MR 2235)
Rewrite the contributing guide. Most of this was written a long time
ago, when pmaports and pmbootstrap still were in the same repository.
This time, focus on what is important for developing pmbootstrap and
omit some of the obvious information (how to make a merge request etc.).

Add relevent information from:
https://wiki.postmarketos.org/wiki/Pmbootstrap_development_guide

...so we can replace the wiki page with a link to this file. Having the
information in a CONTRIBUTING.md seems more intuitive than having it
somewhere in the wiki.

Mention that new or modified code should use f-strings, and that we
support all active python versions.
2024-01-22 00:33:25 +00:00
Fiona Klute
6bf1768c67
Install envkernel.sh (MR 2229) 2024-01-21 23:17:52 +00:00
Fiona Klute
dc653d9c9f
Fall back to pmbootstrap from PATH (MR 2229)
This makes it possible to use envkernel.sh without sourcing it from a
full source tree as long as "pmbootstrap" is available in PATH
(e.g. from a distro package). In this case the "pmbroot" and
"pmbootstrap" aliases won't be set, and neither the pmbootstrap_dir
environment variable.
2024-01-21 23:17:48 +00:00
Fiona Klute
f1311424d1
Guess kbuild out dir for downstreamkernel_package (MR 2231)
find_kbuild_output_dir() searches for certain path patterns, which
won't be in the APKBUILD if it uses downstreamkernel_package. Guess
the default kbuild out dir in that case.

Theoretically this might break if some APKBUILD passes weird paths to
downstreamkernel_package, but no kernel package in pmaports today does
that.
2024-01-21 23:05:00 +00:00
Oliver Smith
f8d203e8e5
CI: bring back mr-settings check (MR 2234)
Add the check again that ensures we can write to the target repository.
This is needed for our merge style, we add the MR-ID to the title of the
commit message, and may do small fixups while merging.
2024-01-21 22:17:59 +00:00
Newbyte
3e3c639d05
pmb.helpers.args: Skip some initialisation code when running checksum (MR 2228)
Without this, pmbootstrap will give an error if you have a nonexistent
device selected when trying to checksum a package. This can be annoying
when switching between different branches where devices may or may not
exist, and I don't think these initialisation steps are necessary for
the checksum action anyway.
2024-01-19 00:00:49 +00:00
Andras Sebok
03a59287dc
pmb.flasher.variables: use getattr instead of hasattr (MR 2232) 2024-01-18 23:24:30 +00:00
Jonas Stevnsvig
cc50d8956b
pmb.flasher.vars: do not assume that args.no_reboot and args.resume are defined (MR 2232)
When running pmbootstrap install --android-recovery-zip it tries to
access pmb.flasher.variables but args.no_reboot and args.resume are
only defined when running pmbootstap flasher.
2024-01-18 22:56:06 +00:00
Oliver Smith
13f277a56c
CI: use gitlab-ci 2024-01-16 22:26:58 +00:00
Oliver Smith
6ffb174870
README.md: update source code location
Related: https://postmarketos.org/blog/2024/01/17/moving-pmbootstrap/
2024-01-16 22:26:55 +00:00
Andras Sebok
e0e3e213ba
flasher: heimdall-bootimg: add support for '--no-reboot' and '--resume'
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C170534361606.26168.17672643433174186875-0@git.sr.ht%3E
2024-01-16 21:16:07 +00:00
xtex
59898f515a
helpers/envkernel.fish: add deactivate & reactivate function for fish
Signed-off-by: xtex <xtexchooser@duck.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20240113123358.6142-3-xtex@envs.net%3E
2024-01-16 21:15:18 +00:00
xtex
fc3d8b06b3
helpers/envkernel.fish: set prompt prefix in fish-shell
Signed-off-by: xtex <xtexchooser@duck.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20240113123358.6142-2-xtex@envs.net%3E
2024-01-16 21:15:12 +00:00
xtex
81fff2c6d6
helpers/envkernel.fish: export pmbootstrap_dir
Signed-off-by: xtex <xtexchooser@duck.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20240113123358.6142-1-xtex@envs.net%3E
2024-01-16 21:14:57 +00:00
Jacob Ludvigsen
392e82db07
install: initial implementation of flat btrfs layout
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Tested-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C170436606365.31622.8646592258649313487-0@git.sr.ht%3E
2024-01-09 16:55:47 +01:00
Luca Weiss
abad57e232
pmb.config: add new newapkbuild arguments
Add support for passing through the correct argument for Python
(gpep517) and Rust to newapkbuild.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20240108222736.1143841-1-luca@z3ntu.xyz%3E
2024-01-09 16:55:47 +01:00
Apollo3zehn
09b4e5e336
pmb.install.format: Write boot mountpoint to log
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C170397557240.20130.18133458588122463459-0@git.sr.ht%3E
2024-01-09 16:55:47 +01:00