Example #1
0
def create_delta_packages(old_packages, new_package):
    if new_package in old_packages:
        ctx.ui.warning(
            _("New package \"{}\" exists in the list of old packages. Skipping it..."
              ).format(new_package))
        while new_package in old_packages:
            old_packages.remove(new_package)

    new_pkg_name = os.path.splitext(os.path.basename(new_package))[0]
    new_pkg_path = util.join_path(ctx.config.tmp_dir(), new_pkg_name)

    new_pkg = inary.package.Package(new_package, tmp_dir=new_pkg_path)
    new_pkg.read()

    # Unpack new package to temp
    new_pkg.extract_inary_files(new_pkg_path)
    new_pkg.extract_dir("scom", new_pkg_path)

    install_dir = util.join_path(new_pkg_path, "install")
    util.clean_dir(install_dir)
    os.mkdir(install_dir)
    new_pkg.extract_install(install_dir)

    delta_packages = create_delta_packages_from_obj(old_packages, new_pkg,
                                                    new_pkg_path)

    # Remove temp dir
    util.clean_dir(new_pkg_path)

    # Return delta package names
    return delta_packages
Example #2
0
    def postinstall(self):

        # Chowning for additional files
        for _file in self.package.get_files().list:
            fpath = util.join_path(ctx.config.dest_dir(), _file.path)
            if os.path.islink(fpath):
                if os.path.lexists(fpath) and os.path.exists(fpath):
                    ctx.ui.info(_("Added symlink '{}' ").format(fpath),
                                verbose=True)
                else:
                    ctx.ui.warning(
                        _("Broken or missing symlink '{}'").format(fpath))

        if 'postOps' in self.metadata.package.isA:
            if ctx.config.get_option(
                    'ignore_configure') or ctx.config.get_option('destdir'):
                self.installdb.mark_pending(self.pkginfo.name)
                return 0
            ctx.ui.info(_('Configuring post-install \"{}\"'.format(
                self.pkginfo.name)),
                        color='brightyellow')
            if not self.trigger.postinstall(self.package.pkg_dir()):
                ctx.ui.error(
                    _('Post-install configuration of \"{}\" package failed.').
                    format(self.pkginfo.name))
                self.installdb.mark_pending(self.pkginfo.name)
                return 0
        if self.old_path != self.package.pkg_dir() and self.old_path != None:
            util.clean_dir(self.old_path)
Example #3
0
    def unpack(self, target_dir, clean_dir=False):
        # first we check if we need to clean-up our working env.
        if os.path.exists(target_dir):
            if clean_dir:
                util.clean_dir(target_dir)

        if not os.path.exists(target_dir):
            os.makedirs(target_dir)
Example #4
0
 def preinstall(self):
     if 'postOps' in self.metadata.package.isA:
         if ctx.config.get_option(
                 'ignore_configure') or ctx.config.get_option('destdir'):
             self.installdb.mark_pending(self.pkginfo.name)
             return 0
         ctx.ui.info(_(
             'Pre-install configuration have been run for \"{}\"'.format(
                 self.pkginfo.name)),
                     color='brightyellow')
         if not self.trigger.preinstall(self.package.pkg_dir()):
             util.clean_dir(self.package.pkg_dir())
             ctx.ui.error(
                 _('Pre-install configuration of \"{}\" package failed.').
                 format(self.pkginfo.name))
Example #5
0
 def run(self):
     self.init(database=False, write=False)
     if ctx.get_option('snapshot'):
         self.take_snapshot()
         return
     elif ctx.get_option('takeback') != -1:
         opno = ctx.get_option('takeback')
         self.takeback(opno)
         return
     elif ctx.get_option('reset'):
         ctx.ui.info(_("Resetting history casts"), verbose=True)
         util.clean_dir(ctx.config.history_dir())
         util.makedirs(ctx.config.history_dir())
         import inary.data.history as History
         history = History.History()
         history.create("reset")
         history.update()
         return
     else:
         self.redirect_output(self.print_history())
Example #6
0
    def read_uri_of_repo(self, uri, repo=None, force=False):
        """Read PSPEC file"""
        if repo:
            tmpdir = os.path.join(ctx.config.index_dir(), repo)
        else:
            tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')

        util.clean_dir(tmpdir)
        util.ensure_dirs(tmpdir)

        # write uri
        urlfile = open(util.join_path(tmpdir, 'uri'), 'w')
        urlfile.write(uri)  # uri
        urlfile.close()

        self.read_uri(uri, tmpdir, force)

        if not repo:
            repo = self.distribution.name()
            # and what do we do with it? move it to index dir properly
            newtmpdir = os.path.join(ctx.config.index_dir(), repo)
            util.clean_dir(newtmpdir)  # replace newtmpdir
            shutil.move(tmpdir, newtmpdir)
Example #7
0
    def update_databases(self):
        """update databases"""

        if self.installdb.has_package(self.pkginfo.name):
            if self.operation == (UPGRADE or DOWNGRADE or REINSTALL):
                self.installdb.remove_package(self.pkginfo)
                self.installdb.add_package(self.pkginfo)

            release = self.installdb.get_release(self.pkginfo.name)
            actions = self.pkginfo.get_update_actions(release)
        else:
            actions = self.pkginfo.get_update_actions("1")

        for package_name in actions.get("serviceRestart", []):
            self.installdb.mark_needs_restart(package_name)

        for package_name in actions.get("systemRestart", []):
            self.installdb.mark_needs_reboot(package_name)

        # filesdb
        ctx.ui.info(_('Adding files of \"{}\" package to database...').format(
            self.metadata.package.name),
                    color='faintpurple')
        ctx.filesdb.add_files(self.metadata.package.name, self.files)

        # installed packages
        self.installdb.add_package(self.pkginfo)

        otype = "delta" if self.package_fname.endswith(
            ctx.const.delta_package_suffix) else None
        self.historydb.add_and_update(pkgBefore=self.old_pkginfo,
                                      pkgAfter=self.pkginfo,
                                      operation=opttostr[self.operation],
                                      otype=otype)

        if self.operation == (UPGRADE or DOWNGRADE or REINSTALL):
            util.clean_dir(self.old_path)
Example #8
0
 def delete_cache():
     """
     Deletes cached packages, cached archives, build dirs, db caches
     """
     ctx.ui.info(
         _("Cleaning package cache \"{}\"...").format(
             ctx.config.cached_packages_dir()))
     util.clean_dir(ctx.config.cached_packages_dir())
     ctx.ui.info(
         _("Cleaning source archive cache \"{}\"...").format(
             ctx.config.archives_dir()))
     util.clean_dir(ctx.config.archives_dir())
     ctx.ui.info(
         _("Cleaning temporary directory \"{}\"...").format(
             ctx.config.tmp_dir()))
     util.clean_dir(ctx.config.tmp_dir())
     for cache in [
             x for x in os.listdir(ctx.config.cache_root_dir())
             if x.endswith(".cache")
     ]:
         cache_file = util.join_path(ctx.config.cache_root_dir(), cache)
         ctx.ui.info(_("Removing cache file \"{}\"...").format(cache_file))
         os.unlink(cache_file)
Example #9
0
 def remove_repo(self, name):
     util.clean_dir(os.path.join(ctx.config.index_dir(), name))
     self.repoorder.remove(name)
Example #10
0
 def remove_inary_files(self):
     ctx.ui.info(
         _('Removing files of \"{}\" package from system...').format(
             self.package_name),
         color='faintpurple')
     util.clean_dir(self.package.pkg_dir())