36107d68cddb9e680de8187af7d4efe6ef3cf970
[ci-management.git] / docker / scripts / lib_dnf.sh
1 # lib_dnf.sh - Docker build script dnf library.
2 #              For import only.
3
4 # Copyright (c) 2020 Cisco and/or its affiliates.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Don't import more than once.
18 if [ -n "$(alias lib_dnf_imported 2> /dev/null)" ] ; then
19     return 0
20 fi
21 alias lib_dnf_imported=true
22
23 export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname $BASH_SOURCE)"}
24 . $CIMAN_DOCKER_SCRIPTS/lib_common.sh
25
26 dump_dnf_package_list() {
27     branchname="$(echo $branch | sed -e 's,/,_,')"
28     dnf list installed > \
29         "$DOCKER_BUILD_LOG_DIR/$FDIOTOOLS_IMAGENAME-$branchname-dnf-packages.log"
30 }
31
32 dnf_install_packages() {
33     dnf install -y $@
34 }
35
36 dnf_install_docker_os_package_dependancies() {
37     dnf_install_packages dnf-utils
38 }
39
40 dnf_install_docker() {
41     # Note: Support for docker has been removed starting with centos-8, so the
42     #       only recourse is to pin the latest version by what's in the download dir.
43     # Browse the base URL to see what is available & update accordingly.
44
45     if [ "$OS_NAME" = "centos-8" ] ; then
46         dnf install -y https://download.docker.com/linux/$OS_ID/$OS_VERSION_ID/$OS_ARCH/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm
47         dnf install -y https://download.docker.com/linux/$OS_ID/$OS_VERSION_ID/$OS_ARCH/stable/Packages/docker-ce-cli-19.03.13-3.el8.x86_64.rpm
48         dnf install -y https://download.docker.com/linux/$OS_ID/$OS_VERSION_ID/$OS_ARCH/stable/Packages/docker-ce-19.03.13-3.el8.x86_64.rpm
49     else
50         echo_log "WARNING: Docker Image unknown for $OS_NAME!"
51     fi
52 }
53
54 generate_dnf_dockerfile() {
55     local executor_os_name=$1
56     local from_image=$2
57     local executor_image=$3
58     local from_image_os_id="$(echo $from_image | cut -d: -f2)"
59
60     cat <<EOF >$DOCKERFILE
61 FROM $from_image AS executor-image
62 LABEL Description="FD.io CI executor docker image for $executor_os_name/$OS_ARCH"
63 LABEL Vendor="fd.io"
64 LABEL Version="$DOCKER_TAG"
65
66 # Build Environment Variables
67 ENV FDIOTOOLS_IMAGE=$executor_image
68 ENV LC_ALL=C.UTF-8
69 ENV CIMAN_ROOT="$DOCKER_CIMAN_ROOT"
70 ENV PATH=$PATH:$DOCKER_CIMAN_ROOT/docker/scripts
71
72 # Copy-in build tree containing
73 # ci-management, vpp, & csit git repos
74 WORKDIR $DOCKER_BUILD_DIR
75 COPY . .
76
77 # Install baseline packages (minimum build & utils).
78 #
79 # ci-management global-jjb requirements:
80 #   for lf-env.sh:
81 #       facter
82 #   from global-jjb/packer/provision/baseline.sh:
83 #       deltarpm
84 #       unzip
85 #       xz
86 #       puppet
87 #       python3-pip
88 #       git
89 #       git-review
90 #       perl-XML-XPath
91 #       make
92 #       wget
93 #
94 # TODO: Fix broken project requirement install targets
95 #
96 #   graphviz           for 'make bootstrap-doxygen' (VPP)
97 #   doxygen            for 'make doxygen' (VPP)
98 #   enchant            for 'make docs' (VPP)
99 #   libffi-devel       for python cffi install (Ubuntu20.04/VPP/aarch64)
100 #   libpcap-devel      for python pypcap install (CSIT)
101 #   lapack-devel    for python numpy/scipy (CSIT/aarch64)
102 #   openblas-devel  for python numpy/scipy (CSIT/aarch64)
103 #
104 RUN dnf update -y \\
105     && dnf install -y \\
106         dnf-plugins-core \\
107         epel-release \\
108     && dnf config-manager --set-enabled PowerTools --set-enabled epel \\
109     && dnf clean all
110 RUN dnf update -y \\
111     && dnf install -y \\
112         dnf-utils \\
113         doxygen \\
114         enchant \\
115         emacs \\
116         facter \\
117         git \\
118         git-review \\
119         graphviz \\
120         iproute \\
121         java-1.8.0-openjdk \\
122         java-1.8.0-openjdk-devel \\
123         jq \\
124         lapack-devel \\
125         libffi-devel \\
126         libpcap-devel \\
127         make \\
128         mawk \\
129         mock \\
130         openblas-devel \\
131         perl \\
132         perl-XML-XPath \\
133         python3-pip \\
134         puppet \\
135         rake \\
136         rsync \\
137         ruby-devel \\
138         sudo \\
139         tree \\
140         unzip \\
141         vim \\
142         wget \\
143         xz \\
144     && dnf clean all
145
146 # Install OS packages for project branches
147 #
148 RUN dbld_vpp_install_packages.sh \\
149     && dbld_install_docker.sh \\
150     && dbld_csit_install_packages.sh \\
151     && dbld_lfit_requirements.sh \\
152     && dnf clean all
153
154 # CI Runtime Environment
155 WORKDIR /
156 ENV VPP_ZOMBIE_NOCHECK=1
157 RUN gem install package_cloud \\
158     && curl -s https://packagecloud.io/install/repositories/fdio/master/script.rpm.sh | sudo bash
159
160 # Clean up
161 RUN dbld_dump_build_logs.sh \\
162     && rm -rf /tmp/*
163 EOF
164 }