From 75b6468fa065e0e71485998d8445f9302ec0b968 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 6 Sep 2014 12:37:09 +0200 Subject: [PATCH] Introduce a way to override dependencies for all pkgs thru a file. The `etc/defaults.virtual` file contains the default replacement for our use cases; at this moment we only use it to use `eudev` rather than `systemd` for udev. If `etc/virtual` exists it overrides the settings of `etc/defaults.virtual`. --- README.md | 14 +++++++- common/xbps-src/shutils/build_dependencies.sh | 36 +++++++++++++++++-- etc/defaults.virtual | 22 ++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 etc/defaults.virtual diff --git a/README.md b/README.md index 70e39685172..9c527b3900b 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,15 @@ To start using it first you'll need some external dependencies: Make sure your user is added to the `xbuilder` group to be able to use `xbps-uchroot(8)`, otherwise `xbps-src` won't work correctly. -The `xbps-src` utility will allow you to generate XBPS binary packages, type +Type: $ ./xbps-src -h to see all available targets/options and start building any available package in the `srcpkgs` directory. +### Configuration + The `etc/defaults.conf` file contains the possible settings that can be overrided through the `etc/conf` configuration file for the `xbps-src` utility; if that file does not exist, will try to read configuration settings from `~/.xbps-src.conf`. @@ -29,5 +31,15 @@ those defined in `etc/defaults.conf`, append to them instead via `etc/conf` i.e: $ echo 'XBPS_CFLAGS+=" your flags here "' >> etc/conf $ echo 'XBPS_LDFLAGS+=" your flags here "' >> etc/conf +#### Virtual packages + +The `etc/defaults.virtual` file contains the default replacements for virtual packages, +used as dependencies in the source packages tree. + +If you want to customize those replacements, copy `etc/defaults.virtual` to `etc/virtual` +and edit it accordingly to your needs. + +### Contributing + See [Manual](https://github.com/voidlinux/xbps-packages/blob/master/Manual.md) for documentation to create and learn about the source packages. diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh index fa86af4a720..e3a44a918e7 100644 --- a/common/xbps-src/shutils/build_dependencies.sh +++ b/common/xbps-src/shutils/build_dependencies.sh @@ -1,7 +1,7 @@ # vim: set ts=4 sw=4 et: # setup_pkg_depends() { - local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname + local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname _replacement if [ -n "$pkg" ]; then # subpkg @@ -17,7 +17,17 @@ setup_pkg_depends() { if [ -z "${_pkgdepname}" ]; then _pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)" fi - + if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then + _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2) + if [ -n "${_replacement}" ]; then + _depname="${_depname/${_pkgdepname:-${_depname}}/${_replacement}}" + fi + elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then + _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2) + if [ -n "${_replacement}" ]; then + _depname="${_depname/${_pkgdepname:-${_depname}}/${_replacement}}" + fi + fi if [ -z "${_pkgdepname}" ]; then _pkgdep="${_depname}>=0" else @@ -35,6 +45,17 @@ setup_pkg_depends() { if [ -z "${_pkgdepname}" ]; then _pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)" fi + if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then + _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2) + if [ -n "${_replacement}" ]; then + _depname="${_depname/${_pkgdepname:-${_depname}}/${_replacement}}" + fi + elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then + _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2) + if [ -n "${_replacement}" ]; then + _depname="${_depname/${_pkgdepname:-${_depname}}/${_replacement}}" + fi + fi if [ -z "${_pkgdepname}" ]; then _pkgdep="${_depname}>=0" else @@ -48,6 +69,17 @@ setup_pkg_depends() { if [ -z "${_pkgdepname}" ]; then _pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)" fi + if [ -s ${XBPS_DISTDIR}/etc/virtual ]; then + _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/virtual|cut -d ' ' -f2) + if [ -n "${_replacement}" ]; then + _depname="${_depname/${_pkgdepname:-${_depname}}/${_replacement}}" + fi + elif [ -s ${XBPS_DISTDIR}/etc/defaults.virtual ]; then + _replacement=$(egrep "^${_pkgdepname:-${_depname}}[[:blank:]]" ${XBPS_DISTDIR}/etc/defaults.virtual|cut -d ' ' -f2) + if [ -n "${_replacement}" ]; then + _depname="${_depname/${_pkgdepname:-${_depname}}/${_replacement}}" + fi + fi if [ -z "${_pkgdepname}" ]; then _pkgdep="${_depname}>=0" else diff --git a/etc/defaults.virtual b/etc/defaults.virtual new file mode 100644 index 00000000000..a7fc22940d4 --- /dev/null +++ b/etc/defaults.virtual @@ -0,0 +1,22 @@ +# --*-- shell --*-- +# +# etc/defaults.virtual +# default configuration of etc/virtual +# +# DO NOT EDIT THIS FILE DIRECTLY; IT MAY BE REPLACED DURING UPDATES, +# EDIT etc/virtual INSTEAD. +# +# This file specifies a mapping between virtual packages and real packages +# available in the source packages collection (srcpkgs). +# +# The format uses 2 arguments delimited by a blank: +# +# If a source package depends on a virtual package () and there's +# a replacement defined in that file, will be used to resolve +# the dependency instead. +# +# - Please add entries sorted alphabetically on its first argument. +# - Create your own etc/virtual file to override these defaults. +# +libgudev-devel eudev-libgudev-devel +libudev-devel eudev-libudev-devel