Debian Codegraph @

Makefile

raw
1 #
2 # Copyright 2024 The Update Framework Authors
3 #
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 # SPDX-License-Identifier: Apache-2.0
17
18 # We want to use bash
19 SHELL:=/bin/bash
20
21 # Set environment variables
22 CLIS:=tuf-client # tuf
23
24 # Default target
25 .PHONY: default
26 default: build
27
28 #####################
29 # build section
30 #####################
31
32 # Build
33 .PHONY: build
34 build: $(addprefix build-, $(CLIS))
35
36 # Target for building a Go binary
37 .PHONY: build-%
38 build-%:
39 @echo "Building $*"
40 @go build -o $* examples/cli/$*/main.go
41
42 #####################
43 # test section
44 #####################
45
46 # Test target
47 .PHONY: test
48 test:
49 GODEBUG=rsa1024min=0 go test -race -covermode atomic ./...
50
51 #####################
52 # lint section
53 #####################
54
55 .PHONY: lint
56 lint:
57 golangci-lint run
58
59 .PHONY: fmt
60 fmt:
61 go fmt ./...
62
63 #####################
64 # examples section
65 #####################
66
67 # Target for running all examples
68 .PHONY: example-all
69 example-all: example-client example-repository example-multirepo example-tuf-client-cli example-root-signing
70
71 # Target for demoing the examples/client/client_example.go
72 .PHONY: example-client
73 example-client:
74 @echo "Executing the following example - client/client_example.go"
75 @cd examples/client/ && go run .
76
77 # Target for demoing the examples/repository/basic_repository.go
78 .PHONY: example-repository
79 example-repository:
80 @echo "Executing the following example - repository/basic_repository.go"
81 @cd examples/repository/ && go run .
82
83 # Target for demoing the examples/multirepo/client/client_example.go
84 .PHONY: example-multirepo
85 example-multirepo:
86 @echo "Executing the following example - multirepo/client/client_example.go"
87 @cd examples/multirepo/client/ && go run .
88
89 # Target for demoing the tuf-client cli
90 .PHONY: example-tuf-client-cli
91 example-tuf-client-cli: build-tuf-client
92 @echo "Clearing any leftover artifacts..."
93 ./tuf-client reset --force
94 @echo "Initializing the following https://jku.github.io/tuf-demo/ TUF repository"
95 @sleep 2
96 ./tuf-client init --url https://jku.github.io/tuf-demo/metadata
97 @echo "Downloading the following target file - rdimitrov/artifact-example.md"
98 @sleep 2
99 ./tuf-client get --url https://jku.github.io/tuf-demo/metadata --turl https://jku.github.io/tuf-demo/targets rdimitrov/artifact-example.md
100
101 # Target for demoing the tuf-client cli with root-signing repo
102 .PHONY: example-root-signing
103 example-root-signing: build-tuf-client
104 @echo "Clearing any leftover artifacts..."
105 ./tuf-client reset --force
106 @echo "Downloading the initial root of trust"
107 @curl -L "https://tuf-repo-cdn.sigstore.dev/5.root.json" > root.json
108 @echo "Initializing the following https://tuf-repo-cdn.sigstore.dev TUF repository"
109 @sleep 2
110 ./tuf-client init --url https://tuf-repo-cdn.sigstore.dev --file root.json
111 @echo "Downloading the following target file - rekor.pub"
112 @sleep 2
113 ./tuf-client get --url https://tuf-repo-cdn.sigstore.dev --turl https://tuf-repo-cdn.sigstore.dev/targets rekor.pub
114
115 # Clean target
116 .PHONY: clean
117 clean:
118 @rm -rf examples/multirepo/client/bootstrap/
119 @rm -rf examples/multirepo/client/download/
120 @rm -rf examples/multirepo/client/metadata/
121 @rm -rf examples/repository/tmp*
122 @rm -rf examples/client/tmp*
123 @rm -rf tuf_download
124 @rm -rf tuf_metadata
125 @rm -f tuf-client
126 @rm -f root.json