-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-install-dumb-init.sh
78 lines (64 loc) · 2.52 KB
/
build-install-dumb-init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# build-install-dumb-init.sh
#
# Copyright (C) 2017-2021 Intel Corporation
#
# SPDX-License-Identifier: GPL-2.0-only
#
set -x
builddir=`mktemp -d` || exit 1
cd $builddir || exit 1
if grep -q Alma /etc/*release; then
INSTALL_CMD="dnf -y install glibc-static"
REMOVE_CMD="dnf -y remove glibc-static"
elif grep -q CentOS /etc/*release; then
INSTALL_CMD="yum -y install glibc-static"
REMOVE_CMD="yum -y remove glibc-static"
elif grep -q Fedora /etc/*release; then
INSTALL_CMD="dnf -y install glibc-static"
REMOVE_CMD="dnf -y remove glibc-static"
elif grep -q Ubuntu /etc/*release || grep -q Debian /etc/*release; then
INSTALL_CMD="apt-get install -y python3-pip"
REMOVE_CMD="apt-get remove -y python3-pip"
elif grep -q openSUSE /etc/*release; then
INSTALL_CMD="zypper --non-interactive install python3-pip glibc-devel-static"
REMOVE_CMD="zypper --non-interactive remove python3-pip glibc-devel-static"
else
exit 1
fi
wget https://github.com/Yelp/dumb-init/archive/v1.2.5.tar.gz || exit 1
echo "3eda470d8a4a89123f4516d26877a727c0945006c8830b7e3bad717a5f6efc4e v1.2.5.tar.gz" > sha256sums || exit 1
sha256sum -c sha256sums || exit 1
tar xf v1.2.5.tar.gz || exit 1
# https://github.com/Yelp/dumb-init/issues/273
sed -i '128 i \ \ \ \ packages=[],' dumb-init*/setup.py || exit 1
# https://github.com/Yelp/dumb-init/issues/286
echo py >> dumb-init*/requirements-dev.txt
# Replace the versions of python used for testing dumb-init. Since it is
# testing c code, and not python it shouldn't matter. Also remove the
# pre-commit test from the test rule because we don't care.
sed -i -e 's/envlist = .*/envlist = py3/' dumb-init*/tox.ini || exit 1
sed -i -e 's/tox -e pre-commit//' dumb-init*/Makefile || exit 1
$INSTALL_CMD || exit 1
# Setup the buildtools enviroment in the subshell, since we really only want
# to use python3 from buildtools.
(
if [ -e /opt/poky/*/environment-setup-*-pokysdk-linux ]; then
. /opt/poky/*/environment-setup-*-pokysdk-linux
fi
pip3 install virtualenv || exit 1
virtualenv $builddir/venv || exit 1
. $builddir/venv/bin/activate || exit 1
pip3 install setuptools tox || exit 1
)
. $builddir/venv/bin/activate || exit 1
cd dumb-init* || exit 1
make dumb-init || exit 1
make test || exit 1
cp dumb-init /usr/bin/dumb-init || exit 1
chmod +x /usr/bin/dumb-init || exit 1
rm $builddir -rf || exit 1
# Really this should be an exit 1 as well if it fails, but for some reason
# on travis, for fedora it consistently says that it cannot acquire the
# the transaction lock.
$REMOVE_CMD || exit 0