diff options
author | Ulrich Müller <ulm@gentoo.org> | 2008-05-23 14:31:25 +0000 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2008-05-23 14:31:25 +0000 |
commit | 77547966694ee7322108730d9fb7616a52ba1803 (patch) | |
tree | 147d7683d5dc6308cec5a55b21237a2aefdc0e35 /app-admin/eselect-emacs/files | |
parent | Prerelease, since opfer doesn't like live ebuilds. ;-) (diff) | |
download | emacs-77547966694ee7322108730d9fb7616a52ba1803.tar.gz emacs-77547966694ee7322108730d9fb7616a52ba1803.tar.bz2 emacs-77547966694ee7322108730d9fb7616a52ba1803.zip |
Prerelease, since opfer doesn't like live ebuilds. ;-)
svn path=/emacs-overlay/; revision=1075
Diffstat (limited to 'app-admin/eselect-emacs/files')
-rwxr-xr-x | app-admin/eselect-emacs/files/emacs-updater | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/app-admin/eselect-emacs/files/emacs-updater b/app-admin/eselect-emacs/files/emacs-updater new file mode 100755 index 0000000..7f94d97 --- /dev/null +++ b/app-admin/eselect-emacs/files/emacs-updater @@ -0,0 +1,122 @@ +#!/bin/bash + +# Copyright 2007-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: emacs-updater,v 1.3 2008/03/08 06:53:06 ulm Exp $ + +# Authors: +# Christian Faulhammer <opfer@gentoo.org> +# Ulrich Mueller <ulm@gentoo.org> + +VERSION=0.6 +SITELISP=/usr/share/emacs/site-lisp +TMPFILE="$(mktemp /tmp/emacs-updater.XXXXXX)" + +cat <<-EOF + +Emacs updater version ${VERSION} +Written by the Gentoo Emacs team http://www.gentoo.org/proj/en/lisp/emacs/ +Find packages that are installed in the wrong location + +EOF + +usage() { + sed -e 's/^X//' <<-EOF + Usage: ${0##*/} [OPTION]... + X -n, --nocolour disable colour in output + X -p, --pretend don't actually emerge packages + X -h, --help display this help and exit + EOF + exit ${1} +} + +# Read in all command-line options and force English output +OPTIONS=$(LC_ALL=C getopt -o hpn --long help,pretend,nocolour \ + -n 'emacs-updater' -- "$@") +[ $? -eq 0 ] || usage 1 + +eval set -- "${OPTIONS}" + +while true +do + case "${1}" in + -h|--help) usage 0 ;; + -p|--pretend) PRETEND="true"; shift 1 ;; + -n|--nocolour) NOCOLOUR="true"; shift 1 ;; + --) shift; break ;; + esac +done + +# Only set colours if output is not redirected or the --no-colour +# option is not set +if [ -t 1 ] && [ -z "${NOCOLOUR}" ] ; then + RED=$(tput -S <<<$'setaf 1\nbold') + GREEN=$(tput -S <<<$'setaf 2\nbold') + YELLOW=$(tput -S <<<$'setaf 3\nbold') + BLUE=$(tput -S <<<$'setaf 4\nbold') + MAGENTA=$(tput -S <<<$'setaf 5\nbold') + CYAN=$(tput -S <<<$'setaf 6\nbold') + BOLD=$(tput bold) + NORMAL=$(tput sgr0) +fi + +message() { + local OUTPUT=$@ + echo "${GREEN}*${NORMAL}${BOLD} ${OUTPUT}${NORMAL}" +} + +warning() { + local OUTPUT=$@ + echo "${YELLOW}*${NORMAL}${BOLD} ${OUTPUT}${NORMAL}" +} + +failure() { + local OUTPUT=$@ + echo "${RED}*${NORMAL}${BOLD} ${OUTPUT}${NORMAL}" +} + +if ! [ -x /usr/bin/qfile ]; then + echo + failure "Please emerge app-portage/portage-utils to use this tool" + exit 1 +fi + +for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el +do + [ "${sf##*/}" = 00site-gentoo.el ] && continue + message "Processing ${sf##*/} ..." + qfile -qCR "${sf}" >> "${TMPFILE}" +done +echo + +if [ ! -s "${TMPFILE}" ]; then + warning "No packages to update, quitting." + exit 2 +fi + +NO_OF_PACKAGES=$(sed -n '$=' "${TMPFILE}") + +[ ${NO_OF_PACKAGES} -eq 1 ] && s= || s=s +message "${NO_OF_PACKAGES} package${s} with site files in the wrong location:" +cat "${TMPFILE}" + +if [ "${PRETEND}" ]; then + exit 3 +fi + +echo +echo -n "${BOLD}Remerge packages?${NORMAL} [${GREEN}Yes${NORMAL}/${RED}No${NORMAL}] " +read choice +echo +case "${choice}" in + y*|Y*|"") + ;; + *) + warning "Quitting." + exit 10 ;; +esac + +emerge --oneshot --ask --verbose $(cat "${TMPFILE}") + +warning "If a package is being rebuilt over and over again," +warning "please report it on http://bugs.gentoo.org/" |