When the native arch (e.g. `x86_64`) `APKINDEX` files are outdated, and `pmbootstrap` gets instructed to build a linux package for a foreign arch, then the `APKINDEX` cache did not get used anymore for the current session. This means that every lookup of a package in an `APKINDEX` caused the whole `APKINDEX` file to get parsed again instead of using the cached version. This slowed it down so much that it felt like `pmbootstrap` was looping forever. How this happens in detail: * Whenever pmbootstrap parses an `APKINDEX`, it fills up the `args.cache["apkindex"]` dict with the parsed information and the last modified date of the file. * `pmbootstrap` checks the last modified date of the `APKINDEX` files and updates them if they are older than 4 hours. * When the bug appeared, then the cache was already filled up, then an update happened and then `pmbootstrap` tried to read from the cache. * So when reading from the `APKINDEX`, the cache gets ignored because the last modified date is different. * Up to this commit, the cache does not get deleted and filled up again! How to test: Try these commands once without this commit, and then with this commit applied: ``` $ sudo touch -m -t 201801010000 \ ~/.local/var/pmbootstrap/cache_apk_x86_64/APKINDEX.* $ pmbootstrap -v build linux-postmarketos-mainline --arch=armhf ``` Without the patch, you can see in `pmbootstrap log` that it is resolving the dependencies properly, but very slowly. With the patch the resolving happens almost instantly. |
||
---|---|---|
.travis | ||
aports | ||
helpers | ||
keys | ||
pmb | ||
test | ||
.gitignore | ||
.travis.yml | ||
CONTRIBUTING.md | ||
LICENSE | ||
MANIFEST.in | ||
README.md | ||
pmbootstrap.py | ||
setup.cfg | ||
setup.py |
README.md
pmbootstrap
Introduction | Security Warning | Devices | |
Sophisticated chroot/build/flash tool to develop and install postmarketOS.
Requirements
- 2 GB of RAM recommended for compiling
- Linux distribution (
x86
,x86_64
, oraarch64
)- Windows subsystem for Linux (WSL) does not work! Please use VirtualBox instead.
- Kernels based on the grsec patchset do not work (Alpine: use linux-vanilla instead of linux-hardened, Arch: linux-hardened is not based on grsec)
- On Alpine Linux only:
apk add coreutils
- Python 3.4+
- OpenSSL
Usage Examples
Please refer to the postmarketOS wiki for in-depth coverage of topics such as porting to a new device or installation. 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
.
Basics
Initial setup:
$ git clone https://github.com/postmarketOS/pmbootstrap
$ cd pmbootstrap
$ alias pmbootstrap=$PWD/pmbootstrap.py
$ pmbootstrap init
To make the pmbootstrap
alias persistent, see the wiki.
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://github.com/postmarketOS/osk-sdl/archive/0.51.tar.gz"
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
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 menuconfig --arch=armhf postmarketos-mainline
System Image
Build the system image:
$ pmbootstrap install
Update existing installation on SD card (full disk encryption disabled):
$ pmbootstrap install --sdcard=/dev/mmcblk0 --no-fde --rsync
Run the image in Qemu:
$ pmbootstrap qemu --image-size=1G
Flash to the device:
$ pmbootstrap flasher flash_kernel
$ pmbootstrap flasher flash_system --partition=userdata
Export the system image, 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
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.