/[gentoo-perl]/perl-cleaner/trunk/bin/perl-cleaner
Gentoo

Diff of /perl-cleaner/trunk/bin/perl-cleaner

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 11 Revision 12
1#!/bin/bash 1#!/bin/bash -xv
2 2
3 3
4# sort of a changelog if you want to call it that... 4# sort of a changelog if you want to call it that...
5# version 1.2 - swtaylor gave some good pointers on making the tmp files, as well as reminding me of grep's -f functionality :) 5# version 1.2 - swtaylor gave some good pointers on making the tmp files, as well as reminding me of grep's -f functionality :)
6# version 1.1 - Mr. Bones gave a lot of good input on cleaning up the script 6# version 1.1 - Mr. Bones gave a lot of good input on cleaning up the script
13 exit 13 exit
14fi 14fi
15eval $(perl '-V:version') 15eval $(perl '-V:version')
16PERL_VERSION=${version} 16PERL_VERSION=${version}
17 17
18source /sbin/functions.sh || {
19 echo "$0: Could not source /sbin/functions.sh!"
20 exit 1
21}
22
18TMPDIR=${TMPDIR:-/tmp} 23TMPDIR=${TMPDIR:-/tmp}
19 24
20PKGDIR=$(/usr/bin/portageq vdb_path) 25PKGDIR=$(/usr/bin/portageq vdb_path)
21DATESTAMP=$(date +"%Y%m%d%H%M%S") 26DATESTAMP=$(date +"%Y%m%d%H%M%S")
22LOG=$(mktemp ${TMPDIR}/perl-cleaner.log.$DATESTAMP.XXXXXXXXXX) 27LOG=$(mktemp ${TMPDIR}/perl-cleaner.log.$DATESTAMP.XXXXXXXXXX)
71 echo "$(date) : Updating ph files" | tee -a $LOG 76 echo "$(date) : Updating ph files" | tee -a $LOG
72 cd /usr/include; h2ph * sys/* arpa/* netinet/* bits/* security/* asm/* gnu/* linux/* | tee -a $LOG 77 cd /usr/include; h2ph * sys/* arpa/* netinet/* bits/* security/* asm/* gnu/* linux/* | tee -a $LOG
73 cd /usr/include/linux; h2ph * | tee -a $LOG 78 cd /usr/include/linux; h2ph * | tee -a $LOG
74} 79}
75 80
81
76# Build a list of modules installed under older perls - only valid if the module was an ebuild :) 82# Build a list of modules installed under older perls - only valid if the module was an ebuild :)
77function module_list() { 83function module_list() {
78# Reset INC - INC is dynamically generated, and if we removed any ph
79# files - and they were the only thing left in a dir - then there's
80# no sense in revisiting that dir
81 echo "$(date) : Building list of modules for reinstall" | tee -a $LOG 84 echo "$(date) : Building list of modules for reinstall" | tee -a $LOG
82 INC=$(perl -e 'for $line (@INC) { next if $line eq "."; next if $line =~ m/'${PERL_VERSION}'/; print "$line\n" }')
83 MODFIND=$(mktemp ${TMPDIR}/modules.found.XXXXXXXXXX)
84 echo "Locating modules for reinstall" 85 echo "Locating modules for reinstall"
85 for file in $(find $INC -iname "*.pm" -type f 2>/dev/null | grep -v "${PERL_VERSION}"); do 86 for checkfile in `find $PKGDIR -maxdepth 3 -mindepth 3 -name "CONTENTS" |xargs grep -l /usr/$(get_libdir)/perl5 `; do
86 echo "$file" >>$MODFIND 87 if [ "`grep -l "${PERL_VERSION}" $checkfile`x" = "x" ]; then
88 echo "$checkfile" >> ${MODULES_LIST}
89 fi;
87 done 90 done
88 grep -f $MODFIND -l $PKGDIR/*/*/CONTENTS >${MODULES_LIST}
89 rm $MODFIND
90} 91}
91 92
92function alternate_module_list() { 93function alternate_module_list() {
93 # Takes longer to run, but identifes modules not associated with 94 # Takes longer to run, but identifes modules not associated with
94 # an ebuild. 95 # an ebuild.
205# The coup is in ! -newer libperl.so - cut out anything that was obviously installed 206# The coup is in ! -newer libperl.so - cut out anything that was obviously installed
206# after our last install of libperl, which should cut out the false positives. 207# after our last install of libperl, which should cut out the false positives.
207 208
208function libperl_list() { 209function libperl_list() {
209 echo "$(date) : Locating ebuilds linked against libperl" | tee -a $LOG 210 echo "$(date) : Locating ebuilds linked against libperl" | tee -a $LOG
210 for i in $(find $(egrep -v "^#" /etc/ld.so.conf) -type f -name '*.so*' ! -newer /usr/lib/libperl.so 2>/dev/null) \ 211 for i in $(find $(egrep -v "^#" /etc/ld.so.conf) -type f -name '*.so*' ! -newer /usr/$(get_libdir)/libperl.so 2>/dev/null) \
211 $(find $(echo $PATH | sed 's/:/ /g') -type f -perm +0111 ! -newer /usr/lib/libperl.so 2>/dev/null) ; 212 $(find $(echo $PATH | sed 's/:/ /g') -type f -perm +0111 ! -newer /usr/$(get_libdir)/libperl.so 2>/dev/null) ;
212 do 213 do
213 if [ -f ${i} ]; then 214 if [ -f ${i} ]; then
214 ldd ${i} 2>&1 | grep "libperl" - >/dev/null && grep -l " $i " $PKGDIR/*/*/CONTENTS>>${MODULES_LIST}; 215 ldd ${i} 2>&1 | grep "libperl" - >/dev/null && grep -l " $i " $PKGDIR/*/*/CONTENTS>>${MODULES_LIST};
215 fi 216 fi
216 done 217 done

Legend:
Removed from v.11  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.20