1#!/bin/bash 2# Check if a Jam repository file is valid with our requirements 3# Ex: validateRepo build/jam/repositories/HaikuPorts/arm 4 5if [ $# -ne 1 ]; then 6 echo "usage: validate <repo_file>" 7 exit 1 8fi 9 10if [ ! -f "$1" ]; then 11 echo "Error: Unable to read repo_file '$1'!" 12 exit 1 13fi 14 15remote_file_exists() { 16 HTTP_STATUS=$(curl -s -I -L "$1" | head -n1 | awk '{ print $2 }') 17 echo "Check $HTTP_STATUS - $1" 18 if [ "$HTTP_STATUS" != "200" ]; then 19 return 0; 20 fi 21 return 1; 22} 23 24REPO_FILE="$1" 25SHA256=$(sha256sum $REPO_FILE | awk '{ print $1 }') 26ARCHITECTURE=$(cat $REPO_FILE | tr '\n' ' ' | awk '{ print $4 } ') 27REPO_URL=$(cat $REPO_FILE | tr '\n' ' ' | awk '{ print $6 } ') 28REPO_EXPECT=$(cat $REPO_FILE | grep -v "#" | tr '\n' ' ' | cut -d':' -f6) 29 30if remote_file_exists "$REPO_URL/$SHA256/package.list" ; then 31 echo "Remote repository doesn't exist!" 32 exit 1 33fi 34 35PACKAGES="" 36for i in $(curl -s -L $REPO_URL/$SHA256/package.list | tr '\n' ' '); do 37 PACKAGES="$PACKAGES $(basename $(echo "$i" | cut -d'-' -f1,2,3))" 38done 39 40for i in $REPO_EXPECT; do 41 if [[ $PACKAGES = *$i* ]]; then 42 echo "OK $i" 43 else 44 echo "WARN $i" 45 fi 46done 47