From 83affb4075e26d00bc291a30eb993d7b4f880193 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Sun, 5 Jun 2005 21:25:11 +0000 Subject: [PATCH] Updated revdep-rebuild from bug #62644 svn path=/; revision=220 --- trunk/ChangeLog | 35 +- trunk/src/revdep-rebuild/AUTHORS | 3 +- trunk/src/revdep-rebuild/ChangeLog | 5 + trunk/src/revdep-rebuild/Makefile | 4 +- trunk/src/revdep-rebuild/TODO | 3 +- trunk/src/revdep-rebuild/find_pkgs.py | 22 ++ trunk/src/revdep-rebuild/revdep-rebuild | 421 ++++++++++++++++------ trunk/src/revdep-rebuild/revdep-rebuild.1 | 91 ++++- 8 files changed, 462 insertions(+), 122 deletions(-) create mode 100755 trunk/src/revdep-rebuild/find_pkgs.py diff --git a/trunk/ChangeLog b/trunk/ChangeLog index 2f7449c..96b3bb8 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,3 +1,36 @@ +2005-06-05 Paul Varner + * revdep-rebuild: Imported revdep-rebuild release from bug 62644 + * revdep-rebuild: Major changes to the functionality when using --package-names/-X + The script should now update slotted packages correctly. (bug 22161) + * revdep-rebuild: Customizable searching controlled through environment variables. + This removes the need for end users to directly modify the script. + (bugs 32276, 38011, 59803) + * revdep-rebuild: The directories to search are no longer hard coded into the script. + revdep-rebuild now determines the directories to search based upon + /etc/profile.env and /etc/ld.so.conf. (bugs 32276, 38011, 89781) + * revdep-rebuild: --ignore option to ignore temporary files left from previous runs. + Automatically ignore temporary files older than 24 hours. (bug 34052) + * revdep-rebuild: Always return an exit status based upon success or failure. (bug 38472) + * revdep-rebuild: Fixed to only emerge packages with direct missing dependencies. (bug 38487) + * revdep-rebuild: New man page. (bug 40042) + * revdep-rebuild: emerge is no longer called with --nodeps. This allows for needed + dependencies to be pulled in. (bug 62893) + * revdep-rebuild: Cleaned up grammatical errors (bug 85278) + * revdep-rebuild: Added support for revdep-rebuild --soname /path/to/library.so (bug 91503) + * revdep-rebuild: Removed symbolically linked directories from search (bug 93574) + * revdep-rebuild: --nocolor option to turn off colored output, the script also obeys + the NOCOLOR setting from /etc/make.conf. + * revdep-rebuild: Removed dependency on qpkg + * revdep-rebuild: Script uses PORTAGE_NICENESS from /etc/make.conf + * revdep-rebuild: Undocumented --keep-temp option. This is primarily for debugging/testing. + This option prevents temporary files from being deleted. + * revdep-rebuild: Changed --soname --soname-regexp options to --library and treat all + arguments as basic regular expressions. --soname and --soname-regexp can + still be used as options for backwards compatability. + * revdep-rebuild: Removed requirement to keep revdep-rebuild and emerge options distinct. + Options that are unrecognized by revdep-rebuild are passed directly to + emerge. + 2005-04-30 Marius Mauch * glsa-check: add V to short option list so it actually works * equery: added new option --name-only to belongs command to make it "emerge-compatible" @@ -17,7 +50,7 @@ * euse: add better support for cascaded profiles * glsa-check: use --oneshot (bug 79819) * glsa.py: fix stupid revision comparison bug (bug 75233) - + 2005-03-12 Aron Griffis * Added eviewcvs to -dev, utility for generating viewcvs URLs diff --git a/trunk/src/revdep-rebuild/AUTHORS b/trunk/src/revdep-rebuild/AUTHORS index 4a74e2e..b3d9b32 100644 --- a/trunk/src/revdep-rebuild/AUTHORS +++ b/trunk/src/revdep-rebuild/AUTHORS @@ -1 +1,2 @@ -Stanislav Brabec +Stanislav Brabec (original author) +Paul Varner diff --git a/trunk/src/revdep-rebuild/ChangeLog b/trunk/src/revdep-rebuild/ChangeLog index d48f7b7..9060781 100644 --- a/trunk/src/revdep-rebuild/ChangeLog +++ b/trunk/src/revdep-rebuild/ChangeLog @@ -1,4 +1,9 @@ +2005-06-05 Paul Varner + + * ChangeLog moved to main gentoolkit ChangeLog + 2004-01-07 Karl Trygve Kalleberg + * Added Makefile * Copied revdep-rebuild script from app-portage/gentoolkit diff --git a/trunk/src/revdep-rebuild/Makefile b/trunk/src/revdep-rebuild/Makefile index fd83852..109b5aa 100644 --- a/trunk/src/revdep-rebuild/Makefile +++ b/trunk/src/revdep-rebuild/Makefile @@ -11,11 +11,13 @@ all: dist: mkdir -p ../../$(distdir)/src/revdep-rebuild - cp Makefile AUTHORS README TODO ChangeLog revdep-rebuild revdep-rebuild.1 ../../$(distdir)/src/revdep-rebuild/ + cp Makefile AUTHORS README TODO ChangeLog revdep-rebuild revdep-rebuild.1 find_pkgs.py ../../$(distdir)/src/revdep-rebuild/ install: install -m 0755 revdep-rebuild $(bindir)/ + install -d $(DESTDIR)/usr/lib/gentoolkit/bin/ + install -m 0755 find_pkgs.py $(DESTDIR)/usr/lib/gentoolkit/bin/ install -d $(docdir)/revdep-rebuild install -m 0644 AUTHORS README TODO $(docdir)/revdep-rebuild/ install -m 0644 revdep-rebuild.1 $(mandir)/ diff --git a/trunk/src/revdep-rebuild/TODO b/trunk/src/revdep-rebuild/TODO index 9844ae6..d9f6350 100644 --- a/trunk/src/revdep-rebuild/TODO +++ b/trunk/src/revdep-rebuild/TODO @@ -3,4 +3,5 @@ - use timestamps of files to know when to rebuild - if ts of cache is older than any of the package's contained files, we must rebuild -- update to use equery +- update to use equery/gentoolkit +- rewrite in python and/or eclectic module diff --git a/trunk/src/revdep-rebuild/find_pkgs.py b/trunk/src/revdep-rebuild/find_pkgs.py new file mode 100755 index 0000000..7013813 --- /dev/null +++ b/trunk/src/revdep-rebuild/find_pkgs.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +# Copyright 1999-2005 Gentoo Foundation +# $Header$ + +# Temporary script to find package versions and slot for revdep-rebuild + +import sys + +sys.path.insert(0, "/usr/lib/gentoolkit/pym") +import gentoolkit + +for pkgname in sys.argv[1:]: + matches = gentoolkit.find_packages(pkgname) + for pkg in matches: + (cat, name, ver, rev) = gentoolkit.split_package_name(pkg.get_cpv()) + slot = pkg.get_env_var("SLOT") + if rev == "r0": + fullversion = ver + else: + fullversion = ver + "-" + rev + + print name + " " + fullversion + " (" + slot + ")" diff --git a/trunk/src/revdep-rebuild/revdep-rebuild b/trunk/src/revdep-rebuild/revdep-rebuild index 699f740..e95a6c6 100755 --- a/trunk/src/revdep-rebuild/revdep-rebuild +++ b/trunk/src/revdep-rebuild/revdep-rebuild @@ -1,31 +1,115 @@ #! /bin/bash -# Copyright 1999-2003 Gentoo Technologies, Inc. +# Copyright 1999-2005 Gentoo Foundation # $Header$ # revdep-rebuild: Reverse dependency rebuilder. -# Author: Stanislav Brabec - -# requires: qpkg +# Original Author: Stanislav Brabec +# Current Maintainer: Paul Varner # Known problems: # -# In exact ebuild mode revdep-rebuild can fails to get order packages, -# which are not up to date. This is because emerge first tries to -# merge latest package and last in resort it tries to degrade. +# In exact ebuild mode revdep-rebuild can fail to properly order packages, +# which are not up to date. # http://bugs.gentoo.org/show_bug.cgi?id=23018 # -# Rebuild in --package-names mode should be default, but emerge has no +# Rebuilding using --package-names mode should be default, but emerge has no # feature to update to latest version of defined SLOT. # http://bugs.gentoo.org/show_bug.cgi?id=4698 -# Mask of specially evaluated libraries (exactly one space separated). -LD_LIBRARY_MASK="libodbcinst.so libodbc.so libjava.so libjvm.so" +# Customizable variables: +# +# LD_LIBRARY_MASK - Mask of specially evaluated libraries +# SEARCH_DIRS - List of directories to search for executibles and libraries +# SEARCH_DIRS_MASK - List of directories to not search +# +# These variables can be prepended to either by setting the variable in +# your environment prior to execution, or by placing an entry in +# /etc/make.conf. +# +# An entry of "-*" means to clear the variable from that point forward. +# Example: env SEARCH_DIRS="/usr/bin -*" revdep-rebuild will set SEARCH_DIRS +# to contain only /usr/bin + +if [ "$1" = "-h" -o "$1" = "--help" ] +then + echo "Usage: $0 [OPTIONS] [--] [EMERGE_OPTIONS]" + echo + echo "Broken reverse dependency rebuilder." + echo + echo " -X, --package-names Emerge based on package names, not exact versions" + echo " --library NAME Emerge existing packages that use the library with NAME" + echo " --library=NAME NAME can be a full path to the library or a basic" + echo " regular expression (man grep)" + echo " -nc, --no-color Turn off colored output" + echo " -i, --ignore Ignore temporary files from previous runs" + echo " -q, --quiet Be less verbose (also passed to emerge command)" + echo + echo "Calls emerge, all other options are used for it (e. g. -p, --pretend)." + echo + echo "Report bugs to " + exit 0 +fi + +echo "Configuring search environment for revdep-rebuild" + +# Obey PORTAGE_NICENESS +PORTAGE_NICENESS=$(portageq envvar PORTAGE_NICENESS) +[ ! -z "$PORTAGE_NICENESS" ] && renice $PORTAGE_NICENESS $$ > /dev/null + +# Set the defaults +PRELIMINARY_LD_LIBRARY_MASK="$LD_LIBRARY_MASK libodbcinst.so libodbc.so libjava.so libjvm.so" +PRELIMINARY_SEARCH_DIRS="$SEARCH_DIRS /bin /sbin /usr/bin /usr/sbin /lib* /usr/lib*" +PRELIMINARY_SEARCH_DIRS_MASK="$SEARCH_DIRS_MASK /opt/OpenOffice" + +# Update the SEARCH_DIRS variable using /etc/profile.env, /etc/ld.so.conf, +# /etc/make.conf, and the environment + +# Read the SEARCH_DIRS variable from /etc/make.conf +if [ -e "/etc/make.conf" ] +then + PRELIMINARY_SEARCH_DIRS="$PRELIMINARY_SEARCH_DIRS $(unset SEARCH_DIRS; . /etc/make.conf; echo $SEARCH_DIRS)" + PRELIMINARY_SEARCH_DIRS_MASK="$PRELIMINARY_SEARCH_DIRS_MASK $(unset SEARCH_DIRS_MASK; . /etc/make.conf; echo $SEARCH_DIRS_MASK)" + PRELIMINARY_LD_LIBRARY_MASK="$PRELIMINARY_LD_LIBRARY_MASK $(unset LD_LIBRARY_MASK; . /etc/make.conf; echo $LD_LIBRARY_MASK)" +fi + +# Get the ROOTPATH and PATH from /etc/profile.env +if [ -e "/etc/profile.env" ] +then + PRELIMINARY_SEARCH_DIRS="$PRELIMINARY_SEARCH_DIRS $((. /etc/profile.env; echo ${ROOTPATH}:${PATH}) | tr ':' ' ')" +fi + +# Get the directories from /etc/ld.so.conf +if [ -e /etc/ld.so.conf ] +then + PRELIMINARY_SEARCH_DIRS="$PRELIMINARY_SEARCH_DIRS $(grep -v "^#" /etc/ld.so.conf | tr '\n' ' ')" +fi + +# Set the final variables +# Note: Using $(echo $variable) removes extraneous spaces from variable assignment +unset SEARCH_DIRS +for i in $(echo $PRELIMINARY_SEARCH_DIRS) +do + [ "$i" = "-*" ] && break + SEARCH_DIRS="$(echo $SEARCH_DIRS $(readlink -f $i))" +done + +unset SEARCH_DIRS_MASK +for i in $(echo $PRELIMINARY_SEARCH_DIRS_MASK) +do + [ "$i" = "-*" ] && break + SEARCH_DIRS_MASK="$(echo $SEARCH_DIRS_MASK $i)" +done + +unset LD_LIBRARY_MASK +for i in $(echo $PRELIMINARY_LD_LIBRARY_MASK) +do + [ "$i" = "-*" ] && break + LD_LIBRARY_MASK="$(echo $LD_LIBRARY_MASK $i)" +done -# List of directories to be searched (feel free to edit it) -# Note /usr/libexec and /usr/local/subprefix cotradicts FHS, but are present -# /var/something is for cgi and similar scripts -SEARCH_DIRS="/lib /bin /sbin /usr/lib /usr/bin /usr/sbin /usr/libexec /usr/X11R6/lib /usr/X11R6/bin /usr/X11R6/sbin /usr/e1* /usr/local /usr/qt* /usr/kde/*/bin /usr/kde/*/lib /usr/*-*-linux-gnu /opt /var/qmail /var/vpopmail /home/httpd/cgi-bin" +# Use the color preference from portage +NOCOLOR=$(portageq envvar NOCOLOR) # Base of temporary files names. LIST=~/.revdep-rebuild @@ -34,7 +118,8 @@ shopt -s nullglob shopt -s expand_aliases unalias -a -NO="\x1b[0;0m" +# Color Definitions +NO="\x1b[0m" BR="\x1b[0;01m" CY="\x1b[36;01m" GR="\x1b[32;01m" @@ -46,69 +131,74 @@ alias echo_v=echo PACKAGE_NAMES=false SONAME="not found" -SONAME_GREP=fgrep +SONAME_GREP=grep SEARCH_BROKEN=true -while : ; do +EMERGE_OPTIONS="" +while [ ! -z "$1" ] ; do case "$1" in - -h | --help ) - echo "Usage: $0 [OPTIONS] [--] [EMERGE_OPTIONS]" - echo - echo "Broken reverse dependency rebuilder." - echo - echo " -X, --package-names recompile based on package names, not exact versions" - echo " --soname SONAME recompile packages using library with SONAME instead" - echo " of broken library (SONAME providing library must be" - echo " present in the system)" - echo " --soname-regexp SONAME" - echo " the same as --soname, but accepts grep-style regexp" - echo " -q, --quiet be less verbose" - echo - echo "Calls emerge, all other options are used for it (e. g. -p, --pretend)." - echo - echo "Report bugs to " - exit 0 - ;; -X | --package-names ) PACKAGE_NAMES=true shift ;; -q | --quiet ) alias echo_v=: + EMERGE_OPTIONS="${EMERGE_OPTIONS} $1" shift ;; - --soname=* ) + --library=* | --soname=* | --soname-regexp=* ) SONAME="${1#*=}" SEARCH_BROKEN=false shift ;; - --soname ) + --library | --soname | --soname-regexp ) SONAME="$2" SEARCH_BROKEN=false shift 2 ;; - --soname-regexp=* ) - SONAME="${1#*=}" - SONAME_GREP=grep - SEARCH_BROKEN=false + -nc | --no-color ) + NOCOLOR=true shift ;; - --soname-regexp ) - SONAME="$2" - SONAME_GREP=grep - SEARCH_BROKEN=false - shift 2 + -i | --ignore ) + rm -f ${LIST}* + shift + ;; + --keep-temp ) + KEEPTEMP=true + shift ;; -- ) shift - break ;; * ) - break + EMERGE_OPTIONS="${EMERGE_OPTIONS} $1" + shift ;; esac done +if [ "$NOCOLOR" = "yes" -o "$NOCOLOR" = "true" ] +then + NOCOLOR=true +else + NOCOLOR=false +fi + +# Make the NOCOLOR variable visible to emerge +export NOCOLOR + +if $NOCOLOR +then + NO="" + BR="" + CY="" + GR="" + RD="" + YL="" + BL="" +fi + function set_trap () { trap "rm_temp $1" SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM } @@ -124,29 +214,67 @@ function rm_temp () { if $SEARCH_BROKEN ; then SONAME_SEARCH="$SONAME" LLIST=$LIST - HEAD_TEXT="broken by any package update" + HEAD_TEXT="broken by a package update" OK_TEXT="Dynamic linking on your system is consistent" WORKING_TEXT=" consistency" else - SONAME_SEARCH=" $SONAME " + # first case is needed to test against /path/to/foo.so + if [ ${SONAME:0:1} == '/' ] ; then + SONAME_SEARCH=" $SONAME " + else + SONAME_SEARCH=" $SONAME " + fi LLIST=${LIST}_$(echo "$SONAME_SEARCH$SONAME" | md5sum | head -c 8) - HEAD_TEXT="using given shared object name" + HEAD_TEXT="using $SONAME" OK_TEXT="There are no dynamic links to $SONAME" WORKING_TEXT="" fi +# If our temporary files are older than 1 day, don't use them +TOO_OLD=$((`date +%s` - 86400)) +for file in ${LIST}* +do + if [ -f $file ] + then + FILE_AGE="$(stat -c %Y $file)" + if [ $FILE_AGE -lt $TOO_OLD ] + then + rm -f ${LIST}* + break + fi + fi +done + echo echo "Checking reverse dependencies..." -echo "Packages containing binaries and libraries $HEAD_TEXT," -echo "will be recompiled." +echo +echo "Packages containing binaries and libraries $HEAD_TEXT" +echo "will be emerged." echo echo -n -e "${GR}Collecting system binaries and libraries...${NO}" -if [ -f $LIST.1_files ] ; then + +if [ -f $LIST.1_files ] +then echo " using existing $LIST.1_files." else - set_trap "$LIST.1_files" - find $SEARCH_DIRS -type f \( -perm +u+x -o -name '*.so' -o -name '*.so.*' \) 2>/dev/null >$LIST.1_files + # Be safe and remove any extraneous temporary files + rm -f ${LIST}* + + set_trap "$LIST.[01]_*" + echo "SEARCH_DIRS=$SEARCH_DIRS" > $LIST.0_env + echo "SEARCH_DIRS_MASK=$SEARCH_DIRS_MASK" >> $LIST.0_env + echo "LD_LIBRARY_MASK=$LD_LIBRARY_MASK" >> $LIST.0_env + find $SEARCH_DIRS -type f \( -perm +u+x -o -name '*.so' -o -name '*.so.*' \) 2>/dev/null | sort | uniq >$LIST.0_files + + # Remove files that match SEARCH_DIR_MASK + for dir in $SEARCH_DIRS_MASK + do + grep -v "^$dir" $LIST.0_files > $LIST.1_files + mv $LIST.1_files $LIST.0_files + done + + mv $LIST.0_files $LIST.1_files echo -e " done.\n ($LIST.1_files)" fi @@ -154,15 +282,16 @@ if $SEARCH_BROKEN ; then echo echo -n -e "${GR}Collecting complete LD_LIBRARY_PATH...${NO}" if [ -f $LIST.2_ldpath ] ; then - echo " using existing $LIST.2_ldpath." + echo " using existing $LIST.2_ldpath." else - set_trap "$LIST.2_ldpath" - ( - grep '.*\.so\(\|\..*\)$' <$LIST.1_files | sed 's:/[^/]*$::' - sed '/^#/d;s/#.*$//' $LIST.2_ldpath - echo -e " done.\n ($LIST.2_ldpath)" + set_trap "$LIST.2_ldpath" + # Ensure that the "trusted" lib directories are at the start of the path + ( + echo /lib* /usr/lib* | sed 's/ /:/g' + sed '/^#/d;s/#.*$//' $LIST.2_ldpath + echo -e " done.\n ($LIST.2_ldpath)" fi export COMPLETE_LD_LIBRARY_PATH="$(cat $LIST.2_ldpath)" fi @@ -179,18 +308,45 @@ else cat $LIST.1_files | while read FILE ; do # Note: double checking seems to be faster than single # with complete path (special add ons are rare). - if ldd "$FILE" 2>/dev/null | grep -v "$LD_MASK" | - $SONAME_GREP -q "$SONAME_SEARCH" ; then + if ldd "$FILE" 2>/dev/null | grep -v "$LD_MASK" | $SONAME_GREP -q "$SONAME_SEARCH" ; then if $SEARCH_BROKEN ; then - if LD_LIBRARY_PATH="$COMPLETE_LD_LIBRARY_PATH" \ - ldd "$FILE" 2>/dev/null | grep -v "$LD_MASK" | - $SONAME_GREP -q "$SONAME_SEARCH" ; then - echo "$FILE" >>$LLIST.3_rebuild - echo_v " broken $FILE (requires $(ldd "$FILE" | sed -n 's/ \(.*\) => not found$/\1/p' | tr '\n' ' ' | sed 's/ $//' ))" - fi + if LD_LIBRARY_PATH="$COMPLETE_LD_LIBRARY_PATH" ldd "$FILE" 2>/dev/null | grep -v "$LD_MASK" | $SONAME_GREP -q "$SONAME_SEARCH" ; then + # FIX: I hate duplicating code + # Only build missing direct dependencies + ALL_MISSING_LIBS=$(ldd "$FILE" 2>/dev/null | sort -u | sed -n 's/ \(.*\) => not found$/\1/p' | tr '\n' ' ' | sed 's/ $//' ) + REQUIRED_LIBS=$(objdump -x $FILE | grep NEEDED | awk '{print $2}' | tr '\n' ' ' | sed 's/ $//') + MISSING_LIBS="" + for lib in $ALL_MISSING_LIBS + do + if echo $REQUIRED_LIBS | grep -q $lib + then + MISSING_LIBS="$MISSING_LIBS $lib" + fi + done + if [ "$MISSING_LIBS" != "" ] + then + echo "$FILE" >>$LLIST.3_rebuild + echo_v " broken $FILE (requires ${MISSING_LIBS})" + fi + fi else - echo "$FILE" >>$LLIST.3_rebuild - echo_v " found $FILE" + # FIX: I hate duplicating code + # Only rebuild for direct dependencies + ALL_MISSING_LIBS=$(ldd "$FILE" 2>/dev/null | sort -u | $SONAME_GREP "$SONAME_SEARCH" | awk '{print $1}' | tr '\n' ' ' | sed 's/ $//' ) + REQUIRED_LIBS=$(objdump -x $FILE | grep NEEDED | awk '{print $2}' | tr '\n' ' ' | sed 's/ $//') + MISSING_LIBS="" + for lib in $ALL_MISSING_LIBS + do + if echo $REQUIRED_LIBS | grep -q $lib + then + MISSING_LIBS="$MISSING_LIBS $lib" + fi + done + if [ "$MISSING_LIBS" != "" ] + then + echo "$FILE" >>$LLIST.3_rebuild + echo_v " found $FILE" + fi fi fi done @@ -205,18 +361,20 @@ if $PACKAGE_NAMES ; then if [ -f $LLIST.4_packages_raw ] ; then echo " using existing $LLIST.4_packages_raw." else - set_trap "$LLIST.4_packages_raw" + set_trap "$LLIST.4_packages*" echo -n >$LLIST.4_packages_raw echo -n >$LLIST.4_package_owners cat $LLIST.3_rebuild | while read FILE ; do - PKG=$(fgrep -l $FILE /var/db/pkg/*/*/CONTENTS|sed -e 's:/var/db/pkg/\(.*\)/CONTENTS:\1:g' -e "s:-r[0-9]\+$::" -e "s:-[0-9][^-]*$::") + EXACT_PKG="$(echo $FILE | sed 's/^/obj /' | (cd /var/db/pkg; grep -l -f - */*/CONTENTS) | sed s:/CONTENTS:: )" + # Ugly sed hack to strip version information + PKG="$(echo $EXACT_PKG | sed 's/-r[0-9].*$//;s/\(^.*\/*\)-.*$/\1/')" if [ -z "$PKG" ] ; then echo -n -e "\n ${RD}*** $FILE not owned by any package is broken! ***${NO}" echo "$FILE -> (none)" >> $LLIST.4_package_owners echo_v -n -e "\n $FILE -> (none)" else - echo "$PKG" >> $LLIST.4_packages_raw - echo "$FILE -> $PKG" >> $LLIST.4_package_owners + echo "$EXACT_PKG" >> $LLIST.4_packages_raw + echo "$FILE -> $EXACT_PKG" >> $LLIST.4_package_owners echo_v -n -e "\n $FILE -> $PKG" fi done @@ -226,16 +384,60 @@ if $PACKAGE_NAMES ; then echo echo -n -e "${GR}Cleaning list of packages to rebuild...${NO}" - if [ -f $LLIST.5_packages ] ; then - echo " using existing $LLIST.5_packages." + if [ -f $LLIST.4_packages ] ; then + echo " using existing $LLIST.4_packages." else - set_trap "$LLIST.5_packages" - sort -u $LLIST.4_packages_raw >$LLIST.5_packages - echo -e " done.\n ($LLIST.5_packages)" + sort -u $LLIST.4_packages_raw >$LLIST.4_packages + echo -e " done.\n ($LLIST.4_packages)" fi - RAW_REBUILD_LIST="$(cat $LLIST.5_packages | tr '\n' ' ')" - + echo + echo -n -e "${GR}Assigning packages to ebuilds...${NO}" + if [ -f $LLIST.4_ebuilds ] ; then + echo " using existing $LLIST.4_ebuilds." + else + if [ -s "$LLIST.4_packages" ] + then + set_trap "$LLIST.4_ebuilds" + cat $LLIST.4_packages | while read EXACT_PKG + do + # Get the slot + PKG="$(echo $EXACT_PKG | sed 's/-r[0-9].*$//;s/\(^.*\/*\)-.*$/\1/')" + SLOT=$(cat /var/db/pkg/${EXACT_PKG}/SLOT) + # If SLOT is equal to 0, then just see what portage says is latest version + if [ "$SLOT" = "0" ] + then + emerge --nospinner --pretend --nodeps $PKG | sed -n 's/ //g;s/\[[^]]*\]//gp' + continue + fi + # Otherwise mask the other SLOTTED versions and check for latest + OTHER_VERSIONS=$(/usr/lib/gentoolkit/bin/find_pkgs.py $PKG | grep -v "($SLOT)" | awk '{print $2}') + if [ -f /etc/portage/package.mask ] + then + mv -f /etc/portage/package.mask /etc/portage/package.mask.revdep-rebuild.backup + else + # Make sure that /etc/portage/package.mask exists + mkdir -p /etc/portage + touch /etc/portage/package.mask + fi + for pkg_version in $(echo $OTHER_VERSIONS | tr '\n' ' ') + do + echo "=${PKG}-${pkg_version}" >> /etc/portage/package.mask + done + emerge --nospinner --pretend --nodeps $PKG | sed -n 's/ //g;s/\[[^]]*\]//gp' + if [ -f /etc/portage/package.mask.revdep-rebuild.backup ] + then + mv -f /etc/portage/package.mask.revdep-rebuild.backup /etc/portage/package.mask + else + rm -f /etc/portage/package.mask + fi + done > $LLIST.4_ebuilds + echo -e " done.\n ($LLIST.4_ebuilds)" + else + echo " Nothing to rebuild" + echo -n > $LLIST.4_ebuilds + fi + fi else EXACT_EBUILDS=true @@ -258,7 +460,6 @@ else fi fi - RAW_REBUILD_LIST="$(cat $LLIST.4_ebuilds | sed s/^/=/ | tr '\n' ' ')" fi echo @@ -266,6 +467,7 @@ echo -n -e "${GR}Evaluating package order...${NO}" if [ -f $LLIST.5_order ] ; then echo " using existing $LLIST.5_order." else + RAW_REBUILD_LIST="$(cat $LLIST.4_ebuilds | sed s/^/=/ | tr '\n' ' ')" if [ ! -z "$RAW_REBUILD_LIST" ] ; then REBUILD_GREP="^\\($( (emerge --nospinner --pretend --oneshot --nodeps $RAW_REBUILD_LIST ; echo $? >$LLIST.5_status ) | sed -n 's/\./\\&/g;s/ //g;s/$/\\/;s/\[[^]]*\]//gp' | tr '\n' '|' | sed 's/|$//'))\$" if [ $(cat $LLIST.5_status) -gt 0 ] ; then @@ -273,12 +475,12 @@ else echo -e "${RD}Warning: Failed to resolve package order." echo -e "Will merge in \"random\" order!${NO}" echo "Possible reasons:" - echo "- Some ebuilds are no more in portage tree." - echo "- Some ebuilds are masked, try to change ACCEPT_KEYWORDS=\"~\"" - echo " and/or use /etc/portage/package.unmask" + echo "- An ebuild is no longer in the portage tree." + echo "- An ebuild is masked, use /etc/portage/packages.keyword" + echo " and/or /etc/portage/package.unmask to unmask it" for i in . . . . . ; do - echo -n -e '\a.' - sleep 1 + echo -n -e '\a.' + sleep 1 done ln -f $LLIST.4_ebuilds $LLIST.5_order else @@ -296,17 +498,22 @@ trap - SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM if [ -z "$REBUILD_LIST" ] ; then echo -e "\n${GR}$OK_TEXT... All done.${NO} " - rm $LIST.[1-2]_* - rm $LLIST.[3-9]_* + if [ ! $KEEPTEMP ] + then + rm $LIST.[0-2]_* + rm $LLIST.[3-9]_* + fi exit 0 fi IS_REAL_MERGE=true -echo " $* " | grep -q '\( -p \| --pretend \| -f \| --fetchonly \)' && IS_REAL_MERGE=false +echo " $EMERGE_OPTIONS " | grep -q '\( -p \| --pretend \| -f \| --fetchonly \)' && IS_REAL_MERGE=false echo echo -e "${GR}All prepared. Starting rebuild...${NO}" -echo "emerge --oneshot --nodeps $@ $REBUILD_LIST" + +echo "emerge --oneshot $EMERGE_OPTIONS $REBUILD_LIST" + if $IS_REAL_MERGE ; then for i in . . . . . . . . . . ; do echo -n -e '\a.' @@ -318,7 +525,7 @@ fi #if $EXACT_EBUILDS ; then # Uncomment following, if you want to recompile masked ebuilds. ## FIXME: Check for PORTDIR_OVERLAY -# echo -e "${GR}Temporarilly disablink package mask...${NO}" +# echo -e "${GR}Temporarilly disabling package mask...${NO}" # trap "mv -i /usr/portage/profiles/package.mask.hidden /usr/portage/profiles/package.mask ; echo -e "\\n\\nTerminated." ; exit 1" \ # SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM # mv -i /usr/portage/profiles/package.mask /usr/portage/profiles/package.mask.hidden @@ -326,7 +533,7 @@ fi # Run in background to correctly handle Ctrl-C ( - emerge --oneshot --nodeps $@ $REBUILD_LIST + emerge --oneshot $EMERGE_OPTIONS $REBUILD_LIST echo $? >$LLIST.6_status ) & wait @@ -338,11 +545,13 @@ wait if [ "$(cat $LLIST.6_status)" -gt 0 ] ; then echo - echo -e "${RD}Result is not OK, you have following choices:${NO}" - echo "- if emerge failed during build, fix the problems and re-run revdep-rebuild" + echo -e "${RD}revdep-rebuild failed to emerge all packages${NO}" + echo -e "${RD}you have the following choices:${NO}" + echo + echo "- if emerge failed during the build, fix the problems and re-run revdep-rebuild" echo " or" - echo "- use -X or --package-names as first argument (try to rebuild package, not exact" - echo " ebuild - ignores SLOT!)" + echo "- use -X or --package-names as first argument (trys to rebuild package, not exact" + echo " ebuild)" echo " or" echo "- set ACCEPT_KEYWORDS=\"~\" and/or /etc/portage/package.unmask" echo " (and remove $LLIST.5_order to be evaluated again)" @@ -354,22 +563,20 @@ if [ "$(cat $LLIST.6_status)" -gt 0 ] ; then echo echo -e "${GR}To remove temporary files, please run:${NO}" echo "rm $LIST*.?_*" + exit $(cat $LLIST.6_status) else if $IS_REAL_MERGE ; then trap "echo -e \" terminated. Please remove them manually:\nrm $LIST*.?_*\" ; exit 1" \ SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM echo -n -e "${GR}Build finished correctly. Removing temporary files...${NO} " - for i in . . . . . . . . . . ; do - echo -n -e '.' - sleep 1 - done echo - rm $LIST.[1-2]_* + rm $LIST.[0-2]_* rm $LLIST.[3-9]_* echo "You can re-run revdep-rebuild to verify that all libraries and binaries" echo "are fixed. If some inconsistency remains, it can be orphaned file, deep" echo "dependency, binary package or specially evaluated library." - else + else echo -e "${GR}Now you can remove -p (or --pretend) from arguments and re-run revdep-rebuild.${NO}" fi fi +exit 0 diff --git a/trunk/src/revdep-rebuild/revdep-rebuild.1 b/trunk/src/revdep-rebuild/revdep-rebuild.1 index 9c6eea5..03affbc 100644 --- a/trunk/src/revdep-rebuild/revdep-rebuild.1 +++ b/trunk/src/revdep-rebuild/revdep-rebuild.1 @@ -1,12 +1,81 @@ -.TH revdep-rebuild "1" "Nov 2003" "gentoolkit" -.SH NAME -revdep-rebuild \- Gentoo: Reverse dependency rebuilder -.SH SYNOPSIS -.B revdep-rebuild -.SH BUGS -This tool does not yet have a man page. Feel free to submit a bug about it to -http://bugs.gentoo.org -.SH AUTHORS -This informative man page was written by Karl Trygve Kalleberg -. +.TH "revdep\-rebuild" "1" "" "gentoolkit" "" +.SH "NAME" +revdep\-rebuild \- Gentoo: Reverse Dependency Rebuilder +.SH "SYNOPSIS" +.B revdep\-rebuild +[OPTIONS] [\-\-] [EMERGE OPTIONS] +.SH "DESCRIPTION" +revdep\-rebuild scans libraries and binaries for missing shared library dependencies and fixes them by re\-emerging those broken binaries and shared libraries. It is useful when an upgraded package breaks other software packages that are dependent upon the upgraded package. +.SH "OPTIONS" +.TP +.B \-X | \-\-package\-names +emerge the best packages available, not neccessarily the exact version of the installed package +.TP +.B \-\-library=NAME +emerge packages that use the named library. Name can be a full path to a library or basic regular expression. (See man grep for the definition of basic regular expressions) +.TP +.B \-nc | \-\-no\-color +turn off colored output (This option is also passed to the emerge command) +.TP +.B \-i | \-\-ignore +ignore temporary files from previous runs +.TP +.B \-q | \-\-quiet +be less verbose (This option is also passed to the emerge command) + +All other options are passed to the emerge command +.SH "CONFIGURATION" +revdep\-rebuild no longer uses hardcoded paths. To change the default behavior the following variables can be changed by the user. + +LD_LIBRARY_MASK \- Mask of specially evaluated libraries +.LP +SEARCH_DIRS \- List of directories to search for executibles and libraries +.LP +SEARCH_DIRS_MASK \- List of directories to not search + +These variables can be prepended to either by setting the variable in your environment prior to execution, or by placing an entry in /etc/make.conf. + +An entry of "\-*" means to clear the variable from that point forward. +Example: SEARCH_DIRS="/usr/bin \-*" will set SEARCH_DIRS to contain only /usr/bin + +revdep\-rebuild honors the NOCOLOR and PORTAGE_NICENESS variables from /etc/make.conf +.SH "EXAMPLES" +It is recommended that when running revdep\-rebuild that the following command be used initially: +.br +\fBrevdep\-rebuild \-\-ignore \-\-pretend\fR + +To search the entire system, while excluding /mnt and /home: +.br +\fBenv SEARCH_DIRS="/ \-*" SEARCH_DIRS_MASK="/mnt /home" revdep\-rebuild\fR + +To rebuild packages that depend on libkdecore.so.4 from KDE 3.3: +.br +\fBrevdep\-rebuild \-\-library /usr/kde/3.3/lib/libkdecore.so.4\fR + +To rebuild packages that depend upon libImlib.so and libImlib2.so: +.br +\fBrevdep\-rebuild \-\-library libImlib[2]*.so.*\fR + +.SH "EXIT STATUS" +revdep\-rebuild returns a zero exit status if it succeeds. +Non zero is returned in case of failure. +.SH "BUGS" +.LP +In exact ebuild mode revdep\-rebuild can fail to properly order packages, which are not up to date. +.br +http://bugs.gentoo.org/show_bug.cgi?id=23018 +.LP +Rebuilding using \-\-package\-names mode should be default, but emerge has no feature to update to latest version of a defined SLOT. +.br +http://bugs.gentoo.org/show_bug.cgi?id=4698 + +\fBNote:\fR The ability to update to the latest version of a slotted package has been added to revdep\-rebuild. However, it is possible for this feature to still not work 100% correctly +.LP +Does not correctly handle interactive emerge commands. +.br +http://bugs.gentoo.org/show_bug.cgi?id=37485 + +Report bugs to +.SH "SEE ALSO" +emerge(1), portage(5), grep(1) -- 2.26.2