Convert to use tmpfiles.d to create initial /root directory

Resolves: RHEL-76497
This commit is contained in:
Martin Osvald 2024-02-27 06:35:44 +00:00 committed by David Tardon
parent 89d69b720b
commit f0ea58e375
2 changed files with 22 additions and 5 deletions

2
rootfiles.conf Normal file
View File

@ -0,0 +1,2 @@
# create initial /root directories shell content
C+ /root/ 644 root root - /usr/share/rootfiles/

View File

@ -1,7 +1,7 @@
Summary: The basic required files for the root user's directory
Name: rootfiles
Version: 8.1
Release: 38%{?dist}
Release: 39%{?dist}
License: LicenseRef-Not-Copyrightable
# This is a Red Hat maintained package which is specific to
@ -12,8 +12,12 @@ Source1: dot-bash_profile
Source2: dot-bash_logout
Source3: dot-tcshrc
Source4: dot-cshrc
Source5: rootfiles.conf
%define ROOTFILES_DIR %{_datadir}/rootfiles
BuildArch: noarch
BuildRequires: systemd-rpm-macros
%description
The rootfiles package contains basic required files that are placed
@ -24,23 +28,34 @@ users' home directories.
%prep
%install
mkdir -p $RPM_BUILD_ROOT/root
mkdir -p $RPM_BUILD_ROOT/%{ROOTFILES_DIR}
install -D -p -m 644 %{SOURCE5} $RPM_BUILD_ROOT/%{_tmpfilesdir}/rootfiles.conf
for file in %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} ; do
f=`basename $file`
install -p -m 644 $file $RPM_BUILD_ROOT/root/${f/dot-/.}
install -p -m 644 $file $RPM_BUILD_ROOT/%{ROOTFILES_DIR}/${f/dot-/.}
done
%posttrans
if [ $1 -eq 0 ] ; then
#copy recursively the content, but do not overwrite the original files provided by rootfiles package
cp -ndr --preserve=ownership,timestamps /etc/skel/. /root/ || :
cp -ndr --preserve=ownership,timestamps /etc/skel/. %{ROOTFILES_DIR}/ || :
fi
%files
%config(noreplace) /root/.[A-Za-z]*
%dir %{ROOTFILES_DIR}
%{ROOTFILES_DIR}/.[A-Za-z]*
%{_tmpfilesdir}/rootfiles.conf
%ghost /root/.bash_logout
%ghost /root/.bash_profile
%ghost /root/.bashrc
%ghost /root/.cshrc
%ghost /root/.tcshrc
%changelog
* Tue Jan 28 2025 David Tardon <dtardon@redhat.com> - 8.1-39
- Use tmpfiles.d to create initial /root directory (RHEL-76497)
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 8.1-38
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018