Commit Graph

1449 Commits

Author SHA1 Message Date
Robert Yang deadcd39f7
aportgen: Convert space indent to tabs (!1734)
APKBUILD should be indented with tabs not spaces.

This also resolves a bug which the replace_functions feature was always
trimming off the beginning of a line.
  For example:
    replace_functions = {"build": "return 0"}
  would be formatted as "rn 0".
2018-12-31 08:34:44 +01:00
Oliver Smith 7f956e2f72 version parsing: fix errors with 3.0.0_pre1 (!1735)
Python < 3.6 randomized the order of keys in dictionaries, unless
OrderedDict was used. Use OrderedDict to store the version suffixes.

When the order was randomized, the valid version string 3.0.0_pre1 did
not always pass the validation check. The suffix "pre" should always be
detected as such, but with the random order, it was sometimes detected
as "p" suffix (see below). The following letters "re" are not a valid
suffix_no (the number expected to follow the suffix) and so it failed.

suffixes = {
    "pre": ["pre", ...],
    "post": ["p". ...]
}
2018-12-31 07:46:47 +01:00
Robert Yang 101a396c90 envkernel: Add x86 architectures (!1733) 2018-12-29 14:33:27 -05:00
Robert Yang 4d6cd2270f envkernel: Support native compiles (!1733)
The cross compile environment variable only needs to be set when the
kernel is being built for a different architecture than the host system.
2018-12-29 14:33:25 -05:00
Robert Yang ce57fae12d envkernel: Set CC and HOSTCC (!1733)
It is necessary to override these environment variables to use an alternate
compiler such as gcc6.
2018-12-29 14:33:15 -05:00
Robert Yang 70126570a4 envkernel: Fix switching envkernel to different source path (!1733)
When there is already another kernel source path mounted then the old mount
should be removed. Otherwise the mount source will still be pointed at the
old kernel source.
2018-12-29 14:33:12 -05:00
Robert Yang 3e845e1edf envkernel: Run make command as user (!1733) 2018-12-29 13:53:56 -05:00
Oliver Smith ef68ed99ad
bump version to 1.1.0 2018-12-26 22:07:30 +01:00
Oliver Smith 96d4f2e6be
deviceinfo: resolve path for parser errors (!1732)
Display the resolved deviceinfo file path in exceptions from the
deviceinfo parser. Instead of messages like these:

RuntimeError: Please add 'deviceinfo_codename="lg-mako"' to: /home/user/.local/var/pmbootstrap/cache_git/pmaports/.gitlab-ci/testcases/../../device/device-lg-mako/deviceinfo

We get the more readable version:

RuntimeError: Please add 'deviceinfo_codename="lg-mako"' to: /home/user/.local/var/pmbootstrap/cache_git/pmaports/device/device-lg-mako/deviceinfo
2018-12-26 21:43:54 +01:00
Luca Weiss 747ccfdd75
deviceinfo: add and require _codename (!1732)
deviceinfo_codneame holds the device's code name, so we can easily look
it up in the finished postmarketOS installation by reading
/etc/deviceinfo.

Related: postmarketOS/pmaports#157
2018-12-26 21:43:38 +01:00
Oliver Smith 23df933db4
Run os.path.expanduser() on all args paths (!1731)
Properly replace ~ with $HOME in all paths. Fix tab completion when
passing a path starting with ~ to pmaports:

$ pmbootstrap --aports ~/src/pmaports/ build linux-<TAB>
2018-12-17 08:55:33 +01:00
Oliver Smith 1662fc1961
Fix packages tab completion (!1731)
Make tab completion work again for packages, if the default pmaports
dir is used. In the last "args" code refactor, the variable replacing
code was moved into its own function. We did not call it in the
packagecompleter() yet, so it could not replace the $WORK variable in
the default pmaports path.
2018-12-17 08:55:25 +01:00
Oliver Smith 60f12ae2df pmbootstrap config -h: show keys / tab complete (!1729)
Show all config keys that can be queried and set in the
'pmbootstrap config -h' output and make tab completion work for the
key names.

I've set "metavar" and placed the variables in the helpstring. That
way, argparse will not generate a huge "positional arguments" string
that blows up the layout of the help output:
[{ccache_size,device,extra_packages,hostname,jobs,kernel,keymap,...
2018-12-17 08:45:46 +01:00
Craig Comstock c4b4aa7252
Allow overriding pmaports path in pmbootstrap.cfg (!1728)
Make it possible to point the pmaports dir to an existing repository
clone, while not having to give the --aports/-p parameter with every
command.

  pmbootstrap --aports=/my/pmaports/path init

If the config file exists already, the dir can also be set with:

  pmbootstrap config aports /my/pmaports/path
2018-12-17 08:38:36 +01:00
Grant Miller dfaca1e06f Enable armv7 (!1730)
I need to do some more work on pmaports in order for this to actually
be useful.
2018-12-17 08:06:10 +01:00
Oliver Smith e2c38a2e31
Run aportgen test in CI again (!1727)
Clear the test blacklist for all tests, except for the QEMU test (which
runs on its own on a special runner). All other tests that were in the
blacklist, except for the aportgen test, had already been moved to
pmaports.git. Keeping them out of the blacklist makes it less confusing.

Now all tests are running in CI again.
2018-12-14 07:35:55 +01:00
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