requirements/tools/list-unused-packages.sh
Sean McGinnis b57da6e888
Add tool to generate a health report for all reqs
This adds a tool script that loops through all of our requirements and
output basic information for each one along with any things we might be
concerned about with each one. For now it just checks a few things, but
we could extend this issue checking as we find other things to check on.

Also refactors the unused package tool to put some common things into a
shared function library used by both scripts.

Change-Id: I140c3a5fb71a8fb82ccb696bade5be13bb9b0ba0
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-05-08 11:14:54 -05:00

47 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Lists any packages in global-constraints that appear to no longer be used
TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BASEDIR=$(dirname ${TOOLSDIR})
source ${TOOLSDIR}/functions
# Make sure we are using our venv
enable_venv "${BASEDIR}"
update=
if [[ "$#" -eq 1 ]]; then
update="${1}"
fi
# Loop through each package and check for its presence in any repo's
# requirements files other than mentions in its own repo
get_tracked_requirements
for req in $reqs; do
count=$(search_reqs ${req} |
grep -v " openstack/${req} " |
wc -l)
if [[ ${count} -eq 0 ]]; then
echo "${req}"
# See if we should clean up the requirements files
if [[ "${update}" == "--update" ]]; then
sed -i "/${req}/d" global-requirements.txt
sed -i "/${req}/d" upper-constraints.txt
fi
fi
done