From 958cb3fd2a05657d281611eff2cb67b47f8d6272 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 4 Jan 2012 06:19:09 +0000 Subject: [PATCH] collapse duplicate branches in save_config code paths to keep things simple --- eclass/savedconfig.eclass | 38 ++++++++++++++++++-------------------- 1 file 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 " + + # 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" -- 2.26.2