Skip to content

Commit 325ea6e

Browse files
committed
Restructure licenses again (revert cd4474a)
This moves licenses of vendored code from one monolith file into a tree of individual files for easier reviews. This fixes both the bash and bazel paths.
1 parent 9213616 commit 325ea6e

File tree

12 files changed

+122
-23824
lines changed

12 files changed

+122
-23824
lines changed

Godeps/LICENSES

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

Godeps/OWNERS

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

build/lib/release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function kube::release::package_node_tarballs() {
203203
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
204204
"${release_stage}/node/bin/"
205205

206-
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
206+
cp -R "${KUBE_ROOT}/LICENSES" "${release_stage}/"
207207

208208
cp "${RELEASE_TARS}/kubernetes-src.tar.gz" "${release_stage}/"
209209

@@ -275,7 +275,7 @@ function kube::release::package_server_tarballs() {
275275
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
276276
"${release_stage}/server/bin/"
277277

278-
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
278+
cp -R "${KUBE_ROOT}/LICENSES" "${release_stage}/"
279279

280280
cp "${RELEASE_TARS}/kubernetes-src.tar.gz" "${release_stage}/"
281281

@@ -559,7 +559,7 @@ EOF
559559

560560
cp -R "${KUBE_ROOT}/docs" "${release_stage}/"
561561
cp "${KUBE_ROOT}/README.md" "${release_stage}/"
562-
cp "${KUBE_ROOT}/Godeps/LICENSES" "${release_stage}/"
562+
cp -R "${KUBE_ROOT}/LICENSES" "${release_stage}/"
563563

564564
echo "${KUBE_GIT_VERSION}" > "${release_stage}/version"
565565

build/release-tars/BUILD

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,20 @@ pkg_tar(
7070
)
7171

7272
# Included in node and server tarballs.
73-
filegroup(
74-
name = "license-targets",
73+
pkg_tar(
74+
name = "license-artifacts",
7575
srcs = [
76-
":kubernetes-src.tar.gz",
77-
"//:Godeps/LICENSES",
76+
":kubernetes-src.tar.gz", # we want the tar file itself
77+
],
78+
mode = "0755",
79+
tags = [
80+
"manual",
81+
"no-cache",
7882
],
7983
visibility = ["//visibility:private"],
84+
deps = [
85+
"//:LICENSES", # we want to expand this
86+
],
8087
)
8188

8289
pkg_tar(
@@ -119,15 +126,17 @@ pkg_tar(
119126

120127
[[pkg_tar(
121128
name = "kubernetes-node-%s-%s" % (os, arch),
122-
srcs = [":license-targets"],
129+
srcs = [],
123130
extension = "tar.gz",
124131
mode = "0644",
125132
package_dir = "kubernetes",
126133
tags = [
127134
"manual",
128135
"no-cache",
129136
],
130-
deps = select({go_platform_constraint(os, arch): [":_node-bin"]}),
137+
deps = select({go_platform_constraint(os, arch): [":_node-bin"]}) + [
138+
":license-artifacts",
139+
],
131140
) for arch in archs] for os, archs in NODE_PLATFORMS.items()]
132141

133142
pkg_tar(
@@ -170,7 +179,7 @@ pkg_tar(
170179

171180
[[pkg_tar(
172181
name = "kubernetes-server-%s-%s" % (os, arch),
173-
srcs = [":license-targets"],
182+
srcs = [],
174183
extension = "tar.gz",
175184
mode = "0644",
176185
package_dir = "kubernetes",
@@ -183,7 +192,9 @@ pkg_tar(
183192
":_server-addons",
184193
":_server-bin",
185194
],
186-
}),
195+
}) + [
196+
":license-artifacts",
197+
],
187198
) for arch in archs] for os, archs in SERVER_PLATFORMS.items()]
188199

189200
pkg_tar(
@@ -235,7 +246,6 @@ pkg_tar(
235246
pkg_tar(
236247
name = "kubernetes",
237248
srcs = [
238-
"//:Godeps/LICENSES",
239249
"//:README.md",
240250
"//:version",
241251
"//cluster:all-srcs",
@@ -253,6 +263,7 @@ pkg_tar(
253263
tags = ["no-cache"],
254264
deps = [
255265
":_full_server",
266+
":license-artifacts",
256267
],
257268
)
258269

build/root/BUILD.root

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package(default_visibility = ["//visibility:public"])
1818

1919
load("@io_k8s_repo_infra//defs:build.bzl", "gcs_upload")
20+
load("@io_k8s_repo_infra//defs:pkg.bzl", "pkg_tar")
2021
load("//build:platforms.bzl", "for_platforms")
2122

2223
filegroup(
@@ -124,3 +125,18 @@ platform(
124125
{PARENT_REMOTE_EXECUTION_PROPERTIES}
125126
""",
126127
)
128+
129+
pkg_tar(
130+
name = "LICENSES",
131+
srcs = glob(
132+
["LICENSES/**/LICENSE"],
133+
allow_empty = False,
134+
exclude_directories = 0,
135+
),
136+
mode = "0755",
137+
strip_prefix = "//",
138+
tags = [
139+
"manual",
140+
"no-cache",
141+
],
142+
)

cluster/gce/gci/configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function install-exec-auth-plugin {
322322
local -r license_url="${EXEC_AUTH_PLUGIN_LICENSE_URL}"
323323
echo "Downloading gke-exec-auth-plugin license"
324324
download-or-bust "" "${license_url}"
325-
mv "${KUBE_HOME}/LICENSE" "${KUBE_BIN}/gke-exec-auth-plugin-license"
325+
mv "${KUBE_HOME}/LICENSES/LICENSE" "${KUBE_BIN}/gke-exec-auth-plugin-license"
326326
}
327327

328328
function install-kube-manifests {

hack/tools/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
vendor/
1+
/vendor/

hack/update-hack-tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ pushd "${KUBE_ROOT}/hack/tools" >/dev/null
3838
go mod tidy
3939
go mod vendor
4040

41-
LICENSE_ROOT="${PWD}" VENDOR_LICENSE_FILE="LICENSES" "${KUBE_ROOT}/hack/update-vendor-licenses.sh"
41+
LICENSE_ROOT="${PWD}" "${KUBE_ROOT}/hack/update-vendor-licenses.sh"
4242
rm -rf vendor
4343
popd >/dev/null

hack/update-vendor-licenses.sh

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

16-
# Update the Godeps/LICENSES document.
17-
# Generates a table of Godep dependencies and their license.
16+
# Update the LICENSES directory.
17+
# Generates a table of Go dependencies and their licenses.
1818
#
1919
# Usage:
2020
# $0 [--create-missing] [/path/to/licenses]
@@ -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 /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,54 +154,66 @@ fi
153154
LICENSE_ROOT="${LICENSE_ROOT:-${KUBE_ROOT}}"
154155
cd "${LICENSE_ROOT}"
155156

156-
VENDOR_LICENSE_FILE="${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}/LICENSES.$$"
161+
162+
# The directory to save all the LICENSE files
163+
LICENSES_DIR="${LICENSES_DIR:-${LICENSE_ROOT}/LICENSES}"
164+
mkdir -p "${LICENSES_DIR}"
165+
166+
# The tmp directory to save all the LICENSE files, will move to LICENSES_DIR
167+
TMP_LICENSES_DIR="${KUBE_TEMP}/LICENSES.DIR.$$"
168+
mkdir -p "${TMP_LICENSES_DIR}"
169+
158170
DEPS_DIR="vendor"
159171
declare -Ag CONTENT
160172

161-
if [[ -f "${LICENSE_ROOT}/LICENSE" ]]; then
162-
# Put the K8S LICENSE on top
173+
# Put the K8S LICENSE on top
174+
if [ -f "${LICENSE_ROOT}/LICENSE" ]; then
163175
(
164-
echo "================================================================================"
165-
echo "= Kubernetes licensed under: ="
166-
echo
167-
cat "${LICENSE_ROOT}/LICENSE"
168-
echo
169-
echo "= LICENSE $(kube::util::md5 "${LICENSE_ROOT}/LICENSE")"
170-
echo "================================================================================"
171-
) > ${TMP_LICENSE_FILE}
176+
echo "================================================================================"
177+
echo "= Kubernetes licensed under: ="
178+
echo
179+
cat "${LICENSE_ROOT}/LICENSE"
180+
echo
181+
echo "= LICENSE $(kube::util::md5 "${LICENSE_ROOT}/LICENSE")"
182+
echo "================================================================================"
183+
) > "${TMP_LICENSE_FILE}"
184+
mv "${TMP_LICENSE_FILE}" "${TMP_LICENSES_DIR}/LICENSE"
172185
fi
173186

174187
# Loop through every vendored package
175188
for PACKAGE in $(go list -m -json all | jq -r .Path | sort -f); do
176189
if [[ -e "staging/src/${PACKAGE}" ]]; then
177-
echo "$PACKAGE is a staging package, skipping" > /dev/stderr
190+
echo "${PACKAGE} is a staging package, skipping" > /dev/stderr
178191
continue
179192
fi
180193
if [[ ! -e "${DEPS_DIR}/${PACKAGE}" ]]; then
181-
echo "$PACKAGE doesn't exist in vendor, skipping" > /dev/stderr
194+
echo "${PACKAGE} doesn't exist in ${DEPS_DIR}, skipping" > /dev/stderr
182195
continue
183196
fi
197+
echo "${PACKAGE}"
184198

185199
process_content "${PACKAGE}" LICENSE
186200
process_content "${PACKAGE}" COPYRIGHT
187201
process_content "${PACKAGE}" COPYING
188202

189-
# display content
190-
echo
191-
echo "================================================================================"
192-
echo "= ${DEPS_DIR}/${PACKAGE} licensed under: ="
193-
echo
203+
# copy content and throw error message
204+
{
205+
echo "= ${DEPS_DIR}/${PACKAGE} licensed under: ="
206+
echo
194207

195-
file=""
196-
if [[ -n "${CONTENT[${PACKAGE}-LICENSE]-}" ]]; then
208+
file=""
209+
if [[ -n "${CONTENT[${PACKAGE}-LICENSE]-}" ]]; then
197210
file="${CONTENT[${PACKAGE}-LICENSE]-}"
198-
elif [[ -n "${CONTENT[${PACKAGE}-COPYRIGHT]-}" ]]; then
211+
elif [[ -n "${CONTENT[${PACKAGE}-COPYRIGHT]-}" ]]; then
199212
file="${CONTENT[${PACKAGE}-COPYRIGHT]-}"
200-
elif [[ -n "${CONTENT[${PACKAGE}-COPYING]-}" ]]; then
213+
elif [[ -n "${CONTENT[${PACKAGE}-COPYING]-}" ]]; then
201214
file="${CONTENT[${PACKAGE}-COPYING]-}"
202-
fi
203-
if [[ -z "${file}" ]]; then
215+
fi
216+
if [[ -z "${file}" ]]; then
204217
cat > /dev/stderr << __EOF__
205218
No license could be found for ${PACKAGE} - aborting.
206219
@@ -212,13 +225,19 @@ Options:
212225
3. Do not use this package in Kubernetes.
213226
__EOF__
214227
exit 9
215-
fi
216-
cat "${file}"
228+
fi
217229

218-
echo
219-
echo "= ${file} $(kube::util::md5 "${file}")"
220-
echo "================================================================================"
221-
echo
222-
done >> ${TMP_LICENSE_FILE}
223-
224-
cat ${TMP_LICENSE_FILE} > "${VENDOR_LICENSE_FILE}"
230+
cat "${file}"
231+
echo
232+
echo "= ${file} $(kube::util::md5 "${file}")"
233+
} >> "${TMP_LICENSE_FILE}"
234+
235+
dest_dir="${TMP_LICENSES_DIR}/vendor/${PACKAGE}"
236+
mkdir -p "${dest_dir}"
237+
mv "${TMP_LICENSE_FILE}" "${dest_dir}/LICENSE"
238+
done
239+
240+
# Leave things like OWNERS alone.
241+
rm -f "${LICENSES_DIR}/LICENSE"
242+
rm -rf "${LICENSES_DIR}/vendor"
243+
mv "${TMP_LICENSES_DIR}"/* "${LICENSES_DIR}"

hack/update-vendor.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,7 @@ for repo in $(kube::util::list_staging_repos); do
319319
done
320320

321321

322-
# Phase 6: rebuild vendor directory
323-
322+
# Phase 7: rebuild vendor directory
324323
kube::log::status "vendor: running 'go mod vendor'"
325324
go mod vendor >>"${LOG_FILE}" 2>&1
326325

@@ -341,18 +340,19 @@ kube::log::status "vendor: updating BUILD files"
341340
# Assume that anything imported through vendor doesn't need Bazel to build.
342341
# Prune out any Bazel build files, since these can break the build due to
343342
# missing dependencies that aren't included by go mod vendor.
344-
find vendor/ -type f \( -name BUILD -o -name BUILD.bazel -o -name WORKSPACE \) -exec rm -f {} \;
343+
find vendor/ -type f \
344+
\( -name BUILD -o -name BUILD.bazel -o -name WORKSPACE \) \
345+
-exec rm -f {} \;
345346
hack/update-bazel.sh >>"${LOG_FILE}" 2>&1
346347

347-
kube::log::status "vendor: updating LICENSES file"
348+
kube::log::status "vendor: updating vendor/LICENSES"
348349
hack/update-vendor-licenses.sh >>"${LOG_FILE}" 2>&1
349350

350351
kube::log::status "vendor: creating OWNERS file"
351-
rm -f "Godeps/OWNERS" "vendor/OWNERS"
352-
cat <<__EOF__ > "Godeps/OWNERS"
352+
rm -f "vendor/OWNERS"
353+
cat <<__EOF__ > "vendor/OWNERS"
353354
# See the OWNERS docs at https://go.k8s.io/owners
354355
355356
approvers:
356357
- dep-approvers
357358
__EOF__
358-
cp "Godeps/OWNERS" "vendor/OWNERS"

0 commit comments

Comments
 (0)