public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sebastian Pipping" <sping@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/emacs-tools:backups/emacs-updater@1480 commit in: /
Date: Sun,  6 May 2012 16:07:20 +0000 (UTC)	[thread overview]
Message-ID: <1239449501.2998c9e84e637322948c3a6f2e1a2dfb3b4b07e4.sping@gentoo> (raw)

commit:     2998c9e84e637322948c3a6f2e1a2dfb3b4b07e4
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 11 11:31:41 2009 +0000
Commit:     Sebastian Pipping <sping <AT> gentoo <DOT> org>
CommitDate: Sat Apr 11 11:31:41 2009 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/emacs-tools.git;a=commit;h=2998c9e8

Per default, determine package manager automatically.

svn path=/emacs-updater/; revision=1244

---
 ChangeLog       |    8 ++++++++
 emacs-updater   |   51 +++++++++++++++++++++++++++++++++------------------
 emacs-updater.8 |    9 ++++++---
 3 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e8cdb99..0a4500f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-04-11  Ulrich Mueller  <ulm@gentoo.org>
+
+	* emacs-updater (have_portage, have_pkgcore, have_paludis):
+	New functions, return true if respective package manager exists.
+	(pm_auto, have_auto): New function, find a package manager.
+	(PM_COMMAND): Default to pm_auto.
+	Test if package manager selected by -P option actually exists.
+
 2009-03-22  Ulrich Mueller  <ulm@gentoo.org>
 
 	* emacs-updater (action_sitedir): 00site-gentoo.el should not

diff --git a/emacs-updater b/emacs-updater
index f6c002e..2ea542b 100755
--- a/emacs-updater
+++ b/emacs-updater
@@ -7,7 +7,7 @@
 # Christian Faulhammer <fauli@gentoo.org>
 # Ulrich Mueller <ulm@gentoo.org>
 
-VERSION=1.3
+VERSION=1.4_pre
 EMACS=/usr/bin/emacs
 SITELISP=/usr/share/emacs/site-lisp
 
@@ -15,7 +15,7 @@ SITELISP=/usr/share/emacs/site-lisp
 ACTIONS="sitedir rebuild"
 
 # Default package manager
-PM_COMMAND=pm_portage
+PM_COMMAND=pm_auto
 
 # Other default variable settings
 EXACT=
@@ -48,12 +48,35 @@ usage() {
 	X  -p, --pretend          don't actually emerge packages
 	X  -P, --package-manager <arg>
 	X                         select a package manager. arg is one out of
-	X                         'portage' (default), 'pkgcore', or 'paludis'
+	X                         'portage', 'pkgcore', or 'paludis'
+	X                         (default: automatically determined)
 	X  -h, --help             display this help and exit
 	EOF
     exit ${1}
 }
 
+# Wrapper for package manager commands
+have_portage() { type -P emerge >/dev/null; }
+pm_portage() { emerge --oneshot --ask --verbose "$@"; }
+
+have_pkgcore() { type -P pmerge >/dev/null; }
+pm_pkgcore() { pmerge --oneshot --ask "$@"; }
+
+have_paludis() { type -P paludis >/dev/null; }
+pm_paludis() { paludis --install --preserve-world "$@"; }
+
+pm_auto() {
+    local pm
+    for pm in portage pkgcore paludis; do
+	if have_${pm}; then
+	    pm_${pm} "$@"
+	    return
+	fi
+    done
+    failure "No package manager found"
+    return 1
+}
+
 # Read in all command-line options and force English output
 OPTIONS=$(LC_ALL=C getopt -o a:ehnpP: \
     --long action:,exact,help,nocolour,pretend,package-manager: \
@@ -78,7 +101,7 @@ do
 			;;
 		    *)
 			echo "Invalid action '$action' given!"
-			exit 20
+			usage 20
 			;;
 		esac
 	    done
@@ -86,12 +109,17 @@ do
 	    ;;
 	-P|--package-manager)
 	    case "${2}" in
+		auto|automatic) PM_COMMAND=pm_auto ;;
 		portage|pkgcore|paludis)
+		    if ! "have_${2}"; then
+			echo "Package manager '${2}' not found!"
+			exit 22
+		    fi
 		    PM_COMMAND=pm_${2}
 		    ;;
 		*)
 		    echo "Package manager '${2}' not known!"
-		    exit 21
+		    usage 21
 		    ;;
 	    esac
 	    shift 2
@@ -188,19 +216,6 @@ action_all() {
     action_rebuild all
 }
 
-# Wrapper for package manager commands
-pm_portage() {
-    emerge --oneshot --ask --verbose "$@"
-}
-
-pm_pkgcore() {
-    pmerge --oneshot --ask "$@"
-}
-
-pm_paludis() {
-    paludis --install --preserve-world "$@"
-}
-
 cleanup() {
     rm -f "${TMPFILE}" "${PKGFILE}"
 }

diff --git a/emacs-updater.8 b/emacs-updater.8
index 330ea69..a280a32 100644
--- a/emacs-updater.8
+++ b/emacs-updater.8
@@ -43,11 +43,14 @@ Don't actually emerge packages
 Select a package manager.
 .I PM
 is one out of
-.B portage
-(default),
+.BR portage ,
 .BR pkgcore ,
 or
-.B paludis
+.BR paludis .
+If the argument
+.B auto
+is given, then the package manager is automatically determined.
+This is the default.
 .TP
 .B -h, --help
 Display help and exit



             reply	other threads:[~2012-05-06 16:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-06 16:07 Sebastian Pipping [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-05-06 16:07 [gentoo-commits] proj/emacs-tools:backups/emacs-updater@1480 commit in: / Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:07 Sebastian Pipping
2012-05-06 16:06 [gentoo-commits] proj/emacs-tools:emacs-updater " Sebastian Pipping
2012-05-06 16:07 ` [gentoo-commits] proj/emacs-tools:backups/emacs-updater@1480 " Sebastian Pipping
2012-05-06 16:06 [gentoo-commits] proj/emacs-tools:emacs-updater " Sebastian Pipping
2012-05-06 16:07 ` [gentoo-commits] proj/emacs-tools:backups/emacs-updater@1480 " Sebastian Pipping
2012-05-06 16:06 [gentoo-commits] proj/emacs-tools:emacs-updater " Sebastian Pipping
2012-05-06 16:07 ` [gentoo-commits] proj/emacs-tools:backups/emacs-updater@1480 " Sebastian Pipping

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=1239449501.2998c9e84e637322948c3a6f2e1a2dfb3b4b07e4.sping@gentoo \
    --to=sping@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