Pmbootstrap development guide

Installation code
Whenever you change the installation process, also adjust the recovery zip installer (which performs a good part of the installation procedure directly on the Android device with a shell script).

What is this variable used everywhere?
See the big comment at the top of.

Executing shell commands
Use one of the following functions instead of Python's built in :


 * 
 * 
 * 
 * 

These functions call internally to write to the log file (that you can read with  ) and timeout when there is no output. A lot of function parameters are passed through to  as well, see its docstring for a detailed description of what these parameters do.

Writing to files
The passed commands gets interpreted as single command, and not executed in a shell. This means something like the following will not work:

Instead, if you need shell functionality in the call, you can wrap the call with. Here's one example with the parameters correctly escaped (you don't need to do that for the strings in this example, but if you pass variables then they should be escaped properly):

Another technique (especially if you need to run many commands in the shell at once) is writing all commands down into a temporary file and executing it with the shell, see for example pmb/chroot/initfs.py.

Writing files to the chroot
The users in the chroots (root and pmos) have different user IDs than the user of the host system. Therefore we can't just write a file to anywhere in the chroot. But we can write to  and move the file afterwards.

Short files
For short files, do it like this. Make sure to use, as otherwise your input gets interpreted by the shell!

The resulting file will be owned by root. If you don't want the file to be owned by root, run afterwards:

Long files
For longer files, write them to a temp dir first with python code and chown them. If you don't do the chown, it will be owned by the user of the outside OS that runs chroot which is wrong for anything that should end up in an image generated by pmbootstrap (it's fine for e.g. a test case).

Testing the APKBUILD parser after changes
Besides the python tests, it's a good idea to let the APKBUILD parsing code run over all APKBUILDs that we have in pmaports.git, before and after making changes. This makes it easy to spot regressions.

Debugging tab completion (argparse)
When tab completion breaks, commands line  will simply not return the expected list of packages anymore. Exceptions are not printed. To change this behavior and get the exceptions, adjust the  in your shell's rc file.

Copy the whole output of the command to your shell's rc file instead of the eval line, but remove. Then it will print exceptions to the shell.