from portage_checksum import perform_md5,perform_checksum,prelink_capable
import eclass_cache
from portage_localization import _
- from portage_update import fixdbentries, update_dbentries
+ from portage_update import fixdbentries, update_dbentries, grab_updates
# Need these functions directly in portage namespace to not break every external tool in existence
from portage_versions import ververify,vercmp,catsplit,catpkgsplit,pkgsplit,pkgcmp
#,"porttree":portagetree(root,virts),"bintree":binarytree(root,virts)}
features=settings["FEATURES"].split()
-def do_upgrade(mykey):
+def do_upgrade(mykey, mycontent):
"""Valid updates are returned as a list of split update commands."""
writemsg("\n\n")
writemsg(green("Performing Global Updates: ")+bold(mykey)+"\n")
writemsg(" "+bold(".")+"='update pass' "+bold("*")+"='binary update' "+bold("@")+"='/var/db move'\n"+" "+bold("s")+"='/var/db SLOT move' "+bold("S")+"='binary SLOT move' "+bold("p")+"='update /etc/portage/package.*'\n")
processed=1
myupd = []
- mylines = grabfile(mykey)
+ mylines = mycontent.splitlines()
for myline in mylines:
mysplit = myline.split()
if len(mysplit) == 0:
def global_updates():
updpath = os.path.join(settings["PORTDIR"], "profiles", "updates")
- mylist = listdir(updpath, EmptyOnError=1)
- # validate the file name (filter out CVS directory, etc...)
- mylist = [myfile for myfile in mylist if len(myfile) == 7 and myfile[1:3] == "Q-"]
- if len(mylist) > 0:
- # resort the list
- mylist = [myfile[3:]+"-"+myfile[:2] for myfile in mylist]
- mylist.sort()
- mylist = [myfile[5:]+"-"+myfile[:4] for myfile in mylist]
-
- if not mtimedb.has_key("updates"):
- mtimedb["updates"] = {}
-
- didupdate = 0
+ if not mtimedb.has_key("updates"):
+ mtimedb["updates"] = {}
+ if settings["PORTAGE_CALLER"] == "fixpackages":
+ update_data = grab_updates(updpath)
+ else:
+ update_data = grab_updates(updpath, mtimedb["updates"])
+ if len(update_data) > 0:
+ didupdate = 1
do_upgrade_packagesmessage = 0
myupd = []
timestamps = {}
- for myfile in mylist:
- mykey = os.path.join(updpath, myfile)
- mystat = os.stat(mykey)
- if not stat.S_ISREG(mystat.st_mode):
- continue
- if mykey not in mtimedb["updates"] or \
- mtimedb["updates"][mykey] != mystat.st_mtime or \
- settings["PORTAGE_CALLER"] == "fixpackages":
- didupdate = 1
- valid_updates, no_errors = do_upgrade(mykey)
- myupd.extend(valid_updates)
- if no_errors:
- # Update our internal mtime since we
- # processed all of our directives.
- timestamps[mykey] = mystat.st_mtime
+ for mykey, mystat, mycontent in update_data:
+ valid_updates, no_errors = do_upgrade(mykey, mycontent)
+ myupd.extend(valid_updates)
+ if no_errors:
+ # Update our internal mtime since we
+ # processed all of our directives.
+ timestamps[mykey] = mystat.st_mtime
update_config_files(myupd)
db["/"]["bintree"] = binarytree("/", settings["PKGDIR"], virts)
file_path = os.path.join(dbdir, myfile)
write_atomic(file_path, mycontent)
return len(updated_items) > 0
+
+def grab_updates(updpath, prev_mtimes=None):
+ """Returns all the updates from the given directory as a sorted list of
+ tuples, each containing (file_path, statobj, content). If prev_mtimes is
+ given then only updates with differing mtimes are considered."""
+ mylist = os.listdir(updpath)
+ if prev_mtimes is None:
+ prev_mtimes = {}
+ # validate the file name (filter out CVS directory, etc...)
+ mylist = [myfile for myfile in mylist if len(myfile) == 7 and myfile[1:3] == "Q-"]
+ if len(mylist) == 0:
+ return []
+
+ # update names are mangled to make them sort properly
+ mylist = [myfile[3:]+"-"+myfile[:2] for myfile in mylist]
+ mylist.sort()
+ mylist = [myfile[5:]+"-"+myfile[:4] for myfile in mylist]
+
+ update_data = []
+ for myfile in mylist:
+ file_path = os.path.join(updpath, myfile)
+ mystat = os.stat(file_path)
+ if file_path not in prev_mtimes or \
+ prev_mtimes[file_path] != mystat.st_mtime:
+ f = open(file_path)
+ content = f.read()
+ f.close()
+ update_data.append((file_path, mystat, content))
+ return update_data