[gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/, man/

2017-06-05 Thread Zac Medico
commit: 8aa1a070921dc643d615a3c38b4f60e55e709850
Author: Manuel RĂ¼ger  gentoo  org>
AuthorDate: Fri May 26 11:59:27 2017 +
Commit: Zac Medico  gentoo  org>
CommitDate: Tue Jun  6 01:56:05 2017 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=8aa1a070

GitSync: Support setting environment variables for git

This can be used to provide private SSH keys to portage in order to
clone repositories from a non-public repository.

An exemplary usage would be setting this in the repositories' repos.conf:
sync-git-env = "GIT_SSH_COMMAND=ssh -i /etc/portage/.ssh/id_rsa -o 
UserKnownHostsFile=/etc/portage/.ssh/known_hosts" GIT_TRACE=false
sync-git-pull-env = "GIT_SSH_COMMAND=ssh -i /etc/portage/.ssh/id_rsa -o 
UserKnownHostsFile=/etc/portage/.ssh/known_hosts" GIT_TRACE=true
sync-git-clone-env = "GIT_SSH_COMMAND=ssh -i /etc/portage/.ssh/id_rsa -o 
UserKnownHostsFile=/etc/portage/.ssh/known_hosts" GIT_TRACE=true

Closes: https://github.com/gentoo/portage/pull/165
Acked-by: Brian Dolbec  gentoo.org>

 man/portage.5| 24 +++-
 pym/portage/sync/modules/git/__init__.py |  5 -
 pym/portage/sync/modules/git/git.py  | 24 ++--
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/man/portage.5 b/man/portage.5
index 366a1fa85..5f1f2bbb0 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -1,4 +1,4 @@
-.TH "PORTAGE" "5" "Jan 2017" "Portage VERSION" "Portage"
+.TH "PORTAGE" "31" "May 2017" "Portage VERSION" "Portage"
 .SH NAME
 portage \- the heart of Gentoo
 .SH "DESCRIPTION"
@@ -979,9 +979,31 @@ Specifies CVS repository.
 .B sync\-depth
 This is a deprecated alias for the \fBclone\-depth\fR option.
 .TP
+.B sync\-git\-clone\-env
+Set environment variables for git when cloning repository (git clone).
+This will override settings from sync-git-env.
+.RS
+.TP
+.I Example:
+sync-git-clone-env="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
+.br
+Gives three variables "VAR1", "VAR2", "VAR3" with the values "word1 word2",
+"word3", "$word 5 6".
+.RE
+.TP
 .B sync\-git\-clone\-extra\-opts
 Extra options to give to git when cloning repository (git clone).
 .TP
+.B sync\-git\-env
+Set environment variables for git when cloning or pulling the repository.
+These will be overridden by setting them again in sync-git-clone-env and 
sync-git-pull-env.
+See also example for sync-git-clone-env.
+.TP
+.B sync\-git\-pull\-env
+Set environment variables for git when updating repository (git pull).
+This will override settings from sync-git-env.
+See also example for sync-git-clone-env.
+.TP
 .B sync\-git\-pull\-extra\-opts
 Extra options to give to git when updating repository (git pull).
 .TP

diff --git a/pym/portage/sync/modules/git/__init__.py 
b/pym/portage/sync/modules/git/__init__.py
index 60b7395b8..e7206e12d 100644
--- a/pym/portage/sync/modules/git/__init__.py
+++ b/pym/portage/sync/modules/git/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Gentoo Foundation
+# Copyright 2014-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 doc = """Git plug-in module for portage.
@@ -52,7 +52,10 @@ module_spec = {
},
'validate_config': CheckGitConfig,
'module_specific_options': (
+   'sync-git-clone-env',
'sync-git-clone-extra-opts',
+   'sync-git-env',
+   'sync-git-pull-env',
'sync-git-pull-extra-opts',
),
}

diff --git a/pym/portage/sync/modules/git/git.py 
b/pym/portage/sync/modules/git/git.py
index d432886dd..bea79c7e7 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -1,4 +1,4 @@
-# Copyright 2005-2015 Gentoo Foundation
+# Copyright 2005-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import logging
@@ -6,7 +6,7 @@ import subprocess
 
 import portage
 from portage import os
-from portage.util import writemsg_level
+from portage.util import writemsg_level, shlex_split
 from portage.output import create_color_func
 good = create_color_func("GOOD")
 bad = create_color_func("BAD")
@@ -50,6 +50,16 @@ class GitSync(NewBase):
sync_uri = sync_uri[6:]
 
git_cmd_opts = ""
+   if self.repo.module_specific_options.get('sync-git-env'):
+   shlexed_env = 
shlex_split(self.repo.module_specific_options['sync-git-env'])
+   env = dict((k, v) for k, _, v in 
(assignment.partition('=') for assignment in shlexed_env) if k)
+   self.spawn_kwargs['env'].update(env)
+
+   if self.repo.module_specific_options.get('sync-git-clone-env'):
+   shlexed_env = 

[gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/, man/, pym/portage/repository/

2017-02-22 Thread Zac Medico
commit: b3f6297a791a748a4bca370283705576568a20c2
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Feb 18 02:40:03 2017 +
Commit: Zac Medico  gentoo  org>
CommitDate: Wed Feb 22 08:40:00 2017 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b3f6297a

repos.conf: rename sync-depth option to clone-depth

Since sync-depth actually controls clone depth, rename it
to clone-depth, and show a warning message when the sync-depth
option has been specified:

UserWarning: repos.conf: sync-depth is deprecated, use clone-depth instead

This makes it feasible to change the meaning of sync-depth in
the future (it could be used to control git pull depth).

X-Gentoo-Bug: 552814
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=552814
Acked-by: Brian Dolbec  gentoo.org>

 man/portage.5|  7 +--
 pym/portage/repository/config.py | 16 
 pym/portage/sync/modules/git/__init__.py | 14 +-
 pym/portage/sync/modules/git/git.py  |  4 +++-
 4 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/man/portage.5 b/man/portage.5
index 415817a47..82e979ecf 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -925,6 +925,10 @@ Valid values: yes, no, true, false.
 If unset, the repo will be treated as set
 yes, true.
 .TP
+.B clone\-depth
+Specifies clone depth to use for DVCS repositories. Defaults to 1 (only
+the newest commit). If set to 0, the depth is unlimited.
+.TP
 .B eclass\-overrides
 Makes given repository inherit eclasses from specified repositories.
 .br
@@ -972,8 +976,7 @@ Valid values: true, false.
 Specifies CVS repository.
 .TP
 .B sync\-depth
-Specifies clone depth to use for DVCS repositories. Defaults to 1 (only
-the newest commit). If set to 0, the depth is unlimited.
+This is a deprecated alias for the \fBclone\-depth\fR option.
 .TP
 .B sync\-git\-clone\-extra\-opts
 Extra options to give to git when cloning repository (git clone).

diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 67c717d34..b65ed97ce 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -75,7 +75,8 @@ class RepoConfig(object):
"""Stores config of one repository"""
 
__slots__ = ('aliases', 'allow_missing_manifest', 
'allow_provide_virtual',
-   'auto_sync', 'cache_formats', 'create_manifest', 
'disable_manifest',
+   'auto_sync', 'cache_formats', 'clone_depth',
+   'create_manifest', 'disable_manifest',
'eapi', 'eclass_db', 'eclass_locations', 'eclass_overrides',
'find_invalid_path_char', 'force', 'format', 'local_config', 
'location',
'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
@@ -168,7 +169,13 @@ class RepoConfig(object):
auto_sync = auto_sync.strip().lower()
self.auto_sync = auto_sync
 
+   self.clone_depth = repo_opts.get('clone-depth')
self.sync_depth = repo_opts.get('sync-depth')
+
+   if self.sync_depth is not None:
+   warnings.warn(_("repos.conf: sync-depth is deprecated,"
+   " use clone-depth instead"))
+
self.sync_hooks_only_on_change = repo_opts.get(
'sync-hooks-only-on-change', 'false').lower() == 'true'
 
@@ -505,7 +512,8 @@ class RepoConfigLoader(object):
if repos_conf_opts is not None:
# Selectively copy only the 
attributes which
# repos.conf is allowed to 
override.
-   for k in ('aliases', 
'auto_sync', 'eclass_overrides',
+   for k in ('aliases', 
'auto_sync',
+   'clone_depth', 
'eclass_overrides',
'force', 'masters', 
'priority', 'strict_misc_digests',
'sync_depth', 
'sync_hooks_only_on_change',
'sync_type', 
'sync_umask', 'sync_uri', 'sync_user',
@@ -929,8 +937,8 @@ class RepoConfigLoader(object):
 
def config_string(self):
bool_keys = ("strict_misc_digests",)
-   str_or_int_keys = ("auto_sync", "format", "location",
-   "main_repo", "priority",
+   str_or_int_keys = ("auto_sync", "clone_depth", "format", 
"location",
+   "main_repo", "priority", "sync_depth",
"sync_type", "sync_umask", "sync_uri", 'sync_user')
str_tuple_keys = ("aliases", "eclass_overrides", "force")
repo_config_tuple_keys = ("masters",)

diff --git a/pym/portage/sync/modules/git/__init__.py