diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-01-04 06:19:09 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-01-04 06:19:09 +0000 |
commit | 7f54b4fef7c3ca978743ffe34f606a853694860a (patch) | |
tree | d07aaa64c94feecbc71f0a0df9f3aab10adbf055 /eclass | |
parent | add tests for savedconfig.eclass:save_config() (diff) | |
download | gentoo-2-7f54b4fef7c3ca978743ffe34f606a853694860a.tar.gz gentoo-2-7f54b4fef7c3ca978743ffe34f606a853694860a.tar.bz2 gentoo-2-7f54b4fef7c3ca978743ffe34f606a853694860a.zip |
collapse duplicate branches in save_config code paths to keep things simple
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/savedconfig.eclass | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/eclass/savedconfig.eclass b/eclass/savedconfig.eclass index 626e7e16be5c..f07ac8658562 100644 --- a/eclass/savedconfig.eclass +++ b/eclass/savedconfig.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/savedconfig.eclass,v 1.16 2011/12/27 17:55:12 fauli Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/savedconfig.eclass,v 1.17 2012/01/04 06:19:09 vapier Exp $ # @ECLASS: savedconfig.eclass # @MAINTAINER: @@ -29,25 +29,23 @@ save_config() { if [[ ${EBUILD_PHASE} != "install" ]]; then die "Bad package! save_config only for use in src_install functions!" fi - [[ -z "${ED}" ]] && ED=${D} - case $# in - 0) die "Tell me what to save" - ;; - 1) if [[ -f "$1" ]]; then - dodir /etc/portage/savedconfig/${CATEGORY} - cp "$1" "${ED}"/etc/portage/savedconfig/${CATEGORY}/${PF} \ - || die "Failed to save $1" - else - dodir /etc/portage/savedconfig/${CATEGORY}/${PF} - treecopy "$1" "${ED}"/etc/portage/savedconfig/${CATEGORY}/${PF} \ - || die "Failed to save $1" - fi - ;; - *) - dodir "${PORTAGE_CONFIGROOT}"/etc/portage/savedconfig/${CATEGORY}/${PF} - treecopy $* "${D}/${PORTAGE_CONFIGROOT}"/etc/portage/savedconfig/${CATEGORY}/${PF} \ - || die "Failed to save $1" - esac + [[ $# -eq 0 ]] && die "Usage: save_config <files>" + + # Be lazy in our EAPI compat + : ${ED:-${D}} + + local dest="/etc/portage/savedconfig/${CATEGORY}" + if [[ $# -eq 1 && -f $1 ]] ; then + # Just one file, so have the ${PF} be that config file + dodir "${dest}" + cp "$@" "${ED}/${dest}/${PF}" || die "failed to save $*" + else + # A dir, or multiple files, so have the ${PF} be a dir + # with all the saved stuff below it + dodir "${dest}/${PF}" + treecopy "$@" "${ED}/${dest}/${PF}" || die "failed to save $*" + fi + elog "Your configuration for ${CATEGORY}/${PF} has been saved in " elog "/etc/portage/savedconfig/${CATEGORY}/${PF} for your editing pleasure." elog "You can edit these files by hand and remerge this package with" |