The option tries to find all real (no symlinks) library names in the paths a compiler/linker search for by default. And add those libraries to libprovides. The option is disabled by default. Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com> --- Side notes: 1- I wasn't sure where to define the option. Since all options were moved to libmakepkg/tidy. 2- A side benefit of this approach is that the developer does not have to guess what to put exactly in provides. A discussion from 2.5 years ago: https://lists.archlinux.org/pipermail/pacman-dev/2013-May/017147.html https://lists.archlinux.org/pipermail/pacman-dev/2013-May/017152.html etc/makepkg.conf.in | 23 ++++++++++++----------- scripts/makepkg.sh.in | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 71ec624..da6e7ad 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -74,18 +74,19 @@ BUILDENV=(!distcc color !ccache check !sign) # Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug) # A negated option will do the opposite of the comments below. # -#-- strip: Strip symbols from binaries/libraries -#-- docs: Save doc directories specified by DOC_DIRS -#-- libtool: Leave libtool (.la) files in packages +#-- strip: Strip symbols from binaries/libraries +#-- docs: Save doc directories specified by DOC_DIRS +#-- libtool: Leave libtool (.la) files in packages #-- staticlibs: Leave static library (.a) files in packages -#-- emptydirs: Leave empty directories in packages -#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip -#-- purge: Remove files specified by PURGE_TARGETS -#-- upx: Compress binary executable files using UPX -#-- optipng: Optimize PNG images with optipng -#-- debug: Add debugging flags as specified in DEBUG_* variables -# -OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug) +#-- emptydirs: Leave empty directories in packages +#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip +#-- purge: Remove files specified by PURGE_TARGETS +#-- upx: Compress binary executable files using UPX +#-- optipng: Optimize PNG images with optipng +#-- debug: Add debugging flags as specified in DEBUG_* variables +#-- autolibprovides: Auto-add so provides +# +OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug !autolibprovides) #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 INTEGRITY_CHECK=(md5) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6ededa3..5475bcc 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -48,6 +48,7 @@ declare -r startdir="$PWD" LIBRARY=${LIBRARY:-'@libmakepkgdir@'} +packaging_options+=('autolibprovides') build_options=('ccache' 'distcc' 'buildflags' 'makeflags') splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' 'backup' @@ -944,6 +945,24 @@ find_libdepends() { printf '%s\n' "${libdepends[@]}" } +auto_libprovides() { + local f solib search_paths autolibprovides + + msg2 "$(gettext "Auto-adding libprovides...")" + + # Only search default library paths + search_paths=($(${CC:-gcc} -print-search-dirs | grep '^lib' | sed "s|^libraries: =|:|;s|:| ${pkgdir}|g")) + + for f in $(find ${search_paths[@]} -maxdepth 1 -type f 2>/dev/null); do + # Match solibs, but exclude ones with a relative path to avoid dups + if [[ "$f" =~ \.so ]] && [[ ! "$f" =~ \.\./ ]]; then + solib="${f##*/}" + autolibprovides+=("${solib%.so.*}.so") + fi + done + + printf '%s\n' "${autolibprovides[@]}" +} find_libprovides() { local p libprovides missing @@ -1130,6 +1149,9 @@ write_pkginfo() { printf "size = %s\n" "$size" printf "arch = %s\n" "$pkgarch" + if check_option "autolibprovides" "y"; then + mapfile -t provides < <(auto_libprovides) + fi mapfile -t provides < <(find_libprovides) mapfile -t depends < <(find_libdepends) -- 2.6.1