[Notes] [Git][BuildStream/buildstream][tristan/notifications] 3 commits: Fix ostree repository mirroring



Title: GitLab

Tristan Van Berkom pushed to branch tristan/notifications at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • buildstream/_frontend/app.py
    ... ... @@ -269,6 +269,9 @@ class App():
    269 269
                     else:
    
    270 270
                         self._message(MessageType.FAIL, session_name, elapsed=elapsed)
    
    271 271
     
    
    272
    +                    # Notify session failure
    
    273
    +                    self._notify("{} failed".format(session_name), "{}".format(e))
    
    274
    +
    
    272 275
                     if self._started:
    
    273 276
                         self._print_summary()
    
    274 277
     
    
    ... ... @@ -286,6 +289,9 @@ class App():
    286 289
                     if self._started:
    
    287 290
                         self._print_summary()
    
    288 291
     
    
    292
    +                # Notify session success
    
    293
    +                self._notify("{} succeeded".format(session_name), "")
    
    294
    +
    
    289 295
         # init_project()
    
    290 296
         #
    
    291 297
         # Initialize a new BuildStream project, either with the explicitly passed options,
    
    ... ... @@ -419,6 +425,12 @@ class App():
    419 425
         #                      Local Functions                     #
    
    420 426
         ############################################################
    
    421 427
     
    
    428
    +    # Local function for calling the notify() virtual method
    
    429
    +    #
    
    430
    +    def _notify(self, title, text):
    
    431
    +        if self.interactive:
    
    432
    +            self.notify(title, text)
    
    433
    +
    
    422 434
         # Local message propagator
    
    423 435
         #
    
    424 436
         def _message(self, message_type, message, **kwargs):
    
    ... ... @@ -571,8 +583,8 @@ class App():
    571 583
                 while choice not in ['continue', 'quit', 'terminate', 'retry']:
    
    572 584
                     click.echo(summary, err=True)
    
    573 585
     
    
    574
    -                self.notify("BuildStream failure", "{} on element {}"
    
    575
    -                            .format(failure.action_name, element.name))
    
    586
    +                self._notify("BuildStream failure", "{} on element {}"
    
    587
    +                             .format(failure.action_name, element.name))
    
    576 588
     
    
    577 589
                     try:
    
    578 590
                         choice = click.prompt("Choice:", default='continue', err=True,
    

  • buildstream/plugins/sources/ostree.py
    ... ... @@ -71,7 +71,7 @@ class OSTreeSource(Source):
    71 71
             self.ref = self.node_get_member(node, str, 'ref', None)
    
    72 72
             self.tracking = self.node_get_member(node, str, 'track', None)
    
    73 73
             self.mirror = os.path.join(self.get_mirror_directory(),
    
    74
    -                                   utils.url_directory_name(self.url))
    
    74
    +                                   utils.url_directory_name(self.original_url))
    
    75 75
     
    
    76 76
             # (optional) Not all repos are signed. But if they are, get the gpg key
    
    77 77
             self.gpg_key_path = None
    
    ... ... @@ -104,10 +104,11 @@ class OSTreeSource(Source):
    104 104
                 return None
    
    105 105
     
    
    106 106
             self.ensure()
    
    107
    +        remote_name = self.ensure_remote(self.url)
    
    107 108
             with self.timed_activity("Fetching tracking ref '{}' from origin: {}"
    
    108 109
                                      .format(self.tracking, self.url)):
    
    109 110
                 try:
    
    110
    -                _ostree.fetch(self.repo, ref=self.tracking, progress=self.progress)
    
    111
    +                _ostree.fetch(self.repo, remote=remote_name, ref=self.tracking, progress=self.progress)
    
    111 112
                 except OSTreeError as e:
    
    112 113
                     raise SourceError("{}: Failed to fetch tracking ref '{}' from origin {}\n\n{}"
    
    113 114
                                       .format(self, self.tracking, self.url, e)) from e
    
    ... ... @@ -116,11 +117,12 @@ class OSTreeSource(Source):
    116 117
     
    
    117 118
         def fetch(self):
    
    118 119
             self.ensure()
    
    120
    +        remote_name = self.ensure_remote(self.url)
    
    119 121
             if not _ostree.exists(self.repo, self.ref):
    
    120 122
                 with self.timed_activity("Fetching remote ref: {} from origin: {}"
    
    121 123
                                          .format(self.ref, self.url)):
    
    122 124
                     try:
    
    123
    -                    _ostree.fetch(self.repo, ref=self.ref, progress=self.progress)
    
    125
    +                    _ostree.fetch(self.repo, remote=remote_name, ref=self.ref, progress=self.progress)
    
    124 126
                     except OSTreeError as e:
    
    125 127
                         raise SourceError("{}: Failed to fetch ref '{}' from origin: {}\n\n{}"
    
    126 128
                                           .format(self, self.ref, self.url, e)) from e
    
    ... ... @@ -171,14 +173,22 @@ class OSTreeSource(Source):
    171 173
                 self.status("Creating local mirror for {}".format(self.url))
    
    172 174
     
    
    173 175
                 self.repo = _ostree.ensure(self.mirror, True)
    
    174
    -            gpg_key = None
    
    175
    -            if self.gpg_key_path:
    
    176
    -                gpg_key = 'file://' + self.gpg_key_path
    
    177 176
     
    
    178
    -            try:
    
    179
    -                _ostree.configure_remote(self.repo, "origin", self.url, key_url=gpg_key)
    
    180
    -            except OSTreeError as e:
    
    181
    -                raise SourceError("{}: Failed to configure origin {}\n\n{}".format(self, self.url, e)) from e
    
    177
    +    def ensure_remote(self, url):
    
    178
    +        if self.original_url == self.url:
    
    179
    +            remote_name = 'origin'
    
    180
    +        else:
    
    181
    +            remote_name = utils.url_directory_name(url)
    
    182
    +
    
    183
    +        gpg_key = None
    
    184
    +        if self.gpg_key_path:
    
    185
    +            gpg_key = 'file://' + self.gpg_key_path
    
    186
    +
    
    187
    +        try:
    
    188
    +            _ostree.configure_remote(self.repo, remote_name, url, key_url=gpg_key)
    
    189
    +        except OSTreeError as e:
    
    190
    +            raise SourceError("{}: Failed to configure origin {}\n\n{}".format(self, self.url, e)) from e
    
    191
    +        return remote_name
    
    182 192
     
    
    183 193
         def progress(self, percent, message):
    
    184 194
             self.status(message)
    

  • tests/frontend/mirror.py
    ... ... @@ -466,10 +466,6 @@ def test_mirror_track_upstream_absent(cli, tmpdir, datafiles, kind):
    466 466
     @pytest.mark.datafiles(DATA_DIR)
    
    467 467
     @pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS])
    
    468 468
     def test_mirror_from_includes(cli, tmpdir, datafiles, kind):
    
    469
    -    if kind == 'ostree':
    
    470
    -        # FIXME: Mirroring fallback fails with ostree
    
    471
    -        pytest.skip("Bug #538 - ostree mirror fallback breaks assertion")
    
    472
    -
    
    473 469
         bin_files_path = os.path.join(str(datafiles), 'files', 'bin-files', 'usr')
    
    474 470
         upstream_repodir = os.path.join(str(tmpdir), 'upstream')
    
    475 471
         mirror_repodir = os.path.join(str(tmpdir), 'mirror')
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]