Migrate rpmdb to /usr/lib/sysimage/rpm (#2042099)
Reference: https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
This commit is contained in:
parent
9e3cd4beae
commit
0b9f813cd5
12
rpm-4.17.x-rpm_dbpath.patch
Normal file
12
rpm-4.17.x-rpm_dbpath.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff '--color=auto' -rup rpm-4.17.0-orig/macros.in rpm-4.17.0/macros.in
|
||||||
|
--- rpm-4.17.0-orig/macros.in 2021-08-20 04:44:56.264259007 -0400
|
||||||
|
+++ rpm-4.17.0/macros.in 2022-01-26 20:11:26.864195884 -0500
|
||||||
|
@@ -140,7 +140,7 @@
|
||||||
|
%_buildshell /bin/sh
|
||||||
|
|
||||||
|
# The location of the rpm database file(s).
|
||||||
|
-%_dbpath %{_var}/lib/rpm
|
||||||
|
+%_dbpath %{_usr}/lib/sysimage/rpm
|
||||||
|
|
||||||
|
# The location of the rpm database file(s) after "rpm --rebuilddb".
|
||||||
|
%_dbpath_rebuild %{_dbpath}
|
48
rpm.spec
48
rpm.spec
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
%global rpmver 4.17.0
|
%global rpmver 4.17.0
|
||||||
#global snapver rc1
|
#global snapver rc1
|
||||||
%global baserelease 6
|
%global baserelease 7
|
||||||
%global sover 9
|
%global sover 9
|
||||||
|
|
||||||
%global srcver %{rpmver}%{?snapver:-%{snapver}}
|
%global srcver %{rpmver}%{?snapver:-%{snapver}}
|
||||||
@ -45,6 +45,11 @@ Source0: http://ftp.rpm.org/releases/%{srcdir}/rpm-%{srcver}.tar.bz2
|
|||||||
|
|
||||||
Source10: rpmdb-rebuild.service
|
Source10: rpmdb-rebuild.service
|
||||||
|
|
||||||
|
Source20: rpmdb-migrate.service
|
||||||
|
Source21: rpmdb_migrate
|
||||||
|
|
||||||
|
# Set rpmdb path to /usr/lib/sysimage/rpm
|
||||||
|
Patch0: rpm-4.17.x-rpm_dbpath.patch
|
||||||
# Disable autoconf config.site processing (#962837)
|
# Disable autoconf config.site processing (#962837)
|
||||||
Patch1: rpm-4.17.x-siteconfig.patch
|
Patch1: rpm-4.17.x-siteconfig.patch
|
||||||
# In current Fedora, man-pages pkg owns all the localized man directories
|
# In current Fedora, man-pages pkg owns all the localized man directories
|
||||||
@ -377,6 +382,10 @@ popd
|
|||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
|
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
|
||||||
install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/%{_unitdir}
|
install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/%{_unitdir}
|
||||||
|
install -m 644 %{SOURCE20} $RPM_BUILD_ROOT/%{_unitdir}
|
||||||
|
|
||||||
|
mkdir -p $RPM_BUILD_ROOT%{rpmhome}
|
||||||
|
install -m 755 %{SOURCE21} $RPM_BUILD_ROOT/%{rpmhome}
|
||||||
|
|
||||||
# Save list of packages through cron
|
# Save list of packages through cron
|
||||||
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily
|
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily
|
||||||
@ -387,12 +396,12 @@ install -m 644 scripts/rpm.log ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/rpm
|
|||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
|
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
|
||||||
mkdir -p $RPM_BUILD_ROOT%{rpmhome}/macros.d
|
mkdir -p $RPM_BUILD_ROOT%{rpmhome}/macros.d
|
||||||
mkdir -p $RPM_BUILD_ROOT/var/lib/rpm
|
mkdir -p $RPM_BUILD_ROOT/usr/lib/sysimage/rpm
|
||||||
|
|
||||||
# init an empty database for %ghost'ing for all supported backends
|
# init an empty database for %ghost'ing for all supported backends
|
||||||
for be in %{?with_ndb:ndb} %{?with_sqlite:sqlite}; do
|
for be in %{?with_ndb:ndb} %{?with_sqlite:sqlite}; do
|
||||||
./rpmdb --define "_db_backend ${be}" --dbpath=${PWD}/${be} --initdb
|
./rpmdb --define "_db_backend ${be}" --dbpath=${PWD}/${be} --initdb
|
||||||
cp -va ${be}/. $RPM_BUILD_ROOT/var/lib/rpm/
|
cp -va ${be}/. $RPM_BUILD_ROOT/usr/lib/sysimage/rpm/
|
||||||
done
|
done
|
||||||
|
|
||||||
# some packages invoke find-debuginfo directly, preserve compat for now
|
# some packages invoke find-debuginfo directly, preserve compat for now
|
||||||
@ -414,16 +423,32 @@ make check TESTSUITEFLAGS=-j%{_smp_build_ncpus} || (cat tests/rpmtests.log; exit
|
|||||||
make clean
|
make clean
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
%pre
|
||||||
|
# Symlink all rpmdb files to the new location if we're still using /var/lib/rpm
|
||||||
|
if [ -d /var/lib/rpm ]; then
|
||||||
|
mkdir -p /usr/lib/sysimage/rpm
|
||||||
|
rpmdb_files=$(find /var/lib/rpm -maxdepth 1 -type f | sed 's|^/var/lib/rpm/||g' | sort)
|
||||||
|
for rpmdb_file in ${rpmdb_files[@]}; do
|
||||||
|
ln -sfr /var/lib/rpm/${rpmdb_file} /usr/lib/sysimage/rpm/${rpmdb_file}
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
%triggerun -- rpm < 4.15.90-0.git14971.10
|
||||||
# Handle rpmdb rebuild service on erasure of old to avoid ordering issues
|
# Handle rpmdb rebuild service on erasure of old to avoid ordering issues
|
||||||
# https://pagure.io/fesco/issue/2382
|
# https://pagure.io/fesco/issue/2382
|
||||||
%triggerun -- rpm < 4.15.90-0.git14971.10
|
|
||||||
if [ -x /usr/bin/systemctl ]; then
|
if [ -x /usr/bin/systemctl ]; then
|
||||||
systemctl --no-reload preset rpmdb-rebuild ||:
|
systemctl --no-reload preset rpmdb-rebuild ||:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
%triggerun -- rpm < 4.17.0-7
|
||||||
|
# Handle rpmdb migrate service on erasure of old to avoid ordering issues
|
||||||
|
if [ -x /usr/bin/systemctl ]; then
|
||||||
|
systemctl --no-reload preset rpmdb-migrate ||:
|
||||||
|
fi
|
||||||
|
|
||||||
%posttrans
|
%posttrans
|
||||||
if [ -f /var/lib/rpm/Packages ]; then
|
if [ -d /var/lib/rpm ]; then
|
||||||
touch /var/lib/rpm/.rebuilddb
|
touch /var/lib/rpm/.migratedb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%files -f rpm.lang
|
%files -f rpm.lang
|
||||||
@ -431,12 +456,13 @@ fi
|
|||||||
%doc CREDITS docs/manual/[a-z]*
|
%doc CREDITS docs/manual/[a-z]*
|
||||||
|
|
||||||
%{_unitdir}/rpmdb-rebuild.service
|
%{_unitdir}/rpmdb-rebuild.service
|
||||||
|
%{_unitdir}/rpmdb-migrate.service
|
||||||
|
|
||||||
%dir %{_sysconfdir}/rpm
|
%dir %{_sysconfdir}/rpm
|
||||||
|
|
||||||
%attr(0755, root, root) %dir /var/lib/rpm
|
%attr(0755, root, root) %dir /usr/lib/sysimage/rpm
|
||||||
%attr(0644, root, root) %ghost %config(missingok,noreplace) /var/lib/rpm/*
|
%attr(0644, root, root) %ghost %config(missingok,noreplace) /usr/lib/sysimage/rpm/*
|
||||||
%attr(0644, root, root) %ghost /var/lib/rpm/.*.lock
|
%attr(0644, root, root) %ghost /usr/lib/sysimage/rpm/.*.lock
|
||||||
|
|
||||||
%{_bindir}/rpm
|
%{_bindir}/rpm
|
||||||
%{_bindir}/rpm2archive
|
%{_bindir}/rpm2archive
|
||||||
@ -580,6 +606,10 @@ fi
|
|||||||
%doc docs/librpm/html/*
|
%doc docs/librpm/html/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jan 26 2022 Neal Gompa <ngompa@fedoraproject.org> - 4.17.0-7
|
||||||
|
- Migrate rpmdb to /usr/lib/sysimage/rpm (#2042099)
|
||||||
|
https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
|
||||||
|
|
||||||
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.17.0-6
|
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 4.17.0-6
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||||
|
|
||||||
|
18
rpmdb-migrate.service
Normal file
18
rpmdb-migrate.service
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=RPM database migration to /usr
|
||||||
|
ConditionPathExists=/var/lib/rpm/.migratedb
|
||||||
|
|
||||||
|
# This should run before any daemons that may open the rpmdb
|
||||||
|
DefaultDependencies=no
|
||||||
|
After=sysinit.target
|
||||||
|
Before=basic.target shutdown.target
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
# In case /var is remote-mounted
|
||||||
|
RequiresMountsFor=/var
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/lib/rpm/rpmdb_migrate
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
@ -1,19 +1,19 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=RPM database rebuild
|
Description=RPM database rebuild
|
||||||
ConditionPathExists=/var/lib/rpm/.rebuilddb
|
ConditionPathExists=/usr/lib/sysimage/rpm/.rebuilddb
|
||||||
|
|
||||||
# This should run before any daemons that may open the rpmdb
|
# This should run before any daemons that may open the rpmdb
|
||||||
DefaultDependencies=no
|
DefaultDependencies=no
|
||||||
After=sysinit.target
|
After=sysinit.target
|
||||||
Before=basic.target shutdown.target
|
Before=basic.target shutdown.target
|
||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
# In case /var is remote-mounted
|
# In case /usr is remote-mounted
|
||||||
RequiresMountsFor=/var
|
RequiresMountsFor=/usr
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/rpmdb --rebuilddb
|
ExecStart=/usr/bin/rpmdb --rebuilddb
|
||||||
ExecStartPost=rm -f /var/lib/rpm/.rebuilddb
|
ExecStartPost=rm -f /usr/lib/sysimage/rpm/.rebuilddb
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=basic.target
|
WantedBy=basic.target
|
||||||
|
40
rpmdb_migrate
Normal file
40
rpmdb_migrate
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script to migrate rpmdb from /var/lib/rpm to new rpmdb path in /usr
|
||||||
|
|
||||||
|
# Copyright (C) 2022 Neal Gompa <ngompa@fedoraproject.org>.
|
||||||
|
#
|
||||||
|
# Fedora-License-Identifier: GPLv2+
|
||||||
|
# SPDX-2.0-License-Identifier: GPL-2.0+
|
||||||
|
# SPDX-3.0-License-Identifier: GPL-2.0-or-later
|
||||||
|
#
|
||||||
|
# This program is free software.
|
||||||
|
# For more information on the license, see COPYING or
|
||||||
|
# <https://www.gnu.org/licenses/gpl-2.0.en.html>.
|
||||||
|
# For more information on free software, see
|
||||||
|
# <https://www.gnu.org/philosophy/free-sw.en.html>.
|
||||||
|
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Script to migrate the rpmdb to /usr
|
||||||
|
rpmdb_path="$(rpm --eval '%_dbpath')"
|
||||||
|
rpmdb_path_old="/var/lib/rpm"
|
||||||
|
rpmdb_path_new="${rpmdb_path}"
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${rpmdb_path}" = "${rpmdb_path_old}" ]; then
|
||||||
|
echo "The rpmdb path is still in /var, exiting!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -L "${rpmdb_path_old}" ]; then
|
||||||
|
echo "The rpmdb has already been migrated, exiting!"
|
||||||
|
rm -v "${rpmdb_path_old}/.migratedb"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
rpm --verbose --rebuilddb
|
||||||
|
|
||||||
|
rm -rfv ${rpmdb_path_old}
|
||||||
|
|
||||||
|
ln -srv ${rpmdb_path_new} ${rpmdb_path_old}
|
Loading…
Reference in New Issue
Block a user