Commit Graph

215 Commits

Author SHA1 Message Date
Oliver Smith 1f80472dda
helpers.git.get_upstream_remote: default to origin (MR 1940)
Do not crash in pmaports.git CI for merge requests where a different
repository was cloned as "origin". Fixes:

"ERROR: pmaports: could not find remote name for URL
 'https://gitlab.com/postmarketOS/pmaports.git' in git repository:
 /builds/plata-gl/pmaports"
2020-05-17 11:06:39 +02:00
Oliver Smith 7f60a6d782
chroot: put built packages into channel subdir (MR 1912)
Migrate to workdir version 5 and move already built packages into the edge
channel subdir, for example:
	$WORK/packages/x86_64/hello-world-1-r5.apk
to:
	$WORK/packages/edge/x86_64/hello-world-1-r5.apk

The build.postmarketos.org code has already been adjusted to find built
packages in either directory structure.
2020-05-17 08:08:45 +02:00
Oliver Smith 3ff0b18a08
pmb.chroot.init: verify chroot channel (MR 1912)
Refuse to work with a chroot that was created for another release
channel.
2020-05-17 08:08:45 +02:00
Oliver Smith ce433ae012
pmb.helpers.repo.urls: use channels.cfg mirrordirs (MR 1912)
Use mirrordir_pmos and mirrordir_alpine from channels.cfg to generate
the mirror URLs for postmarketOS and Alpine, which get written to
/etc/apk/repositories and which postmarketOS uses to download the
APKINDEX files.

Remove hardcoded "master" at the end of the postmarketOS mirror and use
mirrordir_pmos instead (which is "master" for the edge channel). Let the
postmarketOS mirror end in a '/' for consistency with the Alpine mirror
in pmb/config/__init__.py.

Remove obsolete --alpine-version. To experiment with a different Alpine
version, one should pass a custom --config-channels from now on.
2020-05-17 08:08:45 +02:00
Oliver Smith 6d64586b9f
test/test_repo.py: rename to test_helpers_repo.py (MR 1912)
This file is about testing pmb/helpers/repo.py, so make the name of the
test file consistent with other test/test_helpers_*.py files.
2020-05-17 08:08:45 +02:00
Oliver Smith 17f3b3c2f0
pmbootstrap init: ask for release channel (MR 1912)
Ask for release channel and switch pmaports branch to the related branch
defined in channels.cfg.

Store in pmbootstrap.cfg whether the user chose a channel (boolean). If
the user did not choose a channel yet, suggest the recommended channel
from channels.cfg (currently "edge").
2020-05-17 08:08:45 +02:00
Oliver Smith c616874443
pmb.helpers.git: parse channels.cfg (MR 1912)
Prepare to base postmarketOS on Alpine stable by parsing the new
channels.cfg file in pmaports.git, that describes which channel
needs which branches and mirror dirs from postmarketOS and Alpine.

Use the information in pmb.helpers.git.get_branches_official() first,
more is coming in follow-up commits.

Read the file from origin/master, so we get the latest fetched version
even if the last checked out master branch is not up-to-date (think of
currently checked out release branch instead of master, master will
never be updated to point to latest origin/master). Allow to override
the file with a new --config-channels parameter.

Related: https://postmarketos.org/channels.cfg
2020-05-17 08:08:44 +02:00
Oliver Smith f3466dcd3f
pmbootstrap lint: use CUSTOM_VALID_OPTIONS (MR 1934)
Let apkbuild-lint check options again, and pass the pmbootstrap specific
options with the new CUSTOM_VALID_OPTIONS variable. Add a test case and
adjust pmb.helpers.lint.check to return the output of apkbuild-lint, so
we can properly test it.

Related: https://gitlab.alpinelinux.org/Leo/atools/-/merge_requests/28
Fixes: pmaports#553
2020-05-10 16:35:35 +02:00
Daniele Debernardi 9c2d951fc9
pmb.aportgen.device: replace mesa-dri-swrast with mesa-dri-gallium (MR 1917)
The `mesa-dri-swrast` package was merged into `mesa-dri-gallium` in Alpine.
(See 298e20d04f)

The old alias might be removed in the future, so change the generated APKBUILDs
to depend on `mesa-dri-gallium` instead.
2020-04-28 09:23:09 +02:00
Minecrell 87f81de052
test: test_questions_ui_extras: add tests for UI extras (!1911)
Ensure that it does not fail with the "none" UI (it does at the moment).
2020-04-11 20:57:01 +02:00
Minecrell 6731d02c4b
test: test_questions_ui: ensure that we can select "none" (!1911) 2020-04-11 20:57:01 +02:00
Minecrell 7f0898f1c5
test: test_questions_ui: use local aports (!1911)
This allows us to test the extras UI implementation without
modifying some packages in pmaports.
2020-04-11 20:57:01 +02:00
Minecrell 181687a2d7
test: test_qemu_running_processes: ensure "none" UI boots correctly (!1911)
No special process needs to be running, SSH is good already :)
2020-04-11 20:56:57 +02:00
Oliver Smith 8dc8daa05a
test: adjust to device-qemu-amd64 move to main (!1910)
Don't assume that the device selected in "pmbootstrap init" is in the
testing subdir anymore. The default device, qemu-amd64, was recently
moved to main, so this does not hold up anymore. Instead, use
pmb.helpers.pmaports.find to figure out the currect dir.
2020-04-11 18:56:30 +02:00
Oliver Smith 44bd235f3e
test/test_build_package.py: fix new flake8 errors (!1910)
F540 f-string is missing placeholder

Apparently I like the new f-strings so much that I used them even where
they make no sense ;)
2020-04-11 18:56:25 +02:00
Oliver Smith b4a05cbcfb
pmb.build.is_necessary: fix case with Alpine's pkg (!1904)
No build is necessary if pmaport can't be built for given arch.
pmbootstrap must use Alpine's binary package in that case, even if the
pmaport version is higher than Alpine's binary package version.

Fixes: #1897
2020-04-04 13:19:03 +02:00
Oliver Smith 44cb06d345
pmb build --no-depends: stop on outdated pkgs too (!1900)
The --no-depends option is supposed to stop pmbootstrap if it was
instructed to build a package, but a dependency must be built first. So
far, this only covers the case if there is no binary package for a dependency.
Make it stop if the binary package exists, but is outdated, too.

Fixes: #1895
2020-04-01 09:22:35 +02:00
Minecrell b4c54636b3
test/testcases_fast.sh: stop hardcoding testing/ directory (!1899)
Take the change from pmaports that expands a glob for more flexibility.
2020-04-01 02:50:09 +03:00
Oliver Smith 9d17ed29e3
pmb aportgen binutils: add texinfo to makedepends (!1901)
The current version of binutils does not build anymore without texinfo.

Related: #1894
Related: pmaports!1114
2020-03-31 23:33:41 +02:00
Oliver Smith cfd93bc6ea
pmbootstrap status: check if git repo is outdated (!1882)
Use the timestamp of .git/FETCH_HEAD in each git repository, to
determine if too much time has passed since the last fetch/pull.
Modify pmb.helpers.git.clone, so FETCH_HEAD is always created if it does
not exist (because "git clone" would not create it).

Related: #1829
2020-03-14 19:15:32 +03:00
Oliver Smith c8526f2fcb
pmbootstrap status: basic checks for git repos (!1882)
Extend "pmbootstrap status" with checks for all git repositories,
derived from relevant checks in pmb.helpers.git.pull (using shared
code):
* on official branch
* workdir is clean
* tracking proper remote
* up to date

Related: #1829
2020-03-14 19:15:32 +03:00
Oliver Smith 6977f5f3e5
test.test_helpers_git.test_pull: move prep code (!1882)
Create pmb_test.git.prepare_tmpdir() with preparation code, so we can
use it in a "pmbootstrap status" related test without duplication.
2020-03-14 19:15:32 +03: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
Minecrell c399ff81a1
test/test_helpers_pmaports: create empty APKBUILDs for fake packages (!1879)
In general, we should not assume that pmbootstrap considers empty
package directories (without APKBUILD in them). With upcoming changes
this is no longer the case, so lets create an empty file for them.
2020-03-14 08:39:13 +01:00
Minecrell 903491f518
test/test_qemu_running_processes: use Alpine virt kernel (!1886)
The QEMU device ports no longer make use of the linux-postmarketos-
stable/mainline kernels, causing the test to fail with

  RuntimeError: Selected kernel (stable) is not configured for device qemu-amd64.
  Please run 'pmbootstrap init' to select a valid kernel.

Let's configure the test to use the "virt" kernel.
2020-03-14 08:05:32 +01:00
Minecrell 345425ef48
test/test_qemu_running_processes: make timeout actually work (!1886)
Just counting the number of tries does not prevent the QEMU tests
from running long periods of time. In some situations, the ssh command
will keep trying to reach the destination almost indefinitely.

To make the 5 minutes timeout work correctly we need to:
  - Add an appropriate ConnectTimeout to the ssh command
  - Don't sleep for another second if ssh already took several seconds
  - Check the elapsed time instead of setting a fixed amount of tries
2020-03-14 08:05:32 +01:00
Minecrell 320b2faa4c
pmb.qemu: remove QEMU mesa driver setup question (!1886)
mesa-dri-swrast and mesa-dri-virtio are both provided by mesa-dri-gallium
now, so this option does not have much use anymore. With both selections,
exactly the same packages are installed.
2020-03-14 08:05:32 +01:00
Oliver Smith 7c4db04b9d
test_crossdirect: s/armhf/armv7 (!1888)
Work around old rust version in Alpine's armhf repository (builder
currently stuck?) compared to other arches. Armv7 is fine, so switch to
that and avoid this error:

error[E0514]: found crate `std` compiled by an incompatible version of rustc
2020-03-14 01:07:02 +01:00
Minecrell 0997a46b3a
pmb: replace deviceinfo_date with deviceinfo_year, add to wizard (!1888)
See: https://gitlab.com/postmarketOS/pmaports/issues/447
2020-03-14 00:33:22 +01:00
Minecrell 7915e94275
pmb.config: remove deviceinfo_nonfree (!1888)
See: https://gitlab.com/postmarketOS/pmaports/-/issues/438
2020-03-14 00:33:22 +01:00
Alexey Min 7e61e62044
pmb.helpers.cli: add tab completion option for ask() helper (!1875)
Add a helper class that provides readline-based tab completion and an
extra optional argument "completion_choices" with possible completion
targets.

While at this, also improve paramters documentation for ask() func.
2020-02-26 01:20:18 +03:00
Oliver Smith 1724ed4665
pmbootstrap status: show if chroots are outdated (!1878)
Add new "pmbootstrap status" command, which does a quick health check
for the work dir. As first health check, verify that the chroots are not
too old. Replace the reminder text at the end of "pmbootstrap init" to
tell users to run "pmbootstrap status" instead of "pmbootstrap zap" once
a day before working with pmbootstrap.

Related: #1829
2020-02-24 18:18:53 +01:00
Oliver Smith 17673c5bf1
pmb.config.workdir: save/check chroot init date (!1878)
Whenever initializing new chroots, save the date in $WORK/workdir.cfg.
Add pmb.config.workdir.chroots_outdated() to check if it's time to zap
the chroots or not (since we don't update them automatically). Mark them
as outdated after two days.

This will be the first check in "pmbootstrap status" (future patches).
Related: #1829
2020-02-24 18:18:38 +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
Oliver Smith e605a0af32
test/pmb_test: prepare for common test code (!1876)
Replace the "Add topdir to import path" boilerplate lines in each test
file with a simple "import pmb_test". Use the "# noqa" comment if
"pmb_test" is not used further in the test file, so flake8 does not
complain about an unused module.

Make the path to the testdata available as pmb_test.const.testdata, and
use pmb.config.pmb_src to access the topdir in all tests.

This is in preparation for new "pmbootstrap status" related tests, which
will have shared test code in test/pmb_test/. Also, this makes the
pmbootstrap codebase more consistent with the bpo codebase, which has a
similar "import bpo_test" mechanism.
2020-02-24 03:01:04 +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
Minecrell 5f5050f9a3
pmb.parse._apkbuild: Replace variables immediately after parsing (!1866)
At the moment we parse all attributes, split them, and eventually
join them back together for variable replacement.

Replacing variables immediately after parsing (before splitting)
has several advantages:

  - No need to handle different value types
    (e.g. lists by joining them every time they are accessed)

  - Variables like depends="$depends ..." are handled directly
    by the variable parser

  - APKBUILDs are shell scripts, so we match abuild more closely
    if variables defined later do not affect previous attributes
2020-02-19 14:56:46 +03:00
Daniele Debernardi 0244ffbf53
static_code_analysis.sh: find all shell files (!1853) 2020-01-22 00:20:07 +01:00
Daniele Debernardi b60730499c
static_code_analysis.sh: use shellcheck/flake8 from chroot (!1853) 2020-01-22 00:17:23 +01:00
Oliver Smith e04712a636
pmbootstrap pull: new action (!1848)
Add a shortcut for "git pull --ff-only" in all repositories cloned by
pmbootstrap (currently pmaports and aports_upstream, new pmdevices
repository coming soon).

'pmbootstrap pull' will only update the repositories, if:
* they are on an officially supported branch (e.g. master)
* the history is not conflicting (fast-forward is possible)
* the git workdirs are clean

Otherwise it shows the user a descriptive message about what to do. The
list of supported branches is only "master" right now, and will be
extended in later commits, so we can have a stable branch for pmaports
based on Alpine's releases. More about that in the project direction
2020 issue.

Closes: #1858
2020-01-19 20:37:46 +03:00
Oliver Smith 107c9f8b06
pmb.helpers.git.get_path: new function (!1848)
Get the path to the repository, which is either the default one in the
work dir, or a user-specified one in args.
2020-01-19 20:37:46 +03:00
Minecrell 7907e91879
pmb/parse/_apkbuild: Fix locating kernel subpackages with "-" in name (!1857)
When defining a new kernel subpackage with a "-" in it
(e.g. $pkgname-kernel-mainline-modem), then pmbootstrap is unable to
find the function that builds the subpackage:

ERROR: Could not find subpackage function, no line starts with 'kernel_mainline-modem() {'

This is because it assumes that a $pkgname-kernel-<name> subpackage
is built by a kernel_<name> function, but this does not have to be the case.

We should really respect the name of the subpackage function that
is specified when defining the subpackage, but unfortunately it is
stripped away in cut_off_function_names().

For now let's fix this by replacing "-" with "_", but ideally the
APKBUILD parser API should be refactored to expose the subpackage
function in the future.
2020-01-19 19:36:11 +03:00
Luca Weiss 2320e0100c
pmb/parse/_apkbuild: implement parsing for more variable styles (!1854)
Add a test for APKBUILD variable parsing as well
2020-01-19 11:30:59 +01:00
Luca Weiss b0563c54d0
test: fix small mistake (!1854) 2020-01-19 11:30:59 +01:00
Minecrell 1fa61aad37 test: parse_depends: Fix hello-world test after pkgrel bump 2020-01-18 11:23:01 +01:00
Oliver Smith 74f76f03f6
crossdirect: support rust (!1850)
Install rust (rustc) in native chroot, if it is in the APKBUILD's
build dependencies. Add a test to verify that crossdirect + rust works
as expected.

Closes: #1861
2020-01-14 02:50:53 +01:00
Oliver Smith b1cb662645
pmbootstrap init: check for required programs (!1845)
Prepare to require "git" in a follow-up patch.
2020-01-12 00:39:41 +01:00
Daniele Debernardi 3f2a064993
pmb.aportgen: add Contributor/Maintainer to APKBUILD templates (!1852) 2020-01-07 01:46:38 +01:00
Oliver Smith 948e3f931f
Change copyright to 2020 2020-01-06 02:43:00 +01:00
Oliver Smith 5076069209
pmb/aportgen/gcc.py: add LANG_D=false (!1849)
Alpine's APKBUILD for gcc supports a new language that we don't need, so
disable it just like the irrelevant ones.

Related: https://gitlab.com/postmarketOS/pmaports/merge_requests/839
2019-12-30 12:04:12 +01:00