Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: man/, cnf/, pym/portage/sync/modules/rsync/
Date: Thu, 25 Jan 2018 08:00:53
Message-Id: 1516867207.eb98d1ac1f255a004e06debfa1611a65fdc493e2.mgorny@gentoo
1 commit: eb98d1ac1f255a004e06debfa1611a65fdc493e2
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 24 21:01:06 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 25 08:00:07 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=eb98d1ac
7
8 rsync: Introduce support for running full-tree gemato verification
9
10 Add two new configuration options to rsync repositories:
11 sync-rsync-verify-metamanifest and sync-rsync-openpgp-key-path.
12 The first controls whether gemato verification is run for
13 the repository (defaults to true for ::gentoo, false otherwise),
14 the second makes it possible to override the key path for custom
15 repositories.
16
17 Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
18
19 cnf/repos.conf | 2 ++
20 man/portage.5 | 9 +++++++++
21 pym/portage/sync/modules/rsync/__init__.py | 4 +++-
22 pym/portage/sync/modules/rsync/rsync.py | 20 +++++++++++++++++++-
23 4 files changed, 33 insertions(+), 2 deletions(-)
24
25 diff --git a/cnf/repos.conf b/cnf/repos.conf
26 index 062fc0d10..0d2b1f4be 100644
27 --- a/cnf/repos.conf
28 +++ b/cnf/repos.conf
29 @@ -6,6 +6,8 @@ location = /usr/portage
30 sync-type = rsync
31 sync-uri = rsync://rsync.gentoo.org/gentoo-portage
32 auto-sync = yes
33 +sync-rsync-verify-metamanifest = yes
34 +sync-rsync-openpgp-key-path = /var/lib/gentoo/gkeys/keyrings/gentoo/release/pubring.gpg
35
36 # for daily squashfs snapshots
37 #sync-type = squashdelta
38
39 diff --git a/man/portage.5 b/man/portage.5
40 index e724e1f08..2d444a86f 100644
41 --- a/man/portage.5
42 +++ b/man/portage.5
43 @@ -1071,10 +1071,19 @@ Extra options to give to rsync on repository synchronization. It takes
44 precedence over a declaration in [DEFAULT] section, that takes
45 precedence over PORTAGE_RSYNC_EXTRA_OPTS.
46 .TP
47 +.B sync\-rsync\-openpgp\-key\-path
48 +Path to the OpenPGP key(ring) used to verify MetaManifest. Used only
49 +if \fBsync\-rsync\-verify\-metamanifest\fR is enabled. If unset,
50 +the user's keyring is used.
51 +.TP
52 .B sync-rsync-vcs-ignore = true|false
53 Ignore vcs directories that may be present in the repository. It is the
54 user's responsibility to set sync-rsync-extra-opts to protect vcs
55 directories if appropriate.
56 +.TP
57 +.B sync\-rsync\-verify\-metamanifest = true|false
58 +Require the repository to contain a signed MetaManifest and verify
59 +it using \fBapp\-portage/gemato\fR. Defaults to false.
60
61 .RE
62
63
64 diff --git a/pym/portage/sync/modules/rsync/__init__.py b/pym/portage/sync/modules/rsync/__init__.py
65 index c2fdc4188..df9a1995a 100644
66 --- a/pym/portage/sync/modules/rsync/__init__.py
67 +++ b/pym/portage/sync/modules/rsync/__init__.py
68 @@ -1,4 +1,4 @@
69 -# Copyright 2014 Gentoo Foundation
70 +# Copyright 2014-2018 Gentoo Foundation
71 # Distributed under the terms of the GNU General Public License v2
72
73 doc = """Rsync plug-in module for portage.
74 @@ -27,7 +27,9 @@ module_spec = {
75 'validate_config': CheckSyncConfig,
76 'module_specific_options': (
77 'sync-rsync-extra-opts',
78 + 'sync-rsync-openpgp-key-path',
79 'sync-rsync-vcs-ignore',
80 + 'sync-rsync-verify-metamanifest',
81 ),
82 }
83 }
84
85 diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py
86 index c80641ba3..47f0e1ea3 100644
87 --- a/pym/portage/sync/modules/rsync/rsync.py
88 +++ b/pym/portage/sync/modules/rsync/rsync.py
89 @@ -1,4 +1,4 @@
90 -# Copyright 1999-2015 Gentoo Foundation
91 +# Copyright 1999-2018 Gentoo Foundation
92 # Distributed under the terms of the GNU General Public License v2
93
94 import sys
95 @@ -82,6 +82,16 @@ class RsyncSync(NewBase):
96 self.extra_rsync_opts.extend(portage.util.shlex_split(
97 self.repo.module_specific_options['sync-rsync-extra-opts']))
98
99 + # Process GLEP74 verification options.
100 + # Default verification to 'on' for ::gentoo, 'off' otherwise.
101 + self.verify_metamanifest = (
102 + self.repo.module_specific_options.get(
103 + 'sync-rsync-verify-metamanifest', False))
104 + # Default to gentoo-keys keyring.
105 + self.openpgp_key_path = (
106 + self.repo.module_specific_options.get(
107 + 'sync-rsync-openpgp-key-path', None))
108 +
109 # Real local timestamp file.
110 self.servertimestampfile = os.path.join(
111 self.repo.location, "metadata", "timestamp.chk")
112 @@ -259,6 +269,14 @@ class RsyncSync(NewBase):
113 exitcode = EXCEEDED_MAX_RETRIES
114 break
115 self._process_exitcode(exitcode, dosyncuri, out, maxretries)
116 +
117 + # if synced successfully, verify now
118 + if exitcode == 0 and self.verify_metamanifest:
119 + command = ['gemato', 'verify', '-s', self.repo.location]
120 + if self.openpgp_key_path is not None:
121 + command += ['-K', self.openpgp_key_path]
122 + exitcode = portage.process.spawn(command, **self.spawn_kwargs)
123 +
124 return (exitcode, updatecache_flg)