Commit Graph

28 Commits

Author SHA1 Message Date
Clayton Craft 28b6106dd3
chroot.apk,apk_static: always disable interactive mode
This fixes an issue when pmb is run on an Alpine/pmOS host and apk.static sees
that /etc/apk/interactive is set on the host. It's really annoying to have the
build pause so apk can prompt when building chroots, so this uses a flag to apk
to disable interactive mode. I can't think of any situations where we would
actually want to prompt users when building chroots, by then all user
configuration should have been completed via pmb init/config.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Co-developed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20231110185320.8358-1-clayton@craftyguy.net%3E
2023-11-13 09:30:30 +01:00
Oliver Smith 9975d373b0
Bump copyright to 2023 2023-01-22 19:18:06 +01:00
Oliver Smith 6f6a3b0408
Happy new year 2022! 2022-01-02 22:39:14 +01:00
bo41 caf7973e24
args.arch_native: remove (MR 2130)
Replace "args.arch_native" with the direct function call 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-10-24 14:34:30 +02:00
Newbyte 2d23849aa3
pmb, test: remove redundant commas (MR 2115) 2021-09-26 17:58:40 +02:00
Anri Dellal 88ec1d1106
pmb.chroot: fix E501, switch to f-strings (MR 2040) 2021-03-30 15:13:26 +02:00
Oliver Smith 69cd7895e2
pmb.config.apk_tools_min_version: support branches (MR 2015)
Support branches, so pmbootstrap won't fail if v20.05 is selected:
  ERROR: You have an outdated version of the 'apk' package manager installed
  (your version: 2.10.5-r1, expected at least: 2.12.1-r0).

Move the logic for this check to pmb.helpers.apk.check_outdated and
adjust the test.

This fixes the CI failure in test_crossdirect_rust, which uses the
stable channel. (My bad for not creating this patch earlier, while at
the same time explaining in the creating pmbootstrap release instructions,
that this minimum apk version should be adjusted.)
2021-01-27 22:05:25 +01:00
Oliver Smith e9947f42de
pmb.config.apk_tools_static_min_version: rename (MR 2015)
Remove "_static" from the variable name, as this version isn't just
used to compare apk-tools-static's version (used to set up chroot), but
also for regular apk-tools before entering chroots.
2021-01-27 22:05:20 +01:00
Oliver Smith 1c791da482
treewide: bump copyright to 2021 2021-01-07 23:30:47 +01:00
Johannes Marbach bbf0a70e5b
Add progress bar when running apk commands (MR 1996)
This adds a progress bar when running apk commands both inside and
outside of the chroot.

Closes: #1700
2020-12-07 12:41:28 +01:00
Oliver Smith 554dbd73ba
pmb.chroot.apk_static.download: fix mirrordir (MR 1966)
When selecting the stable channel in "pmbootstrap init", do not attempt
to download apk-tools-static from the "edge" mirrordir. This stopped
working, because the version in the APKINDEX of v3.12 is different than
the one in edge now.

Fixes:
	Download http://dl-2.alpinelinux.org/alpine/edge/main/x86_64/apk-tools-static-2.10.5-r1.apk
	ERROR: HTTP Error 404: Not Found

Related: https://builds.sr.ht/~postmarketos/job/272760#task-pmbootstrap_build-123
2020-08-05 10:04:48 +02: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
Oliver Smith 948e3f931f
Change copyright to 2020 2020-01-06 02:43:00 +01:00
Oliver Smith f16bdaf0ca
Update copyright to 2019
Happy new year \o/
2019-01-02 09:31:20 +01:00
Oliver Smith e458b1fdbc Add --offline flag
Allow working offline with pmbootstrap, as long as all packages that
are being used have already been downloaded.
2018-10-25 20:37:33 +00:00
Oliver Smith 1f8832c4cc install apk keys and binfmt data with setup.py 2018-09-17 10:06:57 +00:00
Oliver Smith 8268dc0e3d pmbootstrap: kill process if silent for 5 minutes (rewrite logging) 2018-07-14 01:13:28 +00:00
Oliver Smith b8f35d45b8
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.

After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).

The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:

    pmbootstrap chroot --add=git --user -- \
        git -C /mnt/pmbootstrap-git/aports_upstream pull

Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
  the absolute path to the upstream aport on disk, after checking the
  version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
  APKINDEX if necessary and returns the absolute path to the APKINDEX.
  This code was basically present already, but not as function, so now
  we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
  the official gcc APKBUILD before we modify it (the current APKBUILD
  parser is not meant to be perfect, as this would require a full shell
  parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
  `testcases_fast.sh`.  Previously it was disabled due to traffic
  concerns (cloning the aports repo, but then again we do a full KDE
  plasma mobile installation in Travis now, so that shouldn't matter
  too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
  from the disabled-by-default list (left over from timestamp based
  rebuilds), there were no more test cases disabled by default. I've
  changed it, so now the qemu_running_processes test case is disabled,
  and added an `--all` parameter to the script to disable no test
  cases. Travis runs with the `--all` parameter while it's useful to
  do a quick local test without `--all` in roughly 2 minutes instead of
  10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
  default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
Oliver Smith 99127111a1
Only download APKINDEX for relevant architectures (#1201)
### Only download APKINDEX for relevant architectures
We're downloading the APKINDEX files for all architectures supported by
postmarketOS currently (x86, x86_64, armhf, aarch64). Most of the time,
we only need it for the native and device arch, so this PR reduces the
downloaded files to what is really necessary.

### Intuitive pmbootstrap update logic
* pmb.helpers.repo.update():
  * Default is updating all arches where the APKBUILD files exist
  * Add existing_only parameter
  * Return True when files have been downloaded
  * Properly print which arches will be updated
  * Print update reason only in verbose log
  * Add and improve comments
* pmb.parse.arguments(), update action:
  * Add --non-existing parameter
  * Default for --arch is None (instead of arch.native)
* pmb.helpers.frontend.update():
  * Inform about --non-existing if no APKBUILDs have been updated
2018-03-04 13:44:27 +00:00
Oliver Smith db5e69630e
Index parser: support multiple package providers (#1202)
* The APKINDEX parser used to return a dictionary with one package for
  a given package name. This works for the installed packages database,
  because there can only be one provider for a package. But when
  parsing packages from binary repositories, we need to support
  multiple providers for one package. It is now possible to get a
  dictionary with either multiple providers, or just a single provider
  for each package.
* Dependency parsing logic has been adjusted, to support multiple
  providers. For multiple providers, the one with the same package
  name as the package we are looking up is prefered. If there is none
  (eg. "so:libEGL.so.1" is provided by "mesa-egl"), it prefers packages
  that will be installed anyway, and after that packages that are
  already installed. When all else fails, it just picks the first one
  and prints a note in the "pmbootstrap log".
* Added testcases for all functions in pmb.parse.apkindex and
  pmb.parse.depends
* pmbootstrap chroot has a new "--add" parameter to specify packages
  that pmbootstrap should build if neccessary, and install in the
  chroot. This can be used to quickly test the depencency resolution
  of pmbootstrap without doing a full "pmbootstrap install".

Fixes #1122.
2018-02-20 19:52:28 +00:00
Oliver Smith e5ed3f86d0
Fix error message suggesting to run invalid command "zap -a" (#1132)
The message showed up, when you apk-static download could not be
verified. What the user needs to do instead is checking if openssl
is installed, and possibly delete the http cache ("zap -hc").
2018-01-23 01:03:31 +00:00
Oliver Smith 3c8a93fa7b
Improved pmbootstrap init (#1095)
This PR makes the workflow faster and pmbootstrap will
produce less traffic. Details:
* Check if it's possible to create and read from a device
  node directly when initializing a chroot (closes #472)
* Copy the Qemu binary into the forign-arch chroots
  before initializing them, so the post-install script
  directly work during the chroot setup and we don't need
  to call apk fix afterwards
* Use pmb.helpers.repo.update(), which only updates the
  APKINDEX files if they are older than 4 hours, instead
  of using apk's repo update function which always
  downloads the APKINDEX files
* Chroot initialization
  * Getting the initial APKINDEX to download apk-tools-static
  * Updating the APKINDEX at the start of pmbootstrap install
* Fixed a bug in from_chroot_suffix: the buildroot_x86_64 has
  architecture x86_64, not x86.
2018-01-23 00:54:48 +00:00
Oliver Smith 7750c1dd40
Happy new year! (update copyright to 2018) 2018-01-04 04:53:35 +01:00
Oliver Smith f3f21d3152 Fix #342: don't use distutils.version.LooseVersion anymore (#364)
Previously, distutils.version.LooseVersion was used, because it was
sort of close enough to how Alpine parses versions.

This new version uses the exact same algorithm, as `apk` does, and
it passes *all* of `apk`'s testcases for version checking (previously
we simply skipped the ones, that did not pass).

* Remove pmb/helpers/version.py left-over (it is in parse now)
* Make asserts consistent, do not use unnecessary parenthesis
2017-08-12 14:03:40 +00:00
Oliver Smith 63aa1eae1b
AutoPEP8 1.3.2 slightly changed automatic formatting 2017-07-14 07:00:07 +02:00
Oliver Smith fb1e8ec73b
Update min apk version/add more apk version checks
* Minimum version: 2.7.2 (which fixes two CVEs)
* Check the minimum apk version before doing something with apk and
  before entering the chroot manually (previously, it has just checked
  the apk-tools-static version, which gets used to set up the chroot)
* Reword the message for an outdated APK version. Most likely it is
  just the outdated http cache, instead of a man-in-the-middle attack.

See also:
b849b481a0
2017-06-23 17:04:49 +02:00
Oliver Smith 75641f5fc7
Set up static code analysis, fix style issues reported by flake8 2017-05-28 02:44:53 +02:00
Oliver Smith ae950fb9f7
Hello, there! 2017-05-26 22:08:45 +02:00