mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-12 01:44:30 +00:00
While checking the content of the vendor tarball artifact in the 3.31.0 release page, I realized that it is lacking most of the rust code and all the go code. It turns out that the script is badly broken in many ways : 1. Cargo workspace conflicts: Vendored dependencies were treated as workspace members, causing "current package believes it's in a workspace when it's not" errors. Fixed by adding vendor directory exclusions to root Cargo.toml. 2. Missing Go vendoring: Script only searched for Cargo.lock files, never processing go.mod files despite having a case statement for them. Fixed by adding go.mod to the find command with '-o -name go.mod'. 3. Wrong tar execution directory: Script ran tar from release/ directory but vendor_dir_list contained paths relative to repo root (./vendor, ./src/agent/vendor, etc.), causing "Cannot stat" errors. Fixed by moving tar command before final popd. 4. Relative tarball path: Since tar now runs from repo root, converted tarball path to absolute to ensure it's created in the release directory. 5. Vendored go.mod pollution: Added '-path ./vendor -prune' to find command to exclude vendor directory, preventing the script from finding go.mod files inside vendored Rust dependencies. The fixes are simple enough they can be squashed into a single commit. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Greg Kurz <groug@kaod.org>
68 lines
1.7 KiB
Bash
Executable File
68 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2022 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
script_name="$(basename "${BASH_SOURCE[0]}")"
|
|
|
|
# This is very much error prone in case we re-structure our
|
|
# repos again, but it's also used in a few other places :-/
|
|
repo_dir="${script_dir}/../../.."
|
|
|
|
function usage() {
|
|
|
|
cat <<EOF
|
|
Usage: ${script_name} tarball-name
|
|
This script creates a tarball with all the cargo vendored code
|
|
and the go vendored code that a distro would need to do a full
|
|
build of the project in a disconnected environment, generating
|
|
a "tarball-name" file.
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
create_vendor_tarball() {
|
|
vendor_dir_list=""
|
|
tarball_path="$(cd "$(dirname "${1}")" && pwd)/$(basename "${1}")"
|
|
pushd "${repo_dir}"
|
|
# shellcheck disable=SC2044
|
|
for i in $(find . -path './vendor' -prune -o \( -name 'Cargo.lock' -o -name 'go.mod' \) -print); do
|
|
dir="$(dirname "${i}")"
|
|
pushd "${dir}"
|
|
case "$(basename "${i}")" in
|
|
Cargo.lock)
|
|
[[ -d .cargo ]] || mkdir .cargo
|
|
cargo vendor >> .cargo/config.toml
|
|
vendor_dir_list+=" ${dir}/vendor ${dir}/.cargo/config.toml"
|
|
;;
|
|
go.mod)
|
|
go mod tidy
|
|
go mod vendor
|
|
go mod verify
|
|
vendor_dir_list+=" ${dir}/vendor"
|
|
;;
|
|
esac
|
|
echo "${vendor_dir_list}"
|
|
popd
|
|
done
|
|
|
|
# shellcheck disable=SC2086
|
|
tar -cvzf "${tarball_path}" ${vendor_dir_list}
|
|
popd
|
|
}
|
|
|
|
main () {
|
|
[[ $# -ne 1 ]] && usage && exit 0
|
|
create_vendor_tarball "${1}"
|
|
}
|
|
|
|
main "$@"
|