From: Fabian Groffen Date: Sun, 30 Dec 2007 17:19:05 +0000 (-0000) Subject: Merged from trunk 9094:9118 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=12f1efbdfebc6dba5691fbb69d36d89f222eaae6;p=portage.git Merged from trunk 9094:9118 | 9096 | Move XARGS initialization from portage.data to | | zmedico | isolated-functions.sh. | | 9097 | Move XARGS initialization from portage.data to | | zmedico | isolated-functions.sh. | | 9099 | Remove redundant lchown() compatibility code since the | | zmedico | getattr(os, "lchown", None) call already handles it. | | 9100 | Simplify the userland detection code in portage.data and add | | zmedico | a bash version of it to isolated-functions.sh. | | 9101 | Add back support for silent definition of the dummy lchown() | | zmedico | function when ostype == Darwin. | | 9103 | Remove redundant USERLAND sanity check code from doebuild() | | zmedico | since it's handled in isolated-functions.sh now. | | 9105 | Make the global counter file correspond to the total number | | zmedico | of installation actions that have occurred in the history of | | | this package database. | | 9107 | Rely on USERLAND since it's automatically generated by | | zmedico | isolated-functions.sh when necessary. | | 9109 | Document that docinto works for dohtml. | | zmedico | | | 9111 | Make the ecompressdir vecho output show a leading / on the | | zmedico | directory path. Thanks to armin76. | | 9112 | Fix handling of leading / charactes some more. | | zmedico | | | 9114 | Add PKGDIR to the config.environ() whitelist so that | | zmedico | people's bashrc's don't break. | | 9116 | Fix broken Darwin USERLAND detection. | | zmedico | | | 9117 | Fix USERLAND references to handle Darwin like BSD. | | zmedico | | | 9118 | As suggested by grobian, treat Darwin just like USERLAND=gnu | | zmedico | since they seem to be switching commands to gnu anyway. | svn path=/main/branches/prefix/; revision=9124 --- diff --git a/bin/ecompressdir b/bin/ecompressdir index 75b6059ab..7933322a3 100755 --- a/bin/ecompressdir +++ b/bin/ecompressdir @@ -97,9 +97,10 @@ ret=0 rm -rf "${T}"/ecompress-skip for dir in "$@" ; do + dir=${dir#/} dir="${ED}${dir}" if [[ ! -d ${dir} ]] ; then - vecho "${0##*/}: ${dir#${ED}} does not exist!" + vecho "${0##*/}: /${dir#${ED}} does not exist!" continue fi cd "${dir}" @@ -125,7 +126,7 @@ for dir in "$@" ; do # now lets do our work [[ -z ${suffix} ]] && continue - vecho "${0##*/}: $(ecompress --bin) ${actual_dir#${D}}" + vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${D}}" funk_up_dir "compress" "${suffix}" "ecompress" # finally, restore the skipped stuff diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 807acae56..6c3ad1916 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -30,10 +30,6 @@ fi source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 -# ${USERLAND} is unreliable since the portage tree might be empty, so test -# success of the -r option to distinguish between gnu and bsd date. -date -r 0 >&/dev/null && DATE_ARGS="BSD" || DATE_ARGS="GNU" - do_verbose=0 if hasq webrsync-gpg ${FEATURES} ; then @@ -54,7 +50,7 @@ get_date_part() { local utc_time_in_secs="$1" local part="$2" - if [ "${DATE_ARGS}" = "BSD" ]; then + if [[ ${USERLAND} == BSD ]] || ; then date -r ${utc_time_in_secs} -u +"${part}" else date -d @${utc_time_in_secs} -u +"${part}" diff --git a/bin/etc-update b/bin/etc-update index 68bc065af..e554d4467 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -401,12 +401,12 @@ Please select from the menu above (-1 to exit, losing this merge): " my_input=$(read_int) case ${my_input} in 1) echo "Replacing ${ofile} with ${mfile}" - if [[ ${USERLAND:-GNU} == GNU ]]; then - chown --reference="${ofile}" "${mfile}" - chmod --reference="${ofile}" "${mfile}" - else + if [[ ${USERLAND} == BSD ]] ; then chown "$(stat -f %Su:%Sg "${ofile}")" "${mfile}" chmod $(stat -f %Mp%Lp "${ofile}") "${mfile}" + else + chown --reference="${ofile}" "${mfile}" + chmod --reference="${ofile}" "${mfile}" fi mv ${mv_opts} "${mfile}" "${ofile}" rm ${rm_opts} "${file}" diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 90fc0f59a..d38125fb1 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -377,6 +377,28 @@ case "${NOCOLOR:-false}" in ;; esac +if [[ -z ${USERLAND} ]] ; then + case $(uname -s) in + *BSD|DragonFly) + export USERLAND="BSD" + ;; + *) + export USERLAND="GNU" + ;; + esac +fi + +if [[ -z ${XARGS} ]] ; then + case ${USERLAND} in + BSD) + export XARGS="xargs" + ;; + *) + export XARGS="xargs -r" + ;; + esac +fi + has() { hasq "$@" } diff --git a/man/ebuild.5 b/man/ebuild.5 index c52145bbb..cbd9e9528 100644 --- a/man/ebuild.5 +++ b/man/ebuild.5 @@ -851,7 +851,8 @@ Installs executables into the path controlled by \fBexecinto\fR. This function uses \fBinstall\fR(1). Creates all necessary dirs. .TP \fBdocinto\fR \fI[path]\fR -Sets the subdir used by \fBdodoc\fR when installing into the document tree +Sets the subdir used by \fBdodoc\fR and \fBdohtml\fR +when installing into the document tree (based in /usr/share/doc/${PF}/). Default is no subdir, or just "". .TP \fBdodoc\fR \fI [list of more documents]\fR diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 160ba4d25..ece610ee9 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -879,6 +879,7 @@ class config(object): "EBUILD_EXIT_STATUS_FILE", "EBUILD_FORCE_TEST", "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "EMERGE_FROM", "FEATURES", "FILESDIR", "HOME", "PATH", + "PKGDIR", "PKGUSE", "PKG_LOGDIR", "PKG_TMPDIR", "PORTAGE_ACTUAL_DISTDIR", "PORTAGE_ARCHLIST", "PORTAGE_BASHRC", @@ -2680,8 +2681,6 @@ class config(object): phase = self.get("EBUILD_PHASE") if phase: whitelist = [] - if "package" == phase: - whitelist.append("PKGDIR") if "rpm" == phase: whitelist.append("RPMDIR") for k in whitelist: @@ -4588,13 +4587,10 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, if env_stat: mysettings._filter_calling_env = True else: - for var in "ARCH", "USERLAND", "XARGS": + for var in ("ARCH", ): value = mysettings.get(var) if value and value.strip(): continue - if var == "USERLAND" and userland: - mysettings["USERLAND"] = userland - continue msg = ("%s is not set... " % var) + \ ("Are you missing the '%setc/make.profile' symlink? " % \ mysettings["PORTAGE_CONFIGROOT"]) + \ diff --git a/pym/portage/data.py b/pym/portage/data.py index 88735d5e6..fa441d375 100644 --- a/pym/portage/data.py +++ b/pym/portage/data.py @@ -11,21 +11,18 @@ from portage.output import create_color_func bad = create_color_func("BAD") ostype=os.uname()[0] - userland = None -lchown = getattr(os, "lchown", None) -os.environ.setdefault("XARGS", "xargs -r") -os.environ["XARGS"]="xargs -r" +if ostype == "DragonFly" or ostype.endswith("BSD"): + userland = "BSD" +else: + userland = "GNU" -# "fix" for lchown on Darwin -if ostype == "Darwin": - def lchown(*pos_args, **key_args): - pass +lchown = getattr(os, "lchown", None) if not lchown: - if "lchown" in dir(os): - # Included in python-2.3 - lchown = os.lchown + if ostype == "Darwin": + def lchown(*pos_args, **key_args): + pass else: try: import missingos diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 5efdcc40e..f4d6d625e 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -199,6 +199,8 @@ class vardbapi(dbapi): self._aux_cache_version = "1" self._aux_cache_filename = os.path.join(self.root, CACHE_PATH.lstrip(os.path.sep), "vdb_metadata.pickle") + self._counter_path = os.path.join(root, + CACHE_PATH.lstrip(os.path.sep), "counter") self.libmap = LibraryPackageMap(os.path.join(self.root, CACHE_PATH.lstrip(os.sep), "library_consumers"), self) try: @@ -609,6 +611,13 @@ class vardbapi(dbapi): calls should only take a short time, so performance is sufficient without having to rely on a potentially corrupt global counter file. + + The global counter file located at + $CACHE_PATH/counter serves to record the + counter of the last installed package and + it also corresponds to the total number of + installation actions that have occurred in + the history of this package database. """ cp_list = self.cp_list max_counter = 0 @@ -620,48 +629,52 @@ class vardbapi(dbapi): continue if counter > max_counter: max_counter = counter - return max_counter + 1 - def counter_tick_core(self, myroot, incrementing=1, mycpv=None): - "This method will grab the next COUNTER value and record it back to the global file. Returns new counter value." - cpath = os.path.join(myroot, CACHE_PATH.lstrip(os.sep), "counter") - changed = False counter = -1 try: - cfile = open(cpath, "r") - except EnvironmentError: - writemsg("!!! COUNTER file is missing: '%s'\n" % cpath, - noiselevel=-1) + cfile = open(self._counter_path, "r") + except EnvironmentError, e: + writemsg("!!! Unable to read COUNTER file: '%s'\n" % \ + self._counter_path, noiselevel=-1) + writemsg("!!! %s\n" % str(e), noiselevel=-1) + del e else: try: try: counter = long(cfile.readline().strip()) finally: cfile.close() - except (OverflowError, ValueError): - writemsg("!!! COUNTER file is corrupt: '%s'\n" % cpath, - noiselevel=-1) + except (OverflowError, ValueError), e: + writemsg("!!! COUNTER file is corrupt: '%s'\n" % \ + self._counter_path, noiselevel=-1) + writemsg("!!! %s\n" % str(e), noiselevel=-1) + del e - real_counter = self.get_counter_tick_core(myroot, mycpv=mycpv) - 1 + # We must ensure that we return a counter + # value that is at least as large as the + # highest one from the installed packages, + # since having a corrupt value that is too low + # can trigger incorrect AUTOCLEAN behavior due + # to newly installed packages having lower + # COUNTERs than the previous version in the + # same slot. + if counter > max_counter: + max_counter = counter if counter < 0: - changed = True writemsg("!!! Initializing COUNTER to " + \ - "value of %d\n" % counter, noiselevel=-1) + "value of %d\n" % max_counter, noiselevel=-1) - # Never trust the counter file, since having a - # corrupt value that is too low there can trigger - # incorrect AUTOCLEAN behavior due to newly installed - # packages having lower counters than the previous - # version in the same slot. - counter = real_counter - - if incrementing or changed: + return max_counter + 1 + def counter_tick_core(self, myroot, incrementing=1, mycpv=None): + "This method will grab the next COUNTER value and record it back to the global file. Returns new counter value." + counter = self.get_counter_tick_core(myroot, mycpv=mycpv) - 1 + if incrementing: #increment counter counter += 1 # update new global counter file - write_atomic(cpath, str(counter)) + write_atomic(self._counter_path, str(counter)) return counter class vartree(object):