From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SR4Eg-0007JD-Cf for garchives@archives.gentoo.org; Sun, 06 May 2012 16:23:02 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 84061E08ED; Sun, 6 May 2012 16:13:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 450EEE09CC for ; Sun, 6 May 2012 16:07:22 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B51CC1B405A for ; Sun, 6 May 2012 16:07:21 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 7BFCDE542F for ; Sun, 6 May 2012 16:07:20 +0000 (UTC) From: "Sebastian Pipping" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sebastian Pipping" Message-ID: <1239449501.2998c9e84e637322948c3a6f2e1a2dfb3b4b07e4.sping@gentoo> Subject: [gentoo-commits] proj/emacs-tools:backups/emacs-updater@1480 commit in: / X-VCS-Repository: proj/emacs-tools X-VCS-Files: ChangeLog emacs-updater emacs-updater.8 X-VCS-Directories: / X-VCS-Committer: sping X-VCS-Committer-Name: Sebastian Pipping X-VCS-Revision: 2998c9e84e637322948c3a6f2e1a2dfb3b4b07e4 X-VCS-Branch: backups/emacs-updater@1480 Date: Sun, 6 May 2012 16:07:20 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 061d683d-3742-4733-9a8c-6b8d2829be24 X-Archives-Hash: 9895a52754409081c7a5d3d099480c07 commit: 2998c9e84e637322948c3a6f2e1a2dfb3b4b07e4 Author: Ulrich M=C3=BCller gentoo org> AuthorDate: Sat Apr 11 11:31:41 2009 +0000 Commit: Sebastian Pipping gentoo org> CommitDate: Sat Apr 11 11:31:41 2009 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/emacs-tools.g= it;a=3Dcommit;h=3D2998c9e8 Per default, determine package manager automatically. svn path=3D/emacs-updater/; revision=3D1244 --- 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 + + * 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 =20 * 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 # Ulrich Mueller =20 -VERSION=3D1.3 +VERSION=3D1.4_pre EMACS=3D/usr/bin/emacs SITELISP=3D/usr/share/emacs/site-lisp =20 @@ -15,7 +15,7 @@ SITELISP=3D/usr/share/emacs/site-lisp ACTIONS=3D"sitedir rebuild" =20 # Default package manager -PM_COMMAND=3Dpm_portage +PM_COMMAND=3Dpm_auto =20 # Other default variable settings EXACT=3D @@ -48,12 +48,35 @@ usage() { X -p, --pretend don't actually emerge packages X -P, --package-manager 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} } =20 +# 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=3D$(LC_ALL=3DC 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=3Dpm_auto ;; portage|pkgcore|paludis) + if ! "have_${2}"; then + echo "Package manager '${2}' not found!" + exit 22 + fi PM_COMMAND=3Dpm_${2} ;; *) echo "Package manager '${2}' not known!" - exit 21 + usage 21 ;; esac shift 2 @@ -188,19 +216,6 @@ action_all() { action_rebuild all } =20 -# 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