5e5386b0c1290f8f661372e21be9ff530492fcd3
[validation.git] / docker / os / Makefile
1 ##############################################################################
2 # Copyright (c) 2019 AT&T, ENEA AB, Nokia and others                         #
3 #                                                                            #
4 # Licensed under the Apache License, Version 2.0 (the "License");            #
5 # you maynot use this file except in compliance with the License.            #
6 #                                                                            #
7 # You may obtain a copy of the License at                                    #
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, WITHOUT  #
12 # 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
17 export OS_VULS_DB?=/opt/akraino/validation/tests/os/vuls/db.tar.gz
18
19 .PHONY: .init_db_cache
20 .init_db_cache:
21         if [ ! -f $(OS_VULS_DB) ]; then \
22                 sudo mkdir -p $(dir $(OS_VULS_DB)); \
23                 sudo chown $(shell id -u):$(shell id -g) $(dir $(OS_VULS_DB)); \
24                 tar czf $(OS_VULS_DB) -T /dev/null; \
25         fi
26
27 .PHONY: .build
28 .build::
29         if [ -f $(OS_VULS_DB) ]; then \
30                 echo DB cache file found, will be used during the build; \
31                 cp $(OS_VULS_DB) .; \
32         else \
33                 tar czf $(notdir $(OS_VULS_DB)) -T /dev/null; \
34         fi
35         date +%s > $(notdir $(OS_VULS_DB)).timestamp
36
37 .PHONY: all
38 all: push-image .push_manifest
39
40 .PHONY: build
41 build: .build
42
43 .PHONY: push-image
44 push-image: .push_image
45
46 include ../build.mk
47
48 .PHONY: .build
49 .build::
50         if [ -f $(OS_VULS_DB) ]; then \
51                 echo DB cache file found, will be updated; \
52                 docker run -v $(OS_VULS_DB):$(OS_VULS_DB).host \
53                         --rm --entrypoint cp \
54                         $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER) \
55                         $(OS_VULS_DB) $(OS_VULS_DB).host; \
56         fi
57         rm -f $(notdir $(OS_VULS_DB))*