Ejemplo n.º 1
0
    def run(self):
        cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window",  \
                "--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), "-o", "Synaptic::closeZvt=true"]
        f = tempfile.NamedTemporaryFile()
        cache = apt.Cache()
        if self.remove:
            KERNEL_PKG_NAMES.append('linux-image-unsigned-VERSION-generic'
                                    )  # mainline, remove only
        for name in KERNEL_PKG_NAMES:
            name = name.replace("VERSION", self.version)
            if name in cache:
                pkg = cache[name]
                if self.remove:
                    if pkg.is_installed:
                        pkg_line = "%s\tpurge\n" % name
                        f.write(pkg_line.encode("utf-8"))
                else:
                    pkg_line = "%s\tinstall\n" % name
                    f.write(pkg_line.encode("utf-8"))

        cmd.append("--set-selections-file")
        cmd.append("%s" % f.name)
        f.flush()
        comnd = subprocess.Popen(' '.join(cmd),
                                 stdout=self.application.logger.log,
                                 stderr=self.application.logger.log,
                                 shell=True)
        returnCode = comnd.wait()
        f.close()
Ejemplo n.º 2
0
    def run(self):
        self.application.window.set_sensitive(False)
        do_regular = False
        for (version, kernel_type, origin, remove) in self.kernels:
            if not do_regular:
                do_regular = True
                f = tempfile.NamedTemporaryFile()
                cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window",  \
                    "--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
                    "-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
                if not self.cache:
                    self.cache = apt.Cache()
            _KERNEL_PKG_NAMES = KERNEL_PKG_NAMES.copy()
            if remove:
                _KERNEL_PKG_NAMES.append(
                    "linux-image-unsigned-VERSION-KERNELTYPE"
                )  # mainline, remove only
            for name in _KERNEL_PKG_NAMES:
                name = name.replace("VERSION",
                                    version).replace("-KERNELTYPE",
                                                     kernel_type)
                if name in self.cache.keys():
                    pkg = self.cache[name]
                    if remove:
                        if pkg.is_installed:
                            # skip kernel_type independent packages (headers) if another kernel of the
                            # same version but different type is installed
                            if not kernel_type in name and self.package_needed_by_another_kernel(
                                    version, kernel_type):
                                continue
                            pkg_line = "%s\tpurge\n" % name
                            f.write(pkg_line.encode("utf-8"))
                    else:
                        pkg_line = "%s\tinstall\n" % name
                        f.write(pkg_line.encode("utf-8"))
            f.flush()

        if do_regular:
            subprocess.run([
                "sudo", "/usr/lib/linuxmint/mintUpdate/synaptic-workaround.py",
                "enable"
            ])
            subprocess.run(cmd,
                           stdout=self.application.logger.log,
                           stderr=self.application.logger.log)
            subprocess.run([
                "sudo", "/usr/lib/linuxmint/mintUpdate/synaptic-workaround.py",
                "disable"
            ])
            f.close()
        self.cache = None
        self.application.window.set_sensitive(True)
Ejemplo n.º 3
0
    def run(self):
        Gdk.threads_enter()
        self.application.window.set_sensitive(False)
        Gdk.threads_leave()
        do_regular = False
        self.application.cache_watcher.pause()
        for kernel in self.kernels:
            if not do_regular:
                do_regular = True
                f = tempfile.NamedTemporaryFile()
                cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window",  \
                    "--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
                    "-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
                if not self.cache:
                    self.cache = apt.Cache()
            _KERNEL_PKG_NAMES = KERNEL_PKG_NAMES.copy()
            if kernel.installed:
                _KERNEL_PKG_NAMES.append(
                    "linux-image-unsigned-VERSION-KERNELTYPE"
                )  # mainline, remove only
            for name in _KERNEL_PKG_NAMES:
                name = name.replace("VERSION", kernel.version).replace(
                    "-KERNELTYPE", kernel.type)
                if name in self.cache:
                    pkg = self.cache[name]
                    if kernel.installed:
                        if pkg.is_installed:
                            # skip kernel_type independent packages (headers) if another kernel of the
                            # same version but different type is installed
                            if not kernel.type in name and self.package_needed_by_another_kernel(
                                    kernel.version, kernel.type):
                                continue
                            pkg_line = "%s\tpurge\n" % name
                            f.write(pkg_line.encode("utf-8"))
                    else:
                        pkg_line = "%s\tinstall\n" % name
                        f.write(pkg_line.encode("utf-8"))

                # Clean out left-over meta package
                if kernel.installed:

                    def kernel_series(version):
                        return version.replace("-", ".").split(".")[:3]

                    last_in_series = True
                    this_kernel_series = kernel_series(kernel.version)
                    for _type, _version in self.kernel_window.installed_kernels:
                        if (_type == kernel.type and _version != kernel.version
                                and kernel_series(_version)
                                == this_kernel_series):
                            last_in_series = False
                    if last_in_series:
                        meta_names = []
                        _metas = [
                            s for s in self.cache.keys()
                            if s.startswith("linux" + kernel.type)
                        ]
                        if kernel.type == "-generic":
                            _metas.append("linux-virtual")
                        for meta in _metas:
                            shortname = meta.split(":")[0]
                            if shortname not in meta_names:
                                meta_names.append(shortname)
                        for meta_name in meta_names:
                            if meta_name in self.cache:
                                meta = self.cache[meta_name]
                                if meta.is_installed and \
                                    kernel_series(meta.candidate.version) == this_kernel_series:
                                    f.write(("%s\tpurge\n" %
                                             meta_name).encode("utf-8"))
                                    f.write(("%s\tpurge\n" % meta_name.replace(
                                        "linux-",
                                        "linux-image-")).encode("utf-8"))
                                    f.write(("%s\tpurge\n" % meta_name.replace(
                                        "linux-",
                                        "linux-headers-")).encode("utf-8"))
                                    if meta_name == "linux-virtual":
                                        f.write(
                                            ("linux-headers-generic\tpurge\n"
                                             ).encode("utf-8"))
            f.flush()

        if do_regular:
            subprocess.run([
                "sudo", "/usr/lib/linuxmint/mintUpdate/synaptic-workaround.py",
                "enable"
            ])
            subprocess.run(cmd,
                           stdout=self.application.logger.log,
                           stderr=self.application.logger.log)
            subprocess.run([
                "sudo", "/usr/lib/linuxmint/mintUpdate/synaptic-workaround.py",
                "disable"
            ])
            f.close()
        self.application.refresh()
        self.cache = None
        Gdk.threads_enter()
        self.application.window.set_sensitive(True)
        Gdk.threads_leave()
Ejemplo n.º 4
0
    def run(self):
        self.application.window.set_sensitive(False)
        do_regular = False
        self.application.cache_watcher.pause()
        for kernel in self.kernels:
            if not do_regular:
                do_regular = True
                f = tempfile.NamedTemporaryFile()
                cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window",  \
                    "--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
                    "-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
                if not self.cache:
                    self.cache = apt.Cache()
            _KERNEL_PKG_NAMES = KERNEL_PKG_NAMES.copy()
            if kernel.installed:
                _KERNEL_PKG_NAMES.append("linux-image-unsigned-VERSION-KERNELTYPE") # mainline, remove only
            for name in _KERNEL_PKG_NAMES:
                name = name.replace("VERSION", kernel.version).replace("-KERNELTYPE", kernel.type)
                if name in self.cache:
                    pkg = self.cache[name]
                    if kernel.installed:
                        if pkg.is_installed:
                            # skip kernel_type independent packages (headers) if another kernel of the
                            # same version but different type is installed
                            if not kernel.type in name and self.package_needed_by_another_kernel(kernel.version, kernel.type):
                                continue
                            pkg_line = "%s\tpurge\n" % name
                            f.write(pkg_line.encode("utf-8"))
                    else:
                        pkg_line = "%s\tinstall\n" % name
                        f.write(pkg_line.encode("utf-8"))

                # Clean out left-over meta package
                if kernel.installed:
                    def kernel_series(version):
                        return version.replace("-",".").split(".")[:3]

                    last_in_series = True
                    this_kernel_series = kernel_series(kernel.version)
                    for _type, _version in self.kernel_window.installed_kernels:
                        if (_type == kernel.type and _version != kernel.version and
                            kernel_series(_version) == this_kernel_series
                            ):
                            last_in_series = False
                    if last_in_series:
                        meta_names = []
                        _metas = [s for s in self.cache.keys() if s.startswith("linux" + kernel.type)]
                        if kernel.type == "-generic":
                            _metas.append("linux-virtual")
                        for meta in _metas:
                            shortname = meta.split(":")[0]
                            if shortname not in meta_names:
                                meta_names.append(shortname)
                        for meta_name in meta_names:
                            if meta_name in self.cache:
                                meta = self.cache[meta_name]
                                if meta.is_installed and \
                                    kernel_series(meta.candidate.version) == this_kernel_series:
                                    f.write(("%s\tpurge\n" % meta_name).encode("utf-8"))
                                    f.write(("%s\tpurge\n" % meta_name.replace("linux-","linux-image-")).encode("utf-8"))
                                    f.write(("%s\tpurge\n" % meta_name.replace("linux-","linux-headers-")).encode("utf-8"))
                                    if meta_name == "linux-virtual":
                                        f.write(("linux-headers-generic\tpurge\n").encode("utf-8"))
            f.flush()

        if do_regular:
            subprocess.run(["sudo","/usr/lib/linuxmint/mintUpdate/synaptic-workaround.py","enable"])
            subprocess.run(cmd, stdout=self.application.logger.log, stderr=self.application.logger.log)
            subprocess.run(["sudo","/usr/lib/linuxmint/mintUpdate/synaptic-workaround.py","disable"])
            f.close()
        self.application.refresh()
        self.cache = None
        self.application.window.set_sensitive(True)