Commit Graph

1383 Commits

Author SHA1 Message Date
Robert Yang 60459cfda3
Fix test_aportgen_compare_output (!1727)
test_aportgen.py fails because some test data is missing.
Make the test pass by fixing the test data with the following changes:
- Update testdata pmaports/cross/*
- Don't git ignore test/testdata/aportgen directory
- Add testdata aports/main/* from upstream Alpine Linux aports

Patch files in pmaports/cross/binutils-armhf were removed, as they are
not needed to test the pmbootstrap code.
2018-12-14 07:35:55 +01:00
Zhuowei Zhang 1efe288fe2
losetup: support building rootfs images with 4096 byte sector sizes (!1725)
Adds an optional deviceinfo variable, `deviceinfo_rootfs_image_sector_size`,
which specifies the logical sector size of the device's storage.

Some devices made after 2016 with UFS storage uses 4096 byte sectors
instead of the normal 512 bytes. The partition table in our rootfs
must match, otherwise the root filesystem won't mount on the device.

This change passes the sector size to `losetup` when creating the image
if the deviceinfo specifies it, so the image will have the correct
sector size.

If the deviceinfo doesn't specify the new option, the behaviour
is the same as previous versions of pmbootstrap.

Note that the sector size option only works on Linux 4.14 and above,
so pmbootstrap should be run on a >4.14 computer when installing to
devices with non-standard sector size.

To find if a device needs this parameter, run `fdisk -l` on the device.
If the output shows

`Note: sector size is 4096 (not 512)`

then add `deviceinfo_rootfs_image_sector_size="4096"` to the deviceinfo.

This is needed by the Pixel 3 XL (google-crosshatch) port.

See https://gitlab.com/postmarketOS/pmbootstrap/issues/1696.
2018-12-11 09:08:12 +01:00
Oliver Smith 5102d48064 Make APKINDEX downloads returning 404 non-fatal (!1726)
Do not fail when an APKINDEX can not be downloaded, print a WARNING
instead. This matches, what apk does. Add a new allow_404 parameter to
pmb.helpers.http.download(), and use it in pmb.helpers.repo.update()
for downloading APKINDEX files. Cache the APKINDEX URLs that gave a 404
for the session, so we do not attempt to download these again.

This is needed for the new binary repository: the initial build is done
without existing APKINDEX files, so we must not fail in that case.
2018-12-11 06:56:53 +00:00
Oliver Smith fa7860c8f6 pmb.helpers.repo.update: refactor cache code (!1726)
Change the cache format from args.cache["offline_msg_shown"] to
args.cache["pmb.helpers.repo.update"]["offline_msg_shown"]. This is in
preparation for saving more data in the cache of
pmb.helpers.repo.update in the next commit.
2018-12-11 06:56:53 +00:00
Oliver Smith a874baa037 Cosmetic: pmb.helpers.http: describe parameters (!1726)
Describe all parameters of pmb.helpers.download().
2018-12-11 06:56:53 +00:00
Oliver Smith 49212ba317 Cosmetic: pmb.helpers.repo.update(): fix comment (!1726)
APKBUILD was written where it should have been APKINDEX.
2018-12-11 06:56:53 +00:00
Oliver Smith d6f7571cb9
repo_missing: properly find subpackages, provides (!1724)
Do not fail anymore when attempting to start a new binary repository
build without any existing binary packages:
	pmbootstrap -mp="" repo_missing

Find subpackages defined with subpackage functions:
	subpackages="dev:mydevfunc"

Find provides defined with specific versions:
	provides="mkbootimg=1.0.0"
2018-12-10 21:00:04 +01:00
Oliver Smith 9cb27e5d22
kconfig check: disallow USE_VFB (!1723)
Weston and Plasma Mobile might choose to draw on this virtual frame
buffer, just like it happened for the samsung-jflte. Disabling the
USE_VFB option fixed this, so let's make sure we don't have that option
enabled for any kernel.
2018-12-06 07:42:17 +01:00
Oliver Smith a5a64158e9
allow specifying multiple postmarketOS mirrors (!1718)
Multiple -mp arguments can be used to list multiple mirrors:
$ pmbootstrap -mp=first -mp=second chroot -- cat /etc/apk/repositories

This is needed for the new build infrastructure, so we can have a WIP
repository to which we push packages until all of them are up to date,
and then publish all of them at once. Software like KDE/Plasma Mobile,
which expect a lot of packages to be updated from one version to
another will not end up with a half-way through upgrade that way.
2018-12-06 07:31:43 +01:00
Oliver Smith a92e6a89d0
remove local postmarketOS mirror folder support (!1718)
Obscure feature: it was possible to specify a local path as
--mirror-pmOS. It would then get mounted to /mnt/postmarketos-mirror
inside the chroot, and be specified as such in the generated
/etc/apk/repositories file.

I had used this once for some testing scripts, but I am sure nobody is
using this anymore. The same can be achieved with running a local http
server anyway:
<https://wiki.postmarketos.org/wiki/Installing_packages_on_a_running_phone>

Removing this makes it easier to support multiple postmarketOS mirrors
(next commit).
2018-12-06 07:31:38 +01:00
Oliver Smith 2c6c5a9df9
prettier --help output for -m, -mp arguments (!1718)
-m is the Alpine mirror, -mp is the postmarketOS mirror. Use "URL" as
metavar and add help text that explains how to disable the postmarketOS
mirror (so all pmaports get built locally).
2018-12-06 07:31:32 +01:00
Oliver Smith 1c10dbee50
repo_missing: fix "could not find aport" error
In pmb.helpers.package.get(), we are differentiating between packages
that do not exist at all, and packages that do not exist for the
specified architecture. Make sure to actuallyy download the foreign arch
APKINDEX files, before trying to find the packages in there. Otherwise
the "could not find aport, and could not find this package in any
APKINDEX" package would appear.

We ran into this when testing on sr.ht, because pmbootstrap runs on a
fresh install every time, where no old APKINDEX files are present
(which would work around the bug).

This was meant to be part of the previous commit already, and was
tested, but it was not submitted correctly. So here it is as separate
commit straight to master. It is trivial anyway.
2018-12-03 21:02:18 +01:00
Oliver Smith 933c4d0f0d new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.

This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.

For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.

Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.

Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
  aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
  in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
  distinguish it from the other check_arch function
2018-12-01 21:30:59 +00:00
Oliver Smith a44b80b31d build.find_aport() -> helpers.pmaports.find()
Move find_aport() and find_aport_guess_main() from pmb/build/other.py
to the new file pmb/helpers/pmaports.py.

Finding aports is not only needed when building packages, hence it
makes sense to move it out of pmb.build. The pmb/helpers/pmaports.py
file will have more pmaports related functions in a follow up commit.
2018-12-01 21:30:59 +00:00
Oliver Smith d7b888907f
bump version to 1.0.4 2018-12-01 02:37:44 +01:00
Luca Weiss 9c037831a0
Remove legacy kconfig_check and menuconfig args
Fixes #1690
2018-12-01 01:32:52 +01:00
Robert Yang 0e9644c0f9 native cross: Check if build is necessary on target arch
Target arch is the system the package will run on. Host arch is the
system the package is compiled on.

For example kernel packages can be compiled on host arch x86_64 and
intended to run on target arch armhf. A build is necessary check
against host arch will always return True. The correct way is to check if
the package needs to be built for target arch.
2018-11-30 12:00:25 -05:00
Oliver Smith 977323cf6e
native cross: only require native arch depends
Do not try to build and install dependencies for the package's
architecture when compiling in the "native" mode. That mode is
described here in detail:
https://wiki.postmarketos.org/wiki/Build_internals#Cross-compile_types

This makes it possible to cross compile kernels again, which need to
be built with GCC6. We have switched to Alpine's GCC6 package, but it is
not available for armhf/aarch64 on edge yet, because Alpine's build bots
are stuck (right now armhf is not even listed):
http://build.alpinelinux.org/

Huge thanks to ryang2478/Decatf for posting this patch in pmaports#138!
2018-11-30 10:02:17 +01:00
Daniele Debernardi cce91758a1
Install latest built version of the package instead of APKBUILD version 2018-11-22 00:48:45 +01:00
Oliver Smith 840b603953 Export initramfs-extra (pmbootstrap export)
Create a symlink for initramfs-extra when running 'pmbootstrap export'
just like we create it for the normal initramfs.
2018-11-19 06:06:35 +00:00
Oliver Smith 424ad3f078 tests import path: put shipped pmb code first
Always test the pmb code from the parent folder of the tests, even if
a stable version of pmbootstrap is installed with pip or pysetup.
2018-11-12 07:05:22 +00:00
Oliver Smith 56d813421f build is necessary: better binary > aport message
Clearly state which version is being used, and also display the message
when using build --force.

- Old:
WARNING: Package 'ubuntu-app-launch' in your aports folder has version
0_git20180604-r0, but the binary package repositories already have version
0_p20181101174257-r0! See also: <https://postmarketos.org/warning-repo2>

- New:
WARNING: package hello-world: aport version 1-r4 is lower than 1-r5 from
the binary repository. 1-r5 will be used when installing hello-world.
See also: <https://postmarketos.org/warning-repo2>
2018-11-12 06:56:14 +00:00
Oliver Smith 2f7df661d3 cosmetic: remove timestamp based rebuilds comment
This is outdated for quite a while now.
2018-11-12 06:56:14 +00:00
Oliver Smith c8205013e1 Guess main packages when we don't know them
Find the main package by assuming it is a prefix of the subpkgname. We
do that, because in some APKBUILDs the subpkgname="" variable gets
filled with a shell loop and the APKBUILD parser in pmbootstrap can't
parse this right. (Intentionally, we don't want to implement a full
shell parser.)
2018-11-09 05:31:19 +00:00
Oliver Smith 71ee6f5bb3
aportgen gcc*: set arch to x86_64 only
This covers most use cases and saves a lot of build time. Can be
changed on demand. Again, this simplifies package building as part of
the new build infrastructure effort.
2018-11-08 07:08:04 +01:00
Oliver Smith dab053e96c
bump version to 1.0.3 2018-11-07 08:08:53 +01:00
Oliver Smith 71aca78746
aportgen device-*: don't use noarch anymore
Use the device's architecture instead of noarch. Because the device
packages should never be built for other architectures, even if all
depends can be built for other arches as well.

This simplifies package building as part of the new build
infrastructure effort.

All existing pmaports will be changed shortly, along with a test case
in pmaports.
2018-11-07 07:55:26 +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 5b33eb7520
Export HOME in pmb.chroot.root() and -.user()
Set HOME to /root for commands started with pmb.chroot.root() and to
/home/pmos for commands started with pmb.chroot.user().

POSIX requires this variable to be set, see:
<http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html>

And this prevents a crash in "adb", which takes and alternative code
path if HOME is not set, that does not work with musl (fixes #1638).
Thanks to @ryang2678 for figuring this out!
2018-10-25 07:26:06 +02:00
Oliver Smith 8d461b2ecf
testcases_fast.sh: explicitly use "python3"
Python3 isn't the default for all Linux distributions yet, so
Fedora 28 for example will try to start the testsuite with Python 2
instead.
2018-10-25 07:12:18 +02:00
Oliver Smith f09845bced
recovery zip install: link to wiki page
Show a link to a new wiki page with working sideload instructions
instead of the broken command: <https://postmarketos.org/recoveryzip>
2018-10-24 08:53:55 +02:00
Oliver Smith d8aba7e81b
Add ten more megabytes of free space for /boot 2018-10-12 09:36:33 +02:00
Oliver Smith b8dc816af0
bump version to 1.0.2 2018-10-12 09:09:23 +02:00
Oliver Smith fe1c1dfe2d
setup.py: description is written in markdown
This should make it look pretty on pypi. Closes #1679.
2018-10-12 09:07:30 +02:00
Luca Weiss 6495fca971 Remove fuzzy versions for dependencies
Fixes #1344
2018-10-11 05:30:22 +00:00
Oliver Smith 946417d314
Make --gcc6 work with fish; add 'source' to usage 2018-10-11 07:22:09 +02:00
Robert Yang a2484f2492 Add envkernel.sh argument to use gcc6 cross compiler 2018-10-10 19:02:25 -04:00
Robert Yang e27f11a705 Parse shell arguments passed to envkernel.sh 2018-10-10 19:02:25 -04:00
Oliver Smith 1e495baa3c bump version to 1.0.1
I'll tag a new version, because installing with pip is fixed now.
2018-10-09 04:35:03 +00:00
Luca Weiss 120822aa2f
Restore not-redundant "include_package_data" line
Due to build caches removing that line still installed the files but in
a clean build, the directive is needed.

Fixes #1661 (again)
2018-10-08 21:41:45 +02:00
Robert Yang 9d198f1ea4 Clean kernel source directory before setting up make alias
When kbuild is using a separate directory for output files then it will
check if the kernel source directory is clean.
The build will throw an error when the source directory is not clean:

  .. is not clean, please run 'make mrproper'

Once envkernel.sh has aliased the make command then make mrproper will
be run in the context of .output directory. If the source directory is not
clean then user may be wondering why make mrproper doesn't clean it.

This change will ensure that the source directory is clean when envkernel
is setup.
2018-10-08 05:21:21 +00:00
Oliver Smith 87384aace6 increase min. required pmaports version
After all the GCC6-as-extra-package related changes.
2018-10-08 05:06:59 +00:00
Oliver Smith f54f96069e
aportgen linux: make compatible with GCC8
* create symlinks to the GCC8 patches (introduced in pmaports!35)
* link to the new vendorkernel reference wiki page
* use SPDX license in the license= field
* add comment above the compiler section of the APKBUILD
* remove empty line at the end of the APKBUILD
2018-10-05 09:07:57 +02:00
Oliver Smith 46d7891a22
When copying aports to chroots, resolve symlinks
When doing it this way, we can share patches between kernels the aports
(pmaports!35, pmaports#95).
2018-10-05 09:05:31 +02:00
Luca Weiss 09fcdba597 Fix detection of an aport in multiple subfolders 2018-10-02 07:14:02 +00:00
Robert Yang 277854e80f Kill the child processes spawned by a run command
When the timeout occurs it is important to ensure clean up of child
processes. Killing only the direct process created by a command can
leave child processes running.

For example a pmbootstrap.py install will run apk add. This run command
creates multiple processes as follows:
(cmd line arguments snipped for readability)

  $ ps -e -o pid,ppid,pgid,cmd
  PID  PPID  PGID CMD
  31738 23247 31738 python3 ./pmbootstrap.py -t 15 install --no-fde
  31746 31738 31738 sudo env -i /bin/sh -c ... ;apk --no-progress add
  31747 31746 31738 /bin/sh -c ... ;apk --no-progress add
  31748 31747 31738 apk --no-progress add

The root process of the run command is PID 31746. We want to kill
the child processes too. Otherwise only running kill -9 31746 will leave
the processes 31747 and 31748 running.
2018-10-02 07:06:46 +00:00
Oliver Smith 3e7c95e8b4
Support cross compiling kernels with GCC6
* aportgen: modify code to allow generating gcc6-armhf and other gcc6
  cross compiler packages
* package: when 'gcc6' is in the depends of a package, and the cross
  compiling mode is "native" (as we do it with kernels), install the
  gcc6 cross compiler instead of the usual one (gcc8)

Related: pmaports#103
2018-09-30 04:30:36 +02:00
Oliver Smith f68a7a6baa Link to wiki page if first git clone fails 2018-09-26 05:58:11 +00:00
Oliver Smith 8eb3b5d5c6
bump version to 1.0.0
(imagine epic music playing in background)
2018-09-19 09:51:01 +02:00
Oliver Smith 1f8832c4cc install apk keys and binfmt data with setup.py 2018-09-17 10:06:57 +00:00