diff options
author | Tucker Boniface | 2018-08-13 11:44:11 -0700 |
---|---|---|
committer | Tucker Boniface | 2018-08-13 11:45:43 -0700 |
commit | 3dfc92d6f8063027738b7fb6f4130aff57d18692 (patch) | |
tree | f51dfaa9ecb16d1da59d49c60d32ef271a1e8c63 /detect-old-perl-modules.sh | |
download | aur-3dfc92d6f8063027738b7fb6f4130aff57d18692.tar.gz |
Initial commit
Diffstat (limited to 'detect-old-perl-modules.sh')
-rw-r--r-- | detect-old-perl-modules.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/detect-old-perl-modules.sh b/detect-old-perl-modules.sh new file mode 100644 index 000000000000..cdc8df3a5260 --- /dev/null +++ b/detect-old-perl-modules.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +basedir=/usr/lib/perl5 +perlver=$(perl -e '$v = $^V->{version}; print $v->[0].".".($v->[1]);') + +dir_empty() { + local dir=$1 + [[ $(find $dir -maxdepth 0 -empty -exec echo empty \;) = "empty" ]] && return 0 || return 1 +} + +print_unowned_files() { + local dir=$1 + LC_ALL=C find "$dir" -type f -exec pacman -Qqo {} + |& sed -n 's/^error: No package owns \(.*\)$/\1/p' +} + +for dir in "$basedir/"*; do + if [[ "${dir##*/}" != "$perlver" ]]; then + if [[ -d "$dir" ]] && ! dir_empty "$dir"; then + pkgcount=$(pacman -Qqo "$dir" | wc -l) + if ((pkgcount > 0)); then + printf "WARNING: '%s' contains data from at least %d packages which will NOT be used by the installed perl interpreter.\n" "$dir" "$pkgcount" + printf " -> Run the following command to get a list of affected packages: pacman -Qqo '%s'\n" "$dir" + fi + + unowned_count=$(print_unowned_files "$dir" | wc -l) + if ((unowned_count > 0)); then + printf "WARNING: %d file(s) in %s are not tracked by pacman and need to be rebuilt.\n" "$unowned_count" "$dir" + printf " -> These were most likely installed directly by cpan or a similar tool.\n" + printf " Run the following command to get a list of these files:\n" + printf " LC_ALL=C find \"%s\" -type f -exec pacman -Qqo {} + |& sed -n 's/^error: No package owns \(.*\)$/\\\1/p'\n" "$dir" + fi + fi + fi +done + + |