From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QnBzR-0005kM-2H for garchives@archives.gentoo.org; Sat, 30 Jul 2011 16:02:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EBE1721C0AF for ; Sat, 30 Jul 2011 16:02:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E7CD421C085 for ; Sat, 30 Jul 2011 15:10:36 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 247701B401F for ; Sat, 30 Jul 2011 15:10:36 +0000 (UTC) Received: by flycatcher.gentoo.org (Postfix, from userid 2230) id D24BD2004B; Sat, 30 Jul 2011 15:10:34 +0000 (UTC) From: "Tomas Chvatal (scarabeus)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, scarabeus@gentoo.org Subject: [gentoo-commits] gentoo-x86 commit in eclass: git-2.eclass X-VCS-Repository: gentoo-x86 X-VCS-Files: git-2.eclass X-VCS-Directories: eclass X-VCS-Committer: scarabeus X-VCS-Committer-Name: Tomas Chvatal Content-Type: text/plain; charset=utf8 Message-Id: <20110730151034.D24BD2004B@flycatcher.gentoo.org> Date: Sat, 30 Jul 2011 15:10:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 4cb442b00ecdfc3e33c3ce53efc8d4f3 scarabeus 11/07/30 15:10:34 Modified: git-2.eclass Log: Implement support for multiple checkouts from one ebuild by cleaning up= environment. Also allow overriding unpacking of . This is required for l= ive libreoffice ebuild. Revision Changes Path 1.13 eclass/git-2.eclass file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclas= s?rev=3D1.13&view=3Dmarkup plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclas= s?rev=3D1.13&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-2.eclas= s?r1=3D1.12&r2=3D1.13 Index: git-2.eclass =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- git-2.eclass 16 Jul 2011 13:11:54 -0000 1.12 +++ git-2.eclass 30 Jul 2011 15:10:34 -0000 1.13 @@ -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/git-2.eclass,v 1.12 2011/07/16= 13:11:54 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.13 2011/07/30= 15:10:34 scarabeus Exp $ =20 # @ECLASS: git-2.eclass # @MAINTAINER: @@ -57,7 +57,7 @@ # @ECLASS-VARIABLE: EGIT_DIR # @DESCRIPTION: # Directory where we want to store the git data. -# This should not be overriden unless really required. +# This variable should not be overriden. # # EGIT_DIR=3D"${EGIT_STORE_DIR}/${EGIT_PROJECT}" =20 @@ -113,6 +113,12 @@ # non bare repositories. This is useful if you can't operate with bare # checkouts for some reason. =20 +# @ECLASS-VARIABLE: EGIT_NOUNPACK +# @DEFAULT_UNSET +# @DESCRIPTION: +# If non-empty this variable bans unpacking of ${A} content into the src= dir. +# Default behaviour is to unpack ${A} content. + # @FUNCTION: git-2_init_variables # @DESCRIPTION: # Internal function initializing all git variables. @@ -185,6 +191,8 @@ git-2_branch() { debug-print-function ${FUNCNAME} "$@" =20 + local branchname src + debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\"" pushd "${EGIT_SOURCEDIR}" > /dev/null =20 @@ -198,8 +206,6 @@ || die "${FUNCNAME}: changing the branch failed" =20 popd > /dev/null - - unset branchname src } =20 # @FUNCTION: git-2_gc @@ -208,10 +214,11 @@ git-2_gc() { debug-print-function ${FUNCNAME} "$@" =20 + local args + pushd "${EGIT_DIR}" > /dev/null if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then ebegin "Garbage collecting the repository" - local args [[ -n ${EGIT_PRUNE} ]] && args=3D'--prune' debug-print "${FUNCNAME}: git gc ${args}" git gc ${args} @@ -281,8 +288,8 @@ =20 EGIT_REPO_URI_SELECTED=3D"" for repo_uri in ${EGIT_REPO_URI}; do - debug-print "${FUNCNAME}: git clone ${EGIT_OPTIONS} \"${repo_uri}\" \"= ${EGIT_DIR}\"" - git clone ${EGIT_OPTIONS} "${repo_uri}" "${EGIT_DIR}" + debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri= }\" \"${EGIT_DIR}\"" + git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}" if [[ $? -eq 0 ]]; then # global variable containing the repo_name we will be using debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=3D\"${repo_uri}\"" @@ -304,7 +311,7 @@ =20 local repo_uri =20 - if [[ -n ${EGIT_NONBARE} ]]; then + if [[ -n ${EGIT_LOCAL_NONBARE} ]]; then # checkout master branch and drop all other local branches git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master= branch ${EGIT_MASTER}" for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do @@ -342,7 +349,7 @@ =20 local oldsha cursha repo_type =20 - [[ -n ${EGIT_NONBARE} ]] && repo_type=3D"non-bare repository" || repo_t= ype=3D"bare repository" + [[ -n ${EGIT_LOCAL_NONBARE} ]] && repo_type=3D"non-bare repository" || = repo_type=3D"bare repository" =20 if [[ ! -d ${EGIT_DIR} ]]; then git-2_initial_clone @@ -438,6 +445,8 @@ # Internal function migrating between bare and normal checkout repositor= y. # This is based on usage of EGIT_SUBMODULES, at least until they # start to work with bare checkouts sanely. +# This function also set some global variables that differ between +# bare and non-bare checkout. git-2_migrate_repository() { debug-print-function ${FUNCNAME} "$@" =20 @@ -449,7 +458,11 @@ else target=3D"full" fi - [[ -n ${EGIT_NONBARE} ]] && target=3D"full" + # check if user didn't specify that we want non-bare repo + if [[ -n ${EGIT_NONBARE} ]]; then + target=3D"full" + EGIT_LOCAL_NONBARE=3D"true" + fi =20 # test if we already have some repo and if so find out if we have # to migrate the data @@ -489,19 +502,40 @@ # set various options to work with both targets if [[ ${target} =3D=3D bare ]]; then debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}= \"" - EGIT_OPTIONS+=3D" --bare" + EGIT_LOCAL_OPTIONS+=3D"${EGIT_OPTIONS} --bare" MOVE_COMMAND=3D"git clone -l -s -n ${EGIT_DIR// /\\ }" EGIT_UPDATE_CMD=3D"git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRA= NCH}" UPSTREAM_BRANCH=3D"${EGIT_BRANCH}" else debug-print "${FUNCNAME}: working in bare repository for non-bare \"${= EGIT_DIR}\"" MOVE_COMMAND=3D"cp -pPR ." + EGIT_LOCAL_OPTIONS=3D"${EGIT_OPTIONS}" EGIT_UPDATE_CMD=3D"git pull -f -u ${EGIT_OPTIONS}" UPSTREAM_BRANCH=3D"origin/${EGIT_BRANCH}" - EGIT_NONBARE=3D"true" + EGIT_LOCAL_NONBARE=3D"true" fi } =20 +# @FUNCTION: git-2_cleanup +# @DESCRIPTION: +# Internal function cleaning up all the global variables +# that are not required after the unpack has been done. +git-2_cleanup() { + debug-print-function ${FUNCNAME} "$@" + + # Here we can unset only variables that are GLOBAL + # defined by the eclass, BUT NOT subject to change + # by user (like EGIT_PROJECT). + # If ebuild writer polutes his environment it is + # his problem only. + unset EGIT_DIR + unset MOVE_COMMAND + unset EGIT_LOCAL_OPTIONS + unset EGIT_UPDATE_CMD + unset UPSTREAM_BRANCH + unset EGIT_LOCAL_NONBARE +} + # @FUNCTION: git-2_src_unpack # @DESCRIPTION: # Default git src_unpack function. @@ -517,13 +551,16 @@ git-2_move_source git-2_branch git-2_bootstrap + git-2_cleanup echo ">>> Unpacked to ${EGIT_SOURCEDIR}" =20 # Users can specify some SRC_URI and we should # unpack the files too. - if has ${EAPI:-0} 0 1; then - [[ -n ${A} ]] && unpack ${A} - else - default_src_unpack + if [[ -z ${EGIT_NOUNPACK} ]]; then + if has ${EAPI:-0} 0 1; then + [[ -n ${A} ]] && unpack ${A} + else + default_src_unpack + fi fi }