forked from Mirror/pmbootstrap
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
194 lines
4.8 KiB
Markdown
194 lines
4.8 KiB
Markdown
# pmbootstrap
|
|
[**Introduction**](https://postmarketos.org/blog/2017/05/26/intro/) | [**Security Warning**](https://ollieparanoid.github.io/post/security-warning/) | [**Devices**](https://wiki.postmarketos.org/wiki/Devices)
|
|
|
|
Sophisticated chroot/build/flash tool to develop and install [postmarketOS](https://postmarketos.org).
|
|
|
|
Package build scripts live in the [`pmaports`](https://gitlab.com/postmarketOS/pmaports) repository now.
|
|
|
|
## Requirements
|
|
* 2 GB of RAM recommended for compiling
|
|
* Linux distribution on the host system (`x86`, `x86_64`, or `aarch64`)
|
|
* [Windows subsystem for Linux (WSL)](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) does **not** work! Please use [VirtualBox](https://www.virtualbox.org/) instead.
|
|
* Kernels based on the grsec patchset [do **not** work](https://github.com/postmarketOS/pmbootstrap/issues/107) *(Alpine: use linux-vanilla instead of linux-hardened, Arch: linux-hardened [is not based on grsec](https://www.reddit.com/r/archlinux/comments/68b2jn/linuxhardened_in_community_repo_a_grsecurity/))*
|
|
* On Alpine Linux only: `apk add coreutils procps`
|
|
* [Linux kernel 3.17 or higher](https://postmarketos.org/oldkernel)
|
|
* Python 3.4+
|
|
* OpenSSL
|
|
* git
|
|
|
|
## Usage Examples
|
|
Please refer to the [postmarketOS wiki](https://wiki.postmarketos.org) for in-depth coverage of topics such as [porting to a new device](https://wiki.postmarketos.org/wiki/Porting_to_a_new_device) or [installation](https://wiki.postmarketos.org/wiki/Installation_guide). The help output (`pmbootstrap -h`) has detailed usage instructions for every command. Read on for some generic examples of what can be done with `pmbootstrap`.
|
|
|
|
### Installing pmbootstrap
|
|
<https://wiki.postmarketos.org/wiki/Installing_pmbootstrap>
|
|
|
|
### Basics
|
|
Initial setup:
|
|
```
|
|
$ pmbootstrap init
|
|
```
|
|
|
|
Run this in a second window to see all shell commands that get executed:
|
|
```
|
|
$ pmbootstrap log
|
|
```
|
|
|
|
### Packages
|
|
Build `aports/main/hello-world`:
|
|
```
|
|
$ pmbootstrap build hello-world
|
|
```
|
|
|
|
Cross-compile to `armhf`:
|
|
```
|
|
$ pmbootstrap build --arch=armhf hello-world
|
|
```
|
|
|
|
Build with source code from local folder:
|
|
```
|
|
$ pmbootstrap build linux-postmarketos-mainline --src=~/code/linux
|
|
```
|
|
|
|
Update checksums:
|
|
```
|
|
$ pmbootstrap checksum hello-world
|
|
```
|
|
|
|
Generate a template for a new package:
|
|
```
|
|
$ pmbootstrap newapkbuild "https://gitlab.com/postmarketOS/osk-sdl/-/archive/0.52/osk-sdl-0.52.tar.bz2"
|
|
```
|
|
|
|
### Chroots
|
|
Enter the `armhf` building chroot:
|
|
```
|
|
$ pmbootstrap chroot -b armhf
|
|
```
|
|
|
|
Run a command inside a chroot:
|
|
```
|
|
$ pmbootstrap chroot -- echo test
|
|
```
|
|
|
|
Safely delete all chroots:
|
|
```
|
|
$ pmbootstrap zap
|
|
```
|
|
|
|
### Device Porting Assistance
|
|
Analyze Android [`boot.img`](https://wiki.postmarketos.org/wiki/Glossary#boot.img) files (also works with recovery OS images like TWRP):
|
|
```
|
|
$ pmbootstrap bootimg_analyze ~/Downloads/twrp-3.2.1-0-fp2.img
|
|
```
|
|
|
|
Check kernel configs:
|
|
```
|
|
$ pmbootstrap kconfig check
|
|
```
|
|
|
|
Edit a kernel config:
|
|
```
|
|
$ pmbootstrap kconfig edit --arch=armhf postmarketos-mainline
|
|
```
|
|
|
|
### Root File System
|
|
Build the rootfs:
|
|
```
|
|
$ pmbootstrap install
|
|
```
|
|
|
|
Build the rootfs with full disk encryption:
|
|
```
|
|
$ pmbootstrap install --fde
|
|
```
|
|
|
|
Update existing installation on SD card:
|
|
```
|
|
$ pmbootstrap install --sdcard=/dev/mmcblk0 --rsync
|
|
```
|
|
|
|
Run the image in QEMU:
|
|
```
|
|
$ pmbootstrap qemu --image-size=1G
|
|
```
|
|
|
|
Flash to the device:
|
|
```
|
|
$ pmbootstrap flasher flash_kernel
|
|
$ pmbootstrap flasher flash_rootfs --partition=userdata
|
|
```
|
|
|
|
Export the rootfs, kernel, initramfs, `boot.img` etc.:
|
|
```
|
|
$ pmbootstrap export
|
|
```
|
|
|
|
Extract the initramfs
|
|
```
|
|
$ pmbootstrap initfs extract
|
|
```
|
|
|
|
Build and flash Android recovery zip:
|
|
```
|
|
$ pmbootstrap install --android-recovery-zip
|
|
$ pmbootstrap flasher --method=adb sideload
|
|
```
|
|
|
|
### Repository Maintenance
|
|
List pmaports that don't have a binary package:
|
|
```
|
|
$ pmbootstrap repo_missing --arch=armhf --overview
|
|
```
|
|
|
|
Increase the `pkgrel` for each aport where the binary package has outdated dependencies (e.g. after soname bumps):
|
|
```
|
|
$ pmbootstrap pkgrel_bump --auto
|
|
```
|
|
|
|
Generate cross-compiler aports based on the latest version from Alpine's aports:
|
|
```
|
|
$ pmbootstrap aportgen binutils-armhf gcc-armhf
|
|
```
|
|
|
|
Manually rebuild package index:
|
|
```
|
|
$ pmbootstrap index
|
|
```
|
|
|
|
Delete local binary packages without existing aport of same version:
|
|
```
|
|
$ pmbootstrap zap -m
|
|
```
|
|
|
|
### Debugging
|
|
Use `-v` on any action to get verbose logging:
|
|
```
|
|
$ pmbootstrap -v build hello-world
|
|
```
|
|
|
|
Parse a single APKBUILD and return it as JSON:
|
|
```
|
|
$ pmbootstrap apkbuild_parse hello-world
|
|
```
|
|
|
|
Parse a package from an APKINDEX and return it as JSON:
|
|
```
|
|
$ pmbootstrap apkindex_parse $WORK/cache_apk_x86_64/APKINDEX.8b865e19.tar.gz hello-world
|
|
```
|
|
|
|
`ccache` statistics:
|
|
```
|
|
$ pmbootstrap stats --arch=armhf
|
|
```
|
|
|
|
`distccd` log:
|
|
```
|
|
$ pmbootstrap log_distccd
|
|
```
|
|
|
|
## Development
|
|
### Testing
|
|
Install `pytest` (via your package manager or pip) and run it inside the pmbootstrap folder.
|
|
|
|
## License
|
|
[GPLv3](LICENSE)
|