Skip to content

Instantly share code, notes, and snippets.

@Jehops
Created June 18, 2024 14:06
Show Gist options
  • Save Jehops/9b5150e6e01448f8256e877fb55a9dc0 to your computer and use it in GitHub Desktop.
Save Jehops/9b5150e6e01448f8256e877fb55a9dc0 to your computer and use it in GitHub Desktop.
List ports that fetch from Github and have a top distfile updated over a year # ago.
#!/bin/sh
# List ports that fetch from Github and have a top distfile updated over a year
# ago.
# check whether portgrep is installed
if ! command -v portgrep > /dev/null 2>&1; then
echo "portgrep is not installed. Please install it and try again."
exit 1
fi
pgout=$(portgrep -oO "MASTER_SITES=.*github" USE_GITHUB | sort)
total_ghp=$(echo "$pgout" | wc -w | awk '{$1=$1};1')
old_ghp=0
outfile="./old_github_ports.out"
touch "$outfile"
yats=$(date -v-1y "+%s")
for ghport in $pgout; do
dts=$(grep "^TIMESTAMP" "/usr/ports/$ghport/distinfo" \
2>/dev/null | cut -w -f3)
if [ -z "$dts" ] || [ "$dts" -lt "$yats" ]; then
old_ghp=$((old_ghp + 1))
echo "$ghport" >> "$outfile"
fi
done
echo "Of the ports that fetch from GitHub, $old_ghp of $total_ghp" \
"($((old_ghp*100/total_ghp))%) have a top distfile that has not been" \
"updated in over a year."
cat "$outfile"
## output
## Of the ports that fetch from GitHub, 3922 of 7180 (54%) have a top distfile
## that has not been updated in over a year.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment