Skip to content

Commit c6c7e8b

Browse files
authored
Merge pull request kubernetes#76586 from JishanXing/76093
Fix kubernetes#76093, restructure LICENSES file generation
2 parents 6ff3b68 + a193dfc commit c6c7e8b

File tree

220 files changed

+22633
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+22633
-41
lines changed

Godeps/OWNERS

Lines changed: 0 additions & 4 deletions
This file was deleted.

build/common.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,6 @@ function kube::build::copy_output() {
729729
--prune-empty-dirs \
730730
--filter='- /_temp/' \
731731
--filter='+ /vendor/' \
732-
--filter='+ /Godeps/' \
733-
--filter='+ /staging/***/Godeps/**' \
734732
--filter='+ /_output/dockerized/bin/**' \
735733
--filter='+ zz_generated.*' \
736734
--filter='+ generated.proto' \

build/lib/release.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ function kube::release::package_node_tarballs() {
187187
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
188188
"${release_stage}/node/bin/"
189189

190-
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
190+
cp -R "${KUBE_ROOT}/vendor/ALL_LICENSES" "${release_stage}/"
191+
cp "${KUBE_ROOT}/LICENSE" "${release_stage}/LICENSES"
191192

192193
cp "${RELEASE_TARS}/kubernetes-src.tar.gz" "${release_stage}/"
193194

@@ -252,7 +253,8 @@ function kube::release::package_server_tarballs() {
252253
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
253254
"${release_stage}/server/bin/"
254255

255-
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
256+
cp -R "${KUBE_ROOT}/vendor/ALL_LICENSES" "${release_stage}/"
257+
cp "${KUBE_ROOT}/LICENSE" "${release_stage}/LICENSES"
256258

257259
cp "${RELEASE_TARS}/kubernetes-src.tar.gz" "${release_stage}/"
258260

@@ -565,7 +567,8 @@ EOF
565567

566568
cp -R "${KUBE_ROOT}/docs" "${release_stage}/"
567569
cp "${KUBE_ROOT}/README.md" "${release_stage}/"
568-
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
570+
cp -R "${KUBE_ROOT}/vendor/ALL_LICENSES" "${release_stage}/"
571+
cp "${KUBE_ROOT}/LICENSE" "${release_stage}/LICENSES"
569572

570573
echo "${KUBE_GIT_VERSION}" > "${release_stage}/version"
571574

build/release-tars/BUILD

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,21 @@ pkg_tar(
6969
],
7070
)
7171

72+
filegroup(
73+
name = "all-licenses-files",
74+
srcs = glob([
75+
"vendor/ALL_LICENSES/*",
76+
]),
77+
visibility = ["//visibility:private"],
78+
)
79+
7280
# Included in node and server tarballs.
7381
filegroup(
7482
name = "license-targets",
7583
srcs = [
84+
":all-licenses-files",
7685
":kubernetes-src.tar.gz",
77-
"//:Godeps/LICENSES",
86+
"//:LICENSE",
7887
],
7988
visibility = ["//visibility:private"],
8089
)
@@ -235,7 +244,8 @@ pkg_tar(
235244
pkg_tar(
236245
name = "kubernetes",
237246
srcs = [
238-
"//:Godeps/LICENSES",
247+
":all-licenses-files",
248+
"//:LICENSE",
239249
"//:README.md",
240250
"//:version",
241251
"//cluster:all-srcs",

cluster/gce/gci/configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ function install-kube-binary-config {
421421
mv "${src_dir}/kubelet" "${KUBE_BIN}"
422422
mv "${src_dir}/kubectl" "${KUBE_BIN}"
423423

424-
mv "${KUBE_HOME}/kubernetes/LICENSES" "${KUBE_HOME}"
424+
mv "${KUBE_HOME}/kubernetes/LICENSE" "${KUBE_HOME}"
425425
mv "${KUBE_HOME}/kubernetes/kubernetes-src.tar.gz" "${KUBE_HOME}"
426426
fi
427427

hack/boilerplate/boilerplate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def file_extension(filename):
155155
return os.path.splitext(filename)[1].split(".")[-1].lower()
156156

157157

158-
skipped_dirs = ['Godeps', 'third_party', '_gopath', '_output', '.git', 'cluster/env.sh',
158+
skipped_dirs = ['third_party', '_gopath', '_output', '.git', 'cluster/env.sh',
159159
"vendor", "test/e2e/generated/bindata.go", "hack/boilerplate/test",
160160
"staging/src/k8s.io/kubectl/pkg/generated/bindata.go"]
161161

hack/update-vendor-licenses.sh

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
# Update the Godeps/LICENSES document.
16+
# Update the vendor/ALL_LICENSES document.
1717
# Generates a table of Godep dependencies and their license.
1818
#
1919
# Usage:
@@ -24,12 +24,15 @@
2424
# additionally created files into the vendor auto-generated tree.
2525
#
2626
# Run every time a license file is added/modified within /vendor to
27-
# update /Godeps/LICENSES
27+
# update /vendor/ALL_LICENSES
2828

2929
set -o errexit
3030
set -o nounset
3131
set -o pipefail
3232

33+
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
34+
source "${KUBE_ROOT}/hack/lib/init.sh"
35+
3336
export LANG=C
3437
export LC_ALL=C
3538

@@ -130,8 +133,6 @@ process_content () {
130133
#############################################################################
131134
# MAIN
132135
#############################################################################
133-
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
134-
source "${KUBE_ROOT}/hack/lib/init.sh"
135136

136137
export GO111MODULE=on
137138

@@ -153,8 +154,19 @@ fi
153154
LICENSE_ROOT="${LICENSE_ROOT:-${KUBE_ROOT}}"
154155
cd "${LICENSE_ROOT}"
155156

156-
VENDOR_LICENSE_FILE="Godeps/LICENSES"
157-
TMP_LICENSE_FILE="/tmp/Godeps.LICENSES.$$"
157+
kube::util::ensure-temp-dir
158+
159+
# Save the genreated LICENSE file for each package temporarily
160+
TMP_LICENSE_FILE="${KUBE_TEMP}/vendor.LICENSES.$$"
161+
162+
# The directory to save all the LICENSE files
163+
VENDOR_LICENSE_DIR="${LICENSE_ROOT}/vendor/ALL_LICENSES"
164+
165+
# The tmp directory to save all the LICENSE files, will move to VENDOR_LICENSE_DIR
166+
TMP_VENDOR_LICENSE_DIR="${KUBE_TEMP}/vendor.LICENSES.DIR.$$"
167+
168+
mkdir -p "${TMP_VENDOR_LICENSE_DIR}"
169+
158170
DEPS_DIR="vendor"
159171
declare -Ag CONTENT
160172

@@ -167,7 +179,8 @@ cat "${LICENSE_ROOT}/LICENSE"
167179
echo
168180
echo "= LICENSE $(kube::util::md5 "${LICENSE_ROOT}/LICENSE")"
169181
echo "================================================================================"
170-
) > ${TMP_LICENSE_FILE}
182+
) > "${TMP_LICENSE_FILE}"
183+
mv "${TMP_LICENSE_FILE}" "${TMP_VENDOR_LICENSE_DIR}/LICENSE"
171184

172185
# Loop through every vendored package
173186
for PACKAGE in $(go list -m -json all | jq -r .Path | sort -f); do
@@ -184,11 +197,10 @@ for PACKAGE in $(go list -m -json all | jq -r .Path | sort -f); do
184197
process_content "${PACKAGE}" COPYRIGHT
185198
process_content "${PACKAGE}" COPYING
186199

187-
# display content
188-
echo
189-
echo "================================================================================"
190-
echo "= ${DEPS_DIR}/${PACKAGE} licensed under: ="
191-
echo
200+
# copy content and throw error message
201+
{
202+
echo "= ${DEPS_DIR}/${PACKAGE} licensed under: ="
203+
echo
192204

193205
file=""
194206
if [[ -n "${CONTENT[${PACKAGE}-LICENSE]-}" ]]; then
@@ -211,12 +223,20 @@ Options:
211223
__EOF__
212224
exit 9
213225
fi
214-
cat "${file}"
226+
227+
cat "${file}"
228+
echo
229+
echo "= ${file} $(kube::util::md5 "${file}")"
230+
} >> "${TMP_LICENSE_FILE}"
215231

216-
echo
217-
echo "= ${file} $(kube::util::md5 "${file}")"
218-
echo "================================================================================"
219-
echo
220-
done >> ${TMP_LICENSE_FILE}
221232

222-
cat ${TMP_LICENSE_FILE} > ${VENDOR_LICENSE_FILE}
233+
dest_dir="${TMP_VENDOR_LICENSE_DIR}/${PACKAGE}"
234+
mkdir -p "${dest_dir}"
235+
mv "${TMP_LICENSE_FILE}" "${dest_dir}/LICENSE"
236+
done
237+
238+
if [[ -d "${VENDOR_LICENSE_DIR}" ]]; then
239+
rm -r "${VENDOR_LICENSE_DIR}"
240+
fi
241+
mv "${TMP_VENDOR_LICENSE_DIR}" "${VENDOR_LICENSE_DIR}"
242+

hack/update-vendor.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,10 @@ kube::log::status "vendor: updating LICENSES file"
340340
hack/update-vendor-licenses.sh >>"${LOG_FILE}" 2>&1
341341

342342
kube::log::status "vendor: creating OWNERS file"
343-
rm -f "Godeps/OWNERS" "vendor/OWNERS"
344-
cat <<__EOF__ > "Godeps/OWNERS"
343+
rm -f "vendor/OWNERS"
344+
cat <<__EOF__ > "vendor/OWNERS"
345345
# See the OWNERS docs at https://go.k8s.io/owners
346346
347347
approvers:
348348
- dep-approvers
349349
__EOF__
350-
cp "Godeps/OWNERS" "vendor/OWNERS"

hack/verify-vendor-licenses.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,25 @@ function cleanup {
3333
}
3434
kube::util::trap_add cleanup EXIT
3535

36-
cp -r "${KUBE_ROOT}/Godeps" "${_tmpdir}/Godeps"
36+
#ln -s all subfolder except ALL_LICENSES in vendor
37+
mkdir -p "${_tmpdir}/vendor"
38+
for child in "${KUBE_ROOT}/vendor"/*
39+
do
40+
if [[ "${child}" == "${KUBE_ROOT}/vendor/ALL_LICENSES" ]] ; then
41+
continue
42+
else
43+
ln -s "${child}" "${_tmpdir}/vendor"
44+
fi
45+
done
46+
3747
ln -s "${KUBE_ROOT}/LICENSE" "${_tmpdir}"
38-
ln -s "${KUBE_ROOT}/vendor" "${_tmpdir}"
3948
ln -s "${KUBE_ROOT}/staging" "${_tmpdir}"
4049

4150
# Update vendor Licenses
4251
LICENSE_ROOT="${_tmpdir}" "${KUBE_ROOT}/hack/update-vendor-licenses.sh"
4352

4453
# Compare vendor Licenses
45-
if ! _out="$(diff -Naupr "${KUBE_ROOT}/Godeps/LICENSES" "${_tmpdir}/Godeps/LICENSES")"; then
54+
if ! _out="$(diff -Naupr "${KUBE_ROOT}/vendor/ALL_LICENSES" "${_tmpdir}/vendor/ALL_LICENSES")"; then
4655
echo "Your vendor licenses file is out of date. Run hack/update-vendor-licenses.sh and commit the results." >&2
4756
echo "${_out}" >&2
4857
exit 1

hack/verify-vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export GO111MODULE=on
5555

5656
pushd "${_kubetmp}" > /dev/null 2>&1
5757
# Destroy deps in the copy of the kube tree
58-
rm -rf ./Godeps/LICENSES ./vendor
58+
rm -rf ./vendor
5959

6060
# Recreate the vendor tree using the nice clean set we just downloaded
6161
hack/update-vendor.sh

0 commit comments

Comments
 (0)