diff options
author | 2009-05-15 13:23:57 +0000 | |
---|---|---|
committer | 2009-05-15 13:23:57 +0000 | |
commit | 59b05eceeaee36ff4f0cb96ff91e0bc710ab0f24 (patch) | |
tree | 33d21400ffcdcc3a9baeb4ea615b3ee15e9cc2c5 | |
parent | Substitute prefix, datadir and sysconfdir in libs/Makefile.am; make use of it... (diff) | |
download | eselect-59b05eceeaee36ff4f0cb96ff91e0bc710ab0f24.tar.gz eselect-59b05eceeaee36ff4f0cb96ff91e0bc710ab0f24.tar.bz2 eselect-59b05eceeaee36ff4f0cb96ff91e0bc710ab0f24.zip |
Move all package manager functions to package-manager.bash.
svn path=/trunk/; revision=535
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | libs/Makefile.am | 4 | ||||
-rw-r--r-- | libs/package-manager.bash.in | 49 | ||||
-rw-r--r-- | libs/paludis.bash.in | 46 | ||||
-rw-r--r-- | libs/portage.bash.in | 57 |
5 files changed, 40 insertions, 130 deletions
@@ -1,5 +1,19 @@ 2009-05-15 Ulrich Mueller <ulm@gentoo.org> + * libs/package-manager.bash.in (envvar, best_version, has_version) + (get_repositories, get_repo_news_dir): Directly call package + manager commands with their arguments; no need to hide them in an + extra layer of trivial functions. + (get_news_dir_name): Deprecate, since it provides no additional + functionality. Use get_repo_news_dir instead. + (portageq): Function moved here from portage.bash.in. + (paludis): New function, paludis wrapper with redirected stderr. + (inherit): Don't inherit portage and paludis libs. + * libs/paludis.bash.in, libs/portage.bash.in: Remove, after having + verified that these libraries are not used by any module: neither + internal nor in external app-admin/eselect-* packages. + * libs/Makefile.am (eselectlibs_SCRIPTS, EXTRA_DIST): Update. + * libs/Makefile.am (dosed): Also substitute prefix, datadir and sysconfdir. diff --git a/libs/Makefile.am b/libs/Makefile.am index 01da6e3..e4e2d95 100644 --- a/libs/Makefile.am +++ b/libs/Makefile.am @@ -9,9 +9,7 @@ eselectlibs_SCRIPTS = \ multilib.bash \ output.bash \ package-manager.bash \ - paludis.bash \ path-manipulation.bash \ - portage.bash \ skel.bash \ tests.bash @@ -24,9 +22,7 @@ EXTRA_DIST = \ multilib.bash.in \ output.bash.in \ package-manager.bash.in \ - paludis.bash.in \ path-manipulation.bash.in \ - portage.bash.in \ skel.bash.in \ tests.bash.in diff --git a/libs/package-manager.bash.in b/libs/package-manager.bash.in index 3e5c891..f4d2d52 100644 --- a/libs/package-manager.bash.in +++ b/libs/package-manager.bash.in @@ -16,7 +16,23 @@ # You should have received a copy of the GNU General Public License along with # eselect. If not, see <http://www.gnu.org/licenses/>. -inherit paludis portage +# package-manager PRIVATE +# Return the package manager we're going to use. +package-manager() { + echo "${ESELECT_PACKAGE_MANAGER:-@PACKAGE_MANAGER@}" +} + +# portageq +# Run portageq with safe filename as set by configure. Redirect stderr +portageq() { + @PORTAGEQ@ "$@" 2>/dev/null +} + +# paludis +# Run PALUDIS_COMMAND (defaults to "paludis"). Redirect stderr +paludis() { + ${PALUDIS_COMMAND:-paludis} "$@" 2>/dev/null +} # arch # Return the architecture we're running on... @@ -63,16 +79,15 @@ arch() { } # envvar -# Return the contents of environment variable $2 as seen by package manager(s) +# Return the contents of environment variable $2 as seen by package manager # for package $1. envvar() { [[ $# -eq 2 ]] || die "envvar expects exactly 2 arguments" - local manager=$(package-manager) case ${manager} in - paludis) paludis_envvar "$1" "$2" ;; # portage does not support per-package envvar lookup portage) portageq envvar "$2" ;; + paludis) paludis --environment-variable "$1" "$2" ;; *) die "Unknown package manager: \"${manager}\"" ;; esac } @@ -81,11 +96,10 @@ envvar() { # Return true if package $1 is available in ${ROOT} best_version() { [[ $# -eq 1 ]] || die "best_version expects exactly one argument" - local manager=$(package-manager) case ${manager} in - paludis) paludis_best-version "$1" ;; portage) portageq best_version "${ROOT:-/}" "$1" ;; + paludis) paludis --best-version "$1" ;; *) die "Unknown package manager: \"${manager}\"" ;; esac } @@ -94,11 +108,10 @@ best_version() { # Return true if package $1 is available in ${ROOT} has_version() { [[ $# -eq 1 ]] || die "has_version expects exactly one argument" - local manager=$(package-manager) case ${manager} in - paludis) paludis_has-version "$1" ;; portage) portageq has_version "${ROOT:-/}" "$1" ;; + paludis) paludis --has-version "$1" ;; *) die "Unknown package manager: \"${manager}\"" ;; esac } @@ -108,8 +121,8 @@ has_version() { get_repositories() { local manager=$(package-manager) case ${manager} in - paludis) $(paludis_command) --list-repositories | cut -d' ' -f 2 ;; portage) portageq get_repos "${ROOT:-/}" ;; + paludis) paludis --list-repositories | cut -d' ' -f 2 ;; *) die "Unknown package manager: \"${manager}\"" ;; esac } @@ -121,31 +134,21 @@ get_repo_news_dir() { local repo=$1 local manager=$(package-manager) case ${manager} in - paludis) - $(paludis_command) --configuration-variable ${repo} newsdir - ;; portage) echo "$(portageq get_repo_path \ - "${ROOT:-/}" "${repo}")/metadata/news" - ;; - *) - die "Unknown package manager: \"${manager}\"" - ;; + "${ROOT:-/}" "${repo}")/metadata/news" ;; + paludis) paludis --configuration-variable ${repo} newsdir ;; + *) die "Unknown package manager: \"${manager}\"" ;; esac } +# get_news_dir_name DEPRECATED get_news_dir_name() { [[ $# -eq 1 ]] || die "get_news_dir_name expects exactly one argument" local name=${1%::*} repo=${1##*::} echo "$(get_repo_news_dir "${repo}")/${name}" } -# package-manager PRIVATE -# Return the package manager we're going to use. -package-manager() { - echo "${ESELECT_PACKAGE_MANAGER:-@PACKAGE_MANAGER@}" -} - # Local Variables: # sh-indentation: 4 # indent-tabs-mode: nil diff --git a/libs/paludis.bash.in b/libs/paludis.bash.in deleted file mode 100644 index 034f4bf..0000000 --- a/libs/paludis.bash.in +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2005-2008 Gentoo Foundation. -# $Id$ -# This file is part of the 'eselect' tools framework. -# -# eselect 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. -# -# eselect 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 -# eselect. If not, see <http://www.gnu.org/licenses/>. - -paludis_command() { - echo ${PALUDIS_COMMAND:-paludis} -} - -# paludis_best-version PRIVATE -# Run paludis --best-version with safe filename as set by configure -paludis_best-version() { - $(paludis_command) --best-version $* 2> /dev/null -} - -# paludis-envvar PRIVATE -# Run paludis --environment-variable with safe filename as set by configure -paludis_envvar() { - $(paludis_command) --environment-variable $* 2> /dev/null -} - -# paludis_has-version PRIVATE -# Run paludis --has-version with safe filename as set by configure -paludis_has-version() { - $(paludis_command) --has-version $* 2> /dev/null -} - -# Local Variables: -# sh-indentation: 4 -# indent-tabs-mode: nil -# End: - -# vim: set sw=4 et sts=4 tw=80 : diff --git a/libs/portage.bash.in b/libs/portage.bash.in deleted file mode 100644 index 1c8840a..0000000 --- a/libs/portage.bash.in +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2005-2009 Gentoo Foundation. -# $Id$ -# This file is part of the 'eselect' tools framework. -# -# eselect 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. -# -# eselect 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 -# eselect. If not, see <http://www.gnu.org/licenses/>. - -# portageq ... -# Run portageq with safe filename as set by configure -portageq() { - @PORTAGEQ@ "$@" 2>/dev/null -} - -# Following functions are no longer needed with Portage 2.1.6. -# Use "portageq get_repo_path" and "portageq get_repos" instead. - -# portage_get_repo_name -# Return the name of the repository residing at $1 -# portage_get_repo_name() { -# [[ ${#@} -eq 1 ]] || die "portage_get_repo_name expects exactly 1 arguments!" -# if [[ -r ${1}/profiles/repo_name ]]; then -# cat ${1}/profiles/repo_name -# else -# basename ${1} -# fi -# } - -# portage_get_repository -# Return the path of the repository with the name given in $1 -# portage_get_repository() -# { -# [[ ${#@} -eq 1 ]] || die "portage_get_repository expects exactly 1 arguments!" -# for i in $(portageq envvar PORTDIR PORTDIR_OVERLAY); do -# if [[ $(portage_get_repo_name ${i}) == ${1} ]]; then -# echo ${i} -# return -# fi -# done -# } - -# Local Variables: -# sh-indentation: 4 -# indent-tabs-mode: nil -# End: - -# vim: set sw=4 et sts=4 tw=80 : |