rpm-build/scripts/brp-dupe-bin.in

51 lines
2.1 KiB
Plaintext
Raw Normal View History

brp: Add brp-dupe-bin script Some packages in Sisyphus install files both under %_prefix and outside it in subdirectories of /, e. g. in both /bin and /usr/bin, or in /sbin and /usr/sbin. Those packages must be installable into both unmerged and merged-usr hierarchies and still work correctly. Most of the packages can be adapted for use on both hierarchies, if they are rebuilt with rpm-build with this brp module, with no spec changes required. This brp module ensures that files under %buildroot/bin and %buildroot/usr/bin are a copy of each other. If one of them is a symbolic link to another, it is replaced by a copy of its target. If different files of the same type are found inside the buildroot, it fails the build. Likewise for %buildroot/sbin. This approach has the following advantages: - The resulting package can be installed on a split-usr hierarchy. We cannot use hard links, since our RPM can not auto-replace them while installing in an environment where hard link targets are to be on different storage sources (aka "split-usr"). - Most of packages in the repo should be installed in both hierarchies as is or after rebuild. The single worst disadvantage is disk space requirements: we store 2 copies in the cpio of product rpms and 2 copies while installed on an unmerged-usr hierarchy. We hope that this is not too bad: the copied files themselves are not that big, the cpio in a package file is compressed, and the eventual upgrade of filesystem < 3 is much less likely to hit disk space limits. As for files in /lib*, it is unlikely for packages in the repository to depend on their particular location, so there is no need to put links or copies both outside %_prefix and in %_prefix; all the packages with file conflicts exclusive to merged-usr setups are fixed already. This module can be safely disabled or removed when we eventually drop support for unmerged-usr hierarchies. Link: https://altlinux.org/Usrmerge
2024-01-18 03:35:04 +03:00
#!/bin/sh -e
#
# brp-dupe-bin - change symlinks to files in bin and sbin in buildroot.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# This module attempts to fix all the various arrangements of files under
# /{,s}bin in the buildroot to make the package installable on *both*
# unmerged-usr and merged-usr hierarchies, regardless of split-usr.
# It can be removed when support for unmerged-usr is dropped.
. @RPMCONFIGDIR@/functions
ValidateBuildRoot
cd "$RPM_BUILD_ROOT"
echo "Splitting links to aliased files under /{,s}bin in $RPM_BUILD_ROOT"
for DIR in bin sbin; do
[ -d "$DIR" ] || continue
find "$DIR" -mindepth 1 -type f -printf '%f\n' | while read -r FILE; do
[ -e "usr/$DIR/$FILE" ] || continue
if [ -L "usr/$DIR/$FILE" ] ; then
rm "usr/$DIR/$FILE"
cp -vT --preserve=all -- "$DIR/$FILE" "usr/$DIR/$FILE"
elif ! diff -q "$DIR/$FILE" "usr/$DIR/$FILE"; then
Fatal "Found different files $RPM_BUILD_ROOT/usr/$DIR/$FILE and $RPM_BUILD_ROOT/$DIR/$FILE"
fi
done
find "$DIR" -mindepth 1 -type l -printf '%f\n' | while read -r FILE; do
[ -e "usr/$DIR/$FILE" ] || continue
if [ ! -L "usr/$DIR/$FILE" ] ; then
rm "$DIR/$FILE"
cp -vT --preserve=all -- "usr/$DIR/$FILE" "$DIR/$FILE"
elif ! diff -q "$DIR/$FILE" "usr/$DIR/$FILE" --no-dereference; then
Fatal "Found different symlinks $RPM_BUILD_ROOT/usr/$DIR/$FILE and $RPM_BUILD_ROOT/$DIR/$FILE"
fi
done
done