On Tuesday 20 December 2005 01:49, Marius Mauch wrote:
> Also not talking about implementation details yet, just after comments
> about the general idea of forced portage updates.
I gave it a go anyway... ;)
# emerge -up kde-base/kde
Checking for mandatory system updates... Done.
The following packages can't be merged until your system is updated:
kde-base/kde
The following important packages are either not up to date or not installed:
virtual/baselayout sys-apps/coreutils sys-apps/debianutils
sys-apps/diffutils sys-apps/file sys-apps/findutils sys-apps/gawk
sys-apps/grep sys-apps/groff sys-apps/kbd sys-apps/man sys-apps/man-pages
sys-apps/net-tools >=sys-apps/portage-2.0.51.22 sys-apps/sed
sys-apps/shadow sys-apps/texinfo sys-apps/which virtual/modutils
virtual/pager sys-apps/busybox sys-apps/hdparm sys-apps/util-linux
sys-apps/linux32 >=sys-apps/baselayout-1.9.4-r7
Please retry your command after updating your system.
These are the packages that I would merge, in order:
Calculating system dependencies ...done!
[ebuild N ] sys-apps/sandbox-1.2.17
[ebuild N ] sys-apps/sed-4.1.4 USE="-bootstrap -build -nls -static"
[ebuild N ] sys-apps/debianutils-2.15 USE="-build -static"
[ebuild N ] sys-apps/portage-2.1_pre1 USE="-build"
*** Portage will stop merging at this point and reload itself,
recalculate dependencies, and complete the merge.
You may avoid the remerging of packages by updating portage on its own.
[ebuild N ] sys-apps/help2man-1.35.1 USE="-nls"
[ebuild N ] sys-apps/coreutils-5.3.0-r2 USE="-acl -build -nls -static"
[ebuild N ] sys-apps/sysvinit-2.86-r3 USE="-bootstrap -build -ibm
-static"
[ebuild U ] sys-libs/readline-5.1 [5.0-r2]
[ebuild N ] sys-apps/baselayout-1.12.0_pre11-r3 USE="unicode -bootstrap
-build -static"
[ebuild N ] sys-apps/diffutils-2.8.7-r1 USE="-nls -static"
[ebuild N ] sys-apps/file-4.16 USE="python -build"
...
...
* Portage is moved to the top of both system and world
* All system atoms are checked that they are matched by installed packages
and emerge refuses to do anything until unsatisfied atoms are installed
and/or updated.
* EMERGE_INSANITY_OK is provided for bootstrap.sh (and emerge itself) to
bypass the checks when the system is known to be in an incomplete state.
Reasoning on checking all system atoms is that other groups are just as likely
to need the functionality as we are. Combining that with how rarely versions
are actually updated for system packages, it shouldn't cause any more bother
to users than it needs to.
--
Jason Stubbs
Index: bin/emerge
===================================================================
--- bin/emerge (revision 2414)
+++ bin/emerge (working copy)
@@ -1418,6 +1418,14 @@
mylist = sysdict.keys()
+ newlist = []
+ for atom in mylist:
+ if portage.dep_getkey(atom).split("/")[-1] == "portage":
+ newlist.insert(0, atom)
+ else:
+ newlist.append(atom)
+ mylist = newlist
+
for mydep in mylist:
try:
if not self.select_dep(portage.root, mydep, raise_on_missing=True):
@@ -2501,6 +2509,73 @@
if "--debug" in myopts:
edebug=1
+
+def check_and_update_system():
+ if os.environ.get("EMERGE_INSANITY_OK") or myaction == "system":
+ return
+ rsync_timestamp = open(portage.settings["PORTDIR"]+"/metadata/timestamp").read().strip()
+ last_check = portage.mtimedb.get("last_system_check", "")
+ if rsync_timestamp == last_check:
+ return
+ print "Checking for mandatory system updates... ",
+ system_atoms = getlist("system")
+ vdb = portage.db["/"]["vartree"].dbapi # This check only applies to /
+ unsatisfied_atoms = [atom for atom in system_atoms if not vdb.match(atom)]
+ print "Done."
+ if unsatisfied_atoms:
+ if myfiles:
+ allowed_keys = [portage.dep_getkey(atom) for atom in system_atoms]
+ virtuals = portage.settings.virtuals
+ for key in allowed_keys:
+ if key in virtuals:
+ allowed_keys.extend(virtuals[key])
+ allowed_files = []
+ for myfile in myfiles:
+ key = portage.dep_getkey(myfile)
+ if key in allowed_keys:
+ allowed_files.append(myfile)
+ continue
+ if "/" in myfile:
+ continue
+ for category in portage.settings.categories:
+ if category+"/"+key in allowed_keys:
+ allowed_files.append(myfile)
+ break
+ disallowed_files = [myfile for myfile in myfiles if myfile not in allowed_files]
+ if disallowed_files:
+ print red("\nThe following packages can't be merged until your system is updated:")
+ width = 80
+ for myfile in disallowed_files:
+ width += len(myfile) + 1
+ if width >= 76:
+ width = 2
+ print "\n ",
+ print myfile,
+ myfiles.remove(myfile)
+ print
+ if myfiles:
+ return
+ print red("\nThe following important packages are either not up to date or not installed:")
+ width = 80
+ for atom in unsatisfied_atoms:
+ width += len(atom) + 1
+ if width >= 76:
+ width = 2
+ print "\n ",
+ print atom,
+ print yellow("\n\nPlease retry your command after updating your system.")
+ print
+ portage.portageexit()
+ os.environ["EMERGE_INSANITY_OK"] = "1"
+ params = ["emerge", "system"]
+ params.append("--ask" in myopts and "--ask" or "--pretend")
+ os.execv("/usr/lib/portage/bin/emerge", params)
+ else:
+ portage.mtimedb["last_system_check"] = rsync_timestamp
+
+check_and_update_system()
+
+
if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts):
if "--pretend" in myopts:
print "emerge: \"sync\" actions do not support \"--pretend.\""