From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id D8E8E138247 for ; Mon, 20 Jan 2014 17:54:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 45FB8E1066; Mon, 20 Jan 2014 17:53:29 +0000 (UTC) Received: from mail-ee0-f50.google.com (mail-ee0-f50.google.com [74.125.83.50]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 77649E105F for ; Mon, 20 Jan 2014 17:53:28 +0000 (UTC) Received: by mail-ee0-f50.google.com with SMTP id d17so3582918eek.23 for ; Mon, 20 Jan 2014 09:53:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=Xq9MCH+v0p3cD5Oh+HdvVklZRWmrllVQjmgGuvLYjUo=; b=eY6DZ6+IYQDPrmr403ulMViSa0te9WAEbzYIlf10P/BblWzKeh+JcTVPzveLIxlzNJ BX3p10DHFK9n91kdvSmcFxaewAZbyIEqYG2HZ2jgKdPamELTOB4aR4hBESZTmI5sey5b b6etMsVIig21qHcI6O9YiPskloQ3aczNw8Ik1FmNpekMgPjrfzPNflmcf+h6ssoUSvy9 UqYueqfMOVP2H053YssMoa86X9RPInZ4JK8KK5qUNQfAZUA1OqQEWRJDw6/E6uOlrNwC quSszgaQMPjpDug5hGaLOzLu5yuxgyc8E4mley/3rq+4jM81dIW15zTRl0e5JX4OyTR8 uUJg== X-Received: by 10.14.99.66 with SMTP id w42mr5964304eef.63.1390240407145; Mon, 20 Jan 2014 09:53:27 -0800 (PST) Received: from localhost.localdomain (dsl-trebrasgw2-58c0d8-67.dhcp.inet.fi. [88.192.216.67]) by mx.google.com with ESMTPSA id o47sm5514777eem.21.2014.01.20.09.53.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2014 09:53:26 -0800 (PST) From: Reinis Danne To: gentoo-science@lists.gentoo.org Subject: [gentoo-science] [PATCH 09/10] alternatives-2.eclass: Minor comment changes Date: Mon, 20 Jan 2014 19:53:11 +0200 Message-Id: <1390240392-12173-10-git-send-email-rei4dan@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390240392-12173-1-git-send-email-rei4dan@gmail.com> References: <1390240392-12173-1-git-send-email-rei4dan@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-science@lists.gentoo.org Reply-to: gentoo-science@lists.gentoo.org X-Archives-Salt: 305d0272-f15b-4405-8ed2-6363791cfd0f X-Archives-Hash: 2c12f930c0e212b2698b6297981381e7 --- eclass/alternatives-2.eclass | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass index e15edfa..d9896f1 100644 --- a/eclass/alternatives-2.eclass +++ b/eclass/alternatives-2.eclass @@ -57,22 +57,26 @@ alternatives_for() { local alternative=${1} provider=${2} importance=${3} index src target ret=0 shift 3 - # make sure importance is a signed integer + # Make sure importance is a signed integer if [[ -n ${importance} ]] && ! [[ ${importance} =~ ^[0-9]+(\.[0-9]+)*$ ]]; then eerror "Invalid importance (${importance}) detected" ((ret++)) fi + # Create alternative provider subdirectories under ALTERNATIVES_DIR if needed [[ -d "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}" ]] || dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}" - # keep track of provided alternatives for use in pkg_{postinst,prerm}. keep a mapping between importance and - # provided alternatives and make sure the former is set to only one value + # Keep track of provided alternatives for use in pkg_{postinst,prerm}. + # Keep a mapping between importance and provided alternatives + # and make sure the former is set to only one value. if ! has "${alternative}:${provider}" "${ALTERNATIVES_PROVIDED[@]}"; then + # Add new provider and set its importance index=${#ALTERNATIVES_PROVIDED[@]} ALTERNATIVES_PROVIDED+=( "${alternative}:${provider}" ) ALTERNATIVES_IMPORTANCE[index]=${importance} [[ -n ${importance} ]] && echo "${importance}" > "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance" else + # Set importance for existing provider for((index=0;index<${#ALTERNATIVES_PROVIDED[@]};index++)); do if [[ ${alternative}:${provider} == ${ALTERNATIVES_PROVIDED[index]} ]]; then if [[ -n ${ALTERNATIVES_IMPORTANCE[index]} ]]; then @@ -88,6 +92,7 @@ alternatives_for() { done fi + # Process source-target pairs while (( $# >= 2 )); do src=${1//+(\/)/\/}; target=${2//+(\/)/\/} if [[ ${src} != /* ]]; then @@ -107,8 +112,9 @@ alternatives_for() { dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}${src%/*}" dosym "${reltarget}" "${ALTERNATIVES_DIR}/${alternative}/${provider}${src}" - # say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet) - # the -e test will fail, so check for -L also + # The -e test will fail if existing symlink points to non-existing target, + # so check for -L also. + # Say ${ED}/sbin/init exists and links to /bin/systemd (which doesn't exist yet). if [[ -e ${ED}${src} || -L ${ED}${src} ]]; then local fulltarget=${target} [[ ${fulltarget} != /* ]] && fulltarget=${src%/*}/${fulltarget} @@ -122,6 +128,7 @@ alternatives_for() { shift 2 done + # Stop if there were any errors [[ ${ret} -eq 0 ]] || die "Errors detected for ${provider}, provided for ${alternative}" } -- 1.8.5.3