Skip to content

Commit 1df15b2

Browse files
Fixing/workaround sysroot builds for usrmerge distros.
The conversation of directories to symlinks breaks rpms and that breaks situations where host rpms provides files for the sysroot system. So we move them away before creating the sysroot and copy them back in afterwards (expect they got also provided by sysroot).
1 parent eaf56f9 commit 1df15b2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

build-pkg-rpm

+19
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,14 @@ pkg_install_rpm() {
132132
}
133133

134134
pkg_sysrootinstall_rpm() {
135+
local TEMP_BUILD_SYSROOT="${BUILD_SYSROOT}.hostsystem.temp"
135136
if test "x$1" = "x--prepare" ; then
137+
if test -d "$BUILD_ROOT$BUILD_SYSROOT" -a ! -d "$BUILD_ROOT$TEMP_BUILD_SYSROOT"; then
138+
# The host system may already provide files for the sysroot target
139+
# rpm is not able to handle directory to symlink conversation, so
140+
# we need to move it away first and copy it back later.
141+
mv "$BUILD_ROOT$BUILD_SYSROOT" "$BUILD_ROOT$TEMP_BUILD_SYSROOT"
142+
fi
136143
assert_dir_path "$BUILD_SYSROOT"
137144
chroot $BUILD_ROOT mkdir -p "$BUILD_SYSROOT"
138145
chroot $BUILD_ROOT rpm --root "$BUILD_SYSROOT" --initdb
@@ -141,6 +148,18 @@ pkg_sysrootinstall_rpm() {
141148
return
142149
fi
143150
if test "x$1" = "x--finalize" ; then
151+
if test -d "$BUILD_ROOT$TEMP_BUILD_SYSROOT"; then
152+
# copy back the files provided by the host system
153+
# a simple "cp -a" is not working as some directories
154+
# may be symlinks now
155+
pushd "$BUILD_ROOT$TEMP_BUILD_SYSROOT"
156+
find . -type f | while read fn; do
157+
mkdir -p "$BUILD_ROOT$BUILD_SYSROOT/${fn%/*}"
158+
cp -an "$fn" "$BUILD_ROOT$BUILD_SYSROOT/$fn"
159+
done
160+
popd
161+
rm -rf "$BUILD_ROOT$TEMP_BUILD_SYSROOT"
162+
fi
144163
return
145164
fi
146165
export ADDITIONAL_PARAMS=

0 commit comments

Comments
 (0)