示例#1
0
        def progress(self, package, action, ti_done, ti_total, ts_done,
                     ts_total):
            """
			@param package: A yum package object or simple string of a package name
			@param action: A constant transaction set state
			@param te_current: current number of bytes processed in the transaction
			element being processed
			@param te_total: total number of bytes in the transaction element being
			processed
			@param ts_current: number of processes completed in whole transaction
			@param ts_total: total number of processes in the transaction.
			"""
            if package:
                # package can be both str or dnf package object
                if not isinstance(package, str):
                    pkg_id = str(package)
                else:
                    pkg_id = package
                if action in self.actions:
                    action = self.actions[action]

                if action == "verify":
                    log("installed " + pkg_id)
                    #print()
                print(action, ti_done, ti_total, ts_done, ts_total)
示例#2
0
def dnf_install(d, packages):
    newpid = os.fork()
    if newpid == 0:
        with dnf.Base() as base:
            # Substitutions are needed for correct interpretation of repo files.
            RELEASEVER = dnf.rpm.detect_releasever(base.conf.installroot)
            base.conf.substitutions['releasever'] = RELEASEVER
            # Repositories are needed if we want to install anything.
            base.read_all_repos()
            #base.redirect_logger( stdout=None, stderr=None)
            # A sack is required by marking methods and dependency resolving.
            base.fill_sack()

            sack_query = base.sack.query()

            avail_rpms = sack_query.available()
            to_install = []
            for pkg in packages:
                if check_installed(sack_query, pkg) == False:
                    to_install.append(pkg)
                else:
                    log("Already installed: " + pkg)

            #installed = sack_query.installed()

            #for name in packages:
            #	for i in avail_rpms:
            #		iname=i.name

            #	if pkg.name in packages:
            #		print(type(pkg),pkg.installtime)

            for pkg in avail_rpms:

                if pkg.name in to_install:
                    #print(type(pkg),pkg.installtime)
                    log("I will install :" + pkg.name)
                    base.install(pkg.name)

            base.resolve()

            base.download_packages(base.transaction.install_set)

            base.do_transaction(display=TransactionProgress())

    log("Finished")
示例#3
0
def apt_install(d, my_list):
    f = open("out.dat", "w+")
    f.close()

    global apt_present
    if apt_present == False:
        d.msgbox(
            "apt-get is not present on system are you sure you are on a Debian/Ubunu system?"
        )
        return False

    newpid = os.fork()
    if newpid == 0:
        #dev_null = open('/dev/null', 'w')
        #os.dup2(dev_null, sys.stdout.fileno())

        #os.dup2(dev_null, sys.stderr.fileno())
        cache = apt.cache.Cache()
        log("update")
        cache.update()

        log("Installing " + str(len(my_list)) + " packages")
        installed = 0
        already_installed = 0
        for i in range(0, len(my_list)):
            if my_list[i] in cache:
                pkg = cache[my_list[i]]
                if pkg.is_installed:
                    text = my_list[i] + " (Installed)"
                    already_installed = already_installed + 1
                else:
                    text = my_list[i] + " (Will install)"
                    installed = installed + 1
                    pkg.mark_install()

                log(text)
            else:
                log(my_list[i] + " Not found")
        #try:
        log("commit (this could take a while.)")
        prog = LogInstallProgress()
        cache.commit(install_progress=prog)
        log("\nInstalled= " + str(installed) + " Already installed " +
            str(already_installed))
        #except:
        #	log( "Sorry, package installation failed")

        cache.close()
        sys.exit()
示例#4
0
 def finish_update(self):
     log("Closing package cache")
示例#5
0
 def start_update(self):
     log("start")
示例#6
0
 def dpkg_status_change(self, pkg, status):
     log("Package " + pkg + ", Status: " + status)
示例#7
0
 def status_change(self, pkg, percent, status):
     log("Package: " + pkg + " at " + str(percent) + " -> " + status)
示例#8
0
 def finish_update(self):
     log("Installation is complete")
示例#9
0
 def error(self, pkg, errormsg):
     log("Package " + pkg + " error: " + errormsg)
示例#10
0
 def processing(self, pkg, stage):
     log("Processing " + pkg + " stage: " + stage)
示例#11
0
 def conffile(self, current, new):
     log("conffile prompt: " + current + " " + new)
示例#12
0
def publish_src(d, distro=None, publication_mode="gpl_distro"):

    data_out = ""
    ver = get_ver()
    my_dir = os.getcwd()

    pub_dir = get_pub_path()
    build_dir = os.path.join(pub_dir, "build")
    dest = os.path.join(build_dir, "gpvdm-" + str(ver))

    #mkdir tree
    if os.path.isdir(pub_dir) == True:
        shutil.rmtree(pub_dir)

    os.mkdir(pub_dir)
    os.mkdir(build_dir)

    os.mkdir(dest)
    os.mkdir(os.path.join(dest, "plugins"))

    spath = os.path.join(my_dir, "plot")
    dpath = os.path.join(dest, "plot")
    copy_files(dpath, spath, ".plot")

    os.mkdir(os.path.join(dest, "scripts"))

    spath = os.path.join(my_dir, "gui")
    dpath = os.path.join(dest, "gui")
    copy_files(dpath, spath, ".py")

    spath = os.path.join(my_dir, "images")
    dpath = os.path.join(dest, "images")
    copy_files(dpath, spath, ".jpg")
    copy_files(dpath, spath, ".ico")

    os.mkdir(os.path.join(dest, "images", "scalable"))
    os.mkdir(os.path.join(dest, "images", "splash"))
    os.mkdir(os.path.join(dest, "images", "flags"))
    os.mkdir(os.path.join(dest, "images", "32x32"))
    os.mkdir(os.path.join(dest, "images", "64x64"))
    os.mkdir(os.path.join(dest, "images", "16x16"))
    os.mkdir(os.path.join(dest, "images", "48x32"))

    os.mkdir(os.path.join(dest, "css"))

    spath = os.path.join(my_dir, "html")
    dpath = os.path.join(dest, "html")
    copy_files(dpath, spath, ".html")

    spath = os.path.join(my_dir, "man")
    dpath = os.path.join(dest, "man")
    copy_files(dpath, spath, "Makefile.am")

    spath = os.path.join(my_dir, "docs")
    dpath = os.path.join(dest, "docs")
    copy_files(dpath, spath,
               [".tex", ".bib", "Makefile.am", ".bst", ".config"])

    os.mkdir(os.path.join(dest, "docs", "images"))

    spath = os.path.join(my_dir, "desktop")
    dpath = os.path.join(dest, "desktop")
    copy_files(dpath, spath, [".svg", ".desktop", ".xml"])

    os.mkdir(os.path.join(dest, "ui"))

    copy_lib(dest, my_dir, "lang", mode=publication_mode)
    copy_lib(dest, my_dir, "src", mode=publication_mode)
    copy_lib(dest, my_dir, "lib", mode=publication_mode)
    copy_lib(dest, my_dir, "libi", mode=publication_mode)
    copy_lib(dest, my_dir, "librpn", mode=publication_mode)
    copy_lib(dest, my_dir, "libmemory", mode=publication_mode)
    copy_lib(dest, my_dir, "liblight", mode=publication_mode)
    copy_lib(dest, my_dir, "libmeasure", mode=publication_mode)
    copy_lib(dest, my_dir, "libdump", mode=publication_mode)
    copy_lib(dest, my_dir, "libcontacts", mode=publication_mode)
    copy_lib(dest, my_dir, "libdumpctrl", mode=publication_mode)
    copy_lib(dest, my_dir, "libmesh", mode=publication_mode)
    copy_lib(dest, my_dir, "libserver", mode=publication_mode)
    copy_lib(dest, my_dir, "libdos", mode=publication_mode)
    copy_lib(dest, my_dir, "cluster", mode=publication_mode)
    copy_lib(dest, my_dir, "cluster_", mode=publication_mode)
    copy_lib(dest, my_dir, "libfdtd", mode=publication_mode)

    spath = os.path.join(my_dir, "include")
    dpath = os.path.join(dest, "include")
    copy_files(dpath, spath, [".h"])

    copy_files(
        dest, my_dir,
        ["Makefile.am", "configure", "configure.ac", "README.md", "COPYING"])

    cp_materials(dest, my_dir)
    cp_spectra(dest, my_dir)
    cp_devices(dest, my_dir)

    if d != None:
        data_out = "&>out.dat &"

    if publication_mode == "windows":
        os.system("./pub.sh --windows " + data_out)
    else:
        os.system("./pub.sh --github " + data_out)

    if d != None:
        ret = d.tailbox("out.dat", height=None, width=100)

    data_out = ""

    os.chdir(build_dir)

    #build zip files if needed
    if publication_mode != "windows":
        log("zipping")
        if distro == "debian":
            os.system("tar -zcf ./gpvdm_" + ver + ".orig.tar.gz ./gpvdm-" +
                      ver + "/")
        else:
            os.system("tar -zcf ./gpvdm-" + ver + ".tar.gz ./gpvdm-" + ver +
                      "/")
            os.system("tar -cf ./gpvdm-" + ver + ".tar ./gpvdm-" + ver + "/")

    os.chdir(my_dir)