From 70499e375ed4d0488226cb48621fe52be35b68fb Mon Sep 17 00:00:00 2001 From: bells17 Date: Sat, 20 Apr 2024 04:39:50 +0900 Subject: [PATCH] Changed to use "wc -c" to ensure the command works on both Linux and Mac OS X with a single implementation --- hack/verify-file-sizes.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/hack/verify-file-sizes.sh b/hack/verify-file-sizes.sh index 172a8809278..29894f2c1f7 100755 --- a/hack/verify-file-sizes.sh +++ b/hack/verify-file-sizes.sh @@ -24,22 +24,6 @@ cd "${KUBE_ROOT}" # Files larger than 1MB need to be allowed explicitly. maxsize=$((1 * 1024 * 1024)) -run_stat() { - local file="$1" - case "$(uname -s)" in - Darwin) - stat -f %z "$file" | tr -d '\n' - ;; - Linux) - stat --printf=%s "$file" - ;; - *) - kube::log::error "Unsupported host OS. Must be Linux or Mac OS X." - exit 1 - ;; - esac -} - # Sorted list of those exceptions. allowlist=( staging/src/k8s.io/kubectl/images/kubectl-logo-full.png @@ -58,7 +42,7 @@ largefiles () { case "$tree" in w/-text) # Only binary files have a size limit. - size="$(run_stat "$file")" + size="$(wc -c < "$file")" if [ "${size}" -gt "$maxsize" ] && ! kube::util::array_contains "$file" "${allowlist[@]}"; then echo "$file is too large ($size bytes)"