openhab / openhabian

openHABian - empowering the smart home, for Raspberry Pi and Debian systems
https://community.openhab.org/t/13379
ISC License
818 stars 251 forks source link

Brocken upgrade process #1802

Closed lochmueller closed 11 months ago

lochmueller commented 11 months ago

Issue information:

Hey everyone. I have some trouble with the upgrade process to 4.0.0 today. The upgrade process https://github.com/openhab/openhabian/blob/main/functions/openhab.bash#L48 was startet without any valid "$2" variable (I don't know why) - Debug log found here: https://openhabforum.de/viewtopic.php?t=8307

As result, the apt-get source was removed: "rm -f /etc/apt/sources.list.d/openhab*.list" and the process stops. After that there are no source lists anymore and a second call to the upgrade process results always in an error, because without the source list entry this result always in an empty string: openhabVersion="${3:-$(apt-cache madison ${ohPkgName} | head -n 1 | cut -d'|' -f2 | xargs)}"

perhaps this information helps, if someone other has also the same problem.

I suggest to check if "$2" is not set in the function and throw an exception in this case.

Debug information:

Some debug logs from the execution: https://openhabforum.de/viewtopic.php?t=8307

System information:

PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)" NAME="Raspbian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

mstormi commented 11 months ago

Github isn't here to help you with upgrading, please turn to the community forum instead. If you believe you have found a bug, provide a full log next time (yours is incomplete and doesn't provide any useful hint). And as openHABian does not start upgrading anything unless you tell it to please also explain what needs to be done to reproduce the problem.

lochmueller commented 11 months ago

Hey @mstormi Sorry and thanks for the fast feedback... I will open this issue again in a few days with more details and a pull request to harden this function. Currently, it is not my main problem anymore ;) have a nice day, Tim

mstormi commented 11 months ago

It's not about hardening, the function has no default so should never be called without an argument. So the point is what did you do that it was called without. That situation has to be identified and avoided.

lochmueller commented 11 months ago

Ok. I checked it again and https://github.com/openhab/openhabian/blob/main/functions/menu.bash#L71 call the function with empty second parameter, if there is no valid openhab repository in the source list, because apt-cache madison openhab is empty then. I thought it would be helpful to catch this missconfiguration because it is a external requirement. In the menu.sh or in the openhab.sh.

I already know your answer: Why the openhab source list entry is missing? :-) And i don't know... but if the entry is gone, the scripts are useless, because the scripts are based on apt-cache madison openhab to work. The script add the right repository in https://github.com/openhab/openhabian/blob/main/functions/openhab.bash#L89 but this line is not reached, if there is no openhab source list repository in the beginning of the process.

Regards, Tim

mstormi commented 11 months ago

If you mess up your system, you must not expect openHABian to work around that. There's simply too many things you can do to make it fail when you tinker with the system, we cannot validate all prerequisites and catch them on the fly. And no we won't start attempting so.

lochmueller commented 10 months ago

For everyone else, with the same problem. The fixes in the current version solve this problems... https://github.com/openhab/openhabian/commit/1de3a5f4ad4fa25f2630cb3c55b9efa4e9183307 Thank you.