summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2009-12-08 21:53:45 +0000
committerfuzzyray <fuzzyray@gentoo.org>2009-12-08 21:53:45 +0000
commitacdf616efa73b77936963eaa8b5c715db97646d2 (patch)
treed08ef2efee8b7edbf8c1df1a8de26439d6b42bd3 /bin
parent8a7c93709f74e29b81b5e7ad5310530d86cfe87c (diff)
downloadgentoolkit-acdf616efa73b77936963eaa8b5c715db97646d2.tar.gz
Merge rev 113 from djanderson's genscripts repo
svn path=/trunk/gentoolkit/; revision=703
Diffstat (limited to 'bin')
-rwxr-xr-xbin/eclean30
-rwxr-xr-xbin/epkginfo4
-rwxr-xr-xbin/equery20
-rwxr-xr-xbin/euse84
-rwxr-xr-xbin/revdep-rebuild7
5 files changed, 82 insertions, 63 deletions
diff --git a/bin/eclean b/bin/eclean
index 9953fa7..6fee381 100755
--- a/bin/eclean
+++ b/bin/eclean
@@ -9,7 +9,7 @@ from __future__ import with_statement
# Meta:
__author__ = "Thomas de Grenier de Latour (tgl)"
__email__ = "degrenier@easyconnect.fr"
-__version__ = open('/usr/share/gentoolkit/VERSION').read().strip()
+__version__ = "svn"
__productname__ = "eclean"
__description__ = "A cleaning tool for Gentoo distfiles and binaries."
@@ -206,14 +206,14 @@ def prettySize(size,justify=False):
size = size / 1024.
units.pop()
sizestr = fpformat.fix(size,approx)+units[-1]
- if justify:
+ if justify:
sizestr = " " + blue("[ ") + " "*(7-len(sizestr)) \
+ green(sizestr) + blue(" ]")
return sizestr
###############################################################################
-# yesNoAllPrompt: print a prompt until user answer in yes/no/all. Return a
+# yesNoAllPrompt: print a prompt until user answer in yes/no/all. Return a
# boolean for answer, and also may affect the 'accept_all' option.
# Note: i gave up with getch-like functions, to much bugs in case of escape
# sequences. Back to raw_input.
@@ -259,8 +259,8 @@ def parseSize(size):
###############################################################################
-# parseTime: convert a duration "Xu" ("X" is an int, and "u" a time unit in
-# [Y,M,W,D,H]) into an integer which is a past EPOCH date.
+# parseTime: convert a duration "Xu" ("X" is an int, and "u" a time unit in
+# [Y,M,W,D,H]) into an integer which is a past EPOCH date.
# Raises ParseArgsException('time') in case of failure.
# (yep, big approximations inside... who cares?)
def parseTime(timespec):
@@ -287,7 +287,7 @@ def parseTime(timespec):
# dict.
def parseArgs(myoptions={}):
- # local function for interpreting command line options
+ # local function for interpreting command line options
# and setting myoptions accordingly
def optionSwitch(myoption,opts,action=None):
return_code = True
@@ -323,7 +323,7 @@ def parseArgs(myoptions={}):
# sanity check of --destructive only options:
for myopt in ('fetch-restricted', 'package-names'):
if (not myoptions['destructive']) and myoptions[myopt]:
- if not myoptions['quiet']:
+ if not myoptions['quiet']:
eerror("--%s only makes sense in --destructive mode." \
% myopt, myoptions['nocolor'])
myoptions[myopt] = False
@@ -429,14 +429,14 @@ def parseExcludeFile(filepath):
filecontents = file.readlines()
file.close()
cat_re = re.compile('^(?P<cat>[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$')
- cp_re = re.compile('^(?P<cp>[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$')
+ cp_re = re.compile('^(?P<cp>[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$')
for line in filecontents:
line = line.strip()
if not len(line): continue
if line[0] == '#': continue
try: mycat = cat_re.match(line).group('cat')
except: pass
- else:
+ else:
if not mycat in portage.settings.categories:
raise ParseExcludeFileException("Invalid category: "+mycat)
excl_dict['categories'][mycat] = None
@@ -604,7 +604,7 @@ def findPackages( \
package_names=False):
clean_dict = {}
# create a full package dictionary
-
+
if not (os.path.isdir(pkgdir)):
eerror("%s does not appear to be a directory." % pkgdir, myoptions['nocolor'])
eerror("Please set PKGDIR to a sane value.", myoptions['nocolor'])
@@ -687,7 +687,7 @@ def doCleanup(clean_dict,action,myoptions):
or yesNoAllPrompt(myoptions, \
"Do you want to delete this " \
+ file_type+"?"):
- # non-interactive mode or positive answer.
+ # non-interactive mode or positive answer.
# For each file, try to delete the file and clean it out
# of Packages metadata file
if action == 'packages':
@@ -713,7 +713,7 @@ def doCleanup(clean_dict,action,myoptions):
clean_size += filesize
if action == 'packages':
metadata.packages[:] = [p for p in metadata.packages if 'CPV' in p and p['CPV'] != file]
-
+
if action == 'packages':
with open(os.path.join(pkgdir, 'Packages'), 'w') as metadata_file:
metadata.write(metadata_file)
@@ -740,7 +740,7 @@ def doAction(action,myoptions,exclude_dict={}):
destructive=myoptions['destructive'], \
package_names=myoptions['package-names'], \
time_limit=myoptions['time-limit'])
- else:
+ else:
clean_dict = findDistfiles( \
myoptions, \
exclude_dict=exclude_dict, \
@@ -796,7 +796,7 @@ def main():
elif e.value == 'version':
printVersion()
sys.exit(0)
- else:
+ else:
printUsage(e.value)
sys.exit(2)
# parse the exclusion file
@@ -811,7 +811,7 @@ def main():
eerror("Invalid exclusion file: %s" % myoptions['exclude-file'], \
myoptions['nocolor'])
eerror("See format of this file in `man %s`" % __productname__, \
- myoptions['nocolor'])
+ myoptions['nocolor'])
sys.exit(1)
else: exclude_dict={}
# security check for non-pretend mode
diff --git a/bin/epkginfo b/bin/epkginfo
index 747527a..a335403 100755
--- a/bin/epkginfo
+++ b/bin/epkginfo
@@ -19,7 +19,7 @@ from xml.sax.handler import feature_namespaces
import portage
from portage.output import *
-version = open('/usr/share/gentoolkit/VERSION').read().strip()
+__version__ = "svn"
def earch(workdir):
"""Prints arch keywords for a given dir"""
@@ -177,7 +177,7 @@ def check_metadata(full_package):
def usage(code):
"""Prints the uage information for this script"""
- print green("epkginfo"), "(%s)" % version
+ print green("epkginfo"), "(%s)" % __version__
print
print "Usage: epkginfo [package-cat/]package"
sys.exit(code)
diff --git a/bin/equery b/bin/equery
index bac8a3a..e7bb6ce 100755
--- a/bin/equery
+++ b/bin/equery
@@ -2,9 +2,11 @@
#
# Copyright 2002-2009 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2 or later
+#
+# $Header$
-"""equery is a flexible utility for Gentoo linux which can display various
-information about packages, such as the files they own, their USE flags,
+"""equery is a flexible utility for Gentoo linux which can display various
+information about packages, such as the files they own, their USE flags,
the MD5 sum of each file owned by a given package, and many other things.
"""
@@ -27,6 +29,16 @@ except KeyboardInterrupt:
print
sys.exit(1)
-from gentoolkit import equery
+from gentoolkit import equery, errors
-equery.main()
+try:
+ equery.main()
+except errors.GentoolkitException, err:
+ if '--debug' in sys.argv:
+ raise
+ else:
+ from gentoolkit import pprinter as pp
+ sys.stderr.write(pp.error(str(err)))
+ print
+ print "Add '--debug' to global options for traceback."
+ sys.exit(1)
diff --git a/bin/euse b/bin/euse
index ca9835e..5950888 100755
--- a/bin/euse
+++ b/bin/euse
@@ -7,7 +7,7 @@
# Licensed under the GPL v2
PROGRAM_NAME=euse
-PROGRAM_VERSION=$(cat /usr/share/gentoolkit/VERSION)
+VERSION="svn"
MAKE_CONF_PATH=/etc/make.conf
MAKE_GLOBALS_PATH=/etc/make.globals
@@ -67,9 +67,9 @@ check_sanity() {
# file permission tests
local descdir
local make_defaults
-
+
descdir="$(get_portdir)/profiles"
-
+
[ ! -r "${MAKE_CONF_PATH}" ] && error "${MAKE_CONF_PATH} is not readable"
[ ! -r "${MAKE_GLOBALS_PATH}" ] && error "${MAKE_GLOBALS_PATH} is not readable"
[ ! -h "${MAKE_PROFILE_PATH}" ] && error "${MAKE_PROFILE_PATH} is not a symlink"
@@ -86,7 +86,7 @@ check_sanity() {
showhelp() {
cat << HELP
-${PROGRAM_NAME} (${PROGRAM_VERSION})
+${PROGRAM_NAME} (${VERSION})
Syntax: ${PROGRAM_NAME} <option> [suboptions] [useflaglist]
@@ -113,7 +113,7 @@ HELP
showversion() {
cat << VER
-${PROGRAM_NAME} (${PROGRAM_VERSION})
+${PROGRAM_NAME} (${VERSION})
Written by Marius Mauch
Copyright (C) 2004-2009 Gentoo Foundation, Inc.
@@ -144,16 +144,16 @@ for x in sys.stdin.read().split():
r.append(x)
elif x not in r:
r.append(x)
-print ' '.join(r)"
+print ' '.join(r)"
}
# the following function creates a bash array ACTIVE_FLAGS that contains the
-# global use flags, indexed by origin: 0: environment, 1: make.conf,
+# global use flags, indexed by origin: 0: environment, 1: make.conf,
# 2: make.defaults, 3: make.globals
get_useflags() {
# only calculate once as calling emerge is painfully slow
[ -n "${USE_FLAGS_CALCULATED}" ] && return
-
+
# backup portdir so get_portdir() doesn't give false results later
portdir_backup="${PORTDIR}"
@@ -186,7 +186,7 @@ get_useflaglist() {
local descdir
descdir="$(get_portdir)/profiles"
-
+
if [ -z "${SCOPE}" -o "${SCOPE}" == "global" ]; then
egrep "^[^# ]+ +-" "${descdir}/use.desc" | cut -d\ -f 1
fi
@@ -200,9 +200,9 @@ get_all_make_defaults() {
local curdir
local parent
local rvalue
-
+
curdir="${1:-$(get_real_path ${MAKE_PROFILE_PATH})}"
-
+
[ -f "${curdir}/make.defaults" ] && rvalue="${curdir}/make.defaults ${rvalue}"
if [ -f "${curdir}/parent" ]; then
for parent in $(egrep -v '(^#|^ *$)' ${curdir}/parent); do
@@ -218,9 +218,9 @@ get_all_make_defaults() {
get_make_defaults() {
local curdir
local parent
-
+
curdir="${1:-$(get_real_path ${MAKE_PROFILE_PATH})}"
-
+
if [ ! -f "${curdir}/make.defaults" -a -f "${curdir}/parent" ]; then
for parent in $(egrep -v '(^#|^ *$)' ${curdir}/parent); do
if [ -f "$(get_make_defaults ${curdir}/${parent})" ]; then
@@ -233,9 +233,9 @@ get_make_defaults() {
echo "${curdir}/make.defaults"
}
-# little helper function to get the status of a given flag in one of the
+# little helper function to get the status of a given flag in one of the
# ACTIVE_FLAGS elements. Arguments are 1: flag to test, 2: index of ACTIVE_FLAGS,
-# 3: echo value for positive (and as lowercase for negative) test result,
+# 3: echo value for positive (and as lowercase for negative) test result,
# 4 (optional): echo value for "missing" test result, defaults to blank
get_flagstatus_helper() {
if echo " ${ACTIVE_FLAGS[${2}]} " | grep " ${1} " > /dev/null; then
@@ -277,35 +277,35 @@ get_portdir() {
echo "${PORTDIR}"
}
-# This function takes a list of use flags and shows the status and
+# This function takes a list of use flags and shows the status and
# the description for each one, honoring $SCOPE
showdesc() {
local descdir
local current_desc
local found_one
local args
-
+
args="${*:-*}"
-
+
if [ -z "${SCOPE}" ]; then
SCOPE="global" showdesc ${args}
echo
SCOPE="local" showdesc ${args}
return
fi
-
+
descdir="$(get_portdir)/profiles"
-
+
[ "${SCOPE}" == "global" ] && echo "global use flags (searching: ${args})"
[ "${SCOPE}" == "local" ] && echo "local use flags (searching: ${args})"
echo "************************************************************"
-
+
if [ "${args}" == "*" ]; then
args="$(get_useflaglist | sort -u)"
fi
-
+
set ${args}
-
+
foundone=0
while [ -n "${1}" ]; do
if [ "${SCOPE}" == "global" ]; then
@@ -315,7 +315,7 @@ showdesc() {
fi
grep "^${1} *-" "${descdir}/use.desc"
fi
- # local flags are a bit more complicated as there can be multiple
+ # local flags are a bit more complicated as there can be multiple
# entries per flag and we can't pipe into printf
if [ "${SCOPE}" == "local" ]; then
if grep ":${1} *-" "${descdir}/use.local.desc" > /dev/null; then
@@ -333,7 +333,7 @@ showdesc() {
fi
shift
done
-
+
if [ ${foundone} == 0 ]; then
echo "no matching entries found"
fi
@@ -361,13 +361,13 @@ showinstdesc() {
descdir="$(get_portdir)/profiles"
echo "************************************************************"
-
+
if [ "${args}" = "*" ]; then
args="$(get_useflaglist | sort -u)"
fi
-
+
set "${args[@]}"
-
+
while [ -n "${1}" ]; do
case "${SCOPE}" in
"global")
@@ -406,7 +406,7 @@ showinstdesc() {
esac
shift
done
-
+
if [ ${foundone} -lt 1 ]; then
echo "no matching entries found"
fi
@@ -418,15 +418,15 @@ showflags() {
local args
get_useflags
-
+
args="${*:-*}"
-
+
if [ "${args}" == "*" ]; then
args="$(get_useflaglist | sort -u)"
fi
-
+
set ${args}
-
+
while [ -n "${1}" ]; do
if echo " ${ACTIVE_FLAGS[9]} " | grep " ${1} " > /dev/null; then
printf "%-20s" ${1}
@@ -446,7 +446,7 @@ remove_flag() {
NEW_MAKE_CONF_USE="${NEW_MAKE_CONF_USE// ${1} / }"
}
-# USE flag modification function. Mainly a loop with calls to add_flag and
+# USE flag modification function. Mainly a loop with calls to add_flag and
# remove_flag to create a new USE string which is then inserted into make.conf.
modify() {
if [ -z "${*}" ]; then
@@ -458,11 +458,11 @@ modify() {
set $(get_useflaglist | sort -u)
fi
fi
-
+
get_useflags
-
+
NEW_MAKE_CONF_USE=" ${ACTIVE_FLAGS[1]} "
-
+
while [ -n "${1}" ]; do
if [ "${ACTION}" == "add" ]; then
if echo " ${NEW_MAKE_CONF_USE} " | grep " ${1} " > /dev/null; then
@@ -491,13 +491,13 @@ modify() {
shift
fi
done
-
+
#echo "old flags:"
#echo ${ACTIVE_FLAGS[1]}
#echo
#echo "new flags:"
#echo ${NEW_MAKE_CONF_USE}
-
+
# a little loop to add linebreaks so we don't end with one ultra-long line
NEW_MAKE_CONF_USE_2=""
for x in ${NEW_MAKE_CONF_USE}; do
@@ -510,9 +510,9 @@ modify() {
# make a backup just in case the user doesn't like the new make.conf
cp -p "${MAKE_CONF_PATH}" "${MAKE_CONF_BACKUP_PATH}"
-
+
# as sed doesn't really work with multi-line patterns we have to replace USE
- # on our own here. Basically just skip everything between USE=" and the
+ # on our own here. Basically just skip everything between USE=" and the
# closing ", printing our new USE line there instead.
inuse=0
had_use=0
@@ -536,7 +536,7 @@ modify() {
echo -ne "${NEW_MAKE_CONF_USE_2%% }"
echo '"'
fi ) < "${MAKE_CONF_BACKUP_PATH}" | sed -e 's:\\ $:\\:' > "${MAKE_CONF_PATH}"
-
+
echo "${MAKE_CONF_PATH} was modified, a backup copy has been placed at ${MAKE_CONF_BACKUP_PATH}"
}
diff --git a/bin/revdep-rebuild b/bin/revdep-rebuild
index 55a4d6b..cf86e71 100755
--- a/bin/revdep-rebuild
+++ b/bin/revdep-rebuild
@@ -18,6 +18,7 @@ unset GREP_OPTIONS
# Readonly variables:
declare -r APP_NAME="${0##*/}" # The name of this application
+declare -r VERSION="svn"
declare -r OIFS="$IFS" # Save the IFS
declare -r ENV_FILE=0_env.rr # Contains environment variables
declare -r FILES_FILE=1_files.rr # Contains a list of files to search
@@ -190,6 +191,12 @@ Calls emerge, options after -- are ignored by $APP_NAME
and passed directly to emerge.
Report bugs to <http://bugs.gentoo.org>
+
+${APP_NAME}: (${VERSION})
+
+Copyright (C) 2003-2009 Gentoo Foundation, Inc.
+This is free software; see the source for copying conditions.
+
EOF
}
##