@@ -15,47 +15,59 @@ if [ ! -d ./tmp ]; then
1515 mkdir -p ./tmp/urls
1616fi
1717
18- # Find URLs used
18+ # Debugging
19+ DEBUG=1
20+ if [ " ${1} " = " debug" ]; then DEBUG=0; fi
21+
22+ # Simple debugging trigger
23+ debug_output () {
24+ if [ ${DEBUG} -eq 0 ]; then echo " DEBUG: ${1} " ; fi
25+ }
26+
27+ debug_output " Finding URLs used for setup"
1928urls=$( grep -hEo " (http|https)://[a-zA-Z0-9./?=_%:-]*" ./scripts/setup* .sh | sort -u)
2029
21- # Cache upstream information
30+ debug_output " Caching upstream information"
2231i=1
2332for url in ${urls} ; do
2433 curl -s " ${url} " > ./tmp/urls/${i}
2534 i=$(( i+ 1 ))
2635done
2736
28- # Find local packages
37+ debug_output " Find local package requirements "
2938packages=$( grep -hEv " ^$|^#|^\-e" ./requirements* .txt | cut -f 1 -d ' =' | sort -u)
3039
31- # Check for local defined packages against upstream
40+ debug_output " Check local defined packages against upstream"
3241pkglist=" ./tmp/pkglist"
3342pkgredundant=" ./tmp/pkgredundant"
3443true > " ${pkglist} "
3544true > " ${pkgredundant} "
3645for pkg in ${packages} ; do
3746 # shellcheck disable=SC2046,SC2143
38- if [ ! $( grep -rhE " ^${pkg} " ./tmp/urls) ]; then
39- # echo "${pkg} not in upstream requirements/constraints"
47+ if [ ! $( grep -rhE " ^${pkg} $| ${pkg} [=,.] " ./tmp/urls) ]; then
48+ debug_output " ${pkg} not in upstream requirements/constraints"
4049 echo " ${pkg} " >> " ${pkglist} "
4150 else
51+ debug_output " ${pkg} redundant through upstream requirements/constraints as $( grep -rhE " ^${pkg} $|${pkg} [=<>]" ./tmp/urls) "
4252 echo " ${pkg} " >> " ${pkgredundant} "
4353 fi
4454done
4555
46- # Check for versioning in local packages
56+ debug_output " Check for versioning in local packages"
4757pkgmiss=" ./tmp/pkglist.miss"
4858true > " ${pkgmiss} "
4959# shellcheck disable=SC2013
5060for pkg in $( sort -u ${pkglist} ) ; do
5161 # shellcheck disable=SC2046,SC2143
52- if [ ! $( grep -rhE " ^${pkg} == " ./requirements* .txt) ]; then
53- # echo "${pkg} no versioning defined"
62+ if [ ! $( grep -rhE " ^${pkg} $| ${pkg} [=<>] " ./requirements* .txt) ]; then
63+ debug_output " ${pkg} no versioning defined"
5464 echo " ${pkg} " >> " ${pkgmiss} "
65+ else
66+ debug_output " ${pkg} version locally defined in $( grep -rhE " ^${pkg} $|${pkg} [=<>]" ./requirements* .txt) "
5567 fi
5668done
5769
58- # Check for versioning in setup.py
70+ debug_output " Check for versioning in setup.py"
5971pkgpy=$( sed -n ' /install_requires=\[/,/\]/p' setup.py | tr -d ' \n' | sed ' s/^.*\[\(.*\)\].*$/\1/g' | tr -d ' ,"' )
6072for pkgfull in ${pkgpy} ; do
6173 # Very ugly multi-character split
@@ -64,36 +76,25 @@ for pkgfull in ${pkgpy}; do
6476 # Check for package in upstream
6577 # shellcheck disable=SC2046,SC2143
6678 if [ ! $( grep -rhE " ^${pkg} $|^${pkg} [=<>]+" ./tmp/urls) ]; then
67- # echo "DEBUG: ${pkg} from setup.py not in upstream requirements/constraints"
79+ debug_output " ${pkg} from setup.py not in upstream requirements/constraints"
6880 # Check for package locally
69- if [ ! $( grep -rhE " ^${pkg} == " ./requirements* .txt) ]; then
70- # echo "DEBUG: ${pkg} from setup.py not in local requirements"
81+ if [ ! $( grep -rhE " ^${pkg} $| ${pkg} [=<>] " ./requirements* .txt) ]; then
82+ debug_output " ${pkg} from setup.py not in local requirements"
7183 # shellcheck disable=SC3014
7284 if [ " ${pkg} " = " ${pkgfull} " ]; then
7385 echo " WARNING: ${pkg} not in any requirements and no version specified in setup.py"
74- # else
75- # echo "DEBUG: ${pkg} version specified in setup.py"
86+ else
87+ debug_output " ${pkg} version specified in setup.py as ${pkgfull} "
7688 fi
77- # else
78- # echo "DEBUG: ${pkg} found in local requirements"
89+ else
90+ debug_output " ${pkg} found in local requirements as $( grep -rhE " ^ ${pkg} $| ${pkg} [=<>] " ./requirements * .txt ) "
7991 fi
80- # else
81- # echo "DEBUG: ${pkg} found in upstream URLs"
92+ else
93+ debug_output " ${pkg} found in upstream URLs as $( grep -rhE " ^ ${pkg} $|^ ${pkg} [=<>]+ " ./tmp/urls ) "
8294 fi
8395done
8496echo " "
8597
86- # Print redundant information (no error value)
87- # shellcheck disable=SC2046
88- # if [ $(wc -l "${pkgmiss}" | awk '{print $1}') -gt 0 ]; then
89- # echo "INFO: Packages redundant with upstream:"
90- # # shellcheck disable=SC2013
91- # for pkg in $(sort -u ${pkgredundant}); do
92- # echo "INFO: ${pkg} in ($(grep -hlE "^${pkg}" ./requirements*.txt)) already available via upstream"
93- # done
94- # echo ""
95- # fi
96-
9798# Print missing information and exit error out
9899# shellcheck disable=SC2046
99100if [ $( wc -l " ${pkgmiss} " | awk ' {print $1}' ) -gt 0 ]; then
0 commit comments