Installing packages on a running phone
This article explains how to host packages that were built with pmbootstrap in a local network, so you can install them on your phone via Wi-Fi or USB network.
Easiest way: use pmbootstrap sideload
Connect your phone using USB network and make sure you can login into it with SSH. Then excecute the following:
ps:~$ pmbootstrap sideload --host 172.16.42.1 --port 22 --user user --arch <arch> package-name
replace arch with actual architecture (for example, aarch64).
--install-key argument if you see the error about untrusted signature.
Hard way: host repository locally using a web server
Start the webserver
Go to the pmbootstrap packages dir and start a web server:
pc:~$ cd ~/.local/var/pmbootstrap/packages/stable && python3 -m http.server
Add the repository
Install your favorite editor and open
/etc/apk/repositories on your phone via SSH:
phone:~$ sudo apk add neovim phone:~$ sudo nvim /etc/apk/repositories
Add your own repository on top:
http://172.16.42.2:8000 http://mirror.postmarketos.org/postmarketos/v20.05 http://dl-cdn.alpinelinux.org/alpine/v3.12/main http://dl-cdn.alpinelinux.org/alpine/v3.12/community
Copy the package signing keys
If you did not generate the postmarketOS installation from the same PC, which is now running pmbootstrap to build the packages you want to install, then you need to copy the package signing keys. Otherwise, apk will refuse to install the packages ("UNTRUSTED signature").
On your PC (replace
172.16.42.1 with the IP of your phone,
user with your ssh username, mind the
: at the end of the
pc:~$ scp ~/.local/var/pmbootstrap/config_apk_keys/pmos-*.rsa.pub email@example.com: pc:~$ ssh firstname.lastname@example.org
Run on your phone via SSH:
phone:~$ sudo mv pmos-*.rsa.pub /etc/apk/keys/
Use your repository
apk should recognize your repository, and you should be able to install or upgrade packages built on your PC:
phone:~$ sudo apk update fetch http://172.16.42.2:8000/aarch64/APKINDEX.tar.gz fetch http://postmarketos1.brixit.nl/postmarketos/v20.05/aarch64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/aarch64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/aarch64/APKINDEX.tar.gz postmarketOS [http://172.16.42.2:8000] 2020-09-01 17:02:31.099145 [http://postmarketos1.brixit.nl/postmarketos/v20.05] v3.12.0-283-g612cd12ab6 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main] v3.12.0-276-gbdd3966958 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community] OK: 12967 distinct packages available phone:~$ sudo apk upgrade hello-world
Android devices currently need to run
pmos-update-kernel after a kernel upgrade, to actually write the new kernel to the partition expected by LK (see boot process).
Run it manually
postmarketos-update-kernel, figure out the kernel flavor (in the example below:
postmarketos-qcom-msm8974) and update the kernel:
phone:~$ sudo apk add postmarketos-update-kernel phone:~$ ls /boot/boot.img-* /boot/boot.img-postmarketos-qcom-msm8974 phone:~$ sudo pmos-update-kernel postmarketos-qcom-msm8974
Automate with a script
If you're experimenting with mainline kernel and adding new features you might end up wanting to update your kernel and restart your phone very often. On the kernel building end you can use envkernel.sh +
pmbootstrap build --envkernel MAINLINE_LINUX_PACKAGE_NAME. That will produce a fresh new kernel package with the changes you made. Then you need to install that package to the phone.
Use this script to automate the steps above (adjust
#!/bin/sh -ex # Upgrade all packages (should have your kernel upgrade) sudo apk update sudo apk add postmarketos-update-kernel sudo apk upgrade # Write kernel to location expected by LK sudo pmos-update-kernel postmarketos-qcom-msm8974 # Prompt for restart set +x echo -n 'reboot [yN]? ' read ans test "$ans" = 'y' && sudo reboot