Upgrading 4.2 to 4.3 breaks in joinscript_init

Hi everyone,

while testing an update from UCS 4.2 to UCS 4.3 on a master with a new version of our app I have some uncommon problems.
Whenever I attempt to upgrade the installation of one of our packages fail. Further investiation showed that the problem is somewhere in joinscript_init in /usr/share/univention-join/joinscripthelper.lib.
The package in question executes our joinscript in postinst. The join script loads the mentioned library and runs the function.
For debugging I added set -x and echo surrounding the function call in the join script.

This leads to the following output:

opsi4ucs (4.1.1.5-2) wird eingerichtet ...
File: /etc/pam.d/opsi-auth
Calling joinscript 99opsi4ucs.inst ...
+ echo 'before init'
before init
+ joinscript_init
++ readlink -f /usr/lib/univention-install/99opsi4ucs.inst
+ JS_SCRIPT_FULLNAME=/usr/lib/univention-install/99opsi4ucs.inst
++ date --rfc-3339=ns
+ echo '2018-10-11 17:29:23.788704992+02:00 (in joinscript_init)'
2018-10-11 17:29:23.788704992+02:00 (in joinscript_init)
+ joinscript_get_package_name
+ '[' '!' -f /usr/lib/univention-install/99opsi4ucs.inst ']'
++ echo /usr/lib/univention-install/99opsi4ucs
++ sed 's/.*\///'
++ sed 's/^[0-9][0-9]//'
+ JS_PACKAGE=opsi4ucs
+ '[' -z opsi4ucs ']'
+ return 0
+ joinscript_is_version 45
+ local var=45
+ '[' -z 45 ']'
++ echo 45
++ tr -d 0-9
+ '[' '!' -z '' ']'
+ '[' 45 -lt 1 ']'
+ return 0
+ joinscript_check_joinstatus
+ '[' '!' -f /var/univention-join/joined ']'
+ return 0
+ '[' -z '' ']'
+ joinscript_check_already_executed
+ joinscript_check_specific_version_executed 45
+ local version=45
+ joinscript_is_version 45
+ local var=45
+ '[' -z 45 ']'
++ echo 45
++ tr -d 0-9
+ '[' '!' -z '' ']'
+ '[' 45 -lt 1 ']'
+ return 0
+ touch /var/univention-join/status
+ grep -qs '^opsi4ucs v45 successful' /var/univention-join/status
+ return 0
+ return 0
+ exit 1
dpkg: Fehler beim Bearbeiten des Paketes opsi4ucs (--configure):
 Unterprozess installiertes post-installation-Skript gab den Fehlerwert 1 zurĂĽck
dpkg: Abhängigkeitsprobleme verhindern Konfiguration von opsi4ucsappcenter:
 opsi4ucsappcenter hängt ab von opsi4ucs (>= 4.1.1.5); aber:
  Paket opsi4ucs ist noch nicht konfiguriert.

Please note that the join script in question has bash -e as part of it’s shebang and it is intentionally.

An installation of the app on UCS 4.3 works fine if it wasn’t installed before on the system. It only happens during the upgrade from 4.2 to 4.3.

Looking into the problematic function did not make me any wiser.
Where could I look next to find out what is causing the problem? Do you have any ideas on what to try?

It seems that you already have version 45 of the joinscript installed on UCS 4.2 and update to UCS 4.3 where no higher version than 45 is available. Am I right?

The problem is, that in opsi4ucs.postinst the strict error checking is activated (bash -e) in line 1, but no errors where handled in line 25.

Calling an already executed joinscript will return an exitcode 1, as you see in your output above, since the version is still 45.

There a various possibilities to solve this:

  • create a joinscript with a higher version number than 45 for UCS 4.3, because I suspect there are some more differences to UCS 4.2 :wink:
  • turn off error checking for the block in postinst
set +e
. /usr/share/univention-lib/base.sh
call_joinscript 99opsi4ucs.inst
set -e
  • or return always true for the line in postinst
call_joinscript 99opsi4ucs.inst || true

It seems that you already have version 45 of the joinscript installed on UCS 4.2 and update to UCS 4.3 where no higher version than 45 is available. Am I right?

Version 45 was already executed on UCS 4.2. We build packages for each UCS version but they share the same code. There isn’t a newer version available for UCS 4.3 and this will only be the case some time in the future if we drop support for UCS 4.2.
The join script handles version specific differences so we can use same script for 4.2 and 4.3.
Introducing a higher version number only for UCS 4.3 does not seem to work out for me since we still support UCS 4.2.

Will exit code 1 only be returned if the script has already been run or could this also be returned for any other problem?
If it is only returned for an already executed join script I’d simply check the return code and then handle this accordingly.

Using call_joinscript 99opsi4ucs.inst || true goes a little too far for my liking. I’d like to notice early on if things break to be able to react early.

if call_joinscript returns correctly the exit codes are:
http://docs.software-univention.de/developer-reference-4.3.html#join:exitcode

Yes, handling the return code in postinst is more like a workaround.

The normal processing from the call_joinscript function was interrupted. And as you also activate strict error checking (bash -e) in your joinscript, it quits. Your joinscript returns exit 1 at some point. Btw. its a good practice to add “exit 0” for the last line in the joinscript.

Calling an already executed joinscript more than once will internally return 1. You probably have seen the output in this case, which is ok, but might be a problem for strict error checking:

Calling joinscript 99ucsschool-italc-key.inst ...
2018-10-12 11:17:42.740072342+02:00 (in joinscript_init)
Joinscript 99ucsschool-italc-key.inst finished with exitcode 1

Maybe it helps with set +e at line 10 in your joinscript, and set -e afterwards.

1 Like

I decided to remove the -e from the postinst and now it works as expected. Thank you, @peichert!

Thanks for the hint. I added an explicit exit 0.

Mastodon