From 0bd7722de77c335ee63305c00cea371a8eeeaff6 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Tue, 17 Jun 2008 16:48:53 +0000 Subject: [PATCH] Merged from trunk 10654:10690 | 10656 | Fix config._accept_chost_re so it's only an instance | | zmedico | variable. | | 10658 | Add some write access checks in post_merge() in order to | | zmedico | avoid triggering permission related exceptions. | | 10659 | Make some post_merge() things conditional on the vdb lock | | zmedico | being held (mtimedb commit and info dirs processing). | | 10660 | Bug #223417 - Due to 1 second mtime granularity in < | | zmedico | python-1.5, mtime checks are not always sufficient to | | | invalidate vardbapi caches. Therefore, the caches need to be | | | actively invalidated when packages are added and removed. | | 10661 | Re-enable vardbapi.cpv_all() cache now that bug #223417 is | | zmedico | solved. | | 10669 | Tweak the config._accept_chost() regex. | | zmedico | | | 10671 | Document the new ACCEPT_CHOSTS variable. | | zmedico | | | 10673 | Fix typo. | | zmedico | | | 10675 | Add support for an new "eblank" elog function that shows a | | zmedico | blank line. Consecutive eblank calls are all collapsed into | | | a single blank line. Thanks to Joe Peterson | | | for this patch. | | 10677 | * Rename NEUTRAL color to BLANK for eblank. * Document the | | zmedico | new BLANK code in color.map.5. * Implement python version of | | | eblank for mod_echo. | | 10679 | Fix BLANK order and color. | | zmedico | | | 10681 | Add "blank" to the default PORTAGE_ELOG_CLASSES setting. | | zmedico | | | 10683 | Add a "Interaction with previous installed version" section | | zmedico | to document the upgrade/downgrade phase execution order | | | change from bug #226505. | | 10685 | Add note about bug #226505. | | zmedico | | | 10687 | * Document eblank and eqawarn in the ebuild.5 man page. * | | zmedico | Create "Ebuild Helper Functions" section docbook format, | | | including all the functions documented in the ebuild.5 man | | | page. | | 10690 | fix typo | | genone | | svn path=/main/branches/prefix/; revision=10692 --- RELEASE-NOTES | 9 ++++ bin/isolated-functions.sh | 18 ++++++- cnf/make.conf | 4 +- cnf/make.globals | 2 +- doc/package/ebuild.docbook | 1 + doc/package/ebuild/helper_functions.docbook | 57 +++++++++++++++++++++ doc/package/ebuild/phases.docbook | 57 +++++++++++++++++++++ doc/portage.docbook | 1 + man/color.map.5 | 3 ++ man/ebuild.5 | 7 +++ man/emerge.1 | 6 +-- man/make.conf.5 | 7 +++ pym/_emerge/__init__.py | 31 ++++++----- pym/portage/__init__.py | 6 +-- pym/portage/dbapi/vartree.py | 51 +++++++++--------- pym/portage/elog/mod_echo.py | 3 +- pym/portage/output.py | 15 ++++++ 17 files changed, 230 insertions(+), 48 deletions(-) create mode 100644 doc/package/ebuild/helper_functions.docbook diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 49a0e5941..6b15a2f72 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -35,6 +35,15 @@ portage-2.2 portage-2.1.5 ================================== +* The pkg_postinst phase is now called after the previous version of a + package has been removed. As a consequence, it is no longer possible + to call has_version in pkg_postinst to detect whether the current + install operation is an upgrade or downgrade. If this information is + needed during the pkg_postinst phase, do the has_version call in an + earlier phase (such as pkg_preinst) and store the result in a global + variable to be accessed by pkg_postinst when it is called. Bug #226505 + tracks all issues related to this phase execution order change. + * Blockers are now resolved automatically in many more cases than before. When it's safe, blocked packages are uninstalled automatically so that users are no longer inconvenienced with the diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index e23af3cb6..2df4a8d03 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -168,7 +168,7 @@ elog_base() { local messagetype [ -z "${1}" -o -z "${T}" -o ! -d "${T}/logging" ] && return 1 case "${1}" in - INFO|WARN|ERROR|LOG|QA) + BLANK|INFO|WARN|ERROR|LOG|QA) messagetype="${1}" shift ;; @@ -181,15 +181,28 @@ elog_base() { return 0 } +eblank() { + [[ ${LAST_E_CMD} == "eblank" ]] && return 0 + elog_base BLANK + [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo + echo -e " ${BLANK}*${NORMAL}" + LAST_E_CMD="eblank" + return 0 +} + eqawarn() { elog_base QA "$*" + [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo vecho -e " ${WARN}*${NORMAL} $*" >&2 + LAST_E_CMD="eqawarn" return 0 } elog() { elog_base LOG "$*" + [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo echo -e " ${GOOD}*${NORMAL} $*" + LAST_E_CMD="elog" return 0 } @@ -290,6 +303,7 @@ eend() { _eend ${retval} eerror "$*" + LAST_E_CMD="eend" return ${retval} } @@ -348,6 +362,7 @@ unset_colors() { COLS="25 80" ENDCOL= + BLANK= GOOD= WARN= BAD= @@ -370,6 +385,7 @@ set_colors() { if [ -n "${PORTAGE_COLORMAP}" ] ; then eval ${PORTAGE_COLORMAP} else + BLANK=$'\e[37m' GOOD=$'\e[32;01m' WARN=$'\e[33;01m' BAD=$'\e[31;01m' diff --git a/cnf/make.conf b/cnf/make.conf index c9a9d6074..ba1bd2d5d 100644 --- a/cnf/make.conf +++ b/cnf/make.conf @@ -324,9 +324,9 @@ # logging related variables: # PORTAGE_ELOG_CLASSES: selects messages to be logged, possible values are: -# info, warn, error, log, qa, * +# blank, info, warn, error, log, qa, * # Warning: commenting this will disable elog -PORTAGE_ELOG_CLASSES="warn error log" +PORTAGE_ELOG_CLASSES="blank log warn error" # PORTAGE_ELOG_SYSTEM: selects the module(s) to process the log messages. Modules # included in portage are (empty means logging is disabled): diff --git a/cnf/make.globals b/cnf/make.globals index e5e949adc..cc9f4a01b 100644 --- a/cnf/make.globals +++ b/cnf/make.globals @@ -91,7 +91,7 @@ DEFAULT_PATH="@DEFAULT_PATH@" PORTAGE_WORKDIR_MODE="0700" # Some defaults for elog -PORTAGE_ELOG_CLASSES="log warn error" +PORTAGE_ELOG_CLASSES="blank log warn error" PORTAGE_ELOG_SYSTEM="save_summary echo" PORTAGE_ELOG_MAILURI="@rootuser@" diff --git a/doc/package/ebuild.docbook b/doc/package/ebuild.docbook index 5466f99db..4bdb8129d 100644 --- a/doc/package/ebuild.docbook +++ b/doc/package/ebuild.docbook @@ -1,4 +1,5 @@ Ebuild &package_ebuild_phases; +&package_ebuild_helper_functions; diff --git a/doc/package/ebuild/helper_functions.docbook b/doc/package/ebuild/helper_functions.docbook new file mode 100644 index 000000000..ab83d4ed1 --- /dev/null +++ b/doc/package/ebuild/helper_functions.docbook @@ -0,0 +1,57 @@ + + Helper Functions + + Output + + ebegin + + Like einfo, we output a helpful message and then hint that the following + operation may take some time to complete. Once the task is finished, you + need to call eend. + + + + eblank + + Show a blank line. Consecutive eblank calls collapse into + a single blank line. + + + + eend + + Followup the ebegin message with an appropriate "OK" or "!!" (for errors) + marker. If status is non-zero, then the additional error message is + displayed. + + + + einfo + + Same as elog, but should be used when the message isn't important + to the user (like progress or status messages during the build process). + + + + elog + + If you need to display a message that you wish the user to read + and take notice of, then use elog. It works just like echo(1), + but adds a little more to the output so as to catch the user's eye. + The message will also be logged by portage for later review. + + + + eqawarn + + Same as einfo, but should be used when showing a QA warning to the user. + + + + ewarn + + Same as einfo, but should be used when showing a warning to the user. + + + + diff --git a/doc/package/ebuild/phases.docbook b/doc/package/ebuild/phases.docbook index 5c7f04969..383c605ce 100644 --- a/doc/package/ebuild/phases.docbook +++ b/doc/package/ebuild/phases.docbook @@ -40,4 +40,61 @@ + + Interaction with previous installed version + + The order for upgrade and downgrade operations changed in + version 2.1.5, but the order for reinstall operations remained unchanged. + + + Upgrade/downgrade order used by versions less than 2.1.5 (deprecated) + + + + pkg_preinst + + + pkg_postinst + + + pkg_prerm + + + pkg_postrm + + + + + + Upgrade/downgrade order starting with version 2.1.5 + + The new order for upgrades and downgrades is identical to the order used + for reinstall operations: + + + + + pkg_preinst + + + pkg_prerm + + + pkg_postrm + + + pkg_postinst + + + + + Now that pkg_postinst is called after all other phases, it's not possible to + call has_version in pkg_postinst to detect whether the current install + operation is an upgrade or downgrade. If this information is needed during the + pkg_postinst phase, do the has_version call in an earlier phase (such as + pkg_preinst) and store the result in a global variable to be accessed by + pkg_postinst when it is called. + + + diff --git a/doc/portage.docbook b/doc/portage.docbook index d158c1a21..8c29303e6 100644 --- a/doc/portage.docbook +++ b/doc/portage.docbook @@ -14,6 +14,7 @@ + diff --git a/man/color.map.5 b/man/color.map.5 index 39f76a4cb..acb23ee92 100644 --- a/man/color.map.5 +++ b/man/color.map.5 @@ -15,6 +15,9 @@ value defined internally. \fBBAD\fR = \fI"red"\fR Defines color used for some words occuring in bad context. .TP +\fBBLANK\fR = \fI"lightgray"\fR +Defines color used to display eblank lines. +.TP \fBBRACKET\fR = \fI"blue"\fR Defines color used for brackets. .TP diff --git a/man/ebuild.5 b/man/ebuild.5 index 44bbc45aa..adbb6d824 100644 --- a/man/ebuild.5 +++ b/man/ebuild.5 @@ -580,6 +580,10 @@ VERINS="$(best_version net\-ftp/glftpd)" .RE .SH "HELPER FUNCTIONS: OUTPUT" .TP +\fBeblank\fR +Show a blank line. Consecutive eblank calls collapse into +a single blank line. +.TP \fBeinfo\fR \fI"disposable message"\fR Same as \fBelog\fR, but should be used when the message isn't important to the user (like progress or status messages during the build process). @@ -593,6 +597,9 @@ will also be logged by portage for later review. \fBewarn\fR \fI"warning message"\fR Same as \fBeinfo\fR, but should be used when showing a warning to the user. .TP +\fBeqawarn\fR \fI"QA warning message"\fR +Same as \fBeinfo\fR, but should be used when showing a QA warning to the user. +.TP \fBeerror\fR \fI"error message"\fR Same as \fBeinfo\fR, but should be used when showing an error to the user. .TP diff --git a/man/emerge.1 b/man/emerge.1 index 1a1dbf525..b83b7ecbb 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -567,10 +567,8 @@ problems or are known to have issues on different systems. It resides in \fI/usr/portage/profiles\fR. .TP .BR CHOST -The \CHOST\fR variable in \fBmake.conf\fR(5) is used to mask binary packages -that have been built with a different \CHOST\fR setting. The only -way to unmask such a binary package is to change the \CHOST\fR environment -variable so that it exactly matches that of the binary package. +Use the \fBACCEPT_CHOSTS\fR variable in \fBmake.conf\fR(5) to control +\fBCHOST\fR acceptance for binary packages. .TP .BR EAPI The \fBEAPI\fR variable in an \fBebuild\fR(5) file is used to mask packages diff --git a/man/make.conf.5 b/man/make.conf.5 index b24844b6b..1a32e46f6 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -21,6 +21,13 @@ settings. Clearing these variables requires a clear\-all as in: export USE="\-*" .SH "VARIABLES" .TP +\fBACCEPT_CHOSTS\fR = \fI[space delimited list of CHOST values]\fR +Specifies acceptable \fBCHOST\fR values for binary packages. Regular +expression syntax is supported, so it is necessary to escape +\fBCHOST\fR characters if they have special meaning in regular expressions. +.br +Defaults to the value of $CHOST. +.TP \fBACCEPT_KEYWORDS\fR = \fI[space delimited list of KEYWORDS]\fR Enable testing of ebuilds that have not yet been deemed 'stable'. Users of the 'x86' architecture would set this to '~x86' while ppc users would diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index fc8428ae6..79b598f46 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1020,7 +1020,7 @@ class FakeVartree(portage.vartree): vdb_lock = portage.locks.lockdir(vdb_path) real_dbapi = real_vartree.dbapi slot_counters = {} - for cpv in real_dbapi.cpv_all(use_cache=0): + for cpv in real_dbapi.cpv_all(): cache_key = ("installed", self.root, cpv, "nomerge") pkg = self._pkg_cache.get(cache_key) if pkg is not None: @@ -6807,7 +6807,8 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): if inforoot=='': continue - if not os.path.isdir(inforoot): + if not os.path.isdir(inforoot) or \ + not os.access(inforoot, os.W_OK): continue errmsg = "" file_list = os.listdir(inforoot) @@ -6971,15 +6972,21 @@ def post_emerge(trees, mtimedb, retval): vdb_path = os.path.join(target_root, portage.VDB_PATH) portage.util.ensure_dirs(vdb_path) - vdb_lock = portage.locks.lockdir(vdb_path) - try: - if "noinfo" not in settings.features: - chk_updated_info_files(target_root + EPREFIX, infodirs, info_mtimes, retval) - mtimedb.commit() - finally: - portage.locks.unlockdir(vdb_lock) + vdb_lock = None + if os.access(vdb_path, os.W_OK): + vdb_lock = portage.locks.lockdir(vdb_path) + + if vdb_lock: + try: + if "noinfo" not in settings.features: + chk_updated_info_files(target_root, EPREFIX_LSTRIP + infodirs, info_mtimes, retval) + mtimedb.commit() + finally: + if vdb_lock: + portage.locks.unlockdir(vdb_lock) - chk_updated_cfg_files(target_root + EPREFIX, config_protect) + chk_updated_cfg_files(target_root, EPREFIX_LSTRIP, config_protect) display_news_notification(trees) @@ -9233,8 +9240,8 @@ def emerge_main(): setconfig.active.append(s) if myaction in unmerge_actions and \ not sets[s].supportsOperation("unmerge"): - sys.stderr.write("emerge: the given set %s does " + \ - "not support unmerge operations\n" % s) + sys.stderr.write("emerge: the given set '%s' does " % s + \ + "not support unmerge operations\n") return 1 if not setconfig.getSetAtoms(s): print "emerge: '%s' is an empty set" % s diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 2fd9217f7..b8d7bfd95 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1005,7 +1005,6 @@ class config(object): ] _environ_filter = frozenset(_environ_filter) - _accept_chost_re = None def __init__(self, clone=None, mycpv=None, config_profile_path=None, config_incrementals=None, config_root=None, target_root=None, @@ -1043,6 +1042,7 @@ class config(object): self.puse = [] self.modifiedkeys = [] self.uvlist = [] + self._accept_chost_re = None self.virtuals = {} self.virts_p = {} @@ -2415,7 +2415,7 @@ class config(object): if not accept_chost: self._accept_chost_re = re.compile(".*") elif len(accept_chost) == 1: - self._accept_chost_re = re.compile(accept_chost[0]) + self._accept_chost_re = re.compile(r'^%s$' % accept_chost[0]) else: self._accept_chost_re = re.compile( r'^(%s)$' % "|".join(accept_chost)) @@ -4501,7 +4501,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m # Allow color.map to control colors associated with einfo, ewarn, etc... mycolors = [] - for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET"): + for c in ("BLANK", "GOOD", "WARN", "BAD", "HILITE", "BRACKET"): mycolors.append("%s=$'%s'" % (c, portage.output.codes[c])) mysettings["PORTAGE_COLORMAP"] = "\n".join(mycolors) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 26165a4c8..24c2522ed 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -136,7 +136,7 @@ class LinkageMap(object): libs = {} obj_properties = {} lines = [] - for cpv in self._dbapi.cpv_all(use_cache=0): + for cpv in self._dbapi.cpv_all(): lines += self._dbapi.aux_get(cpv, ["NEEDED.ELF.2"])[0].split('\n') # Cache NEEDED.* files avoid doing excessive IO for every rebuild. self._dbapi.flush_cache() @@ -627,6 +627,22 @@ class vardbapi(dbapi): def checkblockers(self, origdep): pass + def _add(self, pkg_dblink): + self._clear_cache(pkg_dblink) + + def _remove(self, pkg_dblink): + self._clear_cache(pkg_dblink) + + def _clear_cache(self, pkg_dblink): + # Due to 1 second mtime granularity in