Changeset 269949 in webkit


Ignore:
Timestamp:
Nov 18, 2020 2:44:41 AM (3 years ago)
Author:
clopez@igalia.com
Message:

[FlatPak] update-webkitgtk-libs fails after a clean build
https://bugs.webkit.org/show_bug.cgi?id=218724

Reviewed by Philippe Normand.

The issue was caused because when adding a new flatpak repository
via the method FlatpakRepos.add() that repository is not added to
the internal list of available repositories inside the object FlatpakRepos.
So then the check on setup_builddir() added in r268542 failed because
the internal list of repositories on the object FlatpakRepos() was
empty on the first run (after a clean build).
To fix this we ensure to re-generate the internal list of flatpak
repositories any time that a new reporistory is added by calling
FlatpakRepos.update() after FlatpakRepos.add()

On top of that fix, we add another fix to make the code more robust.
Now it allows the generation of toolchains to fail without causing
a fatal error. Also a new check is added in order to retry to generate
the toolchains in the next run if is detected that they were not
correctly generated.

  • flatpak/flatpakutils.py:

(FlatpakRepos.add):
(WebkitFlatpak.load_from_args):
(WebkitFlatpak.main):
(WebkitFlatpak.check_toolchains_generated):
(WebkitFlatpak.pack_toolchain):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r269945 r269949  
     12020-11-18  Carlos Alberto Lopez Perez  <clopez@igalia.com>
     2
     3        [FlatPak] update-webkitgtk-libs fails after a clean build
     4        https://bugs.webkit.org/show_bug.cgi?id=218724
     5
     6        Reviewed by Philippe Normand.
     7
     8        The issue was caused because when adding a new flatpak repository
     9        via the method FlatpakRepos.add() that repository is not added to
     10        the internal list of available repositories inside the object FlatpakRepos.
     11        So then the check on setup_builddir() added in r268542 failed because
     12        the internal list of repositories on the object FlatpakRepos() was
     13        empty on the first run (after a clean build).
     14        To fix this we ensure to re-generate the internal list of flatpak
     15        repositories any time that a new reporistory is added by calling
     16        FlatpakRepos.update() after FlatpakRepos.add()
     17
     18        On top of that fix, we add another fix to make the code more robust.
     19        Now it allows the generation of toolchains to fail without causing
     20        a fatal error. Also a new check is added in order to retry to generate
     21        the toolchains in the next run if is detected that they were not
     22        correctly generated.
     23
     24        * flatpak/flatpakutils.py:
     25        (FlatpakRepos.add):
     26        (WebkitFlatpak.load_from_args):
     27        (WebkitFlatpak.main):
     28        (WebkitFlatpak.check_toolchains_generated):
     29        (WebkitFlatpak.pack_toolchain):
     30
    1312020-11-17  Diego Pino Garcia  <dpino@igalia.com>
    232
  • trunk/Tools/flatpak/flatpakutils.py

    r269205 r269949  
    264264
    265265    def add(self, repo, override=True):
    266         same_name = None
    267         for name, tmprepo in self.repos.items():
    268             if repo.url == tmprepo.url:
    269                 return tmprepo
    270             elif repo.name == name:
    271                 same_name = tmprepo
    272 
    273         if same_name:
    274             if override:
    275                 self.flatpak("remote-modify", repo.name, "--url=" + repo.url)
    276                 same_name.url = repo.url
    277 
    278                 return same_name
     266        try:
     267            same_name = None
     268            for name, tmprepo in self.repos.items():
     269                if repo.url == tmprepo.url:
     270                    return tmprepo
     271                elif repo.name == name:
     272                    same_name = tmprepo
     273
     274            if same_name:
     275                if override:
     276                    self.flatpak("remote-modify", repo.name, "--url=" + repo.url)
     277                    same_name.url = repo.url
     278
     279                    return same_name
     280                else:
     281                    return None
    279282            else:
    280                 return None
    281         else:
    282             args = ["remote-add", repo.name, "--if-not-exists"]
    283             if repo.repo_file:
    284                 args.extend(["--from", repo.repo_file.name])
    285             else:
    286                 args.extend(["--no-gpg-verify", repo.url])
    287             self.flatpak(*args, comment="Adding repo %s" % repo.name)
    288 
    289         repo.repos = self
    290         return repo
     283                args = ["remote-add", repo.name, "--if-not-exists"]
     284                if repo.repo_file:
     285                    args.extend(["--from", repo.repo_file.name])
     286                else:
     287                    args.extend(["--no-gpg-verify", repo.url])
     288                self.flatpak(*args, comment="Adding repo %s" % repo.name)
     289
     290            repo.repos = self
     291            return repo
     292        finally:
     293            self.update()
    291294
    292295
     
    442445        distributed_build_options.add_argument("--use-icecream", dest="use_icecream", help="Use the distributed icecream (icecc) compiler.", action="store_true")
    443446        distributed_build_options.add_argument("-r", "--regenerate-toolchains", dest="regenerate_toolchains", action="store_true",
    444                              help="Regenerate IceCC distribuable toolchain archives")
     447                                               help="Regenerate IceCC distributable toolchain archives")
    445448        distributed_build_options.add_argument("-t", "--sccache-token", dest="sccache_token",
    446449                                               help="sccache authentication token")
     
    872875            version_before_update = repo.version("org.webkit.Sdk")
    873876            repo.flatpak("update", comment="Updating Flatpak %s environment" % self.build_type)
    874             regenerate_toolchains = repo.version("org.webkit.Sdk") != version_before_update
     877            regenerate_toolchains = (repo.version("org.webkit.Sdk") != version_before_update) or not self.check_toolchains_generated()
    875878
    876879            for package in self._get_packages():
     
    890893        result = self.setup_dev_env()
    891894        if regenerate_toolchains:
     895            Console.message("Updating icecc distributable toolchain archives")
    892896            self.icc_version = {}
    893897            toolchains = self.pack_toolchain(("gcc", "g++"), {"/usr/bin/c++": "/usr/bin/g++"})
    894898            toolchains.extend(self.pack_toolchain(("clang", "clang++"), {"/usr/bin/clang++": "/usr/bin/clang++"}))
    895             self.save_config(toolchains)
     899            if len(toolchains) > 1:
     900                self.save_config(toolchains)
     901            else:
     902                Console.error_message("Error generating icecc distributable toolchain archives")
    896903
    897904        return result
     
    932939            Console.message("Created %s sccache config file. It will automatically be used when building WebKit", self.sccache_config_file)
    933940
     941    def check_toolchains_generated(self):
     942        found_toolchains = 0
     943        if os.path.isfile(self.config_file):
     944            with open(self.config_file, 'r') as config_fd:
     945                config = json.load(config_fd)
     946                if 'icecc_version' in config:
     947                    for compiler in config['icecc_version']:
     948                        if os.path.isfile(config['icecc_version'][compiler]):
     949                            found_toolchains += 1
     950        return found_toolchains > 1
     951
    934952    def pack_toolchain(self, compilers, path_mapping):
    935953        with tempfile.NamedTemporaryFile() as tmpfile:
    936954            command = ['icecc', '--build-native']
    937955            command.extend(["/usr/bin/%s" % compiler for compiler in compilers])
    938             self.run_in_sandbox(*command, stdout=tmpfile, cwd=self.source_root, skip_icc=True)
     956            retcode = self.run_in_sandbox(*command, stdout=tmpfile, cwd=self.source_root, skip_icc=True)
     957            if retcode != 0:
     958                Console.error_message('Flatpak command "%s" failed with return code %s', " ".join(command), retcode)
     959                return []
    939960            tmpfile.flush()
    940961            tmpfile.seek(0)
Note: See TracChangeset for help on using the changeset viewer.