Commit Graph

1409 Commits

Author SHA1 Message Date
Clayton Craft 888026e95d
pmb.config.apkbuild_attributes: add sha512sums (MR 2296)
Useful for pmaports CI, see:
https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4994#note_1842433422
2024-04-16 19:09:40 +00:00
Oliver Smith 0d320d0613
pmbootstrap status: rework (MR 2294)
Reimplement "pmbootstrap status" to be just a simple and useful status
overview. The previous version ran a bunch of checks every time, and
would fail on these even if pmaports was used for normal development:
  * "non-official" branch checked out in pmaports
  * pmaports.git is not clean

The information about aports.git was also considered not so useful upon
revisiting this command, since it is only used for "pmbootstrap
aportgen". Most users don't need this, and if the user runs this
command, it will tell if aports.git is outdated.

All of the above made the previous version unpleasant to use and I
suspect most people stopped using the command after trying it out a few
times and seeing the irrelevant but loud NOK complaints.

New version:

  $ pmbootstrap status
  Channel: edge (pmaports: master_staging_systemd)
  Device:  qemu-amd64 (x86_64, kernel: virt)
  UI:      console
  systemd: no (default for selected UI)

Old version (without --details it only shows NOK checks):

  $ pmbootstrap status --details
  [00:55:20] *** CONFIG ***
  [00:55:20] Device: qemu-amd64 (x86_64, "QEMU amd64")
  [00:55:20] Kernel: virt
  [00:55:20] User Interface: console
  [00:55:20]
  [00:55:20] *** GIT REPOS ***
  [00:55:20] Path: /home/user/.local/var/pmbootstrap/cache_git
  [00:55:20] - aports_upstream (master)
  [00:55:20] - pmaports (master)
  [00:55:20]
  [00:55:20] *** CHECKS ***
  [00:55:20] [OK ] Chroots zapped recently (or non-existing)
  [00:55:20] [OK ] aports_upstream: on official channel branch
  [00:55:20] [OK ] aports_upstream: workdir is clean
  [00:55:20] [OK ] aports_upstream: tracking proper remote branch 'origin/master'
  [00:55:20] [OK ] aports_upstream: up to date with remote branch
  [00:55:20] [OK ] aports_upstream: remote information updated recently (via git fetch/pull)
  [00:55:20] [OK ] pmaports: on official channel branch
  [00:55:20] [OK ] pmaports: workdir is clean
  [00:55:20] [OK ] pmaports: tracking proper remote branch 'origin/master'
  [00:55:20] [OK ] pmaports: up to date with remote branch
  [00:55:20] [OK ] pmaports: remote information updated recently (via git fetch/pull)
  [00:55:20]
  [00:55:20] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
  [00:55:20] DONE!
2024-04-16 18:54:35 +00:00
Clayton Craft ca844038f1
Revert "pmb.build._package: build depends of subpackages (MR 2292)"
This patch caused a regression[1] that needs to be debugged/fixed, so
reverting in the meantime.

This reverts commit 8b0dfe489a.

1. https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2341
2024-04-15 23:31:14 -07:00
Oliver Smith 8b0dfe489a
pmb.build._package: build depends of subpackages (MR 2292)
Make sure that we build depends of subpackages, to avoid errors like the
following:

* postmarketos-base has a subpackage postmarketos-base-nftables, which
  depends on postmarketos-config-nftables
* when pmbootstrap builds postmarketos-base with all its dependencies,
  it did not realize it depends on postmarketos-config-nftables through
  the subpackage, but it built it anyway
* when trying to install postmarketos-base-nftables, apk complains that
  there is no postmarketos-config-nftables:
  ERROR: unable to select packages:
    postmarketos-config-nftables (no such package):
      required by: postmarketos-base-nftables-32-r2[postmarketos-config-nftables]

This also adds the missing depenendencies to "pmbootstrap repo_missing",
which bpo uses to resolve dependencies.

Fixes: issue 2084
2024-04-12 14:03:15 +02:00
Oliver Smith 8bafa93bb2
pmbootstrap init: remove text about daily zapping (MR 2293)
Now that pmbootstrap displays a warning on stale chroots, we don't need
to show this at the end of "pmbootstrap init".
2024-04-11 21:50:35 +00:00
Oliver Smith ed8e7c1f85
pmb.chroot.init: warn about outdated chroots (MR 2293)
Prepare to remove the outdated chroot check from "pmbootstrap status".
Display it when the user enters a stale chroot instead. This way the
user is more likely to see it, and we can make "pmbootstrap status" more
minimal (by removing all checks, in future patches).

Related: issue 1903
2024-04-11 21:50:30 +00:00
Newbyte 2972f1d36e
pmb: Handle BuildFailedError (MR 2288)
Also breaks out hinting printing code into its own function to avoid
repetition.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2068
2024-04-10 20:49:21 +00:00
Newbyte d5badd1b0e
pmb.build._package: Raise BuildFailedError when build fails (MR 2288)
This allows us to differentiate between the build failing and any other
runtime error that may be raised from calling this function.
2024-04-10 20:49:21 +00:00
Newbyte ac68535870
pmb.helpers.exceptions: Add BuildFailedError (MR 2288) 2024-04-10 20:49:07 +00:00
Oliver Smith ae75f3b884
build: fix !pmb:crossdirect (MR 2291)
With the !pmb:crossdirect option, the crossdirect compilation method
gets disabled. This means there is no /native directory mounted inside
the foreign arch chroot, all binaries inside the foreign arch chroot are
supposed to run in QEMU. Handle this in the apk_wrapper.sh script that
we use to redirect abuild-apk to /native/usr/bin/abuild-apk.

Fix for (currently with master_staging_systemd branch):
  >>> upower: Analyzing dependencies...
  /usr/local/bin/abuild-apk: line 11: /native/usr/bin/abuild-apk: not found
2024-04-06 09:01:55 +00:00
Newbyte fe5fa422d9
pmb.install._install: Replace osk-sdl with unl0kr in nofde explanation (MR 2289)
See https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2333
2024-04-04 10:59:58 +02:00
Newbyte bd4d818cca
pmb.helpers.repo_missing: Replace osk-sdl with unl0kr in example (MR 2289)
See https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2333
2024-04-04 10:59:58 +02:00
Newbyte 8a518c5304
pmb.flasher.frontend: Replace osk-sdl with Unl0kr in FDE reminder (MR 2289)
See https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2333
2024-04-04 10:59:58 +02:00
Newbyte d02801a8b3
pmb.chroot.apk: Use unl0kr instead of osk-sdl in example (MR 2289)
See https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2333
2024-04-04 10:59:58 +02:00
Oliver Smith 11c2206970
require_bootstrap: ensure apkindex exists (MR 2287)
When the user attempts to build a package with systemd enabled,
pmbootstrap checks first if the postmarketos-base-systemd package is in
any of the APKINDEX files. Fetch the APKINDEXes before trying to find
the package in them.

I'm running into this currently with bpo, when attempting to build any
package from the master_staging_systemd branch.
2024-04-03 19:08:48 +00:00
Newbyte c73e439d0a
pmb.sideload: Remove irrelevant output when querying architecture (MR 2286)
Previously, if this was the first time you were connecting to a device,
the output of the ssh command would contain a warning about that the
host was added to the list of trusted hosts. This causes problems as
this gets included in the output where the code previously expected the
string-representation of the architecture to be.

As such, remove the irrelevant output by splitting it into lines and
only using the last line as we assume ssh won't print anything after the
actual output of the invoked command.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2335
[ci:skip-build]: already built successfully in CI
2024-04-01 22:21:16 +02:00
Newbyte 1d515f9389
pmb.sideload: Run apk incantation in a subshell (MR 2283)
I have Nushell set up on my Librem 5, and it is not a POSIX-compatible
shell. As such, the rc=$? variable assignment in this snippet fails.
Running this in a sh subshell works around this problems and will likely
fix it for other non-POSIX shells as well given that /bin/sh should at
least be POSIX-compatible on any sensible system.
2024-03-30 14:20:13 +00:00
Clayton Craft 3ff178eb32
pmb.parse.arch: use qemu for running armhf on aarch64 (MR 2285)
This works around an issue where some armhf apps are compiled with
instructions that are not compatible with aarch64, for example apk uses
MCR, and that does not exist on aarch64 causing apk to fail in a chroot
with SIGILL. It's impossible to build armhf images on aarch64 hosts, and
this also fixes a crash when running `pmbootstrap zap -a`, since pmb zap
will init an armhf chroot and blow up with apk generates a SIGILL.

For reference, here's how I arrived at the conclusion that apk (and gdb,
and probably others...) are executing invalid instructions on aarch64
when not using binfmt+qemu emulation:

$ uname -m
aarch64

$ file sbin/apk.static
sbin/apk.static: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, BuildID[sha1]=997a8ef97b17cb4951a6220b7807a66fed67bc10, stripped

$ gdb sbin/apk.static
(gdb) r
Starting program: /run/user/10000/foo/sbin/apk.static
Program received signal SIGILL, Illegal instruction.
0x0012843c in ?? ()
(gdb) x /1i $pc
=> 0x12843c:    mcr     15, 0, r0, cr7, cr10, {5}
2024-03-30 00:03:56 +00:00
Newbyte ce08cb6803
pmb.helpers.exceptions: Add licence header (MR 2284)
I forgot to add this in the original commit.

Fixes 19b50a3deb
2024-03-30 00:00:42 +00:00
Newbyte ba2ff0ea70
pmb.parse.arch: Import pmb.config instead of pmb.parse.arch (MR 2282)
I'm not sure why pmb.parse.arch is being imported here given that it's
the module we already are in. Replace it with pmb.config which this
module actually needs.
2024-03-28 11:03:25 +01:00
Newbyte c2a069b1f5
pmb.sideload: Query architecture from foreign device (MR 2282)
Instead of assuming the architecture of the foreign device to be what
the user selected in pmbootstrap init, actually query the architecture
from the device and use that.

This does mean that one extra ssh connection is necessary, which does
slow down the procedure somewhat. However, I think that is worth the
user experience improvement this brings.

Also, the deduction process can be skipped by manually specifying
--arch in the sideload invocation should it fail, or if one really wants
to skip that extra ssh roundtrip.

Related: https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2317
2024-03-28 11:03:25 +01:00
Newbyte 1fc83f8bce
pmb.parse.arch: Break out marchine type to arch into separate function (MR 2282)
Sometimes it's useful to map an arbitrary machine type to an Alpine
architecture. alpine_native only lets you get the Alpine architecture
mapped to the machine type of the system pmbootstrap is running on. As
such, break out this functionality into a new function that takes the
machine type as a parameter.
2024-03-28 11:03:24 +01:00
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
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
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