def CheckForUpdates(root = None): """ Check for an updated manifest. Very simple, uses the configuration module. Returns the new manifest if there is an update, and None otherwise. """ conf = Configuration.Configuration() cur = Configuration.SystemManifest(root) m = conf.FindNewerManifest(cur.Sequence()) if verbose > 1 or debug > 0: print >> sys.stderr, "Current sequence = %d, available sequence = %d" % (cur.Sequence(), m.Sequence() if m is not None else 0) return m
def Install(root = None, manifest = None): """ Perform an install. Uses the system manifest, and installs into root. root must be set. """ if root is None: print >> sys.stderr, "Install must have target root specified" usage() conf = Configuration.Configuration() if manifest is not None: cur = Manifest.Manifest() try: cur.LoadPath(manifest) except Exception as e: print >> sys.stderr, "Could not load manifest from %s: %s" % (manifest, str(e)) return False else: try: cur = Configuration.SystemManifest() except: print >> sys.stderr, "Cannot get system manifest" return False if cur is None or cur.Packages() is None: raise Exception("Cannot load configuration") print "Want to install into %s" % root # # To install, we have to grab each package in the manifest, # and install them into the specified root directory. # When we are done, we write out the system manifest into # the manifest directory. for pkg in cur.Packages(): print "Package %s" % pkg.Name() filename = Manifest.FormatName(pkg.Name(), pkg.Version()) f = conf.FindPackage(filename, pkg.Checksum()) if f is None: print >> sys.stderr, "\tCould not find package file for %s" % filename return False else: if Installer.install_file(f, root) == False: print >> sys.stderr, "Could not install package %s" % filename return False else: print "%s installed" % pkg.Name() conf.StoreManifest(cur, root) return True