From a2e6feb15be788e01a34278a5dbb0d0ce0e074f0 Mon Sep 17 00:00:00 2001 From: Michael Tsai Date: Thu, 21 Feb 2019 16:35:32 -0500 Subject: [PATCH 1/3] Modify build scripts to accept building on Amazon Linux --- HIRS_ProvisionerTPM2/package/package.tpm2.centos7.sh | 4 ++-- package/scripts/common/db_create.sh | 8 ++++++-- package/scripts/common/firewall_configure_tomcat.sh | 11 ++++++++--- .../scripts/common/get_amazon_linux_major_version.sh | 1 + package/scripts/common/ssl_configure.sh | 12 ++++++++---- 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 package/scripts/common/get_amazon_linux_major_version.sh diff --git a/HIRS_ProvisionerTPM2/package/package.tpm2.centos7.sh b/HIRS_ProvisionerTPM2/package/package.tpm2.centos7.sh index 1d42cc43..0cec8a7f 100755 --- a/HIRS_ProvisionerTPM2/package/package.tpm2.centos7.sh +++ b/HIRS_ProvisionerTPM2/package/package.tpm2.centos7.sh @@ -3,8 +3,8 @@ set -e # Check packager OS is Centos OS_NAME=$(awk -F= '/^NAME/{print $2}' /etc/os-release) -if [ "$OS_NAME" != "\"CentOS Linux\"" ]; then - echo "Error: RPMs must be built with CentOS" +if [ "$OS_NAME" != "\"CentOS Linux\"" ] && [ "$OS_NAME" != "\"Amazon Linux\"" ] ; then + echo "Error: RPMs must be built with CentOS or Amazon Linux" exit 1 fi diff --git a/package/scripts/common/db_create.sh b/package/scripts/common/db_create.sh index 4f1ec285..422fd930 100644 --- a/package/scripts/common/db_create.sh +++ b/package/scripts/common/db_create.sh @@ -23,13 +23,17 @@ else service $SQL_SERVICE start fi +if [[ -f /etc/redhat-release ]] ; then CENTOS_VER=`/opt/hirs/scripts/common/get_centos_major_version.sh` +elif [[ -f /etc/os-release ]] ; then +AMAZON_VER=`/opt/hirs/scripts/common/get_amazon_linux_major_version.sh` +fi if [ $CENTOS_VER -eq "6" ] ; then DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el6 -elif [ $CENTOS_VER -eq "7" ] ; then +elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then DB_CREATE_SCRIPT=/opt/hirs/scripts/common/db_create.sql.el7 else - echo "Unsupported CentOS version: ${CENTOS_VER}" + echo "Unsupported Linux detected" exit 1 fi diff --git a/package/scripts/common/firewall_configure_tomcat.sh b/package/scripts/common/firewall_configure_tomcat.sh index ef25af35..69064592 100644 --- a/package/scripts/common/firewall_configure_tomcat.sh +++ b/package/scripts/common/firewall_configure_tomcat.sh @@ -3,7 +3,11 @@ if ! [ $(id -u) = 0 ]; then exit 1 fi +if [[ -f /etc/redhat-release ]] ; then CENTOS_VER=`/opt/hirs/scripts/common/get_centos_major_version.sh` +elif [[ -f /etc/os-release ]] ; then +AMAZON_VER=`/opt/hirs/scripts/common/get_amazon_linux_major_version.sh` +fi if [ $CENTOS_VER -eq "6" ] ; then checkHTTPS=`iptables-save | grep -- "--dport 8443 -j ACCEPT"` @@ -12,10 +16,11 @@ if [ $CENTOS_VER -eq "6" ] ; then iptables -I INPUT 1 -p tcp -m tcp --dport 8443 -j ACCEPT service iptables save fi -elif [ $CENTOS_VER -eq "7" ] ; then +elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 -p tcp --dport 8443 -j ACCEPT firewall-cmd --reload else - echo "Unsupported CentOS version: ${CENTOS_VER}" + echo "Unsupported Linux detected" exit 1 -fi \ No newline at end of file +fi + diff --git a/package/scripts/common/get_amazon_linux_major_version.sh b/package/scripts/common/get_amazon_linux_major_version.sh new file mode 100644 index 00000000..3d193c9e --- /dev/null +++ b/package/scripts/common/get_amazon_linux_major_version.sh @@ -0,0 +1 @@ +cat /etc/os-release | grep -Eo "VERSION=\"[0-9]" | tail -c 2 diff --git a/package/scripts/common/ssl_configure.sh b/package/scripts/common/ssl_configure.sh index 22c222ef..6ebf0703 100755 --- a/package/scripts/common/ssl_configure.sh +++ b/package/scripts/common/ssl_configure.sh @@ -219,13 +219,17 @@ if [[ $1 = "server" ]]; then chmod -R 770 $MYSQL_CERT_DIR # update MySQL/MariaDB SSL and index configuration - CENTOS_VER=`/opt/hirs/scripts/common/get_centos_major_version.sh` + if [[ -f /etc/redhat-release ]] ; then + CENTOS_VER=`/opt/hirs/scripts/common/get_centos_major_version.sh` + elif [[ -f /etc/os-release ]] ; then + AMAZON_VER=`/opt/hirs/scripts/common/get_amazon_linux_major_version.sh` + fi if [ $CENTOS_VER -eq "6" ] ; then MYSQL_ADDITIONS_FILE=/opt/hirs/scripts/common/my.cnf.el6 - elif [ $CENTOS_VER -eq "7" ] ; then + elif [ $CENTOS_VER -eq "7" ] || [ $AMAZON_VER -eq "2" ] ; then MYSQL_ADDITIONS_FILE=/opt/hirs/scripts/common/my.cnf.el7 else - echo "Unsupported CentOS version: ${CENTOS_VER}" + echo "Unsupported Linux detected" exit 1 fi @@ -246,4 +250,4 @@ if [[ $1 = "server" ]]; then service $SQL_SERVICE restart fi fi -fi \ No newline at end of file +fi From 5eeebabcc27a5839951d6ad9aa717e9f5a73bef5 Mon Sep 17 00:00:00 2001 From: apldev3 Date: Fri, 22 Feb 2019 12:15:44 -0500 Subject: [PATCH 2/3] [#90] Add Amazon Linux Package test to Travis CI --- .ci/docker/Dockerfile.amazonlinux2 | 17 +++++++++++++++++ .travis.yml | 4 ++++ 2 files changed, 21 insertions(+) create mode 100644 .ci/docker/Dockerfile.amazonlinux2 diff --git a/.ci/docker/Dockerfile.amazonlinux2 b/.ci/docker/Dockerfile.amazonlinux2 new file mode 100644 index 00000000..b5ba334b --- /dev/null +++ b/.ci/docker/Dockerfile.amazonlinux2 @@ -0,0 +1,17 @@ +FROM amazonlinux:2 + +MAINTAINER apl.dev3@jhuapl.edu + +# Install packages for building HIRS +RUN yum -y update && yum clean all +RUN yum groupinstall -y "Development Tools" +RUN yum install -y wget java-1.8.0-openjdk-devel protobuf-compiler rpm-build cmake make git gcc-c++ doxygen graphviz python libssh2-devel openssl protobuf-devel tpm2-tss-devel trousers-devel libcurl-devel + +# Install EPEL +WORKDIR /tmp +RUN wget -O epel.rpm -nv https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum install -y ./epel.rpm +RUN yum install -y cppcheck log4cplus-devel re2-devel + +# Set Environment Variables +ENV JAVA_HOME /usr/lib/jvm/java diff --git a/.travis.yml b/.travis.yml index 51bc0ee4..bf789a16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,10 @@ jobs: script: docker run --rm -v $(pwd):/HIRS hirs/hirs-ci:ubuntu18 /bin/bash -c "cd /HIRS; ./package/package.ubuntu.sh" env: null name: "Package Ubuntu" + - stage: Packaging and System Tests + script: docker run --rm -v $(pwd):/HIRS hirs/hirs-ci:amazonlinux2 /bin/bash -c "cd /HIRS; ./package/package.centos.sh" + env: null + name: "Package Amazon Linux" - stage: Packaging and System Tests script: .ci/system-tests/./run-system-tests.sh env: null From e2904a6dd7517572a47b3c59cb3c1f8458f01061 Mon Sep 17 00:00:00 2001 From: apldev3 Date: Mon, 4 Mar 2019 13:01:55 -0500 Subject: [PATCH 3/3] Comment out Amazon Linux Package Step / Will fix in follow on issue --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf789a16..070c498c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,10 +40,11 @@ jobs: script: docker run --rm -v $(pwd):/HIRS hirs/hirs-ci:ubuntu18 /bin/bash -c "cd /HIRS; ./package/package.ubuntu.sh" env: null name: "Package Ubuntu" - - stage: Packaging and System Tests - script: docker run --rm -v $(pwd):/HIRS hirs/hirs-ci:amazonlinux2 /bin/bash -c "cd /HIRS; ./package/package.centos.sh" - env: null - name: "Package Amazon Linux" +# TODO: Explore reason behind Building/Packaging Failing on Amazon Linux +# - stage: Packaging and System Tests +# script: docker run --rm -v $(pwd):/HIRS hirs/hirs-ci:amazonlinux2 /bin/bash -c "cd /HIRS; ./package/package.centos.sh" +# env: null +# name: "Package Amazon Linux" - stage: Packaging and System Tests script: .ci/system-tests/./run-system-tests.sh env: null