Skip to content

Commit

Permalink
add initial version to search for used Perl modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jpawlowski committed Jan 5, 2019
1 parent 38f0574 commit 363a96d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/find-perl-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Find missing Perl modules that are in use by official modules

# use
for module in `find $1./FHEM -type f -name "*.pm" -print0 | xargs -0 grep -oP "^use .*;" | sed 's|[;"'\'']||g' | sed 's/$attr{global}{modpath}//g' | sed 's/$main::attr{global}{modpath}//g' | sort -u -f -k2,2 | cut -d : -f 2- | cut -d " " -f 2 | grep -v -i -E "^(\$|\@|warnings|vars|feature|inline|strict|constant|(\d\.\d+)|POSIX|utf8)"`; do
NAME=`echo $module | cut -d " " -f 1 | cut -d ";" -f 1 | cut -d ":" -f 1`
if [[ -e "$1./$NAME" || -e "$1./FHEM/$NAME" || -e "$1./$NAME.pm" || -e "$1./FHEM/$NAME.pm" ]]; then
# This is a FHEM internal Perl module
continue
fi
CHK=`perl -e "use $module" 2>1 >/dev/null`
ret=$?

if [ $ret != "0" ]; then
echo "Checking external module '$module' ... MISSING"
fi
done

# require
for module in `find $1./FHEM -type f -name "*.pm" -print0 | xargs -0 grep -oP "^require .*;" | sed 's|[;"'\'']||g' | sed 's/$attr{global}{modpath}//g' | sed 's/$main::attr{global}{modpath}//g' | sort -u -f -k2,2 | cut -d : -f 2- | cut -d " " -f 2 | grep -v -i -E "^(\$|\@|warnings|vars|feature|inline|strict|constant|(\d\.\d+)|POSIX|utf8)"`; do
NAME=`echo $module | cut -d " " -f 1 | cut -d ";" -f 1 | cut -d ":" -f 1`
if [[ -e "$1./$NAME" || -e "$1./FHEM/$NAME" || -e "$1./$NAME.pm" || -e "$1./FHEM/$NAME.pm" ]]; then
# This is a FHEM internal Perl module
continue
fi
CHK=`perl -e "use $module" 2>1 >/dev/null`
ret=$?

if [ $ret != "0" ]; then
echo "Checking external module '$module' ... MISSING"
fi
done

0 comments on commit 363a96d

Please sign in to comment.