Bug 251073 - sysutils/plasma5-kinfocenter: show up FreeBSD 12.1 on FreeBSD 12.2
Summary: sysutils/plasma5-kinfocenter: show up FreeBSD 12.1 on FreeBSD 12.2
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-kde (Team)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-12 12:51 UTC by marshall
Modified: 2020-12-02 17:32 UTC (History)
3 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments
v1 (413 bytes, patch)
2020-11-13 09:40 UTC, Mikael Urankar
no flags Details | Diff
v0 (1.19 KB, patch)
2020-12-02 07:30 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description marshall 2020-11-12 12:51:29 UTC
port: sysutils/plasma5-kinfocenter
After install the kde5 by ports, after run systemsetting, click "System Information" (which I believe is actually calling kinfocenter, the window reminds me my system is FreeBSD 12.1, but it is 12.2.

"uname -a" gives "FreeBSD HPC-BSD 12.2-RELEASE FreeBSD 12.2-RELEASE r367095 GENERIC  amd64"

so I checked the pkg-plist file, and it seems would install "/usr/local/etc/xdg/kcm-about-distrorc file. which is as follows:

[General]
Name=FreeBSD
LogoPath=/usr/local/share/kinfocenter/images/freebsd_logo.svg
Website=https://www.freebsd.org

After I add a line "Version=12.2"

the kinfocenter gives right FreeBSD release version information.

But I've checked the "kinfocenter/Modules/about-distro/src/KernelEntry.cpp" file, which include the '<sys/utsname.h>', and looks like:

KernelEntry::KernelEntry()
    : Entry(ki18n("Kernel Version:"), kernelVersion())
{
}

QString KernelEntry::kernelVersion()
{
    struct utsname utsName;
    if (uname(&utsName) == 0) {
        return QString::fromLatin1(utsName.release);
    }
    return QString();
}

which means kinfocenter would give correct version number even without  "Version=12.2" in kcm-about-distrorc file.

So I add a line to printf the utsName.release as:

    if (uname(&utsName) == 0) {
        printf("*******:%s\n", utsName.release);
        return QString::fromLatin1(utsName.release);
    }


But strange thing happened, after I run /usr/ports/.../stage/usr/local/bin/kinfocenter, there is nothing show out on console related with "prinf...".

It looks like this code had not been executed at all.

So, I was totally confused, and the only thing I can do is reported to you.

Thanks alot.
Comment 1 Mikael Urankar freebsd_committer 2020-11-12 17:50:39 UTC
does it read /var/run/os-release?
Comment 2 marshall 2020-11-13 01:21:35 UTC
(In reply to Mikael Urankar from comment #1)
No, It did not read the /var/run/os-release

on my PC, the output of "cat /var/run/os-release" are:

NAME=FreeBSD
VERSION=12.2-RELEASE
VERSION_ID=12.2
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 12.2-RELEASE"
CPE_NAME=cpe:/o:freebsd:freebsd:12.2
HOME_URL=https://FreeBSD.org/
BUG_REPORT_URL=https://bugs.FreeBSD.org/

So the bug is somehow the program does not take release information using "uname" function defined in <sys/utsname.h>, instead of read the 12.1 string form some place.....

By the way, my os is upgraded from 12.2 according to handbook by source.

But both the "uanme -a" "freebsd-version" gives "12.2", So I was really confused by where the "12.1" came from.
Comment 3 marshall 2020-11-13 01:23:35 UTC
(In reply to Mikael Urankar from comment #1)
No, It did not read the /var/run/os-release

on my PC, the output of "cat /var/run/os-release" are:

NAME=FreeBSD
VERSION=12.2-RELEASE
VERSION_ID=12.2
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 12.2-RELEASE"
CPE_NAME=cpe:/o:freebsd:freebsd:12.2
HOME_URL=https://FreeBSD.org/
BUG_REPORT_URL=https://bugs.FreeBSD.org/

So the bug is somehow the program does not take release information using "uname" function defined in <sys/utsname.h>, instead of read the "12.1"  from some place.....

By the way, my os is upgraded from 12.1 according to handbook by source.

But both the "uanme -a" "freebsd-version" gives "12.2", So I was really confused by where the "12.1" came from.
Comment 4 Mikael Urankar freebsd_committer 2020-11-13 09:40:39 UTC
Created attachment 219631 [details]
v1

Can you try the attached patch (suggested by tcberner@)?
or just edit /usr/local/etc/xdg/kcm-about-distrorc as root and add this line:
UseOSReleaseVersion=true
Comment 5 marshall 2020-11-13 10:52:49 UTC
(In reply to Mikael Urankar from comment #4)
Hi, Miakel:
    Thanks for your patch, but things get more strange.
    After I add "UseOSReleaseVersion=true" into "/usr/local/etc/xdg/kcm-about-distrorc". Now the kinfocenter gives "FreeBSD 12.1-RLEASE-p10" above the "https://www.freebsd.org".
    If I remove this line, the information was "FreeBSD 12.1"

    The following version information seems ok:
    ...
    Qt Version: 5.15.0
    Kernel Version: 12.2-RELEASE
    OS Type: 64-bit

So, sadly, it did not work on my computer, I think maybe there is some "12.1-RLEASE-p10" string in some place of my system, since I upgrade it from 12.1-RELEASE-p10 to 12.2 by rebuilding the word.

my /usr/src fold is totally 12.2 release, and the upgrade process was followed by FreeBSD Handbook.
Comment 6 Mikael Urankar freebsd_committer 2020-11-13 14:48:34 UTC
ls -l /etc/os-release
if it's not a symlink to /var/run/os-release, post the content of the file
Comment 7 marshall 2020-11-13 15:11:17 UTC
(In reply to Mikael Urankar from comment #6)
Thanks for your kind help, I am sorry for I can not test it until next monday.

I would reply your ASAP.

Thanks again.
Comment 8 Adriaan de Groot freebsd_committer 2020-11-13 16:42:53 UTC
For @marshall, you could try the following program, just to see if the `uname()` function which **presumably** is being called by kinfocenter, is returning the thing that you think it is (or what it should be):

```
#include <sys/utsname.h>
#include <stdio.h>
int main(int argc, char** argv) {
        struct utsname u;
        int r = uname(&u);
        printf("%d: %s\n", r, r ? "<error>" : u.release);
        return 0;
}
```

After that, check if the environment variable affects this program, and also kinfocenter:

```
UNAME_r="derpderp" kinfocenter
UNAME_r="derpderp" ./a.out
```

(Both of those should show "derpderp" as kernel version, because the environment variable takes precedence).
Comment 9 marshall 2020-11-16 02:56:20 UTC
(In reply to Mikael Urankar from comment #6)
The output of "ls -l /etc/os-release" is:

/etc/os-release -> ../var/run/os-release

and output of "cat /var/run/os-release" is:

NAME=FreeBSD
VERSION=12.2-RELEASE
VERSION_ID=12.2
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 12.2-RELEASE"
CPE_NAME=cpe:/o:freebsd:freebsd:12.2
HOME_URL=https://FreeBSD.org/
BUG_REPORT_URL=https://bugs.FreeBSD.org/
Comment 10 marshall 2020-11-16 03:03:46 UTC
(In reply to Adriaan de Groot from comment #8)
Okey, I made a test.c file with what you give me and compile it by clang

here is the test output:

$ ./a.out
0: 12.2-RELEASE
$ UNAME_r="derpderp" ./a.out 
0: derpderp
$ UNAME_r="something_not_fun" ./a.out 
0: something_not_fun

But this is still weird, it can not explain where is the "12.1-P10" comes from.

Anyway, thanks.
Comment 11 marshall 2020-11-16 03:58:57 UTC
Hi, all:

I have no choice but read the kinfocenter source code more carefully, Now I have a little knowledge of what function in KDE gives the mistake-version string.

The related source code is "kinfocenter/Modules/about-distro/src/Module.cpp" after line 104:

void Module::loadOSData()
{
    ......
    KOSRelease os;
    ......
    // well this line is okey with kcm-about-distrorc file
    const QString distroName = cg.readEntry("Name", os.name());
    // and this line gives the wrong version string
    const QString osrVersion = cg.readEntry("UseOSReleaseVersion", false)
            ? os.version()
            : os.versionId();
    const QString versionId = cg.readEntry("Version", osrVersion);
    ......
}

case 1:
  say there is no Version and UseOSReleaseVersion information, osrVersion=os.version() which is 12.1 defined by KDE KOSRelease module
  and if UseOSRleaseVersion=true, then osrVersion=os.versionId(), which is "12.1-RELEASE-p10"

case 2:
  say I set Version=12.2
  then versionId = 12.2 


Okey, So we know the class KOSRelease os gives wrong string.

So Trace it into "/coreaddons/src/lib/util/kosrelease.cpp" and find it would read /etc/os-release file as:

static QString defaultFilePath()
{
    if (QFile::exists(QStringLiteral("/etc/os-release"))) {
        return QStringLiteral("/etc/os-release");
    } else if (QFile::exists(QStringLiteral("/usr/lib/os-release"))) {
        return QStringLiteral("/usr/lib/os-release");
    } else {
        return QString();
    }
}

The I cat "/etc/os-release", it gives:

NAME=FreeBSD
VERSION=12.2-RELEASE
VERSION_ID=12.2
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 12.2-RELEASE"
CPE_NAME=cpe:/o:freebsd:freebsd:12.2
HOME_URL=https://FreeBSD.org/
BUG_REPORT_URL=https://bugs.FreeBSD.org/

This is crazy. everything looks okey, but where is the "12.1-RELEASE-p10" comes from?
Comment 12 marshall 2020-12-02 03:35:33 UTC
Hi, all:
   Today I get sometime and finally solved this little problem. Here is what I've done.

   1.I try to find all os-release file in my computer:
   
   > cd /
   > locate os-release
   
   then I get the output as:

   /compat/linux/etc/centos-release
   /compat/linux/etc/centos-release-upstream
   /compat/linux/etc/os-release
   /compat/linux/usr/lib/os-release
   /compat/linux/usr/share/centos-release
   /compat/linux/usr/share/centos-release/EULA
   /compat/linux/usr/share/doc/centos-release
   /compat/linux/usr/share/doc/centos-release/Contributors
   /compat/linux/usr/share/doc/centos-release/GPL
   /etc/os-release
   /etc/rc.d/os-release
   /usr/local/etc/os-release
   /usr/obj/usr/src/amd64.amd64/share/man/man5/os-release.5.gz
   /usr/ports/sysutils/etc_os-release
   /usr/ports/sysutils/etc_os-release/Makefile
   /usr/ports/sysutils/etc_os-release/pkg-descr
   /usr/share/man/man5/os-release.5.gz
   /usr/src/libexec/rc/rc.d/os-release
   /usr/src/share/man/man5/os-release.5
   /var/db/etcupdate/current/etc/os-release
   /var/db/etcupdate/current/etc/rc.d/os-release
   /var/run/os-release

   2. It seems only 4 files looks related with the bug
   /etc/os-release
   /etc/rc.d/os-release
   /usr/local/etc/os-release
   /var/run/os-release
   so I `cat` them one by one, and find the 12.1-p10 comes from /usr/local/etc/os-release, which means this file have not been upgraded after I upgrade the system from 12.1 to 12.2.
   
   3. Solve the problem
   After I overwrite the /usr/local/etc/os-release by /etc/os-release, now the kinfocenter dialog can gives right version.

   4. still confuse me
   Since the source code of plasma5 indicate that they read the release info. only from "/etc/os-release" and "/usr/lib/os-release", why my "/etc/os-release" does not work and strangely read the "/usr/local/etc/os-release" file.

   5. recommendation
   I think it is better to remove the "/usr/local/etc/os-release" on future releases, or add some automatic process to overwrite it after the user install the world.
Comment 13 Serge Volkov 2020-12-02 06:58:30 UTC
I think you shouldn't delete /usr/local/etc/os-release. This file is installed by the sysutils/etc_os-release package or port https://svnweb.freebsd.org/ports/head/sysutils/etc_os-release/pkg-descr?revision=HEAD. It is enough to do the following:

portsnap fetch extract
cd /usr/ports/sysutils/etc_os-release
make deinstall reinstall clean

Or do the same with a package.
Comment 14 marshall 2020-12-02 07:10:59 UTC
(In reply to Serge Volkov from comment #13)
Thanks a lot. You are right, the '/usr/ports/sysutils/etc_os-release' would generate that /usr/local/etc/os-release file correctly, which has the same contents of /etc/os-release generated by make install the 12.2 world. 
I do not what's the point for that port, and still make me confused when and why kinfocenter read that file instead of /etc/os-release.

Anyway, the problem was solved, and thanks for all you kind people.
Comment 15 Mikael Urankar freebsd_committer 2020-12-02 07:16:34 UTC
os-release is part of base in 12.2, the sysutils/etc_os-release servers no purpose on 12.2

sysutils/gnome-control-center and devel/qt5-core should be fixed and not impose 
sysutils/etc_os-release on 12.2
Comment 16 Mikael Urankar freebsd_committer 2020-12-02 07:30:08 UTC
Created attachment 220160 [details]
v0

fix dep
Comment 17 Tobias C. Berner freebsd_committer 2020-12-02 17:32:08 UTC
@mikael, lgtm to both patches -- v0 should likely get PORTREVISION bumps though.


mfg Tobias