public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/resolver/, bin/
Date: Sun, 13 Jan 2019 23:38:22 +0000 (UTC)	[thread overview]
Message-ID: <1547421452.8463281f6a6daec64a976693447c240f0d669f08.zmedico@gentoo> (raw)

commit:     8463281f6a6daec64a976693447c240f0d669f08
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 13 23:11:40 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jan 13 23:17:32 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8463281f

misc-functions.sh: restore canonicalize func (bug 675284)

The canonicalize function is required by install-qa-check.d/05prefix.

Fixes: aa0a94198794 ("ecompress: Replace with implementation from portage[mgorny]")
Bug: https://bugs.gentoo.org/670484
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 bin/misc-functions.sh                            | 34 ++++++++++++++++++++++++
 lib/portage/tests/resolver/ResolverPlayground.py |  1 +
 2 files changed, 35 insertions(+)

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 5de26b44d..4f8a4112d 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -43,6 +43,40 @@ install_symlink_html_docs() {
 	fi
 }
 
+# replacement for "readlink -f" or "realpath"
+READLINK_F_WORKS=""
+canonicalize() {
+	if [[ -z ${READLINK_F_WORKS} ]] ; then
+		if [[ $(readlink -f -- /../ 2>/dev/null) == "/" ]] ; then
+			READLINK_F_WORKS=true
+		else
+			READLINK_F_WORKS=false
+		fi
+	fi
+	if ${READLINK_F_WORKS} ; then
+		readlink -f -- "$@"
+		return
+	fi
+
+	local f=$1 b n=10 wd=$(pwd)
+	while (( n-- > 0 )); do
+		while [[ ${f: -1} = / && ${#f} -gt 1 ]]; do
+			f=${f%/}
+		done
+		b=${f##*/}
+		cd "${f%"${b}"}" 2>/dev/null || break
+		if [[ ! -L ${b} ]]; then
+			f=$(pwd -P)
+			echo "${f%/}/${b}"
+			cd "${wd}"
+			return 0
+		fi
+		f=$(readlink "${b}")
+	done
+	cd "${wd}"
+	return 1
+}
+
 install_qa_check() {
 	local d f i qa_var x paths qa_checks=() checks_run=()
 	if ! ___eapi_has_prefix_variables; then

diff --git a/lib/portage/tests/resolver/ResolverPlayground.py b/lib/portage/tests/resolver/ResolverPlayground.py
index 626a1f064..0d6340dc0 100644
--- a/lib/portage/tests/resolver/ResolverPlayground.py
+++ b/lib/portage/tests/resolver/ResolverPlayground.py
@@ -99,6 +99,7 @@ class ResolverPlayground(object):
 				"mkdir",
 				"mktemp",
 				"mv",
+				"readlink",
 				"rm",
 				"sed",
 				"sort",


             reply	other threads:[~2019-01-13 23:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-13 23:38 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-11-17 20:21 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/resolver/, bin/ Zac Medico
2023-12-10 22:01 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1547421452.8463281f6a6daec64a976693447c240f0d669f08.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox