From 29dc73709851d3947e91b008f83bccac891c1e4a Mon Sep 17 00:00:00 2001 From: hugel <2712504175@qq.com> Date: Thu, 6 Feb 2025 16:03:58 +0800 Subject: [PATCH] Add fallback to hostname determination --- Add-fallback-to-hostname-determination.patch | 32 ++++++++++++++++++++ setup.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Add-fallback-to-hostname-determination.patch diff --git a/Add-fallback-to-hostname-determination.patch b/Add-fallback-to-hostname-determination.patch new file mode 100644 index 0000000..96f52b3 --- /dev/null +++ b/Add-fallback-to-hostname-determination.patch @@ -0,0 +1,32 @@ +From ddd74b5d971a734c7e88cda3764f7e059f163b51 Mon Sep 17 00:00:00 2001 +From: Pavel Zhukov +Date: Jul 14 2021 10:26:33 +0000 +Subject: Add fallback to hostname determination + +Use hostname in case if hostnamectl is not available/not functional. +fallback to uname in case if both hostname and hostnamectl are +missed (in containers) + +Reference:https://pagure.io/setup/c/ddd74b5d971a734c7e88cda3764f7e059f163b51 +Conflict:Adjusting the command execution sequence and add a prompt. + +--- + +diff --git a/profile b/profile +index 783fe17..542add4 100644 +--- a/profile ++++ b/profile +@@ -42,7 +42,10 @@ else + pathmunge /usr/sbin after + fi + +-HOSTNAME=`/usr/bin/hostnamectl --transient 2>/dev/null` ++HOSTNAME=$(/usr/bin/hostname 2>/dev/null) || \ ++HOSTNAME=$(/usr/bin/uname -n 2>/dev/null) || \ ++HOSTNAME=$(/usr/bin/hostnamectl --transient 2>/dev/null) || echo "System commands: hostname uname and hostnamectl, which do not exist." ++ + HISTSIZE=1000 + if [ "$HISTCONTROL" = "ignorespace" ] ; then + export HISTCONTROL=ignoreboth +-- +2.27.0 diff --git a/setup.spec b/setup.spec index 8b144eb..ae95d63 100644 --- a/setup.spec +++ b/setup.spec @@ -1,13 +1,14 @@ Summary: A set of system configuration and setup files Name: setup Version: 2.13.7 -Release: 3 +Release: 4 License: Public Domain Group: System Environment/Base URL: https://pagure.io/setup/ Source0: http://releases.pagure.org/%{name}/%{name}-%{version}.tar.bz2 Patch0: support-filesystems-xfs.patch Patch1: source-cshlocal-when-login.patch +Patch2: Add-fallback-to-hostname-determination.patch BuildArch: noarch BuildRequires: systemd BuildRequires: bash tcsh perl-interpreter @@ -117,6 +118,9 @@ end %{_tmpfilesdir}/%{name}.conf %changelog +* Thu Feb 6 2025 hugel - 2.13.7-4 +- Add fallback to hostname determination + * Fri May 6 2022 konglidong - 2.13.7-3 - modify bogus date in %changelog -- Gitee