kops/hack/generate-asset-hashes.sh

92 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2024 The Kubernetes Authors.
#
# 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.
set -o errexit
set -o nounset
set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"
function generate_k8s_hashes() {
prefix=$1
max_patch=$2
cat > "${REPO_ROOT}/pkg/assets/assetdata/k8s-${prefix}.yaml" <<EOF
# This file is generated by generate-asset-hashes.sh
filestores:
- base: https://dl.k8s.io/release/
files:
EOF
for ((patch = 0 ; patch < max_patch ; patch++ )); do
version="${prefix}.${patch}"
echo "k8s ${version}"
# We exclude some files that we don't currently need, to keep the size down
go run ./pkg/assets/assetdata/tools/cmd/generatefileassets \
--base https://dl.k8s.io/release/ \
--prefix "v${version}/" \
--exclude "**/arm/**" \
--exclude "**/s390x/**" \
--exclude "**/ppc64le/**" \
--exclude "**/windows/**" \
--exclude "**/*-s390x.tar.gz" \
--exclude "**/*-ppc64le.tar.gz" \
--exclude "**/*.tar.gz" \
| sed "s@files:@# kubernetes ${version}@g" >> "${REPO_ROOT}/pkg/assets/assetdata/k8s-${prefix}.yaml"
done
}
function generate_runc_hashes() {
prefix=$1
max_patch=$2
cat > "${REPO_ROOT}/pkg/assets/assetdata/runc-${prefix}.yaml" <<EOF
# This file is generated by generate-asset-hashes.sh
filestores:
- base: https://dl.k8s.io/release/
files:
EOF
for ((patch = 0 ; patch < max_patch ; patch++ )); do
version="${prefix}.${patch}"
echo "runc ${version}"
# We exclude some files that we don't currently need, to keep the size down
go run ./pkg/assets/assetdata/tools/cmd/generatefileassets \
--base https://github.com/opencontainers/runc/releases/download/ \
--prefix "v${version}/" \
--sums "https://github.com/opencontainers/runc/releases/download/v${version}/runc.sha256sum" \
| sed "s@files:@# runc ${version}@g" >> "${REPO_ROOT}/pkg/assets/assetdata/runc-${prefix}.yaml"
done
}
generate_k8s_hashes 1.24 17
generate_k8s_hashes 1.25 16
generate_k8s_hashes 1.26 15
generate_k8s_hashes 1.27 12
generate_k8s_hashes 1.28 8
generate_k8s_hashes 1.29 3
generate_runc_hashes 1.1 12