License info is shown at every session start in FreeBSD 13.2 due to nonportable use of sed in script #227

Open
opened 2 years ago by Lannig · 7 comments
Lannig commented 2 years ago
Collaborator

Basic information

  • TDE version: R14.1.0
  • Distribution: FreeBSD 13.2-RELEASE amd64
  • Hardware: amd64

Description

Every time I start my TDE session, the licence info window is shown.
I have tracked this down to the /opt/trinity/bin/tde_show_license_info script making a non-portable use of sed to determine TDE_MINOR_VERSION, so it fails to value it under FreeBSD.

Under FreeBSD, the '+' repetition is allowed only when sed is run with the -E option (extended regular expressions).
It should not be quoted as \+ in the RE anyway, although Linux seems to accept this.
Quoted parenthesis \( and \) are NOT accepted by FreeBSD sed if -E option is used but are without this option (doesn't make much sense to me TBH). Parenthesis should not be quoted if -E is used.

Solution: as -E seems to to make things more complex, use the more portable * repetition factor (zero or more) instead of + (one or more) and duplicate the patterns. Suggested patch below.

Steps to reproduce

  1. Install FreeBSD 13.2-RELEASE amd64
  2. Follow https://wiki.trinitydesktop.org/FreeBSD_Trinity_Installation_Instructions#Spread_ports_from_GIT_folder_to_.2Fusr.2Fports including all prerequisites (ports update, pkg manager configuration, packages to install)
  3. Start TDE session, close it and start again: license window comes up again

Screenshots

Suggested patch to /opt/trinity/bin/tde_show_license_info:

*** tde_show_license_info.org   Fri May  5 13:54:41 2023
--- tde_show_license_info       Fri May  5 14:27:09 2023
***************
*** 11,17 ****
    exit 1
  fi

! RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | sed -n  's|^TDE: \(R[0-9]\+\.[0-9]\+\)\.[0-9]\+[^0-9]*|\1|p' )"
  LICENSE_INFO="$( ${TDEDIR}/bin/kreadconfig --file ${TDEHOME}/share/config/kdeglobals --group "License Info" --key "${RELEASE_MINOR_VERSION}" )"

  if [ "$LICENSE_INFO" = "" ] || [ "$LICENSE_INFO" != "true" ]; then
--- 11,17 ----
    exit 1
  fi

! RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | sed -n  's|^TDE: \(R[0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*[^0-9]*|\1|p' )"
  LICENSE_INFO="$( ${TDEDIR}/bin/kreadconfig --file ${TDEHOME}/share/config/kdeglobals --group "License Info" --key "${RELEASE_MINOR_VERSION}" )"

  if [ "$LICENSE_INFO" = "" ] || [ "$LICENSE_INFO" != "true" ]; then
<!-- This is a comment. Please fill in the required fields below. The comments provide instructions on how to do so. Note: You do not need to remove comments. --> ## Basic information - TDE version: R14.1.0 - Distribution: FreeBSD 13.2-RELEASE amd64 - Hardware: amd64 <!-- Use SL/* labels to set the severity level. Please do not set a milestone. --> ## Description Every time I start my TDE session, the licence info window is shown. I have tracked this down to the /opt/trinity/bin/tde_show_license_info script making a non-portable use of sed to determine TDE_MINOR_VERSION, so it fails to value it under FreeBSD. Under FreeBSD, the '+' repetition is allowed only when sed is run with the -E option (extended regular expressions). It should not be quoted as \\+ in the RE anyway, although Linux seems to accept this. Quoted parenthesis \\( and \\) are NOT accepted by FreeBSD sed if -E option is used but are without this option (doesn't make much sense to me TBH). Parenthesis should not be quoted if -E is used. Solution: as -E seems to to make things more complex, use the more portable * repetition factor (zero or more) instead of + (one or more) and duplicate the patterns. Suggested patch below. ## Steps to reproduce 1. Install FreeBSD 13.2-RELEASE amd64 2. Follow https://wiki.trinitydesktop.org/FreeBSD_Trinity_Installation_Instructions#Spread_ports_from_GIT_folder_to_.2Fusr.2Fports including all prerequisites (ports update, pkg manager configuration, packages to install) 3. Start TDE session, close it and start again: license window comes up again ## Screenshots Suggested patch to /opt/trinity/bin/tde_show_license_info: ``` *** tde_show_license_info.org Fri May 5 13:54:41 2023 --- tde_show_license_info Fri May 5 14:27:09 2023 *************** *** 11,17 **** exit 1 fi ! RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | sed -n 's|^TDE: \(R[0-9]\+\.[0-9]\+\)\.[0-9]\+[^0-9]*|\1|p' )" LICENSE_INFO="$( ${TDEDIR}/bin/kreadconfig --file ${TDEHOME}/share/config/kdeglobals --group "License Info" --key "${RELEASE_MINOR_VERSION}" )" if [ "$LICENSE_INFO" = "" ] || [ "$LICENSE_INFO" != "true" ]; then --- 11,17 ---- exit 1 fi ! RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | sed -n 's|^TDE: \(R[0-9][0-9]*\.[0-9][0-9]*\)\.[0-9][0-9]*[^0-9]*|\1|p' )" LICENSE_INFO="$( ${TDEDIR}/bin/kreadconfig --file ${TDEHOME}/share/config/kdeglobals --group "License Info" --key "${RELEASE_MINOR_VERSION}" )" if [ "$LICENSE_INFO" = "" ] || [ "$LICENSE_INFO" != "true" ]; then ```
Lannig commented 2 years ago
Poster
Collaborator

Ouch, the backslashes have been stripped out from my post above, making it hard to understand.

Ouch, the backslashes have been stripped out from my post above, making it hard to understand.
Owner

In order to create a pull-request on the relevant repository, I added you to the Contributors team. Instead of a patch listed in the comment, you can now create a branch and PR in tdebase repository. See wiki page for TGW.

In order to create a pull-request on the relevant repository, I added you to the Contributors team. Instead of a patch listed in the comment, you can now create a branch and PR in tdebase repository. See [wiki page for TGW](https://wiki.trinitydesktop.org/TDE_Gitea_Workspace).
Lannig commented 2 years ago
Poster
Collaborator

Fixed it.

Fixed it.
Owner

Does this work in FreeBSD?

RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | sed -n -E  's|^TDE: (R[0-9]+\.[0-9]+)\.[0-9]+[^0-9]*|\1|p' )"

It avoids repeating the pattern and the plus * usage, compared to the patch above, which IMO gives a slightly more readable regex

Does this work in FreeBSD? ``` RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | sed -n -E 's|^TDE: (R[0-9]+\.[0-9]+)\.[0-9]+[^0-9]*|\1|p' )" ``` It avoids repeating the pattern and the plus `*` usage, compared to the patch above, which IMO gives a slightly more readable regex
Poster
Collaborator

Sorry for the extremely late reply.

Yes, it works as suggested:

$ ${TDEDIR}/bin/tde-config --version | sed -n -E  's|^TDE: (R[0-9]+\.[0-9]+)\.[0-9]+[^0-9]*|\1|p'
R14.1

It's still broken in 14.1.2 though.
I have my own little patch that I apply on every installation.

Sorry for the extremely late reply. Yes, it works as suggested: ``` $ ${TDEDIR}/bin/tde-config --version | sed -n -E 's|^TDE: (R[0-9]+\.[0-9]+)\.[0-9]+[^0-9]*|\1|p' R14.1 ``` It's still broken in 14.1.2 though. I have my own little patch that I apply on every installation.
Collaborator

just with posix sh:

RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | while read m v; do [ $m = "TDE:" ] && (IFS=.;set -- $v;echo $1.$2); done )"
just with posix sh: ~~~ sh RELEASE_MINOR_VERSION="$( ${TDEDIR}/bin/tde-config --version | while read m v; do [ $m = "TDE:" ] && (IFS=.;set -- $v;echo $1.$2); done )" ~~~
Owner

@Lannig could you also confirm the last version suggested by @obache works fine for you? it is ok in linux, so if it works also in FreeBSD (which should), I would update based on the more general posix version.

@Lannig could you also confirm the last version suggested by @obache works fine for you? it is ok in linux, so if it works also in FreeBSD (which should), I would update based on the more general posix version.
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: TDE/tde-packaging#227
Loading…
There is no content yet.