Difference between revisions of "Installing packages on a running phone"

From postmarketOS
Jump to: navigation, search
(update "untrusted signature" bit)
(Add a small script that reinstalls latest packages, updates kernel and reboots)
Line 20: Line 20:
  
 
If you get <code>UNTRUSTED signature</code> and you trust your LAN, then you may consider <code>apk upgrade --allow-untrusted [package name]</code>. Beware of the security implications that <code>--allow-untrusted</code> has.
 
If you get <code>UNTRUSTED signature</code> and you trust your LAN, then you may consider <code>apk upgrade --allow-untrusted [package name]</code>. Beware of the security implications that <code>--allow-untrusted</code> has.
 +
 +
4. (optional) After installing a kernel package, you'll need to call <code>pmos-update-kernel</code>
 +
 +
The apk hosting this command is called <code>postmarketos-update-kernel</code>. Then you need to figure out the name of your kernel flavor. Run <code>ls /boot/boot.img-*</code>. Whatever is after the dash, that is your kernel flavor. So
 +
 +
<source lang="shell">
 +
$ ls /boot/boot.img-*
 +
/boot/boot.img-postmarketos-qcom-msm8974
 +
# your kernel flavor is postmarketos-qcom-msm8974
 +
$ sudo pmos-update-kernel postmarketos-qcom-msm8974
 +
</source>
 +
 +
 +
== 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]] + <code>pmbootstrap build --envkernel MAINLINE_LINUX_PACKAGE_NAME</code>. 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:
 +
 +
<source lang="shell">
 +
#!/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
 +
</source>
  
 
[[Category:Guide]]
 
[[Category:Guide]]

Revision as of 07:33, 1 April 2020

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

$ cd ~/.local/var/pmbootstrap/packages
$ 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) After installing a kernel package, 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