'Helper function to process external packages.
Runs post install hooks and registers the package in the DB.
Args:
explicit (bool): if the package was requested explicitly by
the user, False if it was pulled in as a dependency of an
explicit package.'

def _process_external_package(self, explicit):

    if self.spec.external_module:
        message = '{s.name}@{s.version}    :    has    external    module    in    {module}'
        tty.msg(message.format(s=self, module=self.spec.external_module))
        message = '{s.name}@{s.version}    :    is    actually    installed    in    {path}'
        tty.msg(message.format(s=self, path=self.spec.external_path))
    else:
        message = '{s.name}@{s.version}    :    externally    installed    in    {path}'
        tty.msg(message.format(s=self, path=self.spec.external_path))
    try:
        rec = spack.store.db.get_record(self.spec)
        message = '{s.name}@{s.version}    :    already    registered    in    DB'
        tty.msg(message.format(s=self))
        self._update_explicit_entry_in_db(rec, explicit)
    except KeyError:
        message = '{s.name}@{s.version}    :    generating    module    file'
        tty.msg(message.format(s=self))
        spack.hooks.post_install(self.spec)
        message = '{s.name}@{s.version}    :    registering    into    DB'
        tty.msg(message.format(s=self))
        spack.store.db.add(self.spec, None, explicit=explicit)
