* [gentoo-commits] proj/portage:master commit in: bin/, cnf/
@ 2011-05-31 21:49 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-05-31 21:49 UTC (permalink / raw
To: gentoo-commits
commit: 254e853c8a6aad06d4781b0eb0f5a1d2e1919754
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue May 31 21:48:55 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue May 31 21:48:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=254e853c
etc-update: add clear_term config for bug #142508
---
bin/etc-update | 7 ++++---
cnf/etc-update.conf | 3 +++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/bin/etc-update b/bin/etc-update
index 2369f04..42518ad 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -149,7 +149,7 @@ sel_file() {
elif [ "${DELETE_ALL}" == "yes" ]; then
input=0
else
- clear
+ [[ $CLEAR_TERM == yes ]] && clear
if [[ ${mode} == 0 ]] ; then
echo "The following is the list of files which need updating, each
configuration file is followed by a list of possible replacement files."
@@ -317,7 +317,7 @@ do_cfg() {
elif [[ "${DELETE_ALL}" == "yes" ]] && ! user_special "${ofile}"; then
my_input=2
else
- clear
+ [[ $CLEAR_TERM == yes ]] && clear
if [ "${using_editor}" == 0 ]; then
(
echo "Showing differences between ${ofile} and ${file}"
@@ -421,7 +421,7 @@ Please select from the menu above (-1 to exit, losing this merge): "
return 255
;;
2)
- clear
+ [[ $CLEAR_TERM == yes ]] && clear
if [ "${using_editor}" == 0 ]; then
(
echo "Showing differences between ${ofile} and ${mfile}"
@@ -555,6 +555,7 @@ chown ${UID:-0}:${GID:-0} "${TMP}" || die "failed to set ownership on temp dir"
#CONFIG_PROTECT_MASK=$(/usr/lib/portage/bin/portageq envvar CONFIG_PROTECT_MASK)
# load etc-config's configuration
+CLEAR_TERM=$(get_config clear_term)
EU_AUTOMERGE=$(get_config eu_automerge)
rm_opts=$(get_config rm_opts)
mv_opts=$(get_config mv_opts)
diff --git a/cnf/etc-update.conf b/cnf/etc-update.conf
index 8157c3d..6f69dee 100644
--- a/cnf/etc-update.conf
+++ b/cnf/etc-update.conf
@@ -5,6 +5,9 @@
# note that you need dev-util/dialog installed
mode="0"
+# Whether to clear the term prior to each display
+clear_term="yes"
+
# Whether trivial/comment changes should be automerged
eu_automerge="yes"
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, cnf/
@ 2011-09-28 17:47 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-09-28 17:47 UTC (permalink / raw
To: gentoo-commits
commit: 374aa37ece5d67d003da358e35f0326da3cd2397
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 28 17:47:08 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 28 17:47:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=374aa37e
etc-update: support PAGER env var for bug #384663
---
bin/etc-update | 11 ++++++++++-
cnf/etc-update.conf | 12 ++++++------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/bin/etc-update b/bin/etc-update
index 42518ad..2af04cc 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -33,6 +33,12 @@ get_config() {
"${PORTAGE_CONFIGROOT}"etc/etc-update.conf)
}
+cmd_var_is_valid() {
+ # return true if the first whitespace-separated token contained
+ # in "${1}" is an executable file, false otherwise
+ [[ -x $(type -P ${1%%[[:space:]]*}) ]]
+}
+
diff_command() {
local cmd=${diff_command//%file1/$1}
${cmd//%file2/$2}
@@ -566,7 +572,10 @@ using_editor=$(get_config using_editor)
merge_command=$(get_config merge_command)
declare -i mode=$(get_config mode)
[[ -z ${mode} ]] && mode=0
-[[ -z ${pager} ]] && pager="cat"
+if ! cmd_var_is_valid "${pager}" ; then
+ pager=${PAGER}
+ cmd_var_is_valid "${pager}" || pager=cat
+fi
if [ "${using_editor}" == 0 ]; then
# Sanity check to make sure diff exists and works
diff --git a/cnf/etc-update.conf b/cnf/etc-update.conf
index cea2173..9709862 100644
--- a/cnf/etc-update.conf
+++ b/cnf/etc-update.conf
@@ -21,9 +21,9 @@ mv_opts="-i"
# arguments used whenever cp is called
cp_opts="-i"
-# pager for use with diff commands
-pager="less"
-#pager=""
+# set the pager for use with diff commands (this will
+# cause the PAGER environment variable to be ignored)
+#pager="less"
# For emacs-users (see NOTE_2)
# diff_command="eval emacs -nw --eval=\'\(ediff\ \"%file1\"\ \"%file2\"\)\'"
@@ -47,9 +47,9 @@ merge_command="sdiff -s -o %merged %orig %new"
# pager:
#
# Examples of pager usage:
-# pager="" # don't use a pager
-# pager="less -E" # less
-# pager="more" # more
+# pager="cat" # don't use a pager
+# pager="less -E" # less
+# pager="more" # more
#
#
# diff_command:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:master commit in: bin/, cnf/
@ 2011-09-28 18:41 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-09-28 18:41 UTC (permalink / raw
To: gentoo-commits
commit: 3be910392f1186cacf0796e952fb5dae38b10f57
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 28 18:41:44 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 28 18:41:44 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3be91039
dispatch-conf: support PAGER var for bug #384663
---
bin/dispatch-conf | 32 ++++++++++++++++++++++++++++++++
cnf/dispatch-conf.conf | 10 +++++++++-
2 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index 497927d..55d7f13 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -64,6 +64,20 @@ atexit.register(cleanup)
MANDATORY_OPTS = [ 'archive-dir', 'diff', 'replace-cvs', 'replace-wscomments', 'merge' ]
+def cmd_var_is_valid(cmd):
+ """
+ Return true if the first whitespace-separated token contained
+ in cmd is an executable file, false otherwise.
+ """
+ cmd = portage.util.shlex_split(cmd)
+ if not cmd:
+ return False
+
+ if os.path.isabs(cmd[0]):
+ return os.access(cmd[0], os.EX_OK)
+
+ return find_binary(cmd[0]) is not None
+
class dispatch:
options = {}
@@ -84,6 +98,22 @@ class dispatch:
else:
self.options["log-file"] = "/dev/null"
+ pager = self.options.get("pager")
+ if pager is None or not cmd_var_is_valid(pager):
+ pager = os.environ.get("PAGER")
+ if pager is None or not cmd_var_is_valid(pager):
+ pager = "cat"
+
+ if os.path.basename(pager) == "less":
+ less_opts = self.options.get("less-opts")
+ if less_opts is not None and less_opts.strip():
+ pager += " " + less_opts
+
+ if os.path.basename(portage.util.shlex_split(pager)[0]) == "cat":
+ pager = ""
+ else:
+ pager = " | " + pager
+
#
# Build list of extant configs
#
@@ -226,10 +256,12 @@ class dispatch:
clear_screen()
if show_new_diff:
cmd = self.options['diff'] % (conf['new'], mrgconf)
+ cmd += pager
spawn_shell(cmd)
show_new_diff = 0
else:
cmd = self.options['diff'] % (conf['current'], newconf)
+ cmd += pager
spawn_shell(cmd)
print()
diff --git a/cnf/dispatch-conf.conf b/cnf/dispatch-conf.conf
index b51b61a..c4ab33f 100644
--- a/cnf/dispatch-conf.conf
+++ b/cnf/dispatch-conf.conf
@@ -22,7 +22,15 @@ use-rcs=no
# %s new file
# If using colordiff instead of diff, the less -R option may be required
# for correct display.
-diff="diff -Nu '%s' '%s' | less --no-init --QUIT-AT-EOF"
+diff="diff -Nu '%s' '%s'"
+
+# Set the pager for use with diff commands (this will
+# cause the PAGER environment variable to be ignored).
+# Setting pager="cat" will disable pager usage.
+pager=""
+
+# Default options used if less is the pager
+less-opts="--no-init --QUIT-AT-EOF"
# Diff for interactive merges.
# %s output file
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-28 18:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-28 17:47 [gentoo-commits] proj/portage:master commit in: bin/, cnf/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2011-09-28 18:41 Zac Medico
2011-05-31 21:49 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox