Bug 276102 - freebsd-update: command gives questionable recommendation which command to run next
Summary: freebsd-update: command gives questionable recommendation which command to ru...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.2-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL: https://github.com/BastilleBSD/bastil...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-03 17:19 UTC by Michael Osipov
Modified: 2024-04-17 06:52 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov freebsd_committer freebsd_triage 2024-01-03 17:19:55 UTC
freebsd-update may print something like this:
> To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".
or
> Kernel updates have been installed.  Please reboot and run
> "/usr/sbin/freebsd-update install" again to finish installing updates.

Morespecifically, these:
> $ grep -e '\$0' /usr/sbin/freebsd-update | grep -v basename
>                 echo "Run '$0 install' first."
>                 echo "Run '$0 fetch -F' to proceed anyway."
>                         echo "Run '$0 fetch' first."
>                 echo "Re-run '$0 fetch'."
> before running "$0 install".
>         echo "To install the downloaded upgrades, run \"$0 install\"."
>                         echo "Re-run '$0 fetch'."
> "$0 install" again to finish installing updates.
> installed from the ports tree) and then run "$0 install"
>         echo "Run '$0 install' to proceed." 

The problem with these recommendations is that if freebsd-update is started with options (e.g., -b, -f, etc.) the copied and pasted recommendationd lead to incorrect or even broken results.
Consider running:
> freebsd-update -j deblndw013x4v2j -d $(jls -j deblndw013x4v2j -h path | tail -1)/var/db/freebsd-update -f $(jls -j deblndw013x4v2j -h path | tail -1)/etc/freebsd-update.conf -r 13.2-RELEASE upgrade
then
> freebsd-update install
as next command would be wrong.

This might be nit-picking, but not straight forward for some people. It should either completely replicate the command input or describe rather in prose rather can providing a copiable command.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2024-01-12 19:03:52 UTC
The longer-term strategy for updates is a migration to pkgbase (in 15.0 and later), but improvements for 14/13 would be welcome. Michael are you interested in proposing a patch?
Comment 2 Michael Osipov freebsd_committer freebsd_triage 2024-01-12 20:05:23 UTC
(In reply to Ed Maste from comment #1)

Yes, I'll work on a patch next week. I think it is still worthwhile even in main since long-term does not mean that pkgbase will replace freebsd-update in 15 ATM. It might live side by side.
Comment 3 Michael Osipov freebsd_committer freebsd_triage 2024-01-30 21:14:20 UTC
A review is in the works...
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-03-18 09:36:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=59b02bb420e3b0a49af39f7817764ca444f7c793

commit 59b02bb420e3b0a49af39f7817764ca444f7c793
Author:     Michael Osipov <michaelo@FreeBSD.org>
AuthorDate: 2024-01-30 16:24:45 +0000
Commit:     Michael Osipov <michaelo@FreeBSD.org>
CommitDate: 2024-03-18 09:33:42 +0000

    freebsd-update: Don't provide copiable commands in output

    Previously, freebsd-update provided ready-to-go commands for copying and
    pasting into the terminal. This causes problems as soon as options are
    used and not supplied again by the user, e.g., '-b' or '-d'.
    Stop making them copiable and force the user to construct a valid command
    line by himself to avoid failures.

    PR:             276102
    Approved by:    jrm (mentor), emaste
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D43700

 usr.sbin/freebsd-update/freebsd-update.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-04-17 06:51:12 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=69dbc448cf8b3677e783353bcc0c2108b8a74b9d

commit 69dbc448cf8b3677e783353bcc0c2108b8a74b9d
Author:     Michael Osipov <michaelo@FreeBSD.org>
AuthorDate: 2024-01-30 16:24:45 +0000
Commit:     Michael Osipov <michaelo@FreeBSD.org>
CommitDate: 2024-04-17 06:50:07 +0000

    freebsd-update: Don't provide copiable commands in output

    Previously, freebsd-update provided ready-to-go commands for copying and
    pasting into the terminal. This causes problems as soon as options are
    used and not supplied again by the user, e.g., '-b' or '-d'.
    Stop making them copiable and force the user to construct a valid command
    line by himself to avoid failures.

    PR:             276102
    Approved by:    jrm (mentor), emaste
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D43700

 usr.sbin/freebsd-update/freebsd-update.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-04-17 06:52:14 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d596e573119e245b2d2b53afeb523700510e5bf2

commit d596e573119e245b2d2b53afeb523700510e5bf2
Author:     Michael Osipov <michaelo@FreeBSD.org>
AuthorDate: 2024-01-30 16:24:45 +0000
Commit:     Michael Osipov <michaelo@FreeBSD.org>
CommitDate: 2024-04-17 06:51:38 +0000

    freebsd-update: Don't provide copiable commands in output

    Previously, freebsd-update provided ready-to-go commands for copying and
    pasting into the terminal. This causes problems as soon as options are
    used and not supplied again by the user, e.g., '-b' or '-d'.
    Stop making them copiable and force the user to construct a valid command
    line by himself to avoid failures.

    PR:             276102
    Approved by:    jrm (mentor), emaste
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D43700

 usr.sbin/freebsd-update/freebsd-update.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)