openlumi / homeassistant_on_openwrt

Install Home Assistant on your OpenWrt device with a single command
MIT License
157 stars 43 forks source link

Script exit after opkg update #31

Closed hugoleosp closed 1 year ago

hugoleosp commented 1 year ago

Hi, I'm trying to install HA using this script and it exits right after opkg update.

Checking the script, the next line would be: opkg list | grep python3-base | head -n 1 | grep -Eo '\d+.\d+'

The result of this line is empty, and removing the last grep, it shows: python3-base - 3.10.9-1 - This package contains only the interpreter and the bare minimum for the interpreter to start.

I'm on Orange Pi custom firmware that I compiled myself: Model: Xunlong Orange Pi R1 Plus LTS Architecture: ARMv8 Processor rev 4 Target Platform: rockchip/armv8 Firmware Version: OpenWrt 22.03.2 r19803-9a599fee93 / LuCI openwrt-22.03 branch git-22.288.45147-96ec0cd Kernel Version: 5.10.146

Could you please help me understand what is wrong? Thank you =D

devbis commented 1 year ago

It's difficult to say without logs, but

echo 'python3-base - 3.10.9-1 - This package contains only the interpreter and the bare minimum for the interpreter to start.' | grep -Eo '\d+\.\d+'
3.10

works correctly and returns the python's version.

You may add set -x in the beginning of the file to track every executed command and find a real last command

ohabu commented 1 year ago

Busybox version of grep

root@Openwrt:~# opkg list | grep python3-base | head -n 1 | grep -Eo '\d+.\d+'
3.10
9-1
root@Openwrt:~#
root@Openwrt:~# grep
BusyBox v1.35.0 (2023-04-27 20:28:15 UTC) multi-call binary.

GNU version of grep

root@Openwrt:~# opkg list | grep python3-base | head -n 1 | grep -Eo '\d+.\d+'
root@Openwrt:~#
root@Openwrt:~# opkg list | grep python3-base | head -n 1 | grep -Eo '[[:digit:]]+.[[:digit:]]+'
3.10
9-1
root@Openwrt:~# grep --version
grep (GNU grep) 3.7
devbis commented 1 year ago

You use a different command, not from the script. Note a backslash before the dot in the script in the latest version

ohabu commented 1 year ago

You are right. But still my point is valid. Those regex won't work with GNU grep which returns null.

Busybox grep

root@OPIPlusLTS:~# opkg list | grep python3-base | head -n 1 | grep -Eo '\d+\.\d+'
3.9
root@OPIPlusLTS:~# opkg list | grep python3-base | head -n 1 | grep -Eo '[[:digit:]]+\.[[:digit:]]+'
3.9
root@OPIPlusLTS:~# grep
BusyBox v1.33.2 (2022-04-16 12:59:34 UTC) multi-call binary.

GNU grep

root@OPIPlusLTS:~# opkg list | grep python3-base | head -n 1 | grep -Eo '\d+\.\d+'
root@OPIPlusLTS:~# opkg list | grep python3-base | head -n 1 | grep -Eo '[[:digit:]]+\.[[:digit:]]+'
3.9
root@OPIPlusLTS:~# grep --version
grep (GNU grep) 3.6
devbis commented 1 year ago

Oh, you mean that you have a command that works with both gnu and busybox. That's fine, can you please create a PR to fix that?

ohabu commented 1 year ago

@hugoleosp Script works. opkg install python3-pip-src is needed for openwrt 22.03 branch.

devbis commented 1 year ago

Fixed by #32