Skip to content

Commit 50e943d

Browse files
committed
motd: upgrade to v1.0
tdnf: remove updateinfo timer and service. Instead of inidividual applications shipping timers for populating motd content, MOTD now has its own timer. Change-Id: I08c237c18a88b26223b208a66fb5bfec56186ca7 Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> Reviewed-on: http://photon-gerrit.lvn.broadcom.net/c/photon/+/24839 Tested-by: gerrit-photon <svc.photon-ci@broadcom.com> Reviewed-by: Guruswamy Basavaiah <guruswamy.basavaiah@broadcom.com>
1 parent c32e25d commit 50e943d

File tree

5 files changed

+147
-96
lines changed

5 files changed

+147
-96
lines changed

SPECS/motd/motd.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d /run/motdgen 0755 root root

SPECS/motd/motd.spec

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,43 @@
1-
%define commit0 a152954dcf0583a6efd1af31c42f9e27e6a15bea
1+
%define srcname photon-motdgen
22

33
Summary: Message of the Day
44
Name: motd
5-
Version: 0.1.3
6-
Release: 7%{?dist}
5+
Version: 1.0
6+
Release: 1%{?dist}
77
License: GPLv3
8-
URL: http://github.com/rtnpro/fedora-motd
8+
URL: https://github-vcf.devops.broadcom.net/vcf/photon-motdgen
99
Group: Applications/Daemons
1010
Vendor: VMware, Inc.
1111
Distribution: Photon
1212

13-
Source0: https://github.com/rtnpro/motdgen/archive/motdgen-a152954.tar.gz
14-
%define sha512 motdgen-a152954.tar.gz=784d6fa426c48386a584c7d026a585718a8665a249cae9450073f812b5b4935fa20d4127dcb9c937ac4470b4f19e9349974bf0e4c341d95a162a04438ce98276
13+
Source0: https://github-vcf.devops.broadcom.net/vcf/%{srcname}-%{version}.tar.gz
14+
%define sha512 %{srcname}=031d2209e0a582bab9457cf82e80d920b2b121eab9a685dee54aaa0e4556598b949462e4e1fba6342dbbef22231ba29cd9c66d72139a0ed727b093d75eed5004
1515

16-
Patch0: strip-dnf.patch
16+
Source1: %{name}.conf
1717

1818
BuildArch: noarch
1919

20-
BuildRequires: python3-devel
21-
BuildRequires: python3-setuptools
22-
BuildRequires: python3-xml
23-
BuildRequires: systemd-devel
20+
BuildRequires: make
21+
BuildRequires: coreutils
22+
BuildRequires: systemd-devel
2423

25-
Requires: Linux-PAM
26-
Requires: systemd
27-
Requires: python3
28-
Requires: /bin/grep
24+
Requires: bash
25+
Requires: Linux-PAM
26+
Requires: systemd
2927

3028
%description
3129
Generates Dynamic MOTD.
3230

3331
%prep
34-
%autosetup -p1 -n motdgen-%{commit0}
32+
%autosetup -p1 -n %{srcname}-%{version}
3533

3634
%build
37-
%py3_build
35+
%make_build
3836

3937
%install
40-
python3 setup.py install -O1 --skip-build --install-data=%{_datadir} --root %{buildroot}
38+
%make_install %{?_smp_mflags}
4139
# SELinux: let systemd create our runtime directory and label it properly.
42-
mkdir -p %{buildroot}%{_tmpfilesdir}
43-
echo "d /run/motdgen 0755 root root" > %{buildroot}%{_tmpfilesdir}/motd.conf
40+
install -D -m 644 %{SOURCE1} %{buildroot}%{_tmpfilesdir}/motd.conf
4441

4542
#shadow is providing /etc/pam.d/sshd with (noreplace)
4643

@@ -60,20 +57,22 @@ sed -i '/^\s*session\s*include\s*motdgen.*$/d' \
6057

6158
%postun
6259
[ $1 -eq 0 ] || exit 0
63-
rm -rf %{_localstatedir}/run/motdgen
60+
rm -rf %{_rundir}/motdgen
6461

6562
%files
66-
%doc README.md
6763
%defattr(-,root,root)
68-
%{python3_sitelib}/*
6964
%{_sysconfdir}/pam.d/motdgen
7065
%{_sysconfdir}/motdgen.d
7166
%{_sysconfdir}/profile.d/motdgen.sh
7267
%{_bindir}/motdgen
73-
%{_sysconfdir}/systemd/system/motdgen.service
68+
%{_unitdir}/motdgen.service
69+
%{_unitdir}/motdgen.timer
7470
%{_tmpfilesdir}/motd.conf
7571

7672
%changelog
73+
* Tue Nov 26 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 1.0-1
74+
- Upgrade to v1.0
75+
- Switch to photon-motdgen
7776
* Fri Dec 02 2022 Prashant S Chauhan <psinghchauha@vmware.com> 0.1.3-7
7877
- Update release to compile with python 3.11
7978
* Thu Apr 30 2020 Alexey Makhalov <amakhalov@vmware.com> 0.1.3-6

SPECS/motd/strip-dnf.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

SPECS/tdnf/tdnf.spec

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
%define hist_db_dir %{_libdir}/sysimage/%{name}
2+
%define history_db_fn %{hist_db_dir}/history.db
3+
%define history_autoins %{_sharedstatedir}/%{name}/autoinstalled
4+
%define history_util %{_libdir}/%{name}/%{name}-history-util
5+
%define _tdnfpluginsdir %{_libdir}/%{name}-plugins
6+
7+
%global automatic_services %{name}-automatic.timer %{name}-automatic-notifyonly.timer %{name}-automatic-install.timer
8+
19
Summary: dnf/yum equivalent using C libs
210
Name: tdnf
311
Version: 3.5.10
4-
Release: 1%{?dist}
12+
Release: 2%{?dist}
513
Vendor: VMware, Inc.
614
Distribution: Photon
715
License: LGPLv2.1,GPLv2
@@ -14,6 +22,7 @@ Source0: https://github.com/vmware/tdnf/archive/refs/tags/%{name}-%{version}.tar
1422
Patch0: 0001-do-not-nuke-RPMBUILD_DIR-in-pytests-since-it-can-be-.patch
1523
Patch1: rpm-keyring-API-calls-1.patch
1624
Patch2: rpm-keyring-API-calls-2.patch
25+
Patch3: updateinfo.patch
1726

1827
Requires: rpm-libs
1928
Requires: curl-libs
@@ -57,9 +66,6 @@ Provides: yum
5766
%description
5867
%{name} is a yum/dnf equivalent which uses libsolv and libcurl
5968

60-
%define _tdnfpluginsdir %{_libdir}/%{name}-plugins
61-
%define _tdnf_history_db_dir /usr/lib/sysimage/%{name}
62-
6369
%package devel
6470
Summary: A Library providing C API for %{name}
6571
Group: Development/Libraries
@@ -138,42 +144,43 @@ Systemd units that can periodically download package upgrades and apply them.
138144
%autosetup -p1 -n %{name}-%{version}
139145

140146
%build
141-
%cmake \
147+
%{cmake} \
142148
-DCMAKE_BUILD_TYPE=Debug \
143149
-DBUILD_SHARED_LIBS=OFF \
144150
-DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \
145151
-DSYSTEMD_DIR=%{_unitdir} \
146-
-DHISTORY_DB_DIR=%{_tdnf_history_db_dir}
147-
148-
%cmake_build
152+
-DHISTORY_DB_DIR=%{hist_db_dir}
149153

150-
cd %{__cmake_builddir}
151-
%make_build python
154+
%{cmake_build}
152155

153-
%if 0%{?with_check}
154-
%check
155-
pip3 install flake8
156-
cd %{__cmake_builddir} && make %{?_smp_mflags} check
157-
%endif
156+
%make_build -C %{__cmake_builddir} python
158157

159158
%install
160-
%cmake_install
161-
find %{buildroot} -name '*.a' -delete
162-
mkdir -p %{buildroot}/var/cache/%{name} %{buildroot}%{_unitdir}
163-
mkdir -p %{buildroot}%{_tdnf_history_db_dir}
159+
%{cmake_install}
160+
161+
protected_dir="%{_sysconfdir}/%{name}/protected.d"
162+
163+
mkdir -p %{buildroot}{%{_var}/cache/%{name},%{_unitdir}} \
164+
%{buildroot}%{hist_db_dir} \
165+
%{buildroot}${protected_dir}
166+
164167
ln -sfv %{name} %{buildroot}%{_bindir}/tyum
165168
ln -sfv %{name} %{buildroot}%{_bindir}/yum
166169
ln -sfv %{name} %{buildroot}%{_bindir}/tdnfj
167170

168-
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/protected.d && \
169-
echo %{name} > %{buildroot}%{_sysconfdir}/%{name}/protected.d/%{name}.conf
171+
echo %{name} > %{buildroot}${protected_dir}/%{name}.conf
170172

171173
pushd %{__cmake_builddir}/python
172174
%py3_install
173175
popd
174-
find %{buildroot} -name '*.pyc' -delete
175176

176-
%pre
177+
find %{buildroot} \( -name '*.a' -o -name '*.pyc' \) -delete
178+
179+
rm %{buildroot}%{_unitdir}/%{name}-cache-updateinfo.{timer,service}
180+
181+
%check
182+
pip3 install flake8
183+
%make_build -C %{__cmake_builddir} check
177184

178185
%post
179186
/sbin/ldconfig
@@ -183,46 +190,36 @@ find %{buildroot} -name '*.pyc' -delete
183190
# to the new db.
184191
# must be postrans because we read the rpm db
185192
# cannot use tdnf because that is still running even in postrans
186-
[ -f %{_tdnf_history_db_dir}/history.db ] || %{_libdir}/tdnf/tdnf-history-util init
187-
if [ -f %{_sharedstatedir}/tdnf/autoinstalled ] ; then
188-
%{_libdir}/tdnf/tdnf-history-util mark remove $(cat %{_sharedstatedir}/tdnf/autoinstalled) && \
189-
rm %{_sharedstatedir}/tdnf/autoinstalled
193+
[ -d %{hist_db_dir} ] || mkdir -p %{hist_db_dir}
194+
[ -f %{history_db_fn} ] || %{history_util} init
195+
if [ -f %{history_autoins} ]; then
196+
%{history_util} mark remove $(cat %{history_autoins})
197+
mv %{history_autoins} %{history_autoins}.backup
190198
fi
199+
exit 0
191200

192201
%triggerin -- motd
193202
[ $2 -eq 1 ] || exit 0
194-
if [ $1 -eq 1 ]; then
195-
echo "detected install of %{name}/motd, enabling %{name}-cache-updateinfo.timer" >&2
196-
systemctl enable %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
197-
systemctl start %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
198-
elif [ $1 -eq 2 ]; then
203+
if [ $1 -eq 2 ]; then
199204
echo "detected upgrade of %{name}, daemon-reload" >&2
200205
systemctl daemon-reload >/dev/null 2>&1 || :
201206
fi
202207

203208
%preun
204209
%triggerun -- motd
205210
[ $1 -eq 1 ] && [ $2 -eq 1 ] && exit 0
206-
echo "detected uninstall of %{name}/motd, disabling %{name}-cache-updateinfo.timer" >&2
207-
systemctl --no-reload disable %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
208-
systemctl stop %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
209-
rm -f /var/cache/%{name}/cached-updateinfo.txt
211+
echo "detected uninstall of %{name}/motd" >&2
212+
rm -f %{_var}/cache/%{name}/cached-updateinfo.txt
210213

211214
%postun
212215
/sbin/ldconfig
213-
%triggerpostun -- motd
214-
[ $1 -eq 1 ] && [ $2 -eq 1 ] || exit 0
215-
echo "detected upgrade of %{name}/motd, restarting %{name}-cache-updateinfo.timer" >&2
216-
systemctl try-restart %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
217216

218217
%post cli-libs
219218
/sbin/ldconfig
220219

221220
%postun cli-libs
222221
/sbin/ldconfig
223222

224-
%global automatic_services %{name}-automatic.timer %{name}-automatic-notifyonly.timer %{name}-automatic-install.timer
225-
226223
%post automatic
227224
%systemd_post %{automatic_services}
228225

@@ -239,16 +236,13 @@ systemctl try-restart %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
239236
%{_bindir}/yum
240237
%{_bindir}/tdnfj
241238
%{_bindir}/tdnf-config
242-
%{_bindir}/tdnf-cache-updateinfo
243239
%{_libdir}/libtdnf.so.*
244240
%{_libdir}/tdnf/tdnf-history-util
245241
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
246242
%config(noreplace) %{_sysconfdir}/%{name}/protected.d/%{name}.conf
247-
%config %{_unitdir}/%{name}-cache-updateinfo.service
248-
%config(noreplace) %{_unitdir}/%{name}-cache-updateinfo.timer
249243
%config %{_sysconfdir}/motdgen.d/02-%{name}-updateinfo.sh
250-
%dir /var/cache/%{name}
251-
%dir %{_tdnf_history_db_dir}
244+
%dir %{_var}/cache/%{name}
245+
%dir %{hist_db_dir}
252246
%{_datadir}/bash-completion/completions/%{name}
253247

254248
%files devel
@@ -297,6 +291,9 @@ systemctl try-restart %{name}-cache-updateinfo.timer >/dev/null 2>&1 || :
297291
%{_unitdir}/%{name}-automatic-notifyonly.service
298292

299293
%changelog
294+
* Fri Jan 31 2025 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 3.5.10-2
295+
- Remove updateinfo timer
296+
- MOTD has its own timer now
300297
* Wed Dec 18 2024 Shreenidhi Shedi <shreenidhi.shedi@broadcom.com> 3.5.10-1
301298
- Upgrade to v3.5.10
302299
* Tue Jun 25 2024 Oliver Kurth <oliver.kurth@broadcom.com> 3.5.7-1

SPECS/tdnf/updateinfo.patch

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
From 938816ad9a924ab3c3b00b9d15c359737bdd900d Mon Sep 17 00:00:00 2001
2+
From: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
3+
Date: Wed, 4 Dec 2024 05:47:27 +0000
4+
Subject: [PATCH] Fix updateinfo script
5+
6+
Move instructions from bin/tdnf-cache-updateinfo to 02-tdnf-updateinfo,
7+
when motd triggers it, it will generate the right data.
8+
9+
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
10+
---
11+
CMakeLists.txt | 1 -
12+
bin/CMakeLists.txt | 1 -
13+
bin/tdnf-cache-updateinfo.in | 15 ---------------
14+
etc/motdgen.d/02-tdnf-updateinfo.sh | 10 +++++++---
15+
4 files changed, 7 insertions(+), 20 deletions(-)
16+
delete mode 100755 bin/tdnf-cache-updateinfo.in
17+
18+
diff --git a/CMakeLists.txt b/CMakeLists.txt
19+
index c0aa5071..4cc4d7da 100644
20+
--- a/CMakeLists.txt
21+
+++ b/CMakeLists.txt
22+
@@ -101,6 +101,5 @@ add_subdirectory("${PROJECT_SOURCE_DIR}/tools")
23+
add_subdirectory("${PROJECT_SOURCE_DIR}/pytests")
24+
25+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/bin/tdnf-automatic.in ${PROJECT_SOURCE_DIR}/bin/tdnf-automatic @ONLY)
26+
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/bin/tdnf-cache-updateinfo.in ${PROJECT_SOURCE_DIR}/bin/tdnf-cache-updateinfo @ONLY)
27+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/tdnf.spec.in ${CMAKE_SOURCE_DIR}/tdnf.spec @ONLY)
28+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/build-tdnf-rpms.in ${CMAKE_SOURCE_DIR}/scripts/build-tdnf-rpms @ONLY)
29+
diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt
30+
index 3becd28a..49f3a2f9 100644
31+
--- a/bin/CMakeLists.txt
32+
+++ b/bin/CMakeLists.txt
33+
@@ -7,4 +7,3 @@
34+
#
35+
36+
install(PROGRAMS "tdnf-automatic" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binary)
37+
-install(PROGRAMS "tdnf-cache-updateinfo" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binary)
38+
diff --git a/bin/tdnf-cache-updateinfo.in b/bin/tdnf-cache-updateinfo.in
39+
deleted file mode 100755
40+
index 6ab77161..00000000
41+
--- a/bin/tdnf-cache-updateinfo.in
42+
+++ /dev/null
43+
@@ -1,15 +0,0 @@
44+
-#!/usr/bin/env bash
45+
-
46+
-#
47+
-# Copyright (C) 2020 VMware, Inc. All Rights Reserved.
48+
-#
49+
-# Licensed under the GNU General Public License v2 (the "License");
50+
-# you may not use this file except in compliance with the License. The terms
51+
-# of the License are located in the COPYING file of this distribution.
52+
-#
53+
-
54+
-exec > /var/cache/tdnf/cached-updateinfo.txt
55+
-
56+
-tdnf -q --refresh updateinfo | grep -vE '^Refreshing|^Disabling'
57+
-
58+
-exit ${PIPESTATUS[0]}
59+
diff --git a/etc/motdgen.d/02-tdnf-updateinfo.sh b/etc/motdgen.d/02-tdnf-updateinfo.sh
60+
index fb386a08..031ab1f5 100755
61+
--- a/etc/motdgen.d/02-tdnf-updateinfo.sh
62+
+++ b/etc/motdgen.d/02-tdnf-updateinfo.sh
63+
@@ -10,9 +10,13 @@
64+
65+
path="/var/cache/tdnf/cached-updateinfo.txt"
66+
67+
+tdnf -q --refresh updateinfo | grep -vE '^Refreshing|^Disabling' > "${path}"
68+
+
69+
if [ -s "${path}" ]; then
70+
- grep -qE 'Security|Bugfix|Enhancement' "${path}" || exit 0
71+
- echo; cat "${path}"; echo "Run 'tdnf updateinfo info' to see the details."
72+
+ grep -qE 'Security|Bugfix|Enhancement' "${path}" || exit 0
73+
+ echo
74+
+ cat "${path}"
75+
+ echo "Run 'tdnf updateinfo info' to see the details."
76+
else
77+
- echo "tdnf update info not available yet!"
78+
+ echo "tdnf update info not available yet!"
79+
fi

0 commit comments

Comments
 (0)