|
@@ -164,15 +164,15 @@ if [[ -z $1 ]]; then
|
|
|
exit "$SUCCESS"
|
|
|
fi
|
|
|
|
|
|
# Parse the arguments
|
|
|
while getopts "V:qdvh" opt; do
|
|
|
case "$opt" in
|
|
|
V) virtualenv="$OPTARG";;
|
|
|
q) quiet=1;;
|
|
|
d) debug=1;;
|
|
|
V) virtualenv="$OPTARG";;
|
|
|
q) quiet=1;;
|
|
|
d) debug=1;;
|
|
|
v) version
|
|
|
exit "$SUCCESS";;
|
|
|
h) usage
|
|
|
exit "$SUCCESS";;
|
|
|
*) usage
|
|
|
exit "$ERROR_ARGUMENTS";;
|
|
@@ -211,64 +211,64 @@ if ! which pip-compile >/dev/null 2>&1; then
|
|
|
fi
|
|
|
|
|
|
# Process each environment.
|
|
|
for environment in "$config_dir"/*; do
|
|
|
# Empty directory.
|
|
|
if [[ ! -e $environment ]]; then
|
|
|
error "Configuration directory is empty: $config_dir"
|
|
|
exit "$ERROR_CONFIG_DIR"
|
|
|
error "Configuration directory is empty: $config_dir"
|
|
|
exit "$ERROR_CONFIG_DIR"
|
|
|
fi
|
|
|
|
|
|
# Process each .in file.
|
|
|
for req_in in "$environment"/*.in; do
|
|
|
# Directory without .in files.
|
|
|
if [[ ! -e $req_in ]]; then
|
|
|
error "No .in files in directory, skipping: $environment"
|
|
|
continue
|
|
|
fi
|
|
|
|
|
|
# Figure out if .txt file exists.
|
|
|
req_txt="${req_in%.in}.txt"
|
|
|
if [[ ! -f $req_txt ]]; then
|
|
|
[[ $quiet == 0 ]] && info "Skipping input file with missing .txt file: $req_in"
|
|
|
continue
|
|
|
fi
|
|
|
# Directory without .in files.
|
|
|
if [[ ! -e $req_in ]]; then
|
|
|
error "No .in files in directory, skipping: $environment"
|
|
|
continue
|
|
|
fi
|
|
|
|
|
|
# Figure out if .txt file exists.
|
|
|
req_txt="${req_in%.in}.txt"
|
|
|
if [[ ! -f $req_txt ]]; then
|
|
|
[[ $quiet == 0 ]] && info "Skipping input file with missing .txt file: $req_in"
|
|
|
continue
|
|
|
fi
|
|
|
|
|
|
# Clean up the existing requirements file to contain only
|
|
|
# package versioning information.
|
|
|
current=$(sed -e 's/[[:blank:]]*#.*//' "$req_txt" | grep -v "^$" | sort -u)
|
|
|
|
|
|
# Calculate up-to-date requirements.
|
|
|
new=$(pip-compile --quiet --allow-unsafe --no-header --no-annotate --no-index --output-file - --upgrade "$req_in")
|
|
|
result="$?"
|
|
|
if [[ $result != 0 ]]; then
|
|
|
error "Failed while running pip-compile command against (see error stack trace above): $req_in"
|
|
|
continue
|
|
|
continue
|
|
|
fi
|
|
|
|
|
|
# Clean up the new requirements to contain only package
|
|
|
# versioning information.
|
|
|
new=$(echo "$new" | sed -e 's/[[:blank:]]*#.*//' | grep -v "^$" | sort -u)
|
|
|
|
|
|
debug "Current requirements:\n$(echo "$current")"
|
|
|
debug "New requirements:\n$(echo "$new")"
|
|
|
|
|
|
# Run diff, storing the output and result.
|
|
|
# Run diff, storing the output and result.
|
|
|
# This is using Bash process substitution, which helps avoid
|
|
|
# creating and keeping track of temporary files (since diff
|
|
|
# must be fed with two input files). E.g. the <() will
|
|
|
# essentially be path to a Bash-created/managed temporary
|
|
|
# file.
|
|
|
diff=$(diff -u <(echo "$current") <(echo "$new"))
|
|
|
result="$?"
|
|
|
|
|
|
# Show warning about available updates.
|
|
|
if [[ $result == 0 ]]; then
|
|
|
[[ $quiet == 0 ]] && info "No upgrades available for: $req_txt"
|
|
|
else
|
|
|
warning "Upgrades available for: $req_txt"
|
|
|
echo
|
|
|
echo "$diff"
|
|
|
echo
|
|
|
fi
|
|
|
diff=$(diff -u <(echo "$current") <(echo "$new"))
|
|
|
result="$?"
|
|
|
|
|
|
# Show warning about available updates.
|
|
|
if [[ $result == 0 ]]; then
|
|
|
[[ $quiet == 0 ]] && info "No upgrades available for: $req_txt"
|
|
|
else
|
|
|
warning "Upgrades available for: $req_txt"
|
|
|
echo
|
|
|
echo "$diff"
|
|
|
echo
|
|
|
fi
|
|
|
done
|
|
|
done
|