Installing packages on a running phone

From postmarketOS
Revision as of 17:50, 19 May 2020 by Alexeymin (talk | contribs) (Fix packages directory after adding stable branch to pmaports)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

1. Go to the pmbootstrap packages dir and start a web server:

$ cd ~/.local/var/pmbootstrap/packages/edge
$ python3 -m http.server

2. Add your own repository on top of your /etc/apk/repositories file on the phone (remember to adjust the IP):

# Add your host machine address
http://172.16.42.2:8000
    
https://nl.alpinelinux.org/alpine/edge/main
https://nl.alpinelinux.org/alpine/edge/community
https://nl.alpinelinux.org/alpine/edge/testing

3. Upgrade the package you have built with apk upgrade [package name]

If you get UNTRUSTED signature and you trust your LAN, then you may consider apk upgrade --allow-untrusted [package name]. Beware of the security implications that --allow-untrusted has.

4. Optional: If you are upgrading a kernel package, the new Android boot image is not automatically flashed to the boot partition at the moment. If you are booting the flashed image (i.e. not using pmbootstrap flasher boot) you'll need to call pmos-update-kernel.

The apk hosting this command is called postmarketos-update-kernel. Then you need to figure out the name of your kernel flavor. Run ls /boot/boot.img-*. Whatever is after the dash, that is your kernel flavor. So

$ ls /boot/boot.img-*
/boot/boot.img-postmarketos-qcom-msm8974
# your kernel flavor is postmarketos-qcom-msm8974
$ sudo pmos-update-kernel postmarketos-qcom-msm8974


Updating your kernel from a running phone

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.

After you execute steps 1 and 2 above, install postmarketos-update-kernel, and find your kernel flavor, you can run the following script:

#!/bin/sh

set -e # errors are critical -- will end script immediately
set -x # echo executed commands
sudo apk --allow-untrusted update                    # update package info
sudo apk --allow-untrusted upgrade                   # upgrade all new packages (most likely kernel)
sudo pmos-update-kernel postmarketos-qcom-msm8974    # make sure new kernel is selected after reboot
set +x

echo -n 'reboot [yN]? '                              # prompt for restart 
read ans
test "$ans" = 'y' && sudo reboot