Skip to content

Commit 02f2c25

Browse files
authored
Dynamic collection of license files
This allows for the dynamic inclusion of license files in the built container images.
1 parent 994846e commit 02f2c25

File tree

57 files changed

+46
-5043
lines changed

Some content is hidden

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

57 files changed

+46
-5043
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
/vendor/
33
tools
4+
licenses/*
5+
!licenses/LICENSE.txt

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ images = pgo-apiserver \
9090
postgres-operator
9191

9292
.PHONY: all installrbac setup setupnamespaces cleannamespaces \
93-
deployoperator cli-docs clean push pull release
93+
deployoperator cli-docs clean push pull release license
9494

9595

9696
#======= Main functions =======
@@ -114,7 +114,7 @@ deployoperator:
114114

115115

116116
#======= Binary builds =======
117-
build: build-postgres-operator build-pgo-apiserver build-pgo-client build-pgo-rmdata build-pgo-scheduler
117+
build: build-postgres-operator build-pgo-apiserver build-pgo-client build-pgo-rmdata build-pgo-scheduler license
118118

119119
build-pgo-apiserver:
120120
$(GO_BUILD) -o bin/apiserver ./cmd/apiserver
@@ -180,7 +180,7 @@ endif
180180

181181
pgo-base: pgo-base-$(IMGBUILDER)
182182

183-
pgo-base-build: $(PGOROOT)/build/pgo-base/Dockerfile
183+
pgo-base-build: build $(PGOROOT)/build/pgo-base/Dockerfile
184184
$(IMGCMDSTEM) \
185185
-f $(PGOROOT)/build/pgo-base/Dockerfile \
186186
-t $(PGO_IMAGE_PREFIX)/pgo-base:$(PGO_IMAGE_TAG) \
@@ -230,6 +230,9 @@ clean-deprecated:
230230
[ ! -n '$(GOBIN)' ] || rm -f $(GOBIN)/postgres-operator $(GOBIN)/apiserver $(GOBIN)/*pgo
231231
[ ! -d bin/postgres-operator ] || rm -r bin/postgres-operator
232232

233+
license:
234+
./bin/license_aggregator.sh
235+
233236
push: $(images:%=push-%) ;
234237

235238
push-%:

bin/license_aggregator.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Copyright 2021 Crunchy Data Solutions, Inc.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Inputs / outputs
17+
SCAN_DIR=${GOPATH}/pkg/mod
18+
OUT_DIR=licenses
19+
20+
# Fail on error
21+
set -e
22+
23+
# Clean up before we start our work
24+
rm -rf $OUT_DIR/*/
25+
26+
# Get any file in the vendor directory with the word "license" in it. Note that we'll also keep its path
27+
myLicenses=$(find $SCAN_DIR -type f | grep -i license)
28+
for licensefile in $myLicenses
29+
do
30+
# make a new license directory matching the same vendor structure
31+
licensedir=$(dirname $licensefile)
32+
newlicensedir=$(echo $licensedir | sed "s:$SCAN_DIR:$OUT_DIR:" | sed 's:@[0-9a-zA-Z.\\-]*/:/:' | sed 's:@[0-9a-zA-Z.\\-]*::')
33+
mkdir -p $newlicensedir
34+
# And, copy over the license
35+
cp -f $licensefile $newlicensedir
36+
done
37+
38+
sudo chmod -R 755 licenses

build/pgo-base/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ LABEL vendor="Crunchy Data" \
2121
io.openshift.tags="postgresql,postgres,sql,nosql,crunchy" \
2222
io.k8s.description="Trusted open source PostgreSQL-as-a-Service"
2323

24-
COPY redhat/licenses /licenses
2524
COPY redhat/atomic/help.1 /help.1
2625
COPY redhat/atomic/help.md /help.md
2726
COPY licenses /licenses

licenses/github.com/PuerkitoBio/purell/LICENSE

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

licenses/github.com/PuerkitoBio/urlesc/LICENSE

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

licenses/github.com/cpuguy83/go-md2man/LICENSE.md

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

licenses/github.com/davecgh/go-spew/LICENSE

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

licenses/github.com/docker/spdystream/LICENSE

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

0 commit comments

Comments
 (0)