Commit Graph

49 Commits

Author SHA1 Message Date
Oliver Smith 216b3ef267
pmb.aportgen.device: modernize defaults
Change the defaults in the new device port wizard:

* arch: armv7 -> aarch64
  New devices are more likely to be aarch64.

* flash method: 0xffff -> none
  The only device that uses 0xffff is the N900, it's extremely unlikely
  that it will get used for a new port. Use the neutral "none" instead.

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Reviewed-by: Clayton Craft <clayton@craftyguy.net>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230802172542.4861-2-ollieparanoid@postmarketos.org%3E
2023-08-06 20:05:45 +02:00
Pablo Correa Gómez 0489f7f40c
aportgen: device: rename modules to modules-initfs
The extra verbosity can be useful here.

See https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4169#note_1489955273
for more details

Fixes ad85c7bc17

Signed-off-by: Pablo Correa Gómez <ablocorrea@hotmail.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230728113116.31529-1-pabloyoyoista@postmarketos.org%3E
2023-07-30 19:10:51 +02:00
Pablo Correa Gómez ad85c7bc17
aportgen: replace deviceinfo_modules_initfs for modules file
So deviceinfo_modules_initfs is going to be phased out in pmaports!4169 as
a preparation for pmaports#1836. The implementation for the alternative of
using a modules file has already been merged in pmaports!4193, so stop
promoting the soon-to-be-phased-out deviceinfo variable, and instead use
the new and already-supported alternative.

Related: https://gitlab.com/postmarketOS/pmaports/-/issues/1836
Related: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4169
Related: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4193
Signed-off-by: Pablo Correa Gómez <ablocorrea@hotmail.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230720164706.18936-1-pabloyoyoista@postmarketos.org%3E
2023-07-21 08:54:10 +02:00
Luca Weiss b8d5b9e4e5
treewide: rename _system to _rootfs in various places
A long time ago we renamed the flash_system action into flash_rootfs.
Since we still kept some variables around, it's finally time to clean
that up.

Keep backwards compatibility for now since we cannot update pmaports at
the same time since the new deviceinfo names won't be supported in older
pmbootstrap versions.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230605220329.14328-3-luca@z3ntu.xyz%3E
2023-06-12 08:46:22 +02:00
Luca Weiss 7125412f07
pmb.aportgen.device: fix flash method autocomplete
In order to provide tab completion to the "Flash method" question we
need to provide pmb.helpers.cli.ask with the possible options. Do that.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230403163311.927063-1-luca@z3ntu.xyz%3E
2023-04-04 09:13:04 +02:00
Oliver Smith 9975d373b0
Bump copyright to 2023 2023-01-22 19:18:06 +01:00
Oliver Smith 35784a5fd7
pmb.aportgen.device: no depend on mesa-dri-gallium (MR 2210)
Device packages shouldn't depend on it anymore, in order to end up with
a smaller installation for ui=none this package only gets pulled in by
postmarketos-base if mesa is installed.

Related: pmaports MR 3478
2022-10-12 08:24:53 +02:00
Salvatore Stella 3567b7c123
Fix wrong output of pmbootstrap bootimg_analyze (MR 2198) 2022-08-21 14:25:11 +02:00
Jami Kettunen de890c83e7
pmb.aportgen.device: Generate appropriate header v2 deviceinfo (MR 2194)
Here's an example of the properties this could generate:

  deviceinfo_header_version="2"
  deviceinfo_append_dtb="false"
  deviceinfo_flash_offset_dtb="0x0bc08000"
2022-07-18 14:49:33 -07:00
Oliver Smith 6f6a3b0408
Happy new year 2022! 2022-01-02 22:39:14 +01:00
BO41 944f539dd6
args.logfd: remove (MR 2114)
Replace "args.logfd" with "pmb.helpers.logging.logfd" in order to avoid
passing "args" to all functions that only use it to write to logfd. This
is the first step to get rid of this args-passed-to-all-functions
pattern in pmbootstrap.
2021-10-10 16:59:17 +02:00
Anri Dellal d764b0de58
bootimg_analyze: Add support for boot header version 3 (MR 2073) 2021-07-07 04:43:24 +03:00
Luca Weiss b18281ab26
pmb.aportgen: fix architecture autocomplete (MR 2054)
Previously hitting the tab key wouldn't actually complete the
architecture field.
2021-06-13 15:05:27 +03:00
Luca Weiss edf43916a5
pmb.aportgen: don't suggest armhf (MR 2054)
New ports shouldn't use that architecture; and devices whose CPU only
supports armhf aren't really useful for anything anyways.

This will also make the suggested/default architecture be armv7
(architectures[0]).
2021-06-13 15:05:27 +03:00
nybbled 5f485b8ad3
pmb.aportgen: put dependencies on separate lines (MR 2024)
Generate APKBUILDs with dependencies sorted and placed one per line.
The dependency lists changed are
 - depends in pmb/aportgen/device.py
 - makedepends in pmb/aportgen/linux.py

Sort dependency lists in test/test_aportgen_device_wizard.py
assertions.
2021-02-10 00:08:22 +01:00
Oliver Smith 1c791da482
treewide: bump copyright to 2021 2021-01-07 23:30:47 +01:00
Johannes Marbach e2d4678fb7
pmb.aportgen.device Reformat to 79 characters per line (MR 1993) 2020-11-23 11:30:56 +01:00
Luca Weiss 86d61b8012
pmb.parse.bootimg: detect mediatek header (MR 1955)
Some Mediatek devices have a special 512-byte header around the zImage
which must be generated so the device boots.

Support for that exists for a while in postmarketOS but detection was
missing. Add that.
2020-08-21 18:33:30 +02:00
Luca Weiss 6bb7f022b1
pmb: introduce deviceinfo_chassis (MR 1933)
"Chassis" defines the what kind of device a device is. Currently the
following standardized types exist:

  "desktop", "laptop", "convertible", "server", "tablet", "handset",
  "watch", "embedded", "vm", "container"

This property is exposed by org.freedesktop.hostname1 (e.g.
openrc-settingsd) and can be used by applications for example to display
appropriate strings instead of "About this phone" for non-phone devices.
2020-05-24 08:38:10 +02:00
Minecrell 0465f17e92
pmb.aportgen: Stop generating Maintainer: lines for device ports (MR 1932)
Most device ports that are added to pmaports (particularly the testing
category) are not actually "maintained". Many of them are never updated
after the initial contribution. There is little reason to list a
"Maintainer:" if the device package is actually not actively maintained
by that person.

Let's stop generating the Maintainer: line by default.
Instead, contributors should add the lines themselves if they are willing
to (actively) maintain the device package for a longer period of time.
Once they no longer want to maintain the package, the Maintainer:
line should be removed again.
2020-05-10 18:02:07 +02:00
Minecrell c33edea907
pmb.aportgen: Stop generating Contributor: lines for device ports (MR 1932)
The Git history is a much better representation of contributors
to a particular device port.
2020-05-10 18:02:02 +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 9050010044
pmb.aportgen: strip trailing white space before splitting lines (MR 1924)
Many of the multi-line strings already contain a new line at the
end of the file. When using .split("\n") this will result in an empty
line at the end of the file that is again followed by a new line.

In other words: we have two new lines at the end, which looks weird.
.rstrip() the whitespace at the end of the string to avoid this.
2020-04-25 13:39:09 +03:00
Minecrell 2e9279ac21
pmb.aportgen: pkgname="..." -> pkgname=... (remove quotes) (MR 1924)
apkbuild-lint complains:
TP:[AL3]:APKBUILD:4:pkgname must not be quoted
2020-04-25 13:39:05 +03:00
Minecrell 2ca09cd21c
pmb.aportgen: convert to f-strings (MR 1924)
Finally it's readable again!
2020-04-25 13:38:58 +03: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 7ae04c5698
pmb.aportgen: remove touchscreen properties by default (!1888)
In most cases it is no longer necessary to set them.
directfb will now try to detect the touchscreen automatically.
2020-03-14 00:33:22 +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
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
lambdadroid 67b080b158
Detect if DTB is placed in second area of Android boot image (!1828)
postmarketOS/pmaports!700 adds a new "deviceinfo_bootimg_dtb_second"
option that places the DTB in the "second" area of the Android boot
image.

Attempt to detect this automatically by checking the extracted
second binary for the FDT magic (0xd00dfeed).
2019-10-25 17:36:22 +02:00
Clayton Craft 27e0a0d33e Add uuu flasher support (!1760)
This adds flasher support for uuu, a utility used by NXP devices for
flashing images.

The flasher expects a uuu command list script to be installed in the
device rootfs at /usr/share/uuu/flash_script.lst.
2019-03-03 10:29:16 +01:00
Oliver Smith f16bdaf0ca
Update copyright to 2019
Happy new year \o/
2019-01-02 09:31:20 +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 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 f10ac0eadd deviceinfo: prepend manufacturer to device name 2018-08-23 00:44:46 +00:00
Oliver Smith 3666388619
Properly escape commands in pmb.chroot.user() (#1316)
## Introduction
In #1302 we noticed that `pmb.chroot.user()` does not escape commands
properly: When passing one string with spaces, it would pass them as
two strings to the chroot. The use case is passing a description with
a space inside to `newapkbuild` with `pmboostrap newapkbuild`.

This is not a security issue, as we don't pass strings from untrusted
input to this function.

## Functions for running commands in pmbootstrap
To put the rest of the description in context: We have four high level
functions that run commands:
* `pmb.helpers.run.user()`
* `pmb.helpers.run.root()`
* `pmb.chroot.root()`
* `pmb.chroot.user()`

In addition, one low level function that the others invoke:
* `pmb.helpers.run.core()`

## Flawed test case
The issue described above did not get detected for so long, because we
have a test case in place since day one, which verifies that all of the
functions above escape everything properly:
* `test/test_shell_escape.py`

So the test case ran a given command through all these functions, and
compared the result each time. However, `pmb.chroot.root()`
modified the command variable (passed by reference) and did the
escaping already, which means `pmb.chroot.user()` running directly
afterwards only returns the right output when *not* doing any escaping.

Without questioning the accuracy of the test case, I've escaped
commands and environment variables with `shlex.quote()` *before*
passing them to `pmb.chroot.user()`. In retrospective this does not
make sense at all and is reverted with this commit.

## Environment variables
By coincidence, we have only passed custom environment variables to
`pmb.chroot.user()`, never to the other high level functions. This only
worked, because we did not do any escaping and the passed line gets
executed as shell command:
```
$ MYENV=test echo test2
test 2
```
If it was properly escaped as one shell command:
```
$ 'MYENV=test echo test2'
sh: MYENV=test echo test2: not found
```
So doing that clearly doesn't work anymore. I have added a new `env`
parameter to `pmb.chroot.user()` (and to all other high level functions
for consistency), where environment variables can be passed as a
dictionary. Then the function knows what to do and we end up with
properly escaped commands and environment variables.

## Details
* Add new `env` parameter to all high level command execution functions
* New `pmb.helpers.run.flat_cmd()` function, that takes a command as
  list and environment variables as dict, and creates a properly escaped
  flat string from the input.
* Use that function for proper escaping in all high level exec funcs
* Don't escape commands *before* passing them to `pmb.chroot.user()`
* Describe parameters of the command execution functions
* `pmbootstrap -v` writes the exact command to the log that was
  executed (in addition to the simplified form we always write down for
  readability)
* `test_shell_escape.py`: verify that the command passed by reference
  has not been modified, add a new test for strings with spaces, add
  tests for new function `pmb.helpers.run.flat_cmd()`
* Remove obsolete commend in `pmb.chroot.distccd` about environment
  variables, because we don't use any there anymore
* Add `TERM=xterm` to default environment variables in the chroot,
  so running ncurses applications like `menuconfig` and `nano` works out of
  the box
2018-03-10 22:58:39 +00:00
Daniele Debernardi 94306b51ee deviceinfo: remove external_disk_install and external_disk, use external_storage instead (#1301)
* deviceinfo: remove external_disk_install and external_disk, use external_storage instead
* Complain when external_disk* is used
2018-03-07 22:35:02 +00:00
Oliver Smith 948b5af09b
device packages: depend on postmarketos-base (#1258)
* device-*: add postmarketos-base to depends
* aportgen: add postmarketos-base to depends
* Add test case
* postmarketos-base: Don't depend on devicepkg
* msm-fb-refresher: Enable service in post-install
2018-02-25 18:40:54 +00:00
Mayeul Cantan 00aa65f2d0 pmbootstrap: add qcdt generation to the linux aportgen APKBUILDs (#1125)
* pmbootstrap: __config_.py - update the deviceinfo_attributes table

Add missing attributes:
 * "screen_width"
 * "screen_height"
 * "dev_touchscreen"
 * "dev_touchscreen_calibration"
 * "dev_keyboard"
 * "bootimg_qcdt"

Reorder the list to correspond to pmb/aportgen/device.py

Add a comment in the aforementioned file to avoid forgetting to update
this list.

Signed-off-by: Mayeul Cantan <mayeul.cantan@gmail.com>

* pmbootstrap: add qcdt generation to the linux aportgen APKBUILDs

This checks the next box in #688
When the device has bootimg_qcdt set to true, the following is done to
the linux APKBUILD:

 * Add dtbtool to makedepends
 * Call dtbTool during build() to generate dt.img
 * Add the generated dt.img in the package's boot/dt.img

Signed-off-by: Mayeul Cantan <mayeul.cantan@gmail.com>
2018-01-17 17:53:58 +00:00
Oliver Smith 9fb0147d37
Let new and most old devices depend on mesa dri swrast (#1086)
* Devices: depend on mesa-dri-swrast (where it makes sense)
* Device wizard: add mesa-dri-swrast by default
* Closes #1013.
2018-01-06 14:08:10 +00:00
Piotr Halama 2c5cd5d8bb Revert "init: Add manufacturer to pkgdesc when creating new device (#913)" (#1083)
This reverts commit 99d7b58ee5.

People usually add manufacturer name in the phone full name which
results in having manufacturer written double in pkdesc (e.g. `Samsung
Samsung Galaxy Mini 2`)
2018-01-05 02:44:44 +00:00
Oliver Smith 7750c1dd40
Happy new year! (update copyright to 2018) 2018-01-04 04:53:35 +01:00
Attila Szöllősi c6eb56c200 Rename deviceinfo variable flash_methods to flash_method (#1030)
* Rename deviceinfo variable flash_methods to flash_method
* Update pmb.config.deviceinfo_attributes / add sanity check
* Add test case that parses all deviceinfo files
2017-12-21 22:12:51 +00:00
drebrez 254150567e Add `devicepkg-dev` which generate the touchscreen udev rule based on the deviceinfo (#995)
* Use devicepkg-dev by default in new device wizard
* Add link to reference wiki page
2017-12-14 21:17:18 +00:00
drebrez 0cca286aba Move flash_methods variable to __init__.py (#919) 2017-11-20 16:40:16 +00:00
drebrez 94e2387af5 Add `pmbootstrap bootimg_analyze` / prompt during new device wizard (#905) 2017-11-19 14:35:23 +00:00
Pablo Castellano 99d7b58ee5 init: Add manufacturer to pkgdesc when creating new device (#913) 2017-11-18 11:02:19 +00:00
Oliver Smith 6627599cf0
pmbootstrap init: Wizard for new port device- and linux-packages (#821)
* pmbootstrap init: Generate new port device- and linux-package
* adds `pmbootstrap aportgen device-*` and
  `pmbootstrap aportgen linux-*`
* ask for confirmation when selecting a non-existing device
* generate the packages directly from init
* refactor aportgen code
* fixed some easy things in the linux- APKBUILD (more to come in
  follow-up PRs!)

Testing:
* Test all questions to the user from pmb.config.init and pmb.aportgen.device
  (except for the timezone question, because we would need to monkeypatch the
  os.path.exists() function, which messes up pytest, so we'd need to refactor
  the timezone function to be more testsuite friendly first)
* Run the device wizard in a testcase a few times and check the output, that
  pmbootstrap.aportgen.device and pmbootstrap.aportgen.linux create by parsing
  the resulting APKBUILDs and deviceinfo and checking its contents.
* Build the generated device package once in the same testcase

Thanks a lot to @drebrez for all the help with this one:
<https://github.com/postmarketOS/pmbootstrap/pull/821>

See also the updated porting guide:
<https://wiki.postmarketos.org/wiki/Porting_to_a_new_device>
2017-10-30 19:56:38 +00:00