mk-install-iso.sh: fix rpmdb in iso
relocate-rpmdb.sh: helper script to fix rpmdb in chroot during image
creation on a host where rpm has sqlite backend db but dbpath is
/var/lib/rpm
build-config.json: use ph5 docker image
ph-docker-img-import.sh: refactor logic to run as privileged container
ostree: fix build & script improvements
Change-Id: Ie4eed48f5baeac2029685f79371607a46383f2ea
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/19261
Reviewed-by: Tapas Kundu <tkundu@vmware.com>
Tested-by: gerrit-photon <photon-checkins@vmware.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,88 +0,0 @@ |
| 1 |
-/* |
|
| 2 |
- * Helper program to lock a file |
|
| 3 |
- * |
|
| 4 |
- * Using this in rpm-rebuilddb.sh to lock rpm directory |
|
| 5 |
- * This will help to manage contention between rpm transactions & rebuilddb |
|
| 6 |
- * operation. |
|
| 7 |
- */ |
|
| 8 |
- |
|
| 9 |
-#include <stdio.h> |
|
| 10 |
-#include <stdlib.h> |
|
| 11 |
-#include <errno.h> |
|
| 12 |
-#include <fcntl.h> |
|
| 13 |
-#include <unistd.h> |
|
| 14 |
-#include <signal.h> |
|
| 15 |
-#include <stdint.h> |
|
| 16 |
-#include <stdbool.h> |
|
| 17 |
- |
|
| 18 |
-/* |
|
| 19 |
- * This file acts as a flag to indicate that lock is obtained |
|
| 20 |
- */ |
|
| 21 |
-#define LOCK_FLAG "/var/run/.lkflg" |
|
| 22 |
- |
|
| 23 |
-static bool volatile sigint = false; |
|
| 24 |
- |
|
| 25 |
-static int32_t lock_fd = 0; |
|
| 26 |
- |
|
| 27 |
-static struct flock fl = {F_WRLCK, SEEK_SET, 0, 0, 0};
|
|
| 28 |
- |
|
| 29 |
-void handle_sigint(int32_t sig) |
|
| 30 |
-{
|
|
| 31 |
- sigint = true; |
|
| 32 |
- fl.l_type = F_UNLCK; |
|
| 33 |
- if (fcntl(lock_fd, F_SETLK, &fl) < 0) {
|
|
| 34 |
- perror("fcntl unlock\n");
|
|
| 35 |
- exit(EXIT_FAILURE); |
|
| 36 |
- } |
|
| 37 |
- |
|
| 38 |
- close(lock_fd); |
|
| 39 |
- lock_fd = -1; |
|
| 40 |
- unlink(LOCK_FLAG); |
|
| 41 |
- exit(EXIT_SUCCESS); |
|
| 42 |
-} |
|
| 43 |
- |
|
| 44 |
-int32_t main(int32_t argc, char **argv) |
|
| 45 |
-{
|
|
| 46 |
- if (argc != 2) {
|
|
| 47 |
- fprintf(stderr, "Usage: %s <file path>\n", argv[0]); |
|
| 48 |
- return -1; |
|
| 49 |
- } |
|
| 50 |
- |
|
| 51 |
- lock_fd = open(argv[1], O_CREAT|O_RDWR); |
|
| 52 |
- if (lock_fd < 0) {
|
|
| 53 |
- perror("open lock file\n");
|
|
| 54 |
- return -1; |
|
| 55 |
- } |
|
| 56 |
- |
|
| 57 |
- signal(SIGINT, handle_sigint); |
|
| 58 |
- |
|
| 59 |
- fl.l_pid = 0; |
|
| 60 |
- printf("Trying to get lock on %s(pid: %d) ...\n", argv[1], getpid());
|
|
| 61 |
- fflush(stdout); |
|
| 62 |
- if (fcntl(lock_fd, F_SETLKW, &fl) == -1) {
|
|
| 63 |
- perror("fcntl lock\n");
|
|
| 64 |
- return -1; |
|
| 65 |
- } |
|
| 66 |
- |
|
| 67 |
- {
|
|
| 68 |
- int32_t lockflg_fd = 0; |
|
| 69 |
- lockflg_fd = open(LOCK_FLAG, O_CREAT|O_RDWR); |
|
| 70 |
- if (lockflg_fd < 0) {
|
|
| 71 |
- perror("open lock flag\n");
|
|
| 72 |
- return -1; |
|
| 73 |
- } |
|
| 74 |
- close(lockflg_fd); |
|
| 75 |
- } |
|
| 76 |
- printf("Got lock(pid: %d)\n", getpid());
|
|
| 77 |
- fflush(stdout); |
|
| 78 |
- |
|
| 79 |
- while (!sigint) {
|
|
| 80 |
- sleep(1); |
|
| 81 |
- } |
|
| 82 |
- |
|
| 83 |
- if (lock_fd >= 0) {
|
|
| 84 |
- handle_sigint(0); |
|
| 85 |
- } |
|
| 86 |
- |
|
| 87 |
- return 0; |
|
| 88 |
-} |
| ... | ... |
@@ -1,9 +1,9 @@ |
| 1 |
-%define rpmhome %{_libdir}/rpm
|
|
| 1 |
+%define rpmhome %{_libdir}/%{name}
|
|
| 2 | 2 |
|
| 3 | 3 |
Summary: Package manager |
| 4 | 4 |
Name: rpm |
| 5 | 5 |
Version: 4.18.0 |
| 6 |
-Release: 6%{?dist}
|
|
| 6 |
+Release: 7%{?dist}
|
|
| 7 | 7 |
License: GPLv2+ |
| 8 | 8 |
URL: http://rpm.org |
| 9 | 9 |
Group: Applications/System |
| ... | ... |
@@ -18,19 +18,12 @@ Source2: macros.php |
| 18 | 18 |
Source3: macros.perl |
| 19 | 19 |
Source4: macros.vpath |
| 20 | 20 |
Source5: macros.ldconfig |
| 21 |
-Source6: rpmdb-rebuild.sh |
|
| 22 |
-Source7: rpmdb-migrate.sh |
|
| 23 |
-Source8: rpmdb-rebuild.service |
|
| 24 |
-Source9: rpmdb-migrate.service |
|
| 25 |
-Source10: rpm.conf |
|
| 26 |
-Source11: lock.c |
|
| 27 |
- |
|
| 28 |
-Patch0: rpmdb-rename-dir.patch |
|
| 29 |
-Patch1: silence-warning.patch |
|
| 30 |
-Patch2: sync-buf-cache.patch |
|
| 31 |
-Patch3: wait-for-lock.patch |
|
| 32 |
-Patch4: migrate-rpmdb.patch |
|
| 33 |
-Patch5: fix-race-condition-in-brp-strip.patch |
|
| 21 |
+ |
|
| 22 |
+Patch0: silence-warning.patch |
|
| 23 |
+Patch1: sync-buf-cache.patch |
|
| 24 |
+Patch2: wait-for-lock.patch |
|
| 25 |
+Patch3: migrate-rpmdb.patch |
|
| 26 |
+Patch4: fix-race-condition-in-brp-strip.patch |
|
| 34 | 27 |
|
| 35 | 28 |
Requires: bash |
| 36 | 29 |
Requires: zstd-libs |
| ... | ... |
@@ -62,7 +55,7 @@ RPM package manager |
| 62 | 62 |
|
| 63 | 63 |
%package devel |
| 64 | 64 |
Summary: Libraries and header files for rpm |
| 65 |
-Provides: pkgconfig(rpm) |
|
| 65 |
+Provides: pkgconfig(%{name})
|
|
| 66 | 66 |
Requires: %{name} = %{version}-%{release}
|
| 67 | 67 |
Requires: zstd-devel |
| 68 | 68 |
|
| ... | ... |
@@ -118,7 +111,7 @@ Requires: %{name} = %{version}-%{release}
|
| 118 | 118 |
%description lang |
| 119 | 119 |
These are the additional language files of rpm. |
| 120 | 120 |
|
| 121 |
-%package -n python3-rpm |
|
| 121 |
+%package -n python3-%{name}
|
|
| 122 | 122 |
Summary: Python 3 bindings for rpm. |
| 123 | 123 |
Group: Development/Libraries |
| 124 | 124 |
Requires: python3 |
| ... | ... |
@@ -129,7 +122,7 @@ Python3 rpm. |
| 129 | 129 |
|
| 130 | 130 |
%package plugin-systemd-inhibit |
| 131 | 131 |
Summary: Rpm plugin for systemd inhibit functionality |
| 132 |
-Requires: rpm-libs = %{version}-%{release}
|
|
| 132 |
+Requires: %{name}-libs = %{version}-%{release}
|
|
| 133 | 133 |
Requires: dbus |
| 134 | 134 |
Requires: systemd |
| 135 | 135 |
|
| ... | ... |
@@ -138,7 +131,7 @@ This plugin blocks systemd from entering idle, sleep or shutdown while an rpm |
| 138 | 138 |
transaction is running using the systemd-inhibit mechanism. |
| 139 | 139 |
|
| 140 | 140 |
%prep |
| 141 |
-%autosetup -p1 -n %{name}-%{version}
|
|
| 141 |
+%autosetup -p1 |
|
| 142 | 142 |
|
| 143 | 143 |
%build |
| 144 | 144 |
# pass -L opts to gcc as well to prioritize it over standard libs |
| ... | ... |
@@ -147,8 +140,9 @@ sed -i '/library_dirs/d' python/setup.py.in |
| 147 | 147 |
sed -i 's/extra_link_args/library_dirs/g' python/setup.py.in |
| 148 | 148 |
|
| 149 | 149 |
sh autogen.sh --noconfigure |
| 150 |
+ |
|
| 150 | 151 |
%configure \ |
| 151 |
- CPPFLAGS='-I/usr/include/nspr -I/usr/include/nss -DLUA_COMPAT_APIINTCASTS' \ |
|
| 152 |
+ CPPFLAGS='-I%{_includedir}/nspr -I%{_includedir}/nss -DLUA_COMPAT_APIINTCASTS' \
|
|
| 152 | 153 |
--disable-dependency-tracking \ |
| 153 | 154 |
--disable-static \ |
| 154 | 155 |
--enable-python \ |
| ... | ... |
@@ -166,9 +160,6 @@ sh autogen.sh --noconfigure |
| 166 | 166 |
|
| 167 | 167 |
%make_build |
| 168 | 168 |
|
| 169 |
-gcc -Wall -o lock %{SOURCE11}
|
|
| 170 |
-chmod 700 lock |
|
| 171 |
- |
|
| 172 | 169 |
pushd python |
| 173 | 170 |
%py3_build |
| 174 | 171 |
popd |
| ... | ... |
@@ -182,29 +173,19 @@ ln -sfv %{_bindir}/find-debuginfo %{buildroot}%{rpmhome}/find-debuginfo.sh
|
| 182 | 182 |
%find_lang %{name}
|
| 183 | 183 |
|
| 184 | 184 |
# System macros and prefix |
| 185 |
-install -dm644 %{buildroot}%{_sysconfdir}/rpm
|
|
| 186 |
-install -vm644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm
|
|
| 187 |
-install -vm644 %{SOURCE2} %{buildroot}%{rpmhome}/macros.d
|
|
| 188 |
-install -vm644 %{SOURCE3} %{buildroot}%{rpmhome}/macros.d
|
|
| 189 |
-install -vm644 %{SOURCE4} %{buildroot}%{rpmhome}/macros.d
|
|
| 190 |
-install -vm644 %{SOURCE5} %{buildroot}%{rpmhome}/macros.d
|
|
| 191 |
-install -vm755 %{SOURCE6} %{buildroot}%{_libdir}/rpm
|
|
| 192 |
-install -vm755 %{SOURCE7} %{buildroot}%{_libdir}/rpm
|
|
| 193 |
- |
|
| 194 |
-mkdir -p %{buildroot}%{_unitdir}
|
|
| 195 |
-install -vm644 %{SOURCE8} %{buildroot}%{_unitdir}
|
|
| 196 |
-install -vm644 %{SOURCE9} %{buildroot}%{_unitdir}
|
|
| 197 |
- |
|
| 198 |
-mkdir -p %{buildroot}%{_sysconfdir}/tdnf/minversions.d
|
|
| 199 |
-install -vm644 %{SOURCE10} %{buildroot}%{_sysconfdir}/tdnf/minversions.d
|
|
| 200 |
-mv lock %{buildroot}%{_libdir}/rpm
|
|
| 185 |
+install -dm644 %{buildroot}%{_sysconfdir}/%{name}
|
|
| 186 |
+install -vm644 %{SOURCE1} %{buildroot}%{_sysconfdir}/%{name}
|
|
| 187 |
+install -vm644 %{SOURCE2} %{buildroot}%{_rpmmacrodir}
|
|
| 188 |
+install -vm644 %{SOURCE3} %{buildroot}%{_rpmmacrodir}
|
|
| 189 |
+install -vm644 %{SOURCE4} %{buildroot}%{_rpmmacrodir}
|
|
| 190 |
+install -vm644 %{SOURCE5} %{buildroot}%{_rpmmacrodir}
|
|
| 201 | 191 |
|
| 202 | 192 |
pushd python |
| 203 | 193 |
%py3_install |
| 204 | 194 |
popd |
| 205 | 195 |
|
| 206 |
-%check |
|
| 207 | 196 |
%if 0%{?with_check}
|
| 197 |
+%check |
|
| 208 | 198 |
make check TESTSUITEFLAGS=%{?_smp_mflags} || (cat tests/rpmtests.log; exit 1)
|
| 209 | 199 |
make clean %{?_smp_mflags}
|
| 210 | 200 |
%endif |
| ... | ... |
@@ -212,35 +193,12 @@ make clean %{?_smp_mflags}
|
| 212 | 212 |
%post libs -p /sbin/ldconfig |
| 213 | 213 |
%postun libs -p /sbin/ldconfig |
| 214 | 214 |
|
| 215 |
-%pre |
|
| 216 |
-# Symlink all rpmdb files to the new location if we're still using /var/lib/rpm |
|
| 217 |
-if [ -d %{_sharedstatedir}/rpm ]; then
|
|
| 218 |
- mkdir -p %{_libdir}/sysimage/rpm
|
|
| 219 |
- rpmdb_files=$(find %{_sharedstatedir}/rpm -maxdepth 1 -type f | sed 's|^/var/lib/rpm/||g' | sort)
|
|
| 220 |
- for fn in ${rpmdb_files[@]}; do
|
|
| 221 |
- ln -sfr %{_sharedstatedir}/rpm/${fn} %{_libdir}/sysimage/rpm/${fn}
|
|
| 222 |
- done |
|
| 223 |
-fi |
|
| 224 |
- |
|
| 225 |
-%posttrans libs |
|
| 226 |
-if [ -f %{_sharedstatedir}/rpm/Packages ]; then
|
|
| 227 |
- if [ -x %{_bindir}/systemctl ]; then
|
|
| 228 |
- systemctl --no-reload preset rpmdb-rebuild || : |
|
| 229 |
- fi |
|
| 230 |
- nohup bash %{rpmhome}/rpmdb-rebuild.sh &>/dev/null &
|
|
| 231 |
-fi |
|
| 232 |
- |
|
| 233 |
-if [ -d %{_sharedstatedir}/rpm ] && [ -x %{_bindir}/systemctl ]; then
|
|
| 234 |
- touch %{_sharedstatedir}/rpm/.migratedb
|
|
| 235 |
- systemctl --no-reload preset rpmdb-migrate || : |
|
| 236 |
-fi |
|
| 237 |
- |
|
| 238 | 215 |
%clean |
| 239 | 216 |
rm -rf %{buildroot}
|
| 240 | 217 |
|
| 241 | 218 |
%files |
| 242 | 219 |
%defattr(-,root,root) |
| 243 |
-%{_bindir}/rpm
|
|
| 220 |
+%{_bindir}/%{name}
|
|
| 244 | 221 |
%{_bindir}/gendiff
|
| 245 | 222 |
%{_bindir}/rpm2cpio
|
| 246 | 223 |
%{_bindir}/rpmgraph
|
| ... | ... |
@@ -248,31 +206,31 @@ rm -rf %{buildroot}
|
| 248 | 248 |
%{_bindir}/rpmquery
|
| 249 | 249 |
%{_bindir}/rpmverify
|
| 250 | 250 |
%{rpmhome}/rpmpopt-*
|
| 251 |
-%{rpmhome}/rpm.daily
|
|
| 252 |
-%{rpmhome}/rpm.log
|
|
| 253 |
-%{rpmhome}/rpm.supp
|
|
| 251 |
+%{rpmhome}/%{name}.daily
|
|
| 252 |
+%{rpmhome}/%{name}.log
|
|
| 253 |
+%{rpmhome}/%{name}.supp
|
|
| 254 | 254 |
%{rpmhome}/rpm2cpio.sh
|
| 255 | 255 |
%{rpmhome}/tgpg
|
| 256 | 256 |
%{rpmhome}/platform
|
| 257 |
-%{_libdir}/rpm-plugins/ima.so
|
|
| 258 |
-%{_libdir}/rpm-plugins/syslog.so
|
|
| 259 |
-%{_libdir}/rpm-plugins/prioreset.so
|
|
| 260 |
-%{_libdir}/rpm-plugins/fsverity.so
|
|
| 261 |
-%exclude %{_libdir}/rpm-plugins/dbus_announce.so
|
|
| 257 |
+%{_libdir}/%{name}-plugins/ima.so
|
|
| 258 |
+%{_libdir}/%{name}-plugins/syslog.so
|
|
| 259 |
+%{_libdir}/%{name}-plugins/prioreset.so
|
|
| 260 |
+%{_libdir}/%{name}-plugins/fsverity.so
|
|
| 261 |
+%exclude %{_libdir}/%{name}-plugins/dbus_announce.so
|
|
| 262 | 262 |
|
| 263 |
-%{_sysconfdir}/dbus-1/system.d/org.rpm.conf
|
|
| 263 |
+%{_sysconfdir}/dbus-1/system.d/org.%{name}.conf
|
|
| 264 | 264 |
|
| 265 | 265 |
%{_mandir}/man8/rpm2cpio.8.gz
|
| 266 | 266 |
%{_mandir}/man8/rpmdb.8.gz
|
| 267 | 267 |
%{_mandir}/man8/rpmgraph.8.gz
|
| 268 | 268 |
%{_mandir}/man8/rpmkeys.8.gz
|
| 269 |
-%{_mandir}/man8/rpm-misc.8.gz
|
|
| 270 |
-%{_mandir}/man8/rpm-plugin-ima.8.gz
|
|
| 271 |
-%{_mandir}/man8/rpm-plugin-prioreset.8.gz
|
|
| 272 |
-%{_mandir}/man8/rpm-plugin-syslog.8.gz
|
|
| 273 |
-%{_mandir}/man8/rpm-plugins.8.gz
|
|
| 274 |
-%{_mandir}/man8/rpm.8.gz
|
|
| 275 |
-%{_mandir}/man8/rpm-plugin-dbus-announce.8.gz
|
|
| 269 |
+%{_mandir}/man8/%{name}-misc.8.gz
|
|
| 270 |
+%{_mandir}/man8/%{name}-plugin-ima.8.gz
|
|
| 271 |
+%{_mandir}/man8/%{name}-plugin-prioreset.8.gz
|
|
| 272 |
+%{_mandir}/man8/%{name}-plugin-syslog.8.gz
|
|
| 273 |
+%{_mandir}/man8/%{name}-plugins.8.gz
|
|
| 274 |
+%{_mandir}/man8/%{name}.8.gz
|
|
| 275 |
+%{_mandir}/man8/%{name}-plugin-dbus-announce.8.gz
|
|
| 276 | 276 |
%exclude %{_mandir}/fr/man8/*.gz
|
| 277 | 277 |
%exclude %{_mandir}/ja/man8/*.gz
|
| 278 | 278 |
%exclude %{_mandir}/ko/man8/*.gz
|
| ... | ... |
@@ -283,19 +241,13 @@ rm -rf %{buildroot}
|
| 283 | 283 |
|
| 284 | 284 |
%files libs |
| 285 | 285 |
%defattr(-,root,root) |
| 286 |
-%config(noreplace) %{_sysconfdir}/rpm/macros
|
|
| 286 |
+%config(noreplace) %{_sysconfdir}/%{name}/macros
|
|
| 287 | 287 |
%{_libdir}/librpmio.so.*
|
| 288 | 288 |
%{_libdir}/librpm.so.*
|
| 289 | 289 |
%{rpmhome}/macros
|
| 290 | 290 |
%{rpmhome}/rpmrc
|
| 291 | 291 |
%{rpmhome}/rpmdb_*
|
| 292 |
-%{rpmhome}/rpmdb-rebuild.sh
|
|
| 293 |
-%{rpmhome}/rpmdb-migrate.sh
|
|
| 294 |
-%{rpmhome}/lock
|
|
| 295 | 292 |
%{_bindir}/rpmdb
|
| 296 |
-%{_unitdir}/rpmdb-rebuild.service
|
|
| 297 |
-%{_unitdir}/rpmdb-migrate.service
|
|
| 298 |
-%config(noreplace) %{_sysconfdir}/tdnf/minversions.d/%{name}.conf
|
|
| 299 | 293 |
|
| 300 | 294 |
%files build |
| 301 | 295 |
%defattr(-,root,root) |
| ... | ... |
@@ -305,7 +257,7 @@ rm -rf %{buildroot}
|
| 305 | 305 |
%{_bindir}/rpmlua
|
| 306 | 306 |
%{_libdir}/librpmbuild.so
|
| 307 | 307 |
%{_libdir}/librpmbuild.so.*
|
| 308 |
-%{rpmhome}/macros.d/*
|
|
| 308 |
+%{_rpmmacrodir}/*
|
|
| 309 | 309 |
%{rpmhome}/perl.req
|
| 310 | 310 |
%{rpmhome}/find-lang.sh
|
| 311 | 311 |
%{rpmhome}/find-provides
|
| ... | ... |
@@ -337,7 +289,7 @@ rm -rf %{buildroot}
|
| 337 | 337 |
%files devel |
| 338 | 338 |
%defattr(-,root,root) |
| 339 | 339 |
%{_includedir}/*
|
| 340 |
-%{_libdir}/pkgconfig/rpm.pc
|
|
| 340 |
+%{_libdir}/pkgconfig/%{name}.pc
|
|
| 341 | 341 |
%{_libdir}/librpmio.so
|
| 342 | 342 |
%{_libdir}/librpm.so
|
| 343 | 343 |
%{_libdir}/librpmsign.so
|
| ... | ... |
@@ -346,16 +298,18 @@ rm -rf %{buildroot}
|
| 346 | 346 |
%files lang -f %{name}.lang
|
| 347 | 347 |
%defattr(-,root,root) |
| 348 | 348 |
|
| 349 |
-%files -n python3-rpm |
|
| 349 |
+%files -n python3-%{name}
|
|
| 350 | 350 |
%defattr(-,root,root,-) |
| 351 | 351 |
%{python3_sitelib}/*
|
| 352 | 352 |
|
| 353 | 353 |
%files plugin-systemd-inhibit |
| 354 | 354 |
%defattr(-,root,root) |
| 355 |
-%{_libdir}/rpm-plugins/systemd_inhibit.so
|
|
| 356 |
-%{_mandir}/man8/rpm-plugin-systemd-inhibit.8*
|
|
| 355 |
+%{_libdir}/%{name}-plugins/systemd_inhibit.so
|
|
| 356 |
+%{_mandir}/man8/%{name}-plugin-systemd-inhibit.8*
|
|
| 357 | 357 |
|
| 358 | 358 |
%changelog |
| 359 |
+* Tue Jan 24 2023 Shreenidhi Shedi <sshedi@vmware.com> 4.18.0-7 |
|
| 360 |
+- Remove DB migration & DB rebuild logix & related files |
|
| 359 | 361 |
* Fri Jan 13 2023 Oliver Kurth <okurth@vmware.com> 4.18.0-6 |
| 360 | 362 |
- add tools needed to rpm-build requires |
| 361 | 363 |
* Wed Jan 11 2023 Oliver Kurth <okurth@vmware.com> 4.18.0-5 |
| 362 | 364 |
deleted file mode 100644 |
| ... | ... |
@@ -1,18 +0,0 @@ |
| 1 |
-[Unit] |
|
| 2 |
-Description=RPM database migration to /usr |
|
| 3 |
-ConditionPathExists=/var/lib/rpm/.migratedb |
|
| 4 |
- |
|
| 5 |
-# This should run before any daemons that may open the rpmdb |
|
| 6 |
-DefaultDependencies=no |
|
| 7 |
-After=sysinit.target |
|
| 8 |
-Before=basic.target shutdown.target |
|
| 9 |
-Conflicts=shutdown.target |
|
| 10 |
-# In case /var is remote-mounted |
|
| 11 |
-RequiresMountsFor=/var |
|
| 12 |
- |
|
| 13 |
-[Service] |
|
| 14 |
-Type=oneshot |
|
| 15 |
-ExecStart=/usr/lib/rpm/rpmdb-migrate.sh |
|
| 16 |
- |
|
| 17 |
-[Install] |
|
| 18 |
-WantedBy=basic.target |
| 19 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,66 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-# Script to migrate rpmdb from /var/lib/rpm to new rpmdb path at /usr |
|
| 4 |
-#set -x |
|
| 5 |
- |
|
| 6 |
-# log file name |
|
| 7 |
-log_fn="/var/log/rpmdb-migrate.log" |
|
| 8 |
- |
|
| 9 |
-# redirect stderr & stdout to log file |
|
| 10 |
-exec > "${log_fn}" 2>&1
|
|
| 11 |
- |
|
| 12 |
-sanity_check() |
|
| 13 |
-{
|
|
| 14 |
- if command -v rpm &> /dev/null; then |
|
| 15 |
- if rpm -q rpm &> /dev/null; then |
|
| 16 |
- return 0 |
|
| 17 |
- fi |
|
| 18 |
- fi |
|
| 19 |
- |
|
| 20 |
- if command -v tdnf &> /dev/null; then |
|
| 21 |
- if tdnf list installed tdnf --disablerepo=* &> /dev/null; then |
|
| 22 |
- return 0 |
|
| 23 |
- fi |
|
| 24 |
- fi |
|
| 25 |
- |
|
| 26 |
- # should not reach here |
|
| 27 |
- return 1 |
|
| 28 |
-} |
|
| 29 |
- |
|
| 30 |
-main() |
|
| 31 |
-{
|
|
| 32 |
- local dbpath_old="/var/lib/rpm" |
|
| 33 |
- |
|
| 34 |
- if [ ! -f "${dbpath_old}/.migratedb" ]; then
|
|
| 35 |
- echo "${dbpath_old}/.migratedb not preset, exit"
|
|
| 36 |
- exit 0 |
|
| 37 |
- fi |
|
| 38 |
- |
|
| 39 |
- local dbpath_new="$(rpmdb -E '%_dbpath' 2>/dev/null)" |
|
| 40 |
- |
|
| 41 |
- if [ "${dbpath_new}" = "${dbpath_old}" ]; then
|
|
| 42 |
- echo "RpmDB path is still at ${dbpath_new}, exit"
|
|
| 43 |
- exit 0 |
|
| 44 |
- fi |
|
| 45 |
- |
|
| 46 |
- if [ -L "${dbpath_old}" ]; then
|
|
| 47 |
- echo "RpmDB has been migrated, exit" |
|
| 48 |
- rm -f "${dbpath_old}/.migratedb"
|
|
| 49 |
- exit 0 |
|
| 50 |
- fi |
|
| 51 |
- |
|
| 52 |
- if ! rpmdb --rebuilddb; then |
|
| 53 |
- echo "ERROR: Failed to rebuild RpmDB" 1>&2 |
|
| 54 |
- exit 1 |
|
| 55 |
- fi |
|
| 56 |
- |
|
| 57 |
- if ! sanity_check; then |
|
| 58 |
- echo "ERROR: sanity check failed" 1>&2 |
|
| 59 |
- exit 1 |
|
| 60 |
- fi |
|
| 61 |
- |
|
| 62 |
- rm -rfv "${dbpath_old}"
|
|
| 63 |
- ln -sfr "${dbpath_new}" "${dbpath_old}"
|
|
| 64 |
-} |
|
| 65 |
- |
|
| 66 |
-main |
| 67 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,19 +0,0 @@ |
| 1 |
-[Unit] |
|
| 2 |
-Description=RPM database rebuild |
|
| 3 |
-ConditionPathExists=/usr/lib/sysimage/rpm/.rebuilddb |
|
| 4 |
- |
|
| 5 |
-# This should run before any daemons that may open the rpmdb |
|
| 6 |
-DefaultDependencies=no |
|
| 7 |
-After=sysinit.target |
|
| 8 |
-Before=basic.target shutdown.target |
|
| 9 |
-Conflicts=shutdown.target |
|
| 10 |
-# In case /var is remote-mounted |
|
| 11 |
-RequiresMountsFor=/var |
|
| 12 |
- |
|
| 13 |
-[Service] |
|
| 14 |
-Type=oneshot |
|
| 15 |
-ExecStart=/usr/lib/rpm/rpmdb-rebuild.sh |
|
| 16 |
-ExecStartPost=rm -f /usr/lib/sysimage/rpm/.rebuilddb |
|
| 17 |
- |
|
| 18 |
-[Install] |
|
| 19 |
-WantedBy=basic.target |
| 20 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,177 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-# Script to rebuild rpm backend db |
|
| 4 |
- |
|
| 5 |
-#set -x |
|
| 6 |
- |
|
| 7 |
-# log file name |
|
| 8 |
-log_fn="/var/log/rpmdb-rebuild.log" |
|
| 9 |
- |
|
| 10 |
-# redirect stderr & stdout to log file |
|
| 11 |
-exec > "${log_fn}" 2>&1
|
|
| 12 |
- |
|
| 13 |
-rpmdb_dir="$(rpmdb -E '%_dbpath' 2>/dev/null)" |
|
| 14 |
- |
|
| 15 |
-# this serves as a key for systemd service |
|
| 16 |
-if [ -x /usr/bin/systemctl ]; then |
|
| 17 |
- touch "${rpmdb_dir}/.rebuilddb"
|
|
| 18 |
-fi |
|
| 19 |
- |
|
| 20 |
-rpm_lock_fn="${rpmdb_dir}/.rpm.lock"
|
|
| 21 |
-lock_bin="/usr/lib/rpm/lock" |
|
| 22 |
-lock_flag="/var/run/.lkflg" |
|
| 23 |
- |
|
| 24 |
-# Sometimes rebuilddb succeeds but rpm options won't work |
|
| 25 |
-# this is a simple sanity check |
|
| 26 |
-sanity_check() |
|
| 27 |
-{
|
|
| 28 |
- if command -v rpm &> /dev/null; then |
|
| 29 |
- if rpm -q rpm &> /dev/null; then |
|
| 30 |
- return 0 |
|
| 31 |
- fi |
|
| 32 |
- fi |
|
| 33 |
- |
|
| 34 |
- if command -v tdnf &> /dev/null; then |
|
| 35 |
- if tdnf list installed tdnf --disablerepo=* &> /dev/null; then |
|
| 36 |
- return 0 |
|
| 37 |
- fi |
|
| 38 |
- fi |
|
| 39 |
- |
|
| 40 |
- # should not reach here |
|
| 41 |
- return 1 |
|
| 42 |
-} |
|
| 43 |
- |
|
| 44 |
-lpid="" |
|
| 45 |
- |
|
| 46 |
-unlock() |
|
| 47 |
-{
|
|
| 48 |
- [ -f "${lock_flag}" ] && rm -f "${lock_flag}"
|
|
| 49 |
- kill -9 "${lpid}"
|
|
| 50 |
-} |
|
| 51 |
- |
|
| 52 |
-get_lock() |
|
| 53 |
-{
|
|
| 54 |
- local retry=1500 |
|
| 55 |
- |
|
| 56 |
- # remove "$lock_flag" file to ensure that there is no leftover |
|
| 57 |
- [ -f "${lock_flag}" ] && rm -f "${lock_flag}"
|
|
| 58 |
- |
|
| 59 |
- "${lock_bin}" "${rpm_lock_fn}" &
|
|
| 60 |
- lpid="$!" |
|
| 61 |
- |
|
| 62 |
- # 5 min max delay |
|
| 63 |
- # while building ova & other images, transactions take time |
|
| 64 |
- while [ "${retry}" -gt 0 ]; do
|
|
| 65 |
- if [ -f "${lock_flag}" ]; then
|
|
| 66 |
- return 0 |
|
| 67 |
- fi |
|
| 68 |
- sleep 0.2 |
|
| 69 |
- retry=$((retry-1)) |
|
| 70 |
- done |
|
| 71 |
- |
|
| 72 |
- unlock |
|
| 73 |
- echo -e "\nERROR: failed to get lock" |
|
| 74 |
- exit 1 |
|
| 75 |
-} |
|
| 76 |
- |
|
| 77 |
-# Rebuild rpm db --> This should finish quick |
|
| 78 |
-# Steps: |
|
| 79 |
-# 1. Take backup of existing db |
|
| 80 |
-# 2. Try rebuilding db |
|
| 81 |
-# 3. If ok, do a sanity check and remove backup |
|
| 82 |
-# Else - remove the newly created /var/lib/rpmrebuilddb.* and retry |
|
| 83 |
-# |
|
| 84 |
-# If sanity check fails, revert backup data |
|
| 85 |
-# Stops after 10 attempts |
|
| 86 |
-try_rpm_rebuilddb() |
|
| 87 |
-{
|
|
| 88 |
- local retry=10 |
|
| 89 |
- local backup_dir="" |
|
| 90 |
- |
|
| 91 |
- if [ -x /usr/bin/systemctl ] && [ ! -f "${rpmdb_dir}/.rebuilddb" ]; then
|
|
| 92 |
- echo "${rpmdb_dir}/.rebuilddb doesn't exist, quit"
|
|
| 93 |
- exit 0 |
|
| 94 |
- fi |
|
| 95 |
- |
|
| 96 |
- # need 6 Xs, toybox mktemp doesn't work with 4 Xs |
|
| 97 |
- backup_dir="$(mktemp -d -p "${rpmdb_dir}"/.. .rpmdbXXXXXX)"
|
|
| 98 |
- if [ "$?" -ne 0 ]; then |
|
| 99 |
- echo -e "\nERROR: failed to create backup directory" |
|
| 100 |
- return 1 |
|
| 101 |
- fi |
|
| 102 |
- |
|
| 103 |
- # During taking backup & restoring backup operations |
|
| 104 |
- # we need a lock, otherwise this might create contention. |
|
| 105 |
- # |
|
| 106 |
- # During this copy & restore operation, rpm transaction might run parallely |
|
| 107 |
- # and we might end up in an unlikely situation |
|
| 108 |
- if get_lock; then |
|
| 109 |
- # remove temporary lock files |
|
| 110 |
- rm -f "${rpmdb_dir}"/__db*
|
|
| 111 |
- |
|
| 112 |
- if ! cp -ar "${rpmdb_dir}"/* "${backup_dir}"; then
|
|
| 113 |
- unlock |
|
| 114 |
- [ -d "${backup_dir}" ] && rm -rf "${backup_dir}"
|
|
| 115 |
- echo -e "\nERROR: failed to copy contents to backup directory" |
|
| 116 |
- return 1 |
|
| 117 |
- fi |
|
| 118 |
- unlock |
|
| 119 |
- fi |
|
| 120 |
- |
|
| 121 |
- echo -e "\nINFO: took backup of rpmdb at ${backup_dir}"
|
|
| 122 |
- |
|
| 123 |
- while [ "${retry}" -gt 0 ]; do
|
|
| 124 |
- |
|
| 125 |
- if rpmdb --rebuilddb; then |
|
| 126 |
- if get_lock; then |
|
| 127 |
- if sanity_check; then |
|
| 128 |
- unlock |
|
| 129 |
- |
|
| 130 |
- rm -rf "${backup_dir}" "${rpmdb_dir}"/.rebuilddb
|
|
| 131 |
- |
|
| 132 |
- if [ "${rpmdb_dir}" = "/usr/lib/sysimage/rpm" ]; then
|
|
| 133 |
- rm -rf "/var/lib/rpm" |
|
| 134 |
- ln -sfr "${rpmdb_dir}" "/var/lib/rpm"
|
|
| 135 |
- fi |
|
| 136 |
- |
|
| 137 |
- echo -e "\nINFO: rpmdb --rebuild success" |
|
| 138 |
- return 0 |
|
| 139 |
- fi |
|
| 140 |
- |
|
| 141 |
- local err=0 |
|
| 142 |
- echo -e "\n--- ERROR: SOMETHING WENT TOTALLY WRONG ---" |
|
| 143 |
- echo "Trying to restore RPMDB from backup directory" |
|
| 144 |
- |
|
| 145 |
- if [ "${rpmdb_dir}" = "/var/lib/rpm" ] || [ "${rpmdb_dir}" = "/usr/lib/sysimage/rpm" ]; then
|
|
| 146 |
- rm -f "${rpmdb_dir}"/*
|
|
| 147 |
- fi |
|
| 148 |
- |
|
| 149 |
- if ! cp -ar "${backup_dir}"/* "${rpmdb_dir}"; then
|
|
| 150 |
- err=1 |
|
| 151 |
- echo -e "\nERROR: failed copy contents from ${backup_dir} to ${rpmdb_dir}"
|
|
| 152 |
- else |
|
| 153 |
- [ -d "${backup_dir}" ] && rm -rf "${backup_dir}"
|
|
| 154 |
- fi |
|
| 155 |
- |
|
| 156 |
- if [ "${err}" -eq 0 ]; then
|
|
| 157 |
- echo -e "\nINFO: Revert from backup directory success" |
|
| 158 |
- fi |
|
| 159 |
- |
|
| 160 |
- unlock |
|
| 161 |
- return 1 |
|
| 162 |
- fi |
|
| 163 |
- fi |
|
| 164 |
- |
|
| 165 |
- if ls "${rpmdb_dir}"/../rpmrebuilddb.* &> /dev/null; then
|
|
| 166 |
- rm -rf "${rpmdb_dir}"/../rpmrebuilddb.*
|
|
| 167 |
- fi |
|
| 168 |
- |
|
| 169 |
- echo -e "\nERROR: failed to rebuild rpmdb, retrying" |
|
| 170 |
- retry=$((retry-1)) |
|
| 171 |
- |
|
| 172 |
- done |
|
| 173 |
- |
|
| 174 |
- return 1 |
|
| 175 |
-} |
|
| 176 |
- |
|
| 177 |
-try_rpm_rebuilddb |
| 178 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,531 +0,0 @@ |
| 1 |
-From cdabb35460f45aa657707d3a8f4fec9a798c42dd Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Shreenidhi Shedi <sshedi@vmware.com> |
|
| 3 |
-Date: Mon, 13 Dec 2021 16:41:52 +0530 |
|
| 4 |
-Subject: [PATCH] lib/rpmdb.c: use a fallback method for renaming directories |
|
| 5 |
- |
|
| 6 |
-While migrating rpm db from BDB to SQLITE in a docker container rename |
|
| 7 |
-function throws EXDEV error. |
|
| 8 |
- |
|
| 9 |
-strace of `rpm --rebuilddb` shows |
|
| 10 |
-``` |
|
| 11 |
-... |
|
| 12 |
-rename("/var/lib/rpm", "/var/lib/rpmold.54") = -1 EXDEV (Invalid cross-device link)
|
|
| 13 |
-write(2, "error: ", 7error: ) = 7 |
|
| 14 |
-write(2, "failed to replace old database w"..., 50failed to replace old database with new database! |
|
| 15 |
-) = 50 |
|
| 16 |
-write(2, "error: ", 7error: ) = 7 |
|
| 17 |
-write(2, "replace files in /var/lib/rpm wi"..., 82replace files in /var/lib/rpm with files from /var/lib/rpmrebuilddb.54 to recover |
|
| 18 |
-) = 82 |
|
| 19 |
-fcntl(3, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
|
|
| 20 |
-rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 |
|
| 21 |
-rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0 |
|
| 22 |
-rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 |
|
| 23 |
-close(3) = 0 |
|
| 24 |
-exit_group(1) = ? |
|
| 25 |
-+++ exited with 1 +++ |
|
| 26 |
-``` |
|
| 27 |
- |
|
| 28 |
-This patch fixes this problem by using a wrapper for rename calls. |
|
| 29 |
-If rename returns with EXDEV error, then we need to use fallback |
|
| 30 |
-rename_dir function to achive the same. |
|
| 31 |
- |
|
| 32 |
-For more info: |
|
| 33 |
-https://github.com/torvalds/linux/blob/master/Documentation/filesystems/overlayfs.rst#renaming-directories |
|
| 34 |
- |
|
| 35 |
-Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com> |
|
| 36 |
- include/rpm/rpmdb.h | 23 ++++ |
|
| 37 |
- lib/rpmdb.c | 304 +++++++++++++++++++++++++++++++++++++++++--- |
|
| 38 |
- 2 files changed, 306 insertions(+), 21 deletions(-) |
|
| 39 |
- |
|
| 40 |
-diff --git a/include/rpm/rpmdb.h b/include/rpm/rpmdb.h |
|
| 41 |
-index afd0b85cc..55416e99d 100644 |
|
| 42 |
-+++ b/include/rpm/rpmdb.h |
|
| 43 |
-@@ -251,6 +251,29 @@ int rpmdbStat(const char *prefix, struct stat *statbuf); |
|
| 44 |
- */ |
|
| 45 |
- int rpmdbFStat(rpmdb db, struct stat *statbuf); |
|
| 46 |
- |
|
| 47 |
-+/** \ingroup rpmdb |
|
| 48 |
-+ * Recursively remove a directory |
|
| 49 |
-+ * @param directory path |
|
| 50 |
-+ * @return 0 on success, -1 on error |
|
| 51 |
-+ */ |
|
| 52 |
-+int removedir(const char *path); |
|
| 53 |
-+ |
|
| 54 |
-+/** \ingroup rpmdb |
|
| 55 |
-+ * Copy file from source to destination |
|
| 56 |
-+ * @param src source file name |
|
| 57 |
-+ * @param dst destination file name |
|
| 58 |
-+ * @return 0 on success, -1 on error |
|
| 59 |
-+ */ |
|
| 60 |
-+int copy_file(const char *src, const char *dst); |
|
| 61 |
-+ |
|
| 62 |
-+/** \ingroup rpmdb |
|
| 63 |
-+ * Rename/Move directory from source to destination |
|
| 64 |
-+ * @param src source directory path |
|
| 65 |
-+ * @param dst destination directory path |
|
| 66 |
-+ * @return 0 on success, -1 on error |
|
| 67 |
-+ */ |
|
| 68 |
-+int rename_dir(const char *src, const char *dst); |
|
| 69 |
-+ |
|
| 70 |
- #ifdef __cplusplus |
|
| 71 |
- } |
|
| 72 |
- #endif |
|
| 73 |
-diff --git a/lib/rpmdb.c b/lib/rpmdb.c |
|
| 74 |
-index b3c5da62d..b9831db60 100644 |
|
| 75 |
-+++ b/lib/rpmdb.c |
|
| 76 |
-@@ -9,6 +9,15 @@ |
|
| 77 |
- #include <errno.h> |
|
| 78 |
- #include <dirent.h> |
|
| 79 |
- #include <fcntl.h> |
|
| 80 |
-+#include <fts.h> |
|
| 81 |
-+#include <stdio.h> |
|
| 82 |
-+#include <limits.h> |
|
| 83 |
-+#include <string.h> |
|
| 84 |
-+#include <stdlib.h> |
|
| 85 |
-+#include <unistd.h> |
|
| 86 |
-+#include <sys/stat.h> |
|
| 87 |
-+#include <sys/types.h> |
|
| 88 |
-+#include <sys/errno.h> |
|
| 89 |
- |
|
| 90 |
- #ifndef DYING /* XXX already in "system.h" */ |
|
| 91 |
- #include <fnmatch.h> |
|
| 92 |
-@@ -52,6 +61,247 @@ |
|
| 93 |
- |
|
| 94 |
- static rpmdb rpmdbUnlink(rpmdb db); |
|
| 95 |
- |
|
| 96 |
-+static int create_dest_fn_path(const char *src, char *dst, int dstsize) |
|
| 97 |
-+{
|
|
| 98 |
-+ char *fn = NULL; |
|
| 99 |
-+ char *buf = NULL; |
|
| 100 |
-+ int ret = -1; |
|
| 101 |
-+ |
|
| 102 |
-+ if (src == NULL || dst == NULL || dstsize <= 0) {
|
|
| 103 |
-+ rpmlog(RPMLOG_ERR, "Invalid input argument(s)\n"); |
|
| 104 |
-+ return ret; |
|
| 105 |
-+ } |
|
| 106 |
-+ |
|
| 107 |
-+ buf = xcalloc(dstsize, 1); |
|
| 108 |
-+ |
|
| 109 |
-+ fn = strrchr(src, '/'); |
|
| 110 |
-+ if (fn == NULL) {
|
|
| 111 |
-+ rpmlog(RPMLOG_ERR, "Wrong src path(%s)\n", src); |
|
| 112 |
-+ goto end; |
|
| 113 |
-+ } |
|
| 114 |
-+ |
|
| 115 |
-+ fn++; |
|
| 116 |
-+ |
|
| 117 |
-+ if (snprintf(buf, dstsize, "%s/%s", dst, fn) < 0) {
|
|
| 118 |
-+ rpmlog(RPMLOG_ERR, "snprintf failed\n"); |
|
| 119 |
-+ goto end; |
|
| 120 |
-+ } |
|
| 121 |
-+ strcpy(dst, buf); |
|
| 122 |
-+ |
|
| 123 |
-+ ret = 0; |
|
| 124 |
-+ |
|
| 125 |
-+end: |
|
| 126 |
-+ free(buf); |
|
| 127 |
-+ return ret; |
|
| 128 |
-+} |
|
| 129 |
-+ |
|
| 130 |
-+int removedir(const char *path) |
|
| 131 |
-+{
|
|
| 132 |
-+ FTS *ftsp = NULL; |
|
| 133 |
-+ FTSENT *ent = NULL; |
|
| 134 |
-+ int retval = -1; |
|
| 135 |
-+ char rpath[PATH_MAX] = {0};
|
|
| 136 |
-+ |
|
| 137 |
-+ if (path == NULL) {
|
|
| 138 |
-+ rpmlog(RPMLOG_ERR, "Invalid input argument(s)\n"); |
|
| 139 |
-+ return retval; |
|
| 140 |
-+ } |
|
| 141 |
-+ |
|
| 142 |
-+ if (realpath(path, rpath) == NULL) {
|
|
| 143 |
-+ rpmlog(RPMLOG_ERR, "'%s' doesn't exist\n", path); |
|
| 144 |
-+ return retval; |
|
| 145 |
-+ } |
|
| 146 |
-+ |
|
| 147 |
-+ char *paths[] = {rpath, NULL};
|
|
| 148 |
-+ ftsp = fts_open(paths, FTS_PHYSICAL, NULL); |
|
| 149 |
-+ if (ftsp == NULL) {
|
|
| 150 |
-+ rpmlog(RPMLOG_ERR, "fts_open: %s\n", strerror(errno)); |
|
| 151 |
-+ return retval; |
|
| 152 |
-+ } |
|
| 153 |
-+ |
|
| 154 |
-+ errno = 0; |
|
| 155 |
-+ while ((ent = fts_read(ftsp))) {
|
|
| 156 |
-+ if (ent->fts_info & FTS_DP) {
|
|
| 157 |
-+ if (rmdir(ent->fts_path)) {
|
|
| 158 |
-+ rpmlog(RPMLOG_ERR, "rmdir(%s): %s\n", ent->fts_path, |
|
| 159 |
-+ strerror(errno)); |
|
| 160 |
-+ } |
|
| 161 |
-+ } else if (ent->fts_info & FTS_F){
|
|
| 162 |
-+ if (unlink(ent->fts_path)) {
|
|
| 163 |
-+ rpmlog(RPMLOG_ERR, "unlink(%s): %s\n", ent->fts_path, |
|
| 164 |
-+ strerror(errno)); |
|
| 165 |
-+ } |
|
| 166 |
-+ } |
|
| 167 |
-+ |
|
| 168 |
-+ if (errno) {
|
|
| 169 |
-+ rpmlog(RPMLOG_ERR, "Failed to delete: %s\n", ent->fts_path); |
|
| 170 |
-+ goto end; |
|
| 171 |
-+ } |
|
| 172 |
-+ } |
|
| 173 |
-+ |
|
| 174 |
-+ retval = 0; |
|
| 175 |
-+ |
|
| 176 |
-+end: |
|
| 177 |
-+ fts_close(ftsp); |
|
| 178 |
-+ return retval; |
|
| 179 |
-+} |
|
| 180 |
-+ |
|
| 181 |
-+int copy_file(const char *src, const char *dst) |
|
| 182 |
-+{
|
|
| 183 |
-+ FILE *in = NULL; |
|
| 184 |
-+ FILE *out = NULL; |
|
| 185 |
-+ int retval = -1; |
|
| 186 |
-+ char rbuf[BUFSIZ] = {0};
|
|
| 187 |
-+ |
|
| 188 |
-+ if (src == NULL || dst == NULL) {
|
|
| 189 |
-+ rpmlog(RPMLOG_ERR, "Invalid input argument(s)\n"); |
|
| 190 |
-+ goto end; |
|
| 191 |
-+ } |
|
| 192 |
-+ |
|
| 193 |
-+ in = fopen(src, "rb"); |
|
| 194 |
-+ out= fopen(dst, "wb"); |
|
| 195 |
-+ if (in == NULL || out == NULL) {
|
|
| 196 |
-+ rpmlog(RPMLOG_ERR, "fopen error: %s\n", strerror(errno)); |
|
| 197 |
-+ goto end; |
|
| 198 |
-+ } |
|
| 199 |
-+ |
|
| 200 |
-+ while (1) {
|
|
| 201 |
-+ size_t bytes_read = fread(rbuf, 1, BUFSIZ, in); |
|
| 202 |
-+ if (ferror(in)) {
|
|
| 203 |
-+ rpmlog(RPMLOG_ERR, "fread error: %s\n", strerror(errno)); |
|
| 204 |
-+ goto end; |
|
| 205 |
-+ } |
|
| 206 |
-+ |
|
| 207 |
-+ if ((fwrite(rbuf, 1, bytes_read, out) != bytes_read) || ferror(out)) {
|
|
| 208 |
-+ rpmlog(RPMLOG_ERR, "fwrite error: %s\n", strerror(errno)); |
|
| 209 |
-+ goto end; |
|
| 210 |
-+ } |
|
| 211 |
-+ |
|
| 212 |
-+ if (feof(in)) {
|
|
| 213 |
-+ break; |
|
| 214 |
-+ } |
|
| 215 |
-+ } |
|
| 216 |
-+ |
|
| 217 |
-+ retval = 0; |
|
| 218 |
-+ |
|
| 219 |
-+end: |
|
| 220 |
-+ if (in) {
|
|
| 221 |
-+ fclose(in); |
|
| 222 |
-+ } |
|
| 223 |
-+ |
|
| 224 |
-+ if (out) {
|
|
| 225 |
-+ fclose(out); |
|
| 226 |
-+ } |
|
| 227 |
-+ |
|
| 228 |
-+ return retval; |
|
| 229 |
-+} |
|
| 230 |
-+ |
|
| 231 |
-+int rename_dir(const char *src, const char *dst) |
|
| 232 |
-+{
|
|
| 233 |
-+ FTS *ftsp = NULL; |
|
| 234 |
-+ FTSENT *ent = NULL; |
|
| 235 |
-+ int retval = -1; |
|
| 236 |
-+ char srcpath[PATH_MAX] = {0};
|
|
| 237 |
-+ char dstpath[PATH_MAX] = {0};
|
|
| 238 |
-+ |
|
| 239 |
-+ if (src == NULL || dst == NULL) {
|
|
| 240 |
-+ rpmlog(RPMLOG_ERR, "Invalid input argument(s)\n"); |
|
| 241 |
-+ goto end; |
|
| 242 |
-+ } |
|
| 243 |
-+ |
|
| 244 |
-+ if (realpath(src, srcpath) == NULL) {
|
|
| 245 |
-+ rpmlog(RPMLOG_ERR, "source directory: '%s' doens't exist\n", src); |
|
| 246 |
-+ goto end; |
|
| 247 |
-+ } |
|
| 248 |
-+ |
|
| 249 |
-+ if (realpath(dst, dstpath) == NULL) {
|
|
| 250 |
-+ if (mkdir(dstpath, 0755)) {
|
|
| 251 |
-+ rpmlog(RPMLOG_ERR, |
|
| 252 |
-+ ("failed to create destination directory '%s'\n"),
|
|
| 253 |
-+ dstpath); |
|
| 254 |
-+ goto end; |
|
| 255 |
-+ } |
|
| 256 |
-+ } |
|
| 257 |
-+ |
|
| 258 |
-+ char *paths[] = {srcpath, NULL};
|
|
| 259 |
-+ ftsp = fts_open(paths, FTS_PHYSICAL, NULL); |
|
| 260 |
-+ if (ftsp == NULL) {
|
|
| 261 |
-+ rpmlog(RPMLOG_ERR, "fts_open: %s\n", strerror(errno)); |
|
| 262 |
-+ goto end; |
|
| 263 |
-+ } |
|
| 264 |
-+ |
|
| 265 |
-+ while ((ent = fts_read(ftsp))) {
|
|
| 266 |
-+ char *s = NULL; |
|
| 267 |
-+ char *cursrc = ent->fts_path; |
|
| 268 |
-+ |
|
| 269 |
-+ if (strcmp(cursrc, srcpath) == 0) |
|
| 270 |
-+ continue; |
|
| 271 |
-+ |
|
| 272 |
-+ if (ent->fts_info & FTS_D) {
|
|
| 273 |
-+ struct stat fstat = {0};
|
|
| 274 |
-+ |
|
| 275 |
-+ if (create_dest_fn_path(cursrc, dstpath, sizeof(dstpath))) {
|
|
| 276 |
-+ rpmlog(RPMLOG_ERR, "FTS_D create_dest_fn_path failed\n"); |
|
| 277 |
-+ goto end; |
|
| 278 |
-+ } |
|
| 279 |
-+ |
|
| 280 |
-+ if (stat(srcpath, &fstat) || mkdir(dstpath, fstat.st_mode)) {
|
|
| 281 |
-+ if (errno != EEXIST) {
|
|
| 282 |
-+ rpmlog(RPMLOG_ERR, "mkdir error: %s\n", strerror(errno)); |
|
| 283 |
-+ goto end; |
|
| 284 |
-+ } |
|
| 285 |
-+ } |
|
| 286 |
-+ } else if (ent->fts_info & FTS_DP) {
|
|
| 287 |
-+ s = strrchr(dstpath, '/'); |
|
| 288 |
-+ if (s == NULL) {
|
|
| 289 |
-+ rpmlog(RPMLOG_ERR, "FTS_DP invalid destination path(%s)\n", |
|
| 290 |
-+ dstpath); |
|
| 291 |
-+ goto end; |
|
| 292 |
-+ } |
|
| 293 |
-+ |
|
| 294 |
-+ *s = '\0'; |
|
| 295 |
-+ } else if (ent->fts_info & FTS_F) {
|
|
| 296 |
-+ if (create_dest_fn_path(cursrc, dstpath, sizeof(dstpath))) {
|
|
| 297 |
-+ rpmlog(RPMLOG_ERR, "FTS_F create_dest_fn_path failed\n"); |
|
| 298 |
-+ goto end; |
|
| 299 |
-+ } |
|
| 300 |
-+ |
|
| 301 |
-+ if (copy_file(cursrc, dstpath)) {
|
|
| 302 |
-+ rpmlog(RPMLOG_ERR, |
|
| 303 |
-+ ("Unable to copy file: %s to destination %s\n"),
|
|
| 304 |
-+ cursrc, dstpath); |
|
| 305 |
-+ goto end; |
|
| 306 |
-+ } |
|
| 307 |
-+ sync(); |
|
| 308 |
-+ |
|
| 309 |
-+ s = strrchr(dstpath, '/'); |
|
| 310 |
-+ if (s == NULL) {
|
|
| 311 |
-+ rpmlog(RPMLOG_ERR, |
|
| 312 |
-+ ("FTS_F invalid destination path(%s)\n"),
|
|
| 313 |
-+ dstpath); |
|
| 314 |
-+ goto end; |
|
| 315 |
-+ } |
|
| 316 |
-+ |
|
| 317 |
-+ *s = '\0'; |
|
| 318 |
-+ } else {
|
|
| 319 |
-+ /* Shouldn't reach here */ |
|
| 320 |
-+ rpmlog(RPMLOG_ERR, "Other: %s\n", cursrc); |
|
| 321 |
-+ goto end; |
|
| 322 |
-+ } |
|
| 323 |
-+ } |
|
| 324 |
-+ |
|
| 325 |
-+ if (removedir(src)) {
|
|
| 326 |
-+ rpmlog(RPMLOG_ERR, "Deletion of %s failed\n", src); |
|
| 327 |
-+ goto end; |
|
| 328 |
-+ } |
|
| 329 |
-+ |
|
| 330 |
-+ retval = 0; |
|
| 331 |
-+ |
|
| 332 |
-+end: |
|
| 333 |
-+ fts_close(ftsp); |
|
| 334 |
-+ return retval; |
|
| 335 |
-+} |
|
| 336 |
-+ |
|
| 337 |
- static int buildIndexes(rpmdb db) |
|
| 338 |
- {
|
|
| 339 |
- int rc = 0; |
|
| 340 |
-@@ -456,7 +706,7 @@ static int openDatabase(const char * prefix, |
|
| 341 |
- |
|
| 342 |
- if (dbp) |
|
| 343 |
- *dbp = NULL; |
|
| 344 |
-- if ((mode & O_ACCMODE) == O_WRONLY) |
|
| 345 |
-+ if ((mode & O_ACCMODE) == O_WRONLY) |
|
| 346 |
- return 1; |
|
| 347 |
- |
|
| 348 |
- db = newRpmdb(prefix, dbpath, mode, perms, flags); |
|
| 349 |
-@@ -526,7 +776,7 @@ int rpmdbVerify(const char * prefix) |
|
| 350 |
- |
|
| 351 |
- if (db != NULL) {
|
|
| 352 |
- int xx; |
|
| 353 |
-- |
|
| 354 |
-+ |
|
| 355 |
- if (db->db_pkgs) |
|
| 356 |
- rc += dbiVerify(db->db_pkgs, 0); |
|
| 357 |
- rc += dbiForeach(db->db_indexes, db->db_ndbi, dbiVerify, 0); |
|
| 358 |
-@@ -539,7 +789,7 @@ int rpmdbVerify(const char * prefix) |
|
| 359 |
- } |
|
| 360 |
- |
|
| 361 |
- Header rpmdbGetHeaderAt(rpmdb db, unsigned int offset) |
|
| 362 |
--{
|
|
| 363 |
-+{
|
|
| 364 |
- rpmdbMatchIterator mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, |
|
| 365 |
- &offset, sizeof(offset)); |
|
| 366 |
- Header h = headerLink(rpmdbNextIterator(mi)); |
|
| 367 |
-@@ -711,7 +961,7 @@ static rpmRC dbiFindMatches(rpmdb db, dbiIndex dbi, |
|
| 368 |
- /* No matches on the name, anything else wont match either */ |
|
| 369 |
- if (rc != RPMRC_OK) |
|
| 370 |
- goto exit; |
|
| 371 |
-- |
|
| 372 |
-+ |
|
| 373 |
- /* If we got matches on name and nothing else was specified, we're done */ |
|
| 374 |
- if (epoch < 0 && version == NULL && release == NULL && arch == NULL) |
|
| 375 |
- goto exit; |
|
| 376 |
-@@ -1246,7 +1496,7 @@ int rpmdbSetIteratorRE(rpmdbMatchIterator mi, rpmTagVal tag, |
|
| 377 |
- mi->mi_re = xrealloc(mi->mi_re, (mi->mi_nre + 1) * sizeof(*mi->mi_re)); |
|
| 378 |
- mire = mi->mi_re + mi->mi_nre; |
|
| 379 |
- mi->mi_nre++; |
|
| 380 |
-- |
|
| 381 |
-+ |
|
| 382 |
- mire->tag = tag; |
|
| 383 |
- mire->mode = mode; |
|
| 384 |
- mire->pattern = allpat; |
|
| 385 |
-@@ -1694,7 +1944,7 @@ static rpmdbMatchIterator indexIterInit(rpmdb db, rpmDbiTagVal rpmtag, |
|
| 386 |
- } |
|
| 387 |
- } |
|
| 388 |
- } |
|
| 389 |
-- |
|
| 390 |
-+ |
|
| 391 |
- return mi; |
|
| 392 |
- } |
|
| 393 |
- |
|
| 394 |
-@@ -1749,9 +1999,9 @@ rpmdbMatchIterator rpmdbInitPrefixIterator(rpmdb db, rpmDbiTagVal rpmtag, |
|
| 395 |
- * Convert current tag data to db key |
|
| 396 |
- * @param tagdata Tag data container |
|
| 397 |
- * @param[out] keylen Length of key |
|
| 398 |
-- * @return Pointer to key value or NULL to signal skip |
|
| 399 |
-+ * @return Pointer to key value or NULL to signal skip |
|
| 400 |
- */ |
|
| 401 |
--static const void * td2key(rpmtd tagdata, unsigned int *keylen) |
|
| 402 |
-+static const void * td2key(rpmtd tagdata, unsigned int *keylen) |
|
| 403 |
- {
|
|
| 404 |
- const void * data = NULL; |
|
| 405 |
- unsigned int size = 0; |
|
| 406 |
-@@ -1893,7 +2143,7 @@ int rpmdbIndexIteratorNextTd(rpmdbIndexIterator ii, rpmtd keytd) |
|
| 407 |
- break; |
|
| 408 |
- } |
|
| 409 |
- } |
|
| 410 |
-- |
|
| 411 |
-+ |
|
| 412 |
- return rc; |
|
| 413 |
- } |
|
| 414 |
- |
|
| 415 |
-@@ -1960,11 +2210,11 @@ static void logAddRemove(const char *dbiname, int removing, rpmtd tagdata) |
|
| 416 |
- rpm_count_t c = rpmtdCount(tagdata); |
|
| 417 |
- if (c == 1 && rpmtdType(tagdata) == RPM_STRING_TYPE) {
|
|
| 418 |
- rpmlog(RPMLOG_DEBUG, "%s \"%s\" %s %s index.\n", |
|
| 419 |
-- removing ? "removing" : "adding", rpmtdGetString(tagdata), |
|
| 420 |
-+ removing ? "removing" : "adding", rpmtdGetString(tagdata), |
|
| 421 |
- removing ? "from" : "to", dbiname); |
|
| 422 |
- } else if (c > 0) {
|
|
| 423 |
- rpmlog(RPMLOG_DEBUG, "%s %d entries %s %s index.\n", |
|
| 424 |
-- removing ? "removing" : "adding", c, |
|
| 425 |
-+ removing ? "removing" : "adding", c, |
|
| 426 |
- removing ? "from" : "to", dbiname); |
|
| 427 |
- } |
|
| 428 |
- } |
|
| 429 |
-@@ -2237,7 +2487,7 @@ int rpmdbAdd(rpmdb db, Header h) |
|
| 430 |
- ret = pkgdbOpen(db, 0, &dbi); |
|
| 431 |
- if (ret) |
|
| 432 |
- goto exit; |
|
| 433 |
-- |
|
| 434 |
-+ |
|
| 435 |
- rpmsqBlock(SIG_BLOCK); |
|
| 436 |
- dbCtrl(db, DB_CTRL_LOCK_RW); |
|
| 437 |
- |
|
| 438 |
-@@ -2247,7 +2497,7 @@ int rpmdbAdd(rpmdb db, Header h) |
|
| 439 |
- dbiCursorFree(dbi, dbc); |
|
| 440 |
- |
|
| 441 |
- /* Add associated data to secondary indexes */ |
|
| 442 |
-- if (ret == 0) {
|
|
| 443 |
-+ if (ret == 0) {
|
|
| 444 |
- for (int dbix = 0; dbix < db->db_ndbi; dbix++) {
|
|
| 445 |
- rpmDbiTag rpmtag = db->db_tags[dbix]; |
|
| 446 |
- |
|
| 447 |
-@@ -2293,7 +2543,7 @@ static int rpmdbRemoveFiles(char * pattern) |
|
| 448 |
- |
|
| 449 |
- static int rpmdbRemoveDatabase(const char *dbpath) |
|
| 450 |
- {
|
|
| 451 |
-- int rc = 0; |
|
| 452 |
-+ int rc = 0; |
|
| 453 |
- char *pattern; |
|
| 454 |
- |
|
| 455 |
- pattern = rpmGetPath(dbpath, "/*", NULL); |
|
| 456 |
-@@ -2302,11 +2552,23 @@ static int rpmdbRemoveDatabase(const char *dbpath) |
|
| 457 |
- pattern = rpmGetPath(dbpath, "/.??*", NULL); |
|
| 458 |
- rc += rpmdbRemoveFiles(pattern); |
|
| 459 |
- free(pattern); |
|
| 460 |
-- |
|
| 461 |
-+ |
|
| 462 |
- rc += rmdir(dbpath); |
|
| 463 |
- return rc; |
|
| 464 |
- } |
|
| 465 |
- |
|
| 466 |
-+static int rpmdb_rename(const char *oldpath, const char *newpath) |
|
| 467 |
-+{
|
|
| 468 |
-+ int ret; |
|
| 469 |
-+ |
|
| 470 |
-+ ret = rename(oldpath, newpath); |
|
| 471 |
-+ if (ret != 0 && errno == EXDEV) {
|
|
| 472 |
-+ ret = rename_dir(oldpath, newpath); |
|
| 473 |
-+ } |
|
| 474 |
-+ |
|
| 475 |
-+ return ret; |
|
| 476 |
-+} |
|
| 477 |
-+ |
|
| 478 |
- static int rpmdbMoveDatabase(const char * prefix, const char * srcdbpath, |
|
| 479 |
- const char * dbpath, const char * tmppath) |
|
| 480 |
- {
|
|
| 481 |
-@@ -2319,14 +2581,14 @@ static int rpmdbMoveDatabase(const char * prefix, const char * srcdbpath, |
|
| 482 |
- char * oldkeys = rpmGetPath(old, "/", "pubkeys", NULL); |
|
| 483 |
- char * destkeys = rpmGetPath(dest, "/", "pubkeys", NULL); |
|
| 484 |
- |
|
| 485 |
-- xx = rename(dest, old); |
|
| 486 |
-+ xx = rpmdb_rename(dest, old); |
|
| 487 |
- if (xx) {
|
|
| 488 |
- goto exit; |
|
| 489 |
- } |
|
| 490 |
-- xx = rename(src, dest); |
|
| 491 |
-+ xx = rpmdb_rename(src, dest); |
|
| 492 |
- if (xx) {
|
|
| 493 |
- rpmlog(RPMLOG_ERR, _("could not move new database in place\n"));
|
|
| 494 |
-- xx = rename(old, dest); |
|
| 495 |
-+ xx = rpmdb_rename(old, dest); |
|
| 496 |
- if (xx) {
|
|
| 497 |
- rpmlog(RPMLOG_ERR, _("could also not restore old database from %s\n"),
|
|
| 498 |
- old); |
|
| 499 |
-@@ -2337,7 +2599,7 @@ static int rpmdbMoveDatabase(const char * prefix, const char * srcdbpath, |
|
| 500 |
- } |
|
| 501 |
- |
|
| 502 |
- if (access(oldkeys, F_OK ) != -1) {
|
|
| 503 |
-- xx = rename(oldkeys, destkeys); |
|
| 504 |
-+ xx = rpmdb_rename(oldkeys, destkeys); |
|
| 505 |
- if (xx) {
|
|
| 506 |
- rpmlog(RPMLOG_ERR, _("Could not get public keys from %s\n"), oldkeys);
|
|
| 507 |
- goto exit; |
|
| 508 |
-@@ -2368,7 +2630,7 @@ static int rpmdbSetPermissions(char * src, char * dest) |
|
| 509 |
- struct stat st; |
|
| 510 |
- int xx, rc = -1; |
|
| 511 |
- char * filepath; |
|
| 512 |
-- |
|
| 513 |
-+ |
|
| 514 |
- if (stat(dest, &st) < 0) |
|
| 515 |
- goto exit; |
|
| 516 |
- if (stat(src, &st) < 0) |
|
| 517 |
-@@ -2501,7 +2763,7 @@ int rpmdbRebuild(const char * prefix, rpmts ts, |
|
| 518 |
- rpmdbClose(newdb); |
|
| 519 |
- |
|
| 520 |
- if (failed) {
|
|
| 521 |
-- rpmlog(RPMLOG_WARNING, |
|
| 522 |
-+ rpmlog(RPMLOG_WARNING, |
|
| 523 |
- _("failed to rebuild database: original database "
|
|
| 524 |
- "remains in place\n")); |
|
| 525 |
- |
|
| 526 |
-2.39.0 |
|
| 527 |
- |
| ... | ... |
@@ -8,9 +8,9 @@ |
| 8 | 8 |
"full-package-list-file" : "build_install_options_all.json", |
| 9 | 9 |
"pkg-build-options" : "pkg_build_options.json", |
| 10 | 10 |
|
| 11 |
- "photon-docker-image" : "photon:4.0", |
|
| 12 |
- "ph-docker-img-url" : "https://github.com/vmware/photon-docker-image/raw/ARCH/4.0-20220715/docker/photon-rootfs-4.0-fe8804ac9.tar.gz", |
|
| 13 |
- "ph-builder-tag" : "photon_builder:4.0", |
|
| 11 |
+ "photon-docker-image" : "photon:5.0", |
|
| 12 |
+ "ph-docker-img-url" : "https://github.com/vmware/photon-docker-image/raw/ARCH/5.0-20230128/docker/photon-rootfs-5.0-9e778f409.tar.gz", |
|
| 13 |
+ "ph-builder-tag" : "photon_builder:5.0", |
|
| 14 | 14 |
|
| 15 | 15 |
"build-src-rpm" : true, |
| 16 | 16 |
"build-dbginfo-rpm" : true, |
| ... | ... |
@@ -703,8 +703,10 @@ class RpmBuildTarget: |
| 703 | 703 |
): |
| 704 | 704 |
print("Creating OSTree repo from local RPMs in ostree-repo.tar.gz...")
|
| 705 | 705 |
RpmBuildTarget.create_repo() |
| 706 |
- cmd = f"{photonDir}/support/image-builder/ostree-tools/make-ostree-image.sh"
|
|
| 707 |
- cmd = f"{cmd} {photonDir} {Build_Config.stagePath} {constants.buildArch} {ph_docker_img}"
|
|
| 706 |
+ cmd = ( |
|
| 707 |
+ f"{photonDir}/support/image-builder/ostree-tools/make-ostree-image.sh"
|
|
| 708 |
+ f" {photonDir} {Build_Config.stagePath} {constants.releaseVersion} {ph_docker_img}"
|
|
| 709 |
+ ) |
|
| 708 | 710 |
if runShellCmd(cmd): |
| 709 | 711 |
raise Exception("Not able to execute make-ostree-image.sh")
|
| 710 | 712 |
else: |
| ... | ... |
@@ -908,8 +910,10 @@ class CheckTools: |
| 908 | 908 |
|
| 909 | 909 |
ph_docker_img_url = ph_docker_img_url.replace("ARCH", constants.currentArch)
|
| 910 | 910 |
|
| 911 |
- cmd = f"{photonDir}/tools/scripts/ph4-docker-img-import.sh {ph_docker_img_url}"
|
|
| 912 |
- cmd = f"{cmd} {ph_docker_img} {ph_builder_tag}"
|
|
| 911 |
+ cmd = ( |
|
| 912 |
+ f"{photonDir}/tools/scripts/ph-docker-img-import.sh {ph_docker_img_url}"
|
|
| 913 |
+ f" {ph_docker_img} {ph_builder_tag}"
|
|
| 914 |
+ ) |
|
| 913 | 915 |
runShellCmd(cmd) |
| 914 | 916 |
|
| 915 | 917 |
def check_contain(): |
| ... | ... |
@@ -1139,12 +1143,14 @@ class BuildImage: |
| 1139 | 1139 |
docker_file_dir = "support/dockerfiles/photon" |
| 1140 | 1140 |
docker_script = f"{docker_file_dir}/make-docker-image.sh"
|
| 1141 | 1141 |
|
| 1142 |
- cmd = f"cd {photonDir} &&"
|
|
| 1143 |
- cmd = f"{cmd} sudo docker build --no-cache --tag photon-build {docker_file_dir}"
|
|
| 1144 |
- cmd = f"{cmd} && sudo docker run --rm --privileged --net=host "
|
|
| 1145 |
- cmd = f"{cmd} -e PHOTON_BUILD_NUMBER={constants.buildNumber}"
|
|
| 1146 |
- cmd = f"{cmd} -e PHOTON_RELEASE_VERSION={constants.releaseVersion}"
|
|
| 1147 |
- cmd = f"{cmd} -v {photonDir}:/workspace photon-build {docker_script}"
|
|
| 1142 |
+ cmd = ( |
|
| 1143 |
+ f"cd {photonDir} &&"
|
|
| 1144 |
+ f" sudo docker build --no-cache --tag photon-build {docker_file_dir}"
|
|
| 1145 |
+ f" && sudo docker run --rm --privileged --net=host" |
|
| 1146 |
+ f" -e PHOTON_BUILD_NUMBER={constants.buildNumber}"
|
|
| 1147 |
+ f" -e PHOTON_RELEASE_VERSION={constants.releaseVersion}"
|
|
| 1148 |
+ f" -v {photonDir}:/workspace photon-build {docker_script}"
|
|
| 1149 |
+ ) |
|
| 1148 | 1150 |
|
| 1149 | 1151 |
runShellCmd(cmd) |
| 1150 | 1152 |
check_prerequesite["photon-docker-image"] = True |
| ... | ... |
@@ -1335,6 +1341,8 @@ def initialize_constants(): |
| 1335 | 1335 |
) |
| 1336 | 1336 |
constants.setCompressionMacro(configdict["photon-build-param"]["compression-macro"]) |
| 1337 | 1337 |
|
| 1338 |
+ constants.setPhotonDir(photonDir) |
|
| 1339 |
+ |
|
| 1338 | 1340 |
constants.phBuilderTag = configdict["photon-build-param"]["ph-builder-tag"] |
| 1339 | 1341 |
|
| 1340 | 1342 |
constants.buildSrcRpm = int(configdict["photon-build-param"]["build-src-rpm"]) |
| ... | ... |
@@ -66,11 +66,3 @@ sed -i 's/$photon_cmdline/init=\/lib\/systemd\/systemd loglevel=3 ro console=tty |
| 66 | 66 |
|
| 67 | 67 |
# Remove kernel symbols |
| 68 | 68 |
rm -f /boot/System.map* |
| 69 |
- |
|
| 70 |
-# Added as a part of rpm db migration from BDB to sqlite |
|
| 71 |
-# No harm in cross checking here |
|
| 72 |
-if [ -f /var/lib/rpm/Packages ]; then |
|
| 73 |
- if ! rpmdb --rebuilddb; then |
|
| 74 |
- echo "WARNING: Failed rebuild rpmdb" 1>&2 |
|
| 75 |
- fi |
|
| 76 |
-fi |
| ... | ... |
@@ -55,11 +55,3 @@ rm /boot/system.map* |
| 55 | 55 |
|
| 56 | 56 |
waagent -force -deprovision+user |
| 57 | 57 |
export HISTSIZE=0 |
| 58 |
- |
|
| 59 |
-# Added as a part of rpm db migration from BDB to sqlite |
|
| 60 |
-# No harm in cross checking here |
|
| 61 |
-if [ -f /var/lib/rpm/Packages ]; then |
|
| 62 |
- if ! rpmdb --rebuilddb; then |
|
| 63 |
- echo "WARNING: Failed rebuild rpmdb" 1>&2 |
|
| 64 |
- fi |
|
| 65 |
-fi |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
{
|
| 2 | 2 |
"installer": {
|
| 3 | 3 |
"hostname": "photon-machine", |
| 4 |
- "postinstallscripts": [ "gce-patch.sh" ], |
|
| 4 |
+ "postinstallscripts": [ "gce-patch.sh", "../relocate-rpmdb.sh" ], |
|
| 5 | 5 |
"additional_files": [ |
| 6 | 6 |
{"cloud-photon.cfg": "/etc/cloud/cloud.cfg"},
|
| 7 | 7 |
{"ntpd.service": "/usr/lib/systemd/system/ntpd.service"}
|
| ... | ... |
@@ -104,11 +104,3 @@ chmod a+x /usr/bin/gcloud |
| 104 | 104 |
chmod a+x /usr/bin/gsutil |
| 105 | 105 |
|
| 106 | 106 |
sed -i 's/$photon_cmdline $systemd_cmdline/init=\/lib\/systemd\/systemd loglevel=3 ro console=ttyS0,38400n8/' /boot/grub/grub.cfg |
| 107 |
- |
|
| 108 |
-# Added as a part of rpm db migration from BDB to sqlite |
|
| 109 |
-# No harm in cross checking here |
|
| 110 |
-if [ -f /var/lib/rpm/Packages ]; then |
|
| 111 |
- if ! rpmdb --rebuilddb; then |
|
| 112 |
- echo "WARNING: Failed rebuild rpmdb" 1>&2 |
|
| 113 |
- fi |
|
| 114 |
-fi |
| ... | ... |
@@ -1,7 +1,12 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
|
| 3 |
-set -e |
|
| 4 |
-set -x |
|
| 3 |
+set -ex |
|
| 4 |
+ |
|
| 5 |
+abort() |
|
| 6 |
+{
|
|
| 7 |
+ echo -e "$*" 1>&2 |
|
| 8 |
+ exit 1 |
|
| 9 |
+} |
|
| 5 | 10 |
|
| 6 | 11 |
SCRIPT_PATH=$(dirname $(realpath -s $0)) |
| 7 | 12 |
PRGNAME=${0##*/} # script name minus the path
|
| ... | ... |
@@ -52,16 +57,6 @@ clean_requirements_on_remove=true |
| 52 | 52 |
repodir=${WORKINGDIR}
|
| 53 | 53 |
EOF |
| 54 | 54 |
|
| 55 |
-rpmdb_init_cmd="rpm --root ${INITRD} --initdb --dbpath /var/lib/rpm"
|
|
| 56 |
-if [ "$(rpm -E %{_db_backend})" != "sqlite" ]; then
|
|
| 57 |
- rpmdb_init_cmd="docker run --rm -v ${INITRD}:${INITRD} $PH_BUILDER_TAG /bin/bash -c \"${rpmdb_init_cmd}\""
|
|
| 58 |
-fi |
|
| 59 |
- |
|
| 60 |
-if ! eval "${rpmdb_init_cmd}"; then
|
|
| 61 |
- echo "ERROR: failed to initialize rpmdb" 1>&2 |
|
| 62 |
- exit 1 |
|
| 63 |
-fi |
|
| 64 |
- |
|
| 65 | 55 |
TDNF_CMD="tdnf install -qy \ |
| 66 | 56 |
--releasever $PHOTON_RELEASE_VER \ |
| 67 | 57 |
--installroot $INITRD \ |
| ... | ... |
@@ -72,6 +67,16 @@ TDNF_CMD="tdnf install -qy \ |
| 72 | 72 |
# run host's tdnf, if fails - try one from photon:latest docker image |
| 73 | 73 |
$TDNF_CMD || docker run --rm -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR $PHOTON_DOCKER_IMAGE /bin/bash -c "$TDNF_CMD" |
| 74 | 74 |
|
| 75 |
+if ! cp -p ${SCRIPT_PATH}/../../relocate-rpmdb.sh ${INITRD}; then
|
|
| 76 |
+ abort "ERROR: failed to copy ${SCRIPT_PATH}/relocate-rpmdb.sh to ${INITRD}"
|
|
| 77 |
+fi |
|
| 78 |
+ |
|
| 79 |
+if ! chroot ${INITRD} ./relocate-rpmdb.sh; then
|
|
| 80 |
+ abort "ERROR: failed to fix rpmdb" |
|
| 81 |
+fi |
|
| 82 |
+ |
|
| 83 |
+rm -f ${INITRD}/relocate-rpmdb.sh
|
|
| 84 |
+ |
|
| 75 | 85 |
rm -f ${WORKINGDIR}/photon-local.repo ${WORKINGDIR}/tdnf.conf
|
| 76 | 86 |
|
| 77 | 87 |
# 3. finalize initrd system (mk-finalize-system.sh) |
| ... | ... |
@@ -139,7 +144,7 @@ cp $SCRIPT_PATH/BUILD_DVD/fstab ${INITRD}/etc/fstab
|
| 139 | 139 |
mkdir -p ${INITRD}/etc/yum.repos.d
|
| 140 | 140 |
cat > ${INITRD}/etc/yum.repos.d/photon-iso.repo << EOF
|
| 141 | 141 |
[photon-iso] |
| 142 |
-name=VMWare Photon Linux 1.0(x86_64) |
|
| 142 |
+name=VMWare Photon Linux 5.0(x86_64) |
|
| 143 | 143 |
baseurl=file:///mnt/media/RPMS |
| 144 | 144 |
gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY |
| 145 | 145 |
gpgcheck=1 |
| ... | ... |
@@ -8,23 +8,24 @@ if [ "$#" -lt 0 ]; then |
| 8 | 8 |
exit 1 |
| 9 | 9 |
fi |
| 10 | 10 |
|
| 11 |
-PROGRAM=$0 |
|
| 12 |
-SRCROOT=$1 |
|
| 13 |
-STAGE_DIR=$2 |
|
| 14 |
-ARCHITECTURE=$3 |
|
| 15 |
-PHOTON_DOCKER_IMAGE=$4 |
|
| 16 |
- |
|
| 17 |
-cat > ${SRCROOT}/support/image-builder/ostree-tools/photon-base.json<< EOF
|
|
| 11 |
+SRCROOT="$1" |
|
| 12 |
+STAGE_DIR="$2" |
|
| 13 |
+PH_VERSION="$3" |
|
| 14 |
+PHOTON_DOCKER_IMAGE="$4" |
|
| 15 |
+ARCHITECTURE="$(uname -m)" |
|
| 16 |
+SCRIPT_PATH="$(dirname "$(realpath ${BASH_SOURCE[0]})")"
|
|
| 17 |
+ |
|
| 18 |
+cat > ${SCRIPT_PATH}/photon-base.json << EOF
|
|
| 18 | 19 |
{
|
| 19 | 20 |
"comment": "Photon Minimal OSTree", |
| 20 | 21 |
|
| 21 | 22 |
"osname": "photon", |
| 22 | 23 |
|
| 23 |
- "releasever": "5.0", |
|
| 24 |
+ "releasever": "${PH_VERSION}",
|
|
| 24 | 25 |
|
| 25 |
- "ref": "photon/5.0/${ARCHITECTURE}/minimal",
|
|
| 26 |
+ "ref": "photon/${PH_VERSION}/${ARCHITECTURE}/minimal",
|
|
| 26 | 27 |
|
| 27 |
- "automatic_version_prefix": "5.0_minimal", |
|
| 28 |
+ "automatic_version_prefix": "${PH_VERSION}_minimal",
|
|
| 28 | 29 |
|
| 29 | 30 |
"repos": ["photon-ostree"], |
| 30 | 31 |
|
| ... | ... |
@@ -53,37 +54,72 @@ cat > ${SRCROOT}/support/image-builder/ostree-tools/photon-base.json<< EOF
|
| 53 | 53 |
} |
| 54 | 54 |
EOF |
| 55 | 55 |
|
| 56 |
-cat > ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh << EOF
|
|
| 56 |
+cat > ${SCRIPT_PATH}/mk-ostree-server.sh << EOF
|
|
| 57 | 57 |
#!/bin/bash |
| 58 | 58 |
|
| 59 | 59 |
ROOT=$1 |
| 60 | 60 |
|
| 61 |
-cp photon-ostree.repo /etc/yum.repos.d |
|
| 61 |
+cat > /etc/yum.repos.d/photon-ostree.repo << EOT |
|
| 62 |
+[photon-ostree] |
|
| 63 |
+name=VMware Photon OSTree Linux ${PH_VERSION}($ARCHITECTURE)
|
|
| 64 |
+gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY-4096 |
|
| 65 |
+gpgcheck=0 |
|
| 66 |
+enabled=1 |
|
| 67 |
+skip_if_unavailable=True |
|
| 68 |
+baseurl=file:///RPMS |
|
| 69 |
+EOT |
|
| 70 |
+ |
|
| 71 |
+cat > photon-ostree.repo << EOT |
|
| 72 |
+[photon-ostree] |
|
| 73 |
+name=VMware Photon OSTree Linux ${PH_VERSION}($ARCHITECTURE)
|
|
| 74 |
+gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY-4096 |
|
| 75 |
+gpgcheck=0 |
|
| 76 |
+enabled=1 |
|
| 77 |
+skip_if_unavailable=True |
|
| 78 |
+baseurl=file:///RPMS |
|
| 79 |
+EOT |
|
| 80 |
+ |
|
| 62 | 81 |
if ! tdnf install -y rpm ostree rpm-ostree --disablerepo=* --enablerepo=photon-ostree; then |
| 63 | 82 |
echo "ERROR: failed to install packages while preparing ostree server" 1>&2 |
| 64 | 83 |
exit 1 |
| 65 | 84 |
fi |
| 66 | 85 |
|
| 67 | 86 |
mkdir -p ${ROOT}/srv/rpm-ostree
|
| 68 |
-ostree --repo=${ROOT}/srv/rpm-ostree/repo init --mode=archive-z2
|
|
| 69 |
-rpm-ostree compose tree --repo=${ROOT}/srv/rpm-ostree/repo photon-base.json
|
|
| 87 |
+if ! ostree --repo=${ROOT}/srv/rpm-ostree/repo init --mode=archive-z2; then
|
|
| 88 |
+ echo "ERROR: ostree init failed" 1>&2 |
|
| 89 |
+ exit 1 |
|
| 90 |
+fi |
|
| 91 |
+ |
|
| 92 |
+if ! rpm-ostree compose tree --repo=${ROOT}/srv/rpm-ostree/repo photon-base.json; then
|
|
| 93 |
+ echo "ERROR: rpm-ostree compose failed" 1>&2 |
|
| 94 |
+ exit 1 |
|
| 95 |
+fi |
|
| 70 | 96 |
EOF |
| 71 | 97 |
|
| 72 |
-chmod +x ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh
|
|
| 98 |
+chmod +x ${SCRIPT_PATH}/mk-ostree-server.sh
|
|
| 73 | 99 |
|
| 74 | 100 |
rm -rf ${STAGE_DIR}/ostree-repo
|
| 75 | 101 |
mkdir -p ${STAGE_DIR}/ostree-repo
|
| 76 | 102 |
|
| 77 |
-sudo docker run --privileged -v ${SRCROOT}:/photon \
|
|
| 103 |
+sudo docker run --rm --privileged -v ${SRCROOT}:/photon \
|
|
| 78 | 104 |
-v ${STAGE_DIR}/RPMS:/RPMS \
|
| 79 | 105 |
-v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree \
|
| 80 | 106 |
-w="/photon/support/image-builder/ostree-tools/" \ |
| 81 | 107 |
${PHOTON_DOCKER_IMAGE} ./mk-ostree-server.sh /
|
| 82 | 108 |
|
| 109 |
+if [ $? -ne 0 ]; then |
|
| 110 |
+ echo "ERROR: mk-ostree-server.sh failed" 1>&2 |
|
| 111 |
+ exit 1 |
|
| 112 |
+fi |
|
| 113 |
+ |
|
| 83 | 114 |
REPODIR=${STAGE_DIR}/ostree-repo/repo
|
| 84 | 115 |
if [ -d "$REPODIR" ]; then |
| 85 |
- tar -zcf ${STAGE_DIR}/ostree-repo.tar.gz -C ${REPODIR} .
|
|
| 116 |
+ if ! tar -zcf ${STAGE_DIR}/ostree-repo.tar.gz -C ${REPODIR} .; then
|
|
| 117 |
+ echo "ERROR: tar ostree-repo.tar.gz failed" 1>&2 |
|
| 118 |
+ exit 1 |
|
| 119 |
+ fi |
|
| 86 | 120 |
fi |
| 87 | 121 |
|
| 88 |
-sudo rm -rf ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh \
|
|
| 89 |
- ${STAGE_DIR}/ostree-repo
|
|
| 122 |
+sudo rm -rf ${SCRIPT_PATH}/mk-ostree-server.sh \
|
|
| 123 |
+ ${STAGE_DIR}/ostree-repo \
|
|
| 124 |
+ ${SCRIPT_PATH}/photon-base.json
|
| 90 | 125 |
deleted file mode 100644 |
| ... | ... |
@@ -1,7 +0,0 @@ |
| 1 |
-[photon-ostree] |
|
| 2 |
-name=VMware Photon OSTree Linux 5.0(x86_64) |
|
| 3 |
-gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY-4096 |
|
| 4 |
-gpgcheck=0 |
|
| 5 |
-enabled=1 |
|
| 6 |
-skip_if_unavailable=True |
|
| 7 |
-baseurl=file:///RPMS |
| ... | ... |
@@ -18,7 +18,7 @@ |
| 18 | 18 |
{"resizefs.sh": "/usr/local/bin/resizefs.sh"},
|
| 19 | 19 |
{"resizefs.service": "/lib/systemd/system/resizefs.service"}
|
| 20 | 20 |
], |
| 21 |
- "postinstallscripts": ["rpi-custom-patch.sh" ], |
|
| 21 |
+ "postinstallscripts": [ "rpi-custom-patch.sh", "../relocate-rpmdb.sh" ], |
|
| 22 | 22 |
"linux_flavor": "linux" |
| 23 | 23 |
}, |
| 24 | 24 |
"image_type": "rpi", |
| ... | ... |
@@ -66,6 +66,7 @@ class ToolChainUtils(object): |
| 66 | 66 |
rpmFiles = "" |
| 67 | 67 |
packages = "" |
| 68 | 68 |
listBuildRequiresPackages = [] |
| 69 |
+ ChrootID= chroot.getID() |
|
| 69 | 70 |
|
| 70 | 71 |
listRPMsToInstall=list(constants.listToolChainRPMsToInstall) |
| 71 | 72 |
if constants.crossCompiling: |
| ... | ... |
@@ -78,8 +79,8 @@ class ToolChainUtils(object): |
| 78 | 78 |
if packageName: |
| 79 | 79 |
listBuildRequiresPackages = self.getListDependentPackages(packageName, packageVersion) |
| 80 | 80 |
|
| 81 |
+ pkgUtils = PackageUtils(self.logName, self.logPath) |
|
| 81 | 82 |
for package in listRPMsToInstall: |
| 82 |
- pkgUtils = PackageUtils(self.logName, self.logPath) |
|
| 83 | 83 |
rpmFile = None |
| 84 | 84 |
version = None |
| 85 | 85 |
|
| ... | ... |
@@ -127,30 +128,33 @@ class ToolChainUtils(object): |
| 127 | 127 |
if rpmFile is None: |
| 128 | 128 |
self.logger.error("Unable to find published rpm " + package)
|
| 129 | 129 |
raise Exception("Input Error")
|
| 130 |
- rpmFiles += " " + rpmFile |
|
| 131 |
- packages += " " + package+"-"+version |
|
| 130 |
+ rpmFiles += f" {rpmFile}"
|
|
| 131 |
+ packages += f" {package}-{version}"
|
|
| 132 | 132 |
|
| 133 | 133 |
self.logger.debug(rpmFiles) |
| 134 | 134 |
self.logger.debug(packages) |
| 135 |
- cmd = (self.rpmCommand + " -i -v --nodeps --noorder --force --root " + |
|
| 136 |
- chroot.getID() + " -D \'_dbpath /var/lib/rpm\' " + rpmFiles) |
|
| 135 |
+ cmd = f"{self.rpmCommand} -iv --nodeps --force --root {ChrootID} {rpmFiles}"
|
|
| 137 | 136 |
|
| 138 | 137 |
# If rpm doesn't have zstd support, use rpm from photon_builder image |
| 139 | 138 |
if constants.checkIfHostRpmNotUsable(): |
| 140 | 139 |
# if we are not root, make installed files owned by effective user to |
| 141 | 140 |
# support pure non-root package building. |
| 142 | 141 |
if os.geteuid(): |
| 143 |
- cmd = cmd + "; chown -R {0}:{1} {2}".format(os.geteuid(), os.getegid(), chroot.getID())
|
|
| 144 |
- cmd = ("docker run --rm -i -v " + constants.prevPublishRPMRepo + ":" + constants.prevPublishRPMRepo +
|
|
| 145 |
- " -v " + constants.inputRPMSPath + ":" + constants.inputRPMSPath + |
|
| 146 |
- " -v " + constants.rpmPath + ":" + constants.rpmPath + " -v " + chroot.getID() + ":" + |
|
| 147 |
- chroot.getID() + " " + constants.phBuilderTag + " /bin/bash -c \"" + cmd + "\"") |
|
| 148 |
- |
|
| 149 |
- self.logger.debug("Executing cmd: " + cmd)
|
|
| 142 |
+ cmd = cmd + "; chown -R {0}:{1} {ChrootID}".format(os.geteuid(), os.getegid())
|
|
| 143 |
+ cmd = ( |
|
| 144 |
+ f"docker run --rm -i" |
|
| 145 |
+ f" -v {constants.prevPublishRPMRepo}:{constants.prevPublishRPMRepo}"
|
|
| 146 |
+ f" -v {constants.inputRPMSPath}:{constants.inputRPMSPath}"
|
|
| 147 |
+ f" -v {constants.rpmPath}:{constants.rpmPath} -v {ChrootID}:{ChrootID}"
|
|
| 148 |
+ f" {constants.phBuilderTag}"
|
|
| 149 |
+ f" /bin/bash -c \"{cmd}\""
|
|
| 150 |
+ ) |
|
| 151 |
+ |
|
| 152 |
+ self.logger.debug(f"Executing cmd: {cmd}")
|
|
| 150 | 153 |
if CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug): |
| 151 | 154 |
self.logger.error("Installing toolchain RPMS failed")
|
| 152 | 155 |
raise Exception("RPM installation failed")
|
| 153 |
- self.logger.debug("Successfully installed default toolchain RPMS in Chroot:" + chroot.getID())
|
|
| 156 |
+ self.logger.debug(f"Successfully installed default toolchain RPMS in Chroot: {ChrootID}")
|
|
| 154 | 157 |
|
| 155 | 158 |
if packageName: |
| 156 | 159 |
self.installExtraToolchainRPMS(chroot, packageName, packageVersion) |
| ... | ... |
@@ -162,12 +166,13 @@ class ToolChainUtils(object): |
| 162 | 162 |
listOfToolChainPkgs = SPECS.getData(constants.buildArch).getExtraBuildRequiresForPackage(packageName, packageVersion) |
| 163 | 163 |
if not listOfToolChainPkgs: |
| 164 | 164 |
return |
| 165 |
- self.logger.debug("Installing package specific toolchain RPMs for " + packageName +
|
|
| 166 |
- ": " + str(listOfToolChainPkgs)) |
|
| 165 |
+ self.logger.debug(f"Installing package specific toolchain RPMs for {packageName}: " +
|
|
| 166 |
+ str(listOfToolChainPkgs)) |
|
| 167 | 167 |
rpmFiles = "" |
| 168 | 168 |
packages = "" |
| 169 |
+ |
|
| 170 |
+ pkgUtils = PackageUtils(self.logName, self.logPath) |
|
| 169 | 171 |
for package in listOfToolChainPkgs: |
| 170 |
- pkgUtils = PackageUtils(self.logName, self.logPath) |
|
| 171 | 172 |
if re.match("openjre*", packageName) is not None or re.match("openjdk*", packageName):
|
| 172 | 173 |
path = constants.prevPublishXRPMRepo |
| 173 | 174 |
sandboxPath = "/publishxrpms" |
| ... | ... |
@@ -176,17 +181,15 @@ class ToolChainUtils(object): |
| 176 | 176 |
sandboxPath = "/publishrpms" |
| 177 | 177 |
rpmFile = self._findPublishedRPM(package, path) |
| 178 | 178 |
if rpmFile is None: |
| 179 |
- self.logger.error("Unable to find rpm "+ package +
|
|
| 180 |
- " in current and previous versions") |
|
| 179 |
+ self.logger.error(f"Unable to find rpm {package} in current and previous versions")
|
|
| 181 | 180 |
raise Exception("Input Error")
|
| 182 | 181 |
rpmFiles += " " + rpmFile.replace(path, sandboxPath) |
| 183 |
- packages += " " + package |
|
| 182 |
+ packages += f" {package}"
|
|
| 184 | 183 |
|
| 185 | 184 |
self.logger.debug("Installing custom rpms:" + packages)
|
| 186 |
- cmd = ("rpm -i -v --nodeps --noorder --force " + rpmFiles)
|
|
| 187 |
- retVal = sandbox.run(cmd, logfn=self.logger.debug) |
|
| 188 |
- if retVal != 0: |
|
| 189 |
- self.logger.debug("Command Executed:" + cmd)
|
|
| 185 |
+ cmd = f"rpm -iv --nodeps --force {rpmFiles}"
|
|
| 186 |
+ if sandbox.run(cmd, logfn=self.logger.debug): |
|
| 187 |
+ self.logger.debug(f"Command Executed: {cmd}")
|
|
| 190 | 188 |
self.logger.error("Installing custom toolchains failed")
|
| 191 | 189 |
raise Exception("RPM installation failed")
|
| 192 | 190 |
|
| ... | ... |
@@ -196,6 +199,8 @@ class ToolChainUtils(object): |
| 196 | 196 |
pkgUtils = PackageUtils(self.logName, self.logPath) |
| 197 | 197 |
rpmFiles = "" |
| 198 | 198 |
packages = "" |
| 199 |
+ ChrootID= chroot.getID() |
|
| 200 |
+ |
|
| 199 | 201 |
for package in constants.listCoreToolChainPackages: |
| 200 | 202 |
if stopAtPackage and package == stopAtPackage: |
| 201 | 203 |
break |
| ... | ... |
@@ -207,21 +212,21 @@ class ToolChainUtils(object): |
| 207 | 207 |
subpackages = SPECS.getData().getRPMPackages(basePkg, version) |
| 208 | 208 |
for p in subpackages: |
| 209 | 209 |
rpmFile = pkgUtils.findRPMFile(p, version, constants.targetArch) |
| 210 |
- rpmFiles += " " + rpmFile |
|
| 211 |
- packages += " " + package+"-"+version |
|
| 210 |
+ rpmFiles += f" {rpmFile}"
|
|
| 211 |
+ packages += f" {package}-{version}"
|
|
| 212 | 212 |
|
| 213 | 213 |
self.logger.debug(packages) |
| 214 | 214 |
|
| 215 |
- cmd = "mkdir -p " + chroot.getID() +"/target-"+ constants.targetArch+"/var/lib/rpm" |
|
| 215 |
+ cmd = f"mkdir -p {ChrootID}/target-{constants.targetArch}"
|
|
| 216 | 216 |
CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug) |
| 217 | 217 |
|
| 218 | 218 |
if rpmFiles != "": |
| 219 |
- cmd = (self.rpmCommand + " -Uvh --nodeps --ignorearch --noscripts --root " + |
|
| 220 |
- chroot.getID() + "/target-" + |
|
| 221 |
- constants.targetArch + " -D \'_dbpath /var/lib/rpm\' " + rpmFiles) |
|
| 222 |
- retVal = CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug) |
|
| 223 |
- if retVal != 0: |
|
| 224 |
- self.logger.debug("Command Executed:" + cmd)
|
|
| 219 |
+ cmd = ( |
|
| 220 |
+ f"{self.rpmCommand} -Uvh --nodeps --ignorearch --noscripts --root"
|
|
| 221 |
+ f" {ChrootID}/target-{constants.targetArch} {rpmFiles}"
|
|
| 222 |
+ ) |
|
| 223 |
+ if CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug): |
|
| 224 |
+ self.logger.debug(f"Command Executed: {cmd}")
|
|
| 225 | 225 |
self.logger.error("Installing toolchain failed")
|
| 226 | 226 |
raise Exception("RPM installation failed")
|
| 227 |
- self.logger.debug("Successfully installed target toolchain RPMS in chroot:" + chroot.getID())
|
|
| 227 |
+ self.logger.debug(f"Successfully installed target toolchain RPMS in chroot: {ChrootID}")
|
| ... | ... |
@@ -43,6 +43,7 @@ class constants(object): |
| 43 | 43 |
currentArch = buildArch |
| 44 | 44 |
hostRpmIsNotUsable = -1 |
| 45 | 45 |
phBuilderTag = "" |
| 46 |
+ photonDir = "" |
|
| 46 | 47 |
buildSrcRpm = 0 |
| 47 | 48 |
buildDbgInfoRpm = 0 |
| 48 | 49 |
buildDbgInfoRpmList = [] |
| ... | ... |
@@ -483,6 +484,10 @@ class constants(object): |
| 483 | 483 |
constants.testForceRPMS = listsPackages |
| 484 | 484 |
|
| 485 | 485 |
@staticmethod |
| 486 |
+ def setPhotonDir(phDir): |
|
| 487 |
+ constants.photonDir = phDir |
|
| 488 |
+ |
|
| 489 |
+ @staticmethod |
|
| 486 | 490 |
def addMacro(macroName, macroValue): |
| 487 | 491 |
constants.userDefinedMacros[macroName] = macroValue |
| 488 | 492 |
|
| ... | ... |
@@ -509,6 +514,7 @@ class constants(object): |
| 509 | 509 |
cmds = [ |
| 510 | 510 |
"rpm --showrc | grep -qw 'rpmlib(PayloadIsZstd)'", |
| 511 | 511 |
"rpm -E %{_db_backend} | grep -qw 'sqlite'",
|
| 512 |
+ "rpm -E %{_dbpath} | grep -qw '/usr/lib/sysimage/rpm'",
|
|
| 512 | 513 |
] |
| 513 | 514 |
|
| 514 | 515 |
for cmd in cmds: |
| ... | ... |
@@ -83,10 +83,10 @@ aarch64/python3-3.11.0-2.ph4.aarch64.rpm |
| 83 | 83 |
aarch64/python3-libs-3.11.0-2.ph4.aarch64.rpm |
| 84 | 84 |
aarch64/readline-8.2-1.ph4.aarch64.rpm |
| 85 | 85 |
aarch64/readline-devel-8.2-1.ph4.aarch64.rpm |
| 86 |
-aarch64/rpm-4.16.1.3-7.ph4.aarch64.rpm |
|
| 87 |
-aarch64/rpm-build-4.16.1.3-7.ph4.aarch64.rpm |
|
| 88 |
-aarch64/rpm-devel-4.16.1.3-7.ph4.aarch64.rpm |
|
| 89 |
-aarch64/rpm-libs-4.16.1.3-7.ph4.aarch64.rpm |
|
| 86 |
+aarch64/rpm-4.18.0-7.ph5.aarch64.rpm |
|
| 87 |
+aarch64/rpm-build-4.18.0-7.ph5.aarch64.rpm |
|
| 88 |
+aarch64/rpm-devel-4.18.0-7.ph5.aarch64.rpm |
|
| 89 |
+aarch64/rpm-libs-4.18.0-7.ph5.aarch64.rpm |
|
| 90 | 90 |
aarch64/sed-4.8-1.ph4.aarch64.rpm |
| 91 | 91 |
aarch64/sqlite-3.39.4-2.ph4.aarch64.rpm |
| 92 | 92 |
aarch64/sqlite-libs-3.39.4-2.ph4.aarch64.rpm |
| ... | ... |
@@ -83,10 +83,10 @@ x86_64/python3-3.11.0-2.ph4.x86_64.rpm |
| 83 | 83 |
x86_64/python3-libs-3.11.0-2.ph4.x86_64.rpm |
| 84 | 84 |
x86_64/readline-8.2-1.ph4.x86_64.rpm |
| 85 | 85 |
x86_64/readline-devel-8.2-1.ph4.x86_64.rpm |
| 86 |
-x86_64/rpm-4.16.1.3-7.ph4.x86_64.rpm |
|
| 87 |
-x86_64/rpm-build-4.16.1.3-7.ph4.x86_64.rpm |
|
| 88 |
-x86_64/rpm-devel-4.16.1.3-7.ph4.x86_64.rpm |
|
| 89 |
-x86_64/rpm-libs-4.16.1.3-7.ph4.x86_64.rpm |
|
| 86 |
+x86_64/rpm-4.18.0-7.ph5.x86_64.rpm |
|
| 87 |
+x86_64/rpm-build-4.18.0-7.ph5.x86_64.rpm |
|
| 88 |
+x86_64/rpm-devel-4.18.0-7.ph5.x86_64.rpm |
|
| 89 |
+x86_64/rpm-libs-4.18.0-7.ph5.x86_64.rpm |
|
| 90 | 90 |
x86_64/sed-4.8-1.ph4.x86_64.rpm |
| 91 | 91 |
x86_64/sqlite-3.39.4-2.ph4.x86_64.rpm |
| 92 | 92 |
x86_64/sqlite-libs-3.39.4-2.ph4.x86_64.rpm |
| 93 | 93 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+# Helper script to move rpm db from /var/lib/rpm to /usr/lib/sysimage/rpm |
|
| 3 |
+# This script comes to picture when host's rpm has sqlite backend db but |
|
| 4 |
+# /var/lib/rpm as dbpath. |
|
| 5 |
+# If db path is /usr/lib/sysimage/rpm, nothing will be done |
|
| 6 |
+ |
|
| 7 |
+old_rpmdb_path="/var/lib/rpm" |
|
| 8 |
+actual_rpmdb_path="$(rpm -E %_dbpath)" |
|
| 9 |
+ |
|
| 10 |
+abort() |
|
| 11 |
+{
|
|
| 12 |
+ echo -e "$*" 1>&2 |
|
| 13 |
+ exit 1 |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+if rpm --quiet -q rpm --dbpath "${old_rpmdb_path}"; then
|
|
| 17 |
+ if [ "${old_rpmdb_path}" != "${actual_rpmdb_path}" ]; then
|
|
| 18 |
+ echo "INFO: RpmDB is at ${old_rpmdb_path} and needs to be migrated"
|
|
| 19 |
+ if ! mkdir -p "${actual_rpmdb_path}"; then
|
|
| 20 |
+ abort "ERROR: failed to create ${actual_rpmdb_path} dir"
|
|
| 21 |
+ fi |
|
| 22 |
+ |
|
| 23 |
+ if ! mv "${old_rpmdb_path}"/* "${actual_rpmdb_path}"; then
|
|
| 24 |
+ abort "ERROR: failed to move files from ${old_rpmdb_path} to ${actual_rpmdb_path}"
|
|
| 25 |
+ fi |
|
| 26 |
+ |
|
| 27 |
+ if ! rpmdb --rebuilddb; then |
|
| 28 |
+ abort "ERROR: failed to rebuild db" |
|
| 29 |
+ fi |
|
| 30 |
+ fi |
|
| 31 |
+elif rpm --quiet -q rpm --dbpath "${actual_rpmdb_path}"; then
|
|
| 32 |
+ echo "INFO: RpmDB is at ${actual_rpmdb_path} and healthy"
|
|
| 33 |
+else |
|
| 34 |
+ abort "ERROR: RpmDB is either corrupt or does not exist" |
|
| 35 |
+fi |
|
| 36 |
+ |
|
| 37 |
+exit 0 |
| 0 | 38 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,62 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+if [ $# -ne 3 ]; then |
|
| 3 |
+ echo "$0: ERROR: invalid number of args" 1>&2 |
|
| 4 |
+ exit 1 |
|
| 5 |
+fi |
|
| 6 |
+ |
|
| 7 |
+img_url=$1 |
|
| 8 |
+img_tag=$2 |
|
| 9 |
+ph_builder_tag=$3 |
|
| 10 |
+ |
|
| 11 |
+ret="$(docker image inspect -f {{.Comment}} ${img_tag} 2>/dev/null)"
|
|
| 12 |
+if [ $? -eq 0 ]; then |
|
| 13 |
+ ret="$(echo ${ret} | cut -d' ' -f3)"
|
|
| 14 |
+else |
|
| 15 |
+ ret="" |
|
| 16 |
+fi |
|
| 17 |
+ |
|
| 18 |
+if [ "${ret}" != "${img_url}" ]; then
|
|
| 19 |
+ docker rmi -f "${img_tag}" "${ph_builder_tag}"
|
|
| 20 |
+ |
|
| 21 |
+ echo "Creating photon builder docker image ..." |
|
| 22 |
+ if ! docker import "${img_url}" "${img_tag}"; then
|
|
| 23 |
+ echo "ERROR: docker import of ${img_url} docker image failed" 1>&2
|
|
| 24 |
+ exit 1 |
|
| 25 |
+ fi |
|
| 26 |
+ |
|
| 27 |
+ dbpath="/usr/lib/sysimage/rpm" |
|
| 28 |
+ if [ "$(rpm -E %{_db_backend})" = "sqlite" ] && [ "$(rpm -E %{_dbpath})" = "${dbpath}" ]; then
|
|
| 29 |
+ echo "Host's rpm supports sqlite and RpmDB path is as expected" |
|
| 30 |
+ exit 0 |
|
| 31 |
+ fi |
|
| 32 |
+ |
|
| 33 |
+ tmp_tag="$(mktemp -t photon_builder.XXXX -u | cut -d'/' -f3)" |
|
| 34 |
+ if ! docker run --name "${tmp_tag}" --net=host --privileged "${img_tag}" /bin/bash -c "tdnf install -y rpm" 1>/dev/null; then
|
|
| 35 |
+ docker rmi -f "${img_tag}"
|
|
| 36 |
+ echo "ERROR: docker run ${tmp_tag} failed" 1>&2
|
|
| 37 |
+ exit 1 |
|
| 38 |
+ fi |
|
| 39 |
+ |
|
| 40 |
+ if ! docker stop "${tmp_tag}" 1>/dev/null; then
|
|
| 41 |
+ docker rm -f "${tmp_tag}"
|
|
| 42 |
+ docker rmi -f "${img_tag}"
|
|
| 43 |
+ echo "ERROR: docker stop ${tmp_tag} failed" 1>&2
|
|
| 44 |
+ exit 1 |
|
| 45 |
+ fi |
|
| 46 |
+ |
|
| 47 |
+ if ! docker commit "${tmp_tag}" "${ph_builder_tag}" 1>/dev/null; then
|
|
| 48 |
+ docker rm -f "${tmp_tag}"
|
|
| 49 |
+ docker rmi -f "${img_tag}"
|
|
| 50 |
+ echo "ERROR: docker commit ${tmp_tag} failed" 1>&2
|
|
| 51 |
+ exit 1 |
|
| 52 |
+ fi |
|
| 53 |
+ |
|
| 54 |
+ if ! docker rm -f "${tmp_tag}" 1>/dev/null; then
|
|
| 55 |
+ docker rmi -f "${img_tag}"
|
|
| 56 |
+ echo "ERROR: docker rm -f ${tmp_tag} failed" 1>&2
|
|
| 57 |
+ exit 1 |
|
| 58 |
+ fi |
|
| 59 |
+fi |
|
| 60 |
+ |
|
| 61 |
+exit 0 |
| 0 | 62 |
deleted file mode 100755 |
| ... | ... |
@@ -1,41 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
- |
|
| 3 |
-if [ $# -ne 3 ]; then |
|
| 4 |
- echo "$0: ERROR: invalid number of args" 1>&2 |
|
| 5 |
- exit 1 |
|
| 6 |
-fi |
|
| 7 |
- |
|
| 8 |
-img_url=$1 |
|
| 9 |
-img_tag=$2 |
|
| 10 |
-ph_builder_tag=$3 |
|
| 11 |
- |
|
| 12 |
-ret="$(docker image inspect -f {{.Comment}} ${img_tag} 2>/dev/null)"
|
|
| 13 |
-if [ $? -eq 0 ]; then |
|
| 14 |
- ret="$(echo ${ret} | cut -d' ' -f3)"
|
|
| 15 |
-else |
|
| 16 |
- ret="" |
|
| 17 |
-fi |
|
| 18 |
- |
|
| 19 |
-photon_builder_dockerfile="support/package-builder/Dockerfile.photon_builder" |
|
| 20 |
- |
|
| 21 |
-if [ "${ret}" != "${img_url}" ]; then
|
|
| 22 |
- docker rmi -f "${img_tag}" "${ph_builder_tag}"
|
|
| 23 |
- |
|
| 24 |
- echo "Creating photon builder docker image ..." |
|
| 25 |
- if ! docker import "${img_url}" "${img_tag}"; then
|
|
| 26 |
- echo "ERROR: docker import of ph3 docker image failed" 1>&2 |
|
| 27 |
- exit 1 |
|
| 28 |
- fi |
|
| 29 |
- |
|
| 30 |
- if [ "$(rpm -E %{_db_backend})" = "sqlite" ]; then
|
|
| 31 |
- echo "Host's rpm supports sqlite" |
|
| 32 |
- exit 0 |
|
| 33 |
- fi |
|
| 34 |
- |
|
| 35 |
- if ! docker build --tag "${ph_builder_tag}" -f ${photon_builder_dockerfile} . 1>/dev/null; then
|
|
| 36 |
- echo "ERROR: failed to build ${ph_builder_tag} docker image" 1>&2
|
|
| 37 |
- exit 1 |
|
| 38 |
- fi |
|
| 39 |
-fi |
|
| 40 |
- |
|
| 41 |
-exit 0 |