-
Notifications
You must be signed in to change notification settings - Fork 54
153 lines (126 loc) · 6.1 KB
/
build_centos.yml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: CentOS binaries
# This machine tests building the software on a both 32 and 64 Windows architecture.
on: [push]
jobs:
redhat_based:
strategy:
fail-fast: false
matrix:
include:
- environment: "centos:7"
cc: "gcc"
upload_for_test: "false"
name: build on ${{ matrix.environment }}
runs-on: ubuntu-latest
container: ${{ matrix.environment }}
steps:
- name: Setup OS
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
yum -y update
yum -y install epel-release
yum -y install gcc gcc-c++ cmake gengetopt openssl openssl-devel libedit-devel libcurl-devel libusbx-devel
yum -y install pcsc-lite-devel help2man chrpath rpm-build redhat-rpm-config
yum -y install checksec procps-ng jq file which curl wget git
yum -y install bison make
git clone https://sourceware.org/git/glibc.git -b glibc-2.27 --depth 1
mkdir glibc/build
cd glibc/build
./../configure --prefix=/usr
make
make install
- name: install OpenSSL
run: |
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
tar xfz openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config --prefix=$GITHUB_WORKSPACE/openssl --openssldir=$GITHUB_WORKSPACE/openssl
make
make install
- name: clone the Yubico/yubihsm-shell repository
run: |
git clone https://github.com/Yubico/yubihsm-shell.git -b 2.6.0
- name: apply environment specific changes to CMakeLists.txt
working-directory: yubihsm-shell
if: ${{ matrix.environment == 'centos:7' }}
run: |
# centos 7 comes with cmake version 2.8, but the project requires 3.5
# we downgrade that requirement for the centos 7 build
sed -i 's/cmake_minimum_required (VERSION 3.5)/cmake_minimum_required (VERSION 2.8)/' CMakeLists.txt
# we also remove the following policies which are not supported in the older cmake version
sed -i 's/cmake_policy(SET CMP0025 NEW)/#cmake_policy(SET CMP0025 NEW)/' CMakeLists.txt
sed -i 's/cmake_policy(SET CMP0042 NEW)/#cmake_policy(SET CMP0042 NEW)/' CMakeLists.txt
sed -i 's/cmake_policy(SET CMP0054 NEW)/#cmake_policy(SET CMP0054 NEW)/' CMakeLists.txt
sed -i 's/cmake_policy(SET CMP0091 NEW)/#cmake_policy(SET CMP0091 NEW)/' CMakeLists.txt
# append the following flags: -Wno-missing-braces -Wno-missing-field-initializers -Wno-implicit-function-declaration
sed -i 's/-Wall -Wextra -Werror/-Wall -Wextra -Werror -Wno-missing-braces -Wno-missing-field-initializers/' cmake/SecurityFlags.cmake
- name: extract platform name
env:
DOCKER_IMAGE: ${{ matrix.environment }}
run: |
# Remove everything from DOCKER_IMAGE that is not a letter or a number
PLATFORM=$(echo -n "$DOCKER_IMAGE" | sed -E 's/[^a-zA-Z0-9]//g')
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
# - name: install dependencies
# env:
# PLATFORM: ${{ env.PLATFORM }}
# run: |
# cd yubihsm-shell/resources/release/linux
# ./install_redhat_dependencies.sh $PLATFORM
#
# if [ $PLATFORM = "centos7" ]; then
# # enable the epel repository for centos
# yum install -y epel-release
# fi
# yum install -y checksec procps-ng jq file which curl
- name: build release
working-directory: yubihsm-shell
env:
PLATFORM: ${{ env.PLATFORM }}
run: |
export CMAKE="cmake"
export INPUT=$GITHUB_WORKSPACE/yubihsm-shell
export OUTPUT=$GITHUB_WORKSPACE/$PLATFORM/yubihsm-shell
rm -rf $OUTPUT
mkdir -p $OUTPUT
export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/openssl/lib/pkgconfig
# These 2 lines can be replaced by the command "rpmdev-setuptree", but this command seems to add macros that force check paths that do not exist
mkdir -p $GITHUB_WORKSPACE/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > $GITHUB_WORKSPACE/.rpmmacros
RPM_DIR=$GITHUB_WORKSPACE/rpmbuild
cp resources/release/linux/yubihsm-shell.spec $RPM_DIR/SPECS/
QA_SKIP_BUILD_ROOT=1 QA_RPATHS=$(( 0x0001|0x0010 )) rpmbuild -bb $RPM_DIR/SPECS/yubihsm-shell.spec
cp /github/home/rpmbuild/RPMS/x86_64/*.rpm $OUTPUT/
LICENSE_DIR="$OUTPUT/share/yubihsm-shell"
mkdir -p $LICENSE_DIR
cp -r $INPUT/resources/release/linux/licenses $LICENSE_DIR/
for lf in $LICENSE_DIR/licenses/*; do
chmod 644 $lf
done
cd $OUTPUT
rm -f "yubihsm-shell-$PLATFORM-amd64.tar.gz"
tar -C ".." -zcvf "../yubihsm-shell-$PLATFORM-amd64.tar.gz" "yubihsm-shell"
rm -f *.rpm
rm -rf licenses
rm -rf ../yubihsm-shell
- name: install binaries
working-directory: /github/home/rpmbuild/RPMS/x86_64
run: |
yum install -y ./yubihsm-shell-*.rpm
- name: check binaries for hardening
run: |
cs() {
checksec --file=/usr/bin/yubihsm-shell --format=json | jq -r ".[] | .$1"
}
if [ "`cs relro`" != "full" ]; then echo "relro is `cs relro`"; exit 1; fi
if [ "`cs canary`" != "yes" ]; then echo "canary is `cs canary`"; exit 1; fi
if [ "`cs nx`" != "yes" ]; then echo "nx is `cs nx`"; exit 1; fi
if [ "`cs pie`" != "yes" ]; then echo "pie is `cs pie`"; exit 1; fi
if [ "`cs fortify_source`" != "yes" ]; then echo "fortify_source is `cs fortify_source`"; exit 1; fi
- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: "yubihsm-shell-${{ env.PLATFORM }}-amd64"
path: ${{ env.PLATFORM }}