def _storeJobInfo(remainingJobs, updJob):
    changeSetSource = updJob.getTroveSource()
    restartDir = tempfile.mkdtemp(prefix='conary-restart-')
    csIndexPath = os.path.join(restartDir, 'changesets')
    csIndex = open(csIndexPath, "w")
    for idx, (cs, fname, incFConts) in enumerate(changeSetSource.iterChangeSetsFlags()):
        if isinstance(cs, changeset.ChangeSetFromFile):
            # Write the file name in the changesets file - when thawing we
            # will need this information
            csFileName = util.normpath(os.path.abspath(cs.fileName))
        else:
            cs.reset()
            csFileName = os.path.join(restartDir, '%d.ccs' % idx)
            cs.writeToFile(csFileName)
        csIndex.write("%s %s\n" % (csFileName, int(incFConts)))

    csIndex.close()

    jobSetPath = os.path.join(restartDir, 'joblist')
    jobFile = open(jobSetPath, 'w')
    # Flatten list
    jobFile.write(_serializeJobList(itertools.chain(*remainingJobs)))
    jobFile.close()
    # Write the version of the conary client
    # CNY-1034: we need to save more information about the currently running
    # client; upon restart, the new client may later check the old client's
    # version and recompute the update set if the old client was buggy.

    # Unfortunately, _loadRestartInfo will only ignore joblist, so we can't
    # drop a state file in the same restartDir. We'll create a new directory
    # and save the version file there.
    extraDir = restartDir + "misc"
    try:
        os.mkdir(extraDir)
    except OSError:
        # restartDir was a temporary directory, the likelyhood of extraDir
        # existing is close to zero
        # Just in case, remove the existing directory and re-create it
        util.rmtree(extraDir, ignore_errors=True)
        os.mkdir(extraDir)

    versionFilePath = os.path.join(extraDir, "__version__")
    versionFile = open(versionFilePath, "w+")
    versionFile.write("version %s\n" % constants.version)
    versionFile.close()

    # Save the version file in the regular directory too
    versionFilePath = os.path.join(restartDir, "__version__")
    versionFile = open(versionFilePath, "w+")
    versionFile.write("version %s\n" % constants.version)
    versionFile.close()

    # Save restart infromation
    invocationInfoPath = os.path.join(restartDir, "job-invocation")
    updJob.saveInvocationInfo(invocationInfoPath)

    # Save features
    featuresFilePath = os.path.join(restartDir, "features")
    updJob.saveFeatures(featuresFilePath)

    # Save information about pre scripts already run
    path = os.path.join(restartDir, "jobPreScriptsAlreadyRun")
    file(path, "w").write(_serializePreScripts(
        updJob.iterJobPreScriptsAlreadyRun()))

    troveMapDir = os.path.join(restartDir, "trove-changesets")
    updJob.saveTroveMap(troveMapDir)

    return restartDir
dataset/ETHPy150Open sassoftware/conary/conary/conaryclient/update.py/_storeJobInfo/original