Bug 238953

Summary: sysutils/etc_os-release: version number becomes obsolete after system updates
Product: Ports & Packages Reporter: Ting-Wei Lan <lantw44>
Component: Individual Port(s)Assignee: Tobias C. Berner <tcberner>
Status: In Progress ---    
Severity: Affects Only Me CC: alien.xupypr, emaste, ilaurie, imp, lwhsu
Priority: --- Flags: tcberner: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
URL: https://reviews.freebsd.org/D22271

Description Ting-Wei Lan 2019-07-03 07:51:50 UTC
Since this port records the version number of the system during the build, there is no way to update the version number stored in /usr/local/etc/os-release without rebuilding or updating the port. Therefore, the version number stored in the file becomes wrong as soon as the user updates the system with freebsd-update. Is it considered a problem, or it is just ignored?

I don't know what is the expected way to use the port, but it will be confusing to users if data stored in /usr/local/etc/os-release is used to show the version of the system. For example, gnome-control-center uses /etc/os-release to show OS version in its about page, and it is likely for a user to find the version number showed there is different from what freebsd-version command reports.
Comment 1 Tobias C. Berner freebsd_committer 2019-07-07 09:04:00 UTC
Hit there

Yeah, that is not great. But as long as that is not part of the base system there is no easy fix for this, other than following the rule to upgrade ports after a system upgrade.

As that file is only needed to display some Operating System information in Qt and Gtk applications, a slight mismatch won't likely cause any problems other than confusion :)


mfg Tobias
Comment 2 Ting-Wei Lan 2019-07-07 17:39:02 UTC
(In reply to Tobias C. Berner from comment #1)
Instead of shipping an os-release file directly in the package, do you think it will be better if it ships a script which can be used to update the os-release file? It can also include necessary files to update it during boot in a way similar to motd or drop a file into /usr/local/etc/cron.d to check and update it every hour.
Comment 3 Tobias C. Berner freebsd_committer 2019-07-07 17:49:23 UTC
(In reply to Ting-Wei Lan from comment #2)
That sounds like a bit of overkill for what we use it for at the moment. 
If stuff some day really requires it to be accurate, I think it should be shipped as part of the base system, and thereby be up to date through system upgrades.
Comment 4 nixuser 2019-09-01 09:35:21 UTC
Since the /usr/local/etc/os-release file is provided by the package etc_os-release can't the package version number simply be bumped, with the corrected text, so that it updates with a "pkg update && pkg upgrade" like other packages?  

This has caused me a lot of grief because although I could confirm my kernel upgraded correctly, I thought there was a userland upgrade issue because this file didn't upgrade with the userland programs.  I've been trying to hunt down what went wrong.  I think this issue is rather serious.

Is there a way to force the 11.3 version of etc_os-release package to replace the 11.2 version I have?
Comment 5 Tobias C. Berner freebsd_committer 2019-11-02 18:59:13 UTC
(In reply to nixuser from comment #4)

First of all, sorry for my long timeout here.


The only proper way is to ship this file in base -- our "well, at least we have something now"-workaround to shipping this file unfortunately has this limitation.

There is no good way to bump the pkg when needed (because how should the repo know when you updated your installation).

[Well the is a very overkill version: the port could install an rc-file that updates the ${PREFIX}/etc/os_release on boot :) ]


mfg Tobias
Comment 6 nixuser 2019-11-03 05:06:07 UTC
No Problem.

I created a script that can create the file manually as needed.  In the hope someone else may find it useful here it is:

#!/bin/sh
#
# This script will generate a new os-release file in the current directory.
# Normally the file lives in /usr/local/etc/ on freeBSD systems.

VERSION=`freebsd-version -u`
VERSION_ID=`echo "$VERSION" | sed "s/^\([0-9\.]*\).*$/\1/"`

echo "NAME=FreeBSD" > os-release
echo "VERSION=$VERSION" >> os-release
echo "VERSION_ID=$VERSION_ID" >> os-release
echo "ID=freebsd" >> os-release
echo "ANSI_COLOR=\"0;31\"" >> os-release
echo "PRETTY_NAME=\"FreeBSD $VERSION\"" >> os-release
echo "CPE_NAME=cpe:/o:freebsd:freebsd:$VERSION_ID" >> os-release
echo "HOME_URL=https://freebsd.org/" >> os-release
echo "BUG_REPORT_URL=https://bugs.freebsd.org" >> os-release
Comment 7 Warner Losh freebsd_committer 2019-11-07 01:52:12 UTC
This should be in base and generated on each boot...
Comment 9 commit-hook freebsd_committer 2019-11-20 23:46:09 UTC
A commit references this bug:

Author: imp
Date: Wed Nov 20 23:45:33 UTC 2019
New revision: 354922
URL: https://svnweb.freebsd.org/changeset/base/354922

Log:
  Create /etc/os-release file.

  Each boot, regenerate /var/run/os-release based on the currently running
  system. Create a /etc/os-release symlink pointing to this file (so that this
  doesn't create a new reason /etc can not be mounted read-only).

  This is compatible with what other systems do and is what the sysutil/os-release
  port attempted to do, but in an incomplete way. Linux, Solaris and DragonFly all
  implement this natively as well. The complete standard can be found at
  https://www.freedesktop.org/software/systemd/man/os-release.html

  Moving this to the base solves both the non-standard location problem with the
  port, as well as the lack of update of this file on system update.

  Bump __FreeBSD_version to 1300060

  PR: 238953
  Differential Revision:  https://reviews.freebsd.org/D22271

Changes:
  head/etc/Makefile
  head/libexec/rc/rc.conf
  head/libexec/rc/rc.d/Makefile
  head/libexec/rc/rc.d/os-release
  head/share/man/man5/Makefile
  head/share/man/man5/os-release.5
  head/sys/sys/param.h
Comment 10 commit-hook freebsd_committer 2019-11-23 20:19:29 UTC
A commit references this bug:

Author: tcberner
Date: Sat Nov 23 20:19:23 UTC 2019
New revision: 518270
URL: https://svnweb.freebsd.org/changeset/ports/518270

Log:
  sysutils/etc-os-release: use the one provided by base if the system is new enough

  PR:		238953
  Reviewed by:	zeising
  Differential Revision:	https://reviews.freebsd.org/D22488

Changes:
  head/devel/kf5-kcoreaddons/Makefile
  head/devel/qt5-core/Makefile
  head/sysutils/etc_os-release/Makefile
  head/sysutils/gnome-control-center/Makefile