* [gentoo-portage-dev] [PATCH] GitSync: Support setting environment variables for git
@ 2017-06-05 8:40 Zac Medico
2017-06-05 13:39 ` Brian Dolbec
0 siblings, 1 reply; 3+ messages in thread
From: Zac Medico @ 2017-06-05 8:40 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Manuel Rüger
From: Manuel Rüger <mrueg@gentoo.org>
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
---
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 = shlex_split(self.repo.module_specific_options['sync-git-clone-env'])
+ clone_env = dict((k, v) for k, _, v in (assignment.partition('=') for assignment in shlexed_env) if k)
+ self.spawn_kwargs['env'].update(clone_env)
+
if self.settings.get("PORTAGE_QUIET") == "1":
git_cmd_opts += " --quiet"
if self.repo.clone_depth is not None:
@@ -86,6 +96,16 @@ class GitSync(NewBase):
'''
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-pull-env'):
+ shlexed_env = shlex_split(self.repo.module_specific_options['sync-git-pull-env'])
+ pull_env = dict((k, v) for k, _, v in (assignment.partition('=') for assignment in shlexed_env) if k)
+ self.spawn_kwargs['env'].update(pull_env)
+
if self.settings.get("PORTAGE_QUIET") == "1":
git_cmd_opts += " --quiet"
if self.repo.module_specific_options.get('sync-git-pull-extra-opts'):
--
2.13.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] GitSync: Support setting environment variables for git
2017-06-05 8:40 [gentoo-portage-dev] [PATCH] GitSync: Support setting environment variables for git Zac Medico
@ 2017-06-05 13:39 ` Brian Dolbec
2017-06-06 2:05 ` Zac Medico
0 siblings, 1 reply; 3+ messages in thread
From: Brian Dolbec @ 2017-06-05 13:39 UTC (permalink / raw
To: gentoo-portage-dev
On Mon, 5 Jun 2017 01:40:08 -0700
Zac Medico <zmedico@gentoo.org> wrote:
> From: Manuel Rüger <mrueg@gentoo.org>
>
> 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
> --- 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 =
> shlex_split(self.repo.module_specific_options['sync-git-clone-env'])
> + clone_env = dict((k, v) for k, _, v in
> (assignment.partition('=') for assignment in shlexed_env) if k)
> + self.spawn_kwargs['env'].update(clone_env)
> +
> if self.settings.get("PORTAGE_QUIET") == "1":
> git_cmd_opts += " --quiet"
> if self.repo.clone_depth is not None:
> @@ -86,6 +96,16 @@ class GitSync(NewBase):
> '''
>
> 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-pull-env'):
> + shlexed_env =
> shlex_split(self.repo.module_specific_options['sync-git-pull-env'])
> + pull_env = dict((k, v) for k, _, v in
> (assignment.partition('=') for assignment in shlexed_env) if k)
> + self.spawn_kwargs['env'].update(pull_env)
> +
> if self.settings.get("PORTAGE_QUIET") == "1":
> git_cmd_opts += " --quiet"
> if
> self.repo.module_specific_options.get('sync-git-pull-extra-opts'):
looks good, Thanks Manuel, Zac
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] GitSync: Support setting environment variables for git
2017-06-05 13:39 ` Brian Dolbec
@ 2017-06-06 2:05 ` Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2017-06-06 2:05 UTC (permalink / raw
To: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]
On Mon, Jun 5, 2017 at 6:39 AM, Brian Dolbec <dolsen@gentoo.org> wrote:
> On Mon, 5 Jun 2017 01:40:08 -0700
> Zac Medico <zmedico@gentoo.org> wrote:
>
> > From: Manuel Rüger <mrueg@gentoo.org>
> >
> > 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
> > --- 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(-)
>
> looks good, Thanks Manuel, Zac
>
Thanks, pushed:
https://gitweb.gentoo.org/proj/portage.git/commit/?id=8aa1a070921dc643d615a3c38b4f60e55e709850
--
Thanks,
Zac
[-- Attachment #2: Type: text/html, Size: 2133 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-06 2:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-05 8:40 [gentoo-portage-dev] [PATCH] GitSync: Support setting environment variables for git Zac Medico
2017-06-05 13:39 ` Brian Dolbec
2017-06-06 2:05 ` Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox