Commit Graph

1588 Commits

Author SHA1 Message Date
Minecrell 6540c25a9b
envkernel.sh: add dependencies for x86_64 (!1870)
x86_64 kernels require some additional dependencies to build properly.

At this point, the list is getting quite long. Ideally we should only
install the build dependencies that are necessary for a particular
kernel package. Add a FIXME to document this for the future.
2020-02-07 19:20:40 +03:00
Minecrell 569c8ff5b0
envkernel.sh: fix x86_64 (arch == host_arch) (!1870)
Attempting to use envkernel.sh on x86_64 fails at the moment:

$ . ~/pmos/pmbootstrap/helpers/envkernel.sh
Initializing Alpine chroot (details: 'pmbootstrap log')
ERROR: unsatisfiable constraints:
  binutils-x86_64 (missing):
    required by: world[binutils-x86_64]
  gcc-x86_64 (missing):
    required by: world[gcc-x86_64]

We do not need to install a cross compiler if the device arch is
equal to the host architecture. Check if we need a cross compiler
earlier, and avoid installing it if not necessary.

Also rename "is_cc" to "need_cross_compiler". "is_cc" is confusingly
named since "cc" can refer to the compiler symlink ("C compiler")
or "cross compiler".
2020-02-07 19:20:01 +03:00
Oliver Smith fbbcc1c26f
pmb.parse.arguments: common func for packages arg (!1872)
Create add_packages_add() function, so we don't need to write the three
lines for adding the "packages" argument to an action with proper
autocompletion.
2020-02-06 16:29:31 +03:00
Danct12 a021d1924c
pmb.helpers.lint: add simple linting (!1855)
Run linting, just like in pmaports.git CI checks. Start with
apkbuild-lint, eventually this should run all checks.

Related: #1869
2020-02-06 13:45:21 +01:00
Oliver Smith 2f01c91c1a
pmbootstrap -s: remove option (!1868)
Remove in favor of similar, but more visible "--no-install" option for
"pmbootstrap flasher" and "pmbootstrap export".

It seems that the option wasn't really used by anybody, so let's just
remove it without a deprication period. If dear reader thinks otherwise
after this is merged, and is not happy with "--no-install", please state
your reasoning in a new issue, so we can discuss it.

Related: !1863
2020-02-06 12:33:21 +01:00
Minecrell 630310ebfb
pmb.aportgen.linux: Fix linting issues in generated APKBUILDs (!1869)
Avoid generating an APKBUILD with the following linting issues:
  - unnecesary usage of braces: ${_flavor}
  - unnecesary usage of braces: ${arch}
  - unnecesary usage of braces: ${_commit}
  - unnecesary usage of braces: ${_repository}
2020-02-02 06:49:12 +03:00
Minecrell d3fede3262
pmb.qemu.run.install_depends: Fix Mesa Gallium DRI depends (!1867)
Commit 43520967 ("pmb.qemu.run.install_depends: adjust to mesa pkgs (!1865)")
replaced mesa-dri-swrast, mesa-dri-virtio and mesa-dri-vmwgfx with
mesa-va-gallium. But the Gallium DRI drivers are actually provided by
mesa-dri-gallium. mesa-va-gallium contains libva drivers for hardware
video acceleration.

Fortunately this did not break anything because mesa-dri-gallium
was still installed as dependency of mesa-dri-ati/intel/nouveau.

QEMU does not make use of libva, so lets just replace mesa-va-gallium
with mesa-dri-gallium. While we are at it, stop depending on the
deprecated mesa-dri-ati/intel/nouveau packages. Those are only kept
for compatibility reasons and install more dependencies than necessary.
2020-01-31 04:10:50 +01:00
Minecrell 60217d0818
pmb.flasher/export: Add --no-install option to skip kernel/initfs update (!1863)
At the moment, pmbootstrap updates the kernel and the initfs whenever
using the flasher or export. This is useful, but sometimes you just want
to boot exactly the same kernel several times. In that case, having to wait
several seconds for the (redundant) update to complete is quite annoying.

Add a --no-install option that allows skipping the kernel/initfs update.
2020-01-31 01:35:26 +01:00
Oliver Smith 8f4bd7dea1
Prepare 1.14.0 release 2020-01-27 00:35:05 +01:00
Luca Weiss 859159254e
pmb/parse/_apkbuild: wrap more calls in try-catch (!1864)
Otherwise pmb crashes on some APKBUILDs, for example:

source="https://files.pythonhosted.org/packages/source/${_pyname%${_pyname#?}}/$_pyname/$_pyname-$pkgver.tar.gz"
2020-01-26 23:06:39 +01:00
Minecrell c8737740b1
pmb.install: Add pmbootstrap install --(no-)sparse option (!1862)
At the moment, sparse images are generated if the device sets
deviceinfo_flash_sparse="true". But for testing purposes it can be
useful to specifically enable or disable the default behavior.

Add a --sparse and --no-sparse option that enables or disables
sparse image generation.
2020-01-26 22:56:42 +01:00
Oliver Smith 4352096783
pmb.qemu.run.install_depends: adjust to mesa pkgs (!1865)
Adjust the mesa related packages installed for running in qemu, after
the mesa APKBUILD in Alpine was changed. Install mesa-va-gallium instead
of:
* mesa-dri-freedreno
* mesa-dri-swrast
* mesa-dri-virtio
* mesa-dri-vmwgfx

Fix error in pmbootstrap-qemu CI test:
ERROR: Could not find dependency 'mesa-dri-freedreno' in any aports folder or APKINDEX.

Related: 298e20d04f
2020-01-26 21:05:42 +01:00
Minecrell 44e887f11e
pmb.install: remove qemu-user binary stub from device rootfs (!1861)
Now that the qemu-user binary is bind-mounted, we no longer copy
the binary to the device rootfs. However, there is still the empty
stub file that we used as a destination mount point.

Let's remove it before copying it to the device rootfs.
It is automatically re-created the next time the qemu-user binary
is needed.
2020-01-26 19:47:43 +01:00
Minecrell d0376ee0fb
pmb.chroot.init: mount --bind qemu-user binary (!1861)
Avoid copying the qemu-user binary to each chroot by using a bind mount.
This ensures that we remove it when we shutdown the chroot.
2020-01-26 19:47:42 +01:00
Minecrell 81d9bfe3ba
pmb.helpers.mount: bind_file: Add create_folders option (!1861)
Create the necessary directory structure if create_folders=True.
2020-01-26 19:47:42 +01:00
Minecrell f43d552039
pmb.helpers.mount: Rename bind_blockdevice() to bind_file() (!1861)
bind_blockdevice() can be also used to mount --bind files,
rename it to bind_file().
2020-01-26 19:47:28 +01:00
Oliver Smith f3dc6a55cf
gitlab-ci.yml: allow 'git config' cmds to fail
Two "su pmos -c 'git config --global user....'" commands were added to
the before_script in .gitlab-ci.yml. They work fine with the regular
gitlab runners, but fail with the custom gitlab runner that runs the
qemu test. Simply allow the command to fail, because it isn't needed on
the custom gitlab runner, as it doesn't run related tests.

Fixes: 16e2d3c77c ("gitlab-ci.yml: set git user/email (!1848)")
2020-01-24 22:41:23 +01:00
Daniele Debernardi 0244ffbf53
static_code_analysis.sh: find all shell files (!1853) 2020-01-22 00:20:07 +01:00
Daniele Debernardi b0ea7ad8a0
envkernel.sh: fix shellcheck errors (!1853) 2020-01-22 00:17:23 +01:00
Daniele Debernardi 39f6dbef2e
gitlab-ci.yml: remove flake8/shellcheck (!1853) 2020-01-22 00:17:23 +01:00
Daniele Debernardi 3092fcaddb
gitlab-ci.yml: init pmbootstrap for static_code_analysis.sh (!1853) 2020-01-22 00:17:23 +01:00
Daniele Debernardi b60730499c
static_code_analysis.sh: use shellcheck/flake8 from chroot (!1853) 2020-01-22 00:17:23 +01:00
Minecrell 4b2750e4a9
pmb.config: do not force installation of ttf-droid (!1860)
Right now we explicitly add ttf-droid to /etc/apk/world, and force
installation of it on every postmarketOS installation. But there really
is no reason to force this from pmbootstrap:

  - If ttf-droid is really required for every postmarketOS installation,
    it should be a depends of postmarketos-base.

  - Even with this change it is still installed on every device,
    because postmarketos-splash depends on it.

  - There is no need for fonts when using the "none" UI.

For now, the only difference of this change is that we no longer add
ttf-droid explicitly to the APK world. Instead, it is installed as
dependency of postmarketos-splash.
2020-01-20 14:19:41 +03:00
Minecrell 66fdb74b5b
qemu: Make QEMU audio backend configurable (!1859)
At the moment we assume that everyone running QEMU is either using
ALSA, or has the ALSA PulseAudio plugin configured on the host system.
(Since we run QEMU outside of the chroot at the moment, configuration
files are read from the host system instead of the chroot...)

Other distributions have much wider support for PulseAudio,
so not everyone will actually have the ALSA PulseAudio plugin configured.
In that case, it is better to use QEMU's PulseAudio backend since that
does not require any configuration. It also lets us drop the alsa-lib
fork, since that was only needed for loading the ALSA PulseAudio plugin.

In general, it seems difficult to detect which audio backend the user
wants to run (if any). Selecting the wrong one results in ugly warnings
when running QEMU. So let's not assume any by default, and add a
--audio option instead which accepts one of QEMU's audio backends
(alsa, pa or sdl).
2020-01-20 00:53:52 +03: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 16e2d3c77c
gitlab-ci.yml: set git user/email (!1848)
Prevent upcoming tests for "pmbootstrap pull" from failing, when trying
to create a git repository.
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
Oliver Smith bbe3f5a219
pmb.helpers.git.rev_parse: add extra_args argument (!1848) 2020-01-19 20:37:46 +03:00
Oliver Smith 9ca06bc6c2
pmb.helpers.git.rev_parse: add path argument (!1848) 2020-01-19 20:37:46 +03:00
Oliver Smith 2b1dfe7cfc
pmb.helpers.git.rev_parse: don't return "" on err (!1848)
Remove a legacy code path from back in the day, where pmaports were in
the same repository as pmbootstrap ([1]). Nowadays, pmaports are always in a
git repository, so this is not necessary anymore. If git fails at this
point, crash hard and don't carry on with an empty string.

This is in preparation for using rev_parse in new code paths, so we
don't need to check the return value of rev_parse.

[1] 39548835 "Write custom os-release (closes #324) (#439)"
    https://github.com/postmarketOS/pmbootstrap/pull/439
2020-01-19 20:37:43 +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
Oliver Smith 3f5cc734d9
pmb.config: add deviceinfo_boot_part_start
Fixes: 9f1dd64fa1 ("install/partition: allow specifying a different boot partition start (!1856)")
2020-01-18 23:03:32 +01:00
Clayton Craft 9f1dd64fa1
install/partition: allow specifying a different boot partition start (!1856)
This adds a new deviceinfo parameter, 'boot_part_start' which accepts an
int and indicates the number of sectors from the start of the drive to
place the boot partition.

The librem5 devkit (and actual phone) u-boot has grown beyond the 2048
sector space previously before the boot partition, so this is necessary in
order to boot pmos on this device.
2020-01-18 19:26:31 +00: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 728f304dc7
pmb.config.chroot_home_symlinks: cache rust dirs (!1850)
Rust packaging is new and still a bit weird in Alpine and postmarketOS.
As of writing, we only have one package (squeekboard), and use cargo to
download the source of all dependencies at build time (several git
repositories!) and compile it. Usually, this is a no-go, but at least
until this is resolved properly, let's cache the downloads as suggested
in: https://doc.rust-lang.org/cargo/guide/cargo-home.html

Related: #1861
2020-01-14 02:50:53 +01:00
Oliver Smith b93e83d8b3
pmb.chroot.init: home links: create missing dirs (!1850)
When initializing the building chroots, some symlinks are created to
/mnt/pmbootstrap* dirs. With upcoming rust-related symlinks, they will
point to subdirs in /mnt/pmbootstrap-rust, such as
/mnt/pmbootstrap-rust/registry/cache. Create this directory structure if
it does not exist.
2020-01-14 02:50:53 +01:00
Oliver Smith 02e514f4d3
pmb.helpers.git.clone: use git from host system (!1845)
Do not install git in the native chroot and use it from there. Remove the
chown_to_user argument from pmb.helpers.git.clone(), the resulting dir
is now always owned by the user. While at it, refactor the function and
display the clone URL.

Previously we had cloned aports_upstream (from Alpine) with
chown_to_user=False (legacy) and pmaports with chown_to_user=True.
pmb.helpers.git.rev_parse() would only work after chown_to_user=True.

Check if git is installed in "pmbootstrap init", and remove the same
check from rev_parse(). Add a new work dir version, that checks for git
and changes ownership of already checked out aports_upstream to the
host system's user.

When creating a new work dir, create cache_git instead of cache_http.
cache_http is created on demand already, with proper permissions. But
cache_git must be created, otherwise pmb.helpers.mount.bind will create it
as root.

This is in preparation for the "pmbootstrap pull" feature, as it allows
using the host system's git in all new code paths. We will be able to
handle repositories even if they were cloned outside of the work dir
(which we do in a few CI scripts for example).

Related: #1858
2020-01-12 00:39:47 +01:00
Oliver Smith cba37d5d79
chroot: keep ownership of cache_git (!1845)
Remove /home/pmos/git from pmb.config.chroot_home_symlinks, so
pmb.chroot.init.init() will not change the ownership of the
$WORK/cache_git dir.

The symlink was added two years ago in [1] as compatibility to previous
behavior, because the mountpoint of cache_git was changed from
/home/user/git to /mnt/pmbootstrap-git. Forcing the ownership of that
dir to be the pmos user inside the chroot made sense, because the only
cloned repository (aports_upstream) would also be owned by the pmos
user. With the upcoming change to have all cloned repos owned by the
host-system's user, this is just confusing.

The /home/pmos/git symlink does not seem to be used by anybody, it is
not mentioned in the pmbootstrap code and in the wiki.

[1] b4dd7a89 "Close #709: Improve user creation (#725)"
    https://github.com/postmarketOS/pmbootstrap/pull/725
2020-01-12 00:39:47 +01:00
Oliver Smith c53988b978
git aports_upstream: use gitlab.alpinelinux.org (!1845)
Use Alpine's primary mirror instead of the mirrored version at github
for new clones. A follow up commit will display the clone URL.
2020-01-12 00:39:47 +01:00
Oliver Smith a38026f98e
pmbootstrap init: migrate work dir if necessary (!1845)
This should have already happened, but probably broke when splitting
pmaports into a separate git repository.
2020-01-12 00:39:47 +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 680ee1bf97
Prepare 1.13.0 release 2020-01-03 05:28:24 +01:00
Oliver Smith ae1b3fc38c
pmb/helpers/pmaports: ignore provides without ver (!1851)
The APKBUILD reference for "provides" [1] is not worded clearly; but
after reading it over and over again, my understanding is:

* package with provides='foo=1.2' will be automatically installed if
  user requests installing "foo"
* package with provides='foo' (without version) will NOT get
  automatically installed if user requests installing "foo"

For pmbootstrap, this means, that we must not attempt to build a package
where the pkgname mentioned in provides matches what we are currently
resolving, unless there is an equals sign in the provides entry.

Fixes: #1862, pmaports#404

[1] https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#provides says:

"List of package names (and optionally version info) this package
provides.

If package with a version is provided (provides='foo=1.2') apk will
consider it as an alternate name and it will automatically consider the
package for installation by the alternate name, and conflict with other
packages having the same name, or provides.

If version is not provided (provides='foo'), apk will consider it as
virtual package name. Several package with same non-versioned provides
can be installed simultaneously. However, none of them will be installed
by default when requested by the virtual name - instead, error message
is given and user is asked to choose which package providing the virtual
name should be installed."
2020-01-02 17:16:05 +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
Daniele Debernardi d145f88276
pmb/qemu/run.py: add audio support (!1840)
Changes:
  * Added the ALSA_PLUGIN_DIRS environment variable otherwise it tries
    to load the plugins of the host pc and they fails.
  * Added the /usr/lib/pulseaudio path to the library-path argument
  * Added the audiodev and soundhw parameters to the qemu command
  * Added the required packages necessary to be installed in the chroot
2019-12-28 01:42:40 +01:00