The most common use-case is, that you want to package an Android kernel. But it does not compile with our GCC6, so you need to patch the kernel. Unlike in the Android world, we do not fork the kernel repository and apply our patches there. Instead we ship our custom patches with the package build recipe in the aport folder.
This guide assumes, that you already know what to patch - if you don't know what to patch and only have the error, try to search the web for that error message. More often than not, there is a patch already available, that will fix it. If you don't have any luck, ask in the chat.
As everywhere else in the wiki, please expand this guide wherever information is missing that would have helped you!
- Try to compile your program with
pmbootstrap build my-package. Note in which chroot it will actually build, it is the start of the building message. When it starts with
(native)for example, the chroot is the "native" chroot (which is the default).
- Wait until it fails or runs through (it works in both cases)
- The sources of the kernel are now extracted in
/home/pmos/build/srcin the chroot where it was building.
pmbootstrap chrootto enter the chroot and to create the patch. It will enter the native chroot by default, if you need another chroot, then look at
pmbootstrap chroot --help. Then do the following inside the chroot shell:
gitand an editor such as
apk add git nano
- Switch from root to the user that we use for building:
su - pmos
- Go into the source folder:
- Patches get applied in the builddir, so usually there is another folder inside
src, that you need to enter. You can check with
lswhich folders/files are inside the
srcfolder. Enter that subfolder if necessary.
- We'll be using git to create a patch file, so we will initialize a new repository and add everything:
git init .(it will say: "Initialized empty Git repository in /home/pmos/build/src/.git/")
git add -A
git commit -m "initial"
- Now it's time to edit the file you want to edit.
nano Makefile(or whichever file you want to edit)
- NOTE: nano is glitchy when used like that. If it is unusable for you, run
chmod 777 Makefileand then edit the file from outside the chroot with your favorite editor (a graphical one works, too!). The path is similar to:
- (You need to still be in the chroot!) run
git diffto get a patch file generated to the screen. You can save it to a file by redirecting it:
git diff > /tmp/mypatch.patch.
- Quit the chroot by pressing
^D(CTRL+D) twice (typing
- Copy the patch file you have created to your aport folder (adjust the work path, that you have given
pmbootstrap initand the chroot suffix
cp ~/.local/var/pmbootstrap/chroot_native/tmp/mypatch.patch ~/code/pmbootstrap/aports/device/linux-my-cool-kernel/mypatch.patch
- Rename the
mypatch.patchfile to give it a meaningful name!
- You can add arbitrary text at the top of the patch file. Use this to paste the error message that you got during compilation there, with a note that this will be fixed by this patch.