Skip to content

Commit 76241dc

Browse files
authored
Merge pull request #76 from SamYuan1990/ubiSupport
enable ubi support
2 parents ba1d0bd + 82fbdbe commit 76241dc

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

main.sh

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,55 @@ print_config() {
137137
}
138138

139139
linuxHeader() {
140-
sudo apt-get install -y linux-headers-"$(uname -r)"
141-
sudo apt-get install -y linux-modules-"$(uname -r)"
142-
sudo apt-get install -y linux-modules-extra-"$(uname -r)"
140+
if [ -f /usr/bin/apt-get ]; then
141+
sudo apt-get install -y linux-headers-"$(uname -r)"
142+
sudo apt-get install -y linux-modules-"$(uname -r)"
143+
sudo apt-get install -y linux-modules-extra-"$(uname -r)"
144+
fi
145+
if [ -f /usr/bin/yum ]; then
146+
echo "do nothing for yum with linux header?"
147+
fi
143148
}
144149

145150
ebpf() {
146-
sudo apt-get install -y binutils-dev build-essential pkg-config libelf-dev
147-
mkdir -p temp-libbpf
148-
cd temp-libbpf
149-
git clone -b "$LIBBPF_VERSION" https://github.com/libbpf/libbpf
150-
cd libbpf/src
151-
sudo BUILD_STATIC_ONLY=y make install
152-
sudo make install_uapi_headers
153-
cd ../../..
154-
sudo rm -rf temp-libbpf
151+
if [ -f /usr/bin/apt-get ]; then
152+
sudo apt-get install -y binutils-dev build-essential pkg-config libelf-dev
153+
mkdir -p temp-libbpf
154+
cd temp-libbpf
155+
git clone -b "$LIBBPF_VERSION" https://github.com/libbpf/libbpf
156+
cd libbpf/src
157+
sudo BUILD_STATIC_ONLY=y make install
158+
sudo make install_uapi_headers
159+
cd ../../..
160+
sudo rm -rf temp-libbpf
161+
fi
162+
if [ -f /usr/bin/yum ]; then
163+
export workdir=$PWD
164+
yum -y install yum-utils cpio bzip2 clang llvm-devel zlib-devel libcurl-devel m4 xz
165+
yum-config-manager --enable ubi-9-baseos-source
166+
mkdir -p /tmp/elfutils-source
167+
cd /tmp/elfutils-source
168+
yumdownloader --source elfutils
169+
rpm2cpio elfutils-0.189-3.el9.src.rpm | cpio -iv
170+
ls -al
171+
tar xjvf elfutils-0.189.tar.bz2
172+
cd /tmp/elfutils-source/elfutils-0.189
173+
./configure --disable-debuginfod
174+
make install
175+
176+
mkdir -p /tmp/libbpf-source
177+
cd /tmp/libbpf-source
178+
yumdownloader --source libbpf
179+
rpm2cpio libbpf-1.2.0-1.el9.src.rpm | cpio -iv
180+
tar xf ./linux-*el9.tar.xz
181+
cd /tmp/libbpf-source/linux-5.14.0-333.el9/tools/lib/bpf
182+
make install_headers
183+
prefix=/usr BUILD_STATIC_ONLY=y make install
184+
cd /tmp/libbpf-source/linux-5.14.0-333.el9/tools/bpf
185+
make bpftool
186+
187+
cd "$workdir"
188+
fi
155189
}
156190

157191
containerruntime() {

test/ubi.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ RUN yum update -y && yum install -y git sudo
99
#RUN yum install -y yum-utils
1010
#RUN yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
1111
#RUN yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
12+
RUN sudo ./main.sh prerequisites
1213
RUN sudo ./main.sh containerruntime
1314
RUN sudo ./verify.sh containerruntime

0 commit comments

Comments
 (0)