diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 272c186..a3a0c89 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -8,28 +8,11 @@ env: LATEST_TAG: ghcr.io/guyzsarun/xrootd-cmsjson:latest jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Check out Git repository - uses: actions/checkout@v2 - - - uses: docker/setup-buildx-action@v2 - - - name: Build Docker image - uses: docker/build-push-action@v4 - with: - context: . - file: docker/Dockerfile - tags: ${{ env.BASE_TAG }} - load: true - cache-from: type=gha - cache-to: type=gha,mode=max - - test-json: - name: Test JSON Conversion - needs: build + build-test: + strategy: + fail-fast: false + matrix: + version: ["centos:7", "almalinux:8", "almalinux:9"] runs-on: ubuntu-latest steps: - name: Check out Git repository @@ -43,6 +26,8 @@ jobs: context: . file: docker/Dockerfile tags: ${{ env.BASE_TAG }} + build-args: | + IMAGE=${{ matrix.version }} load: true cache-from: type=gha cache-to: type=gha,mode=max @@ -51,9 +36,12 @@ jobs: run: | docker run --rm ${{ env.BASE_TAG }} python3 -m pytest -v - test-rpm: - name: Package RPM - needs: build + build-rpm: + needs: build-test + strategy: + fail-fast: false + matrix: + version: ["centos:7", "almalinux:8", "almalinux:9"] runs-on: ubuntu-latest steps: - name: Check out Git repository @@ -66,6 +54,9 @@ jobs: with: context: . file: docker/Dockerfile.rpm + tags: ${{ env.BASE_TAG }} + build-args: | + IMAGE=${{ matrix.version }} load: true cache-from: type=gha cache-to: type=gha,mode=max diff --git a/CMakeLists.txt b/CMakeLists.txt index 64870fd..9cd8335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,9 @@ find_package( XercesC REQUIRED ) find_package( Pcre REQUIRED ) find_package( Jsoncpp REQUIRED ) -if( CMAKE_COMPILER_IS_GNUCXX ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror" ) -endif() +set (CMAKE_CXX_STANDARD 11) -if( CMAKE_COMPILER_IS_GNUCC ) - set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror" ) -endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" ) include_directories( "${PROJECT_SOURCE_DIR}" "${XROOTD_INCLUDES}" "${XERCES_INCLUDES}" "${PCRE_INCLUDES}" "${JSONCPP_INCLUDES}") diff --git a/docker/Dockerfile b/docker/Dockerfile index 6e54770..4e9f79d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,38 +1,49 @@ -FROM almalinux:8 +ARG IMAGE=almalinux:8 +FROM $IMAGE + MAINTAINER Sarun Nuntaviriyakul LABEL org.opencontainers.image.source https://github.com/guyzsarun/xrootd-cmsjson WORKDIR /xrootd +ARG IMAGE=almalinux:8 RUN yum -y update && \ - yum install -y dnf \ - https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ - https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el8-release-latest.rpm \ - epel-release + yum install -y --skip-broken \ + dnf \ + https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el$(echo $IMAGE | cut -d ":" -f 2)-release-latest.rpm \ + epel-release \ + centos-release-scl RUN dnf group install -y "Development Tools" # CMS TFC dependency -RUN yum install -y cmake \ - wget \ - xrootd \ - python3-devel \ - python3-xrootd \ - xrootd-devel \ - pcre-devel \ - xerces-c-devel \ - xrootd-devel \ - https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-1.9.4-4.el8s.x86_64.rpm \ - https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-devel-1.9.4-4.el8s.x86_64.rpm +RUN yum install -y --enablerepo=osg-contrib \ + cmake3 \ + xrootd \ + python3-devel \ + python3-xrootd \ + xrootd-devel \ + pcre-devel \ + xerces-c-devel \ + jsoncpp \ + jsoncpp-devel + + +# For Centos 7 +RUN if [[ $(echo $IMAGE | cut -d ":" -f 2) = "7" ]]; then \ + yum install -y devtoolset-7; \ + fi RUN pip3 install pytest COPY . . -RUN mkdir -p build -RUN cd build && \ - cmake .. -DBUILD_TEST=true && \ +RUN if [[ $(echo $IMAGE | cut -d ":" -f 2) = "7" ]]; then \ + source /opt/rh/devtoolset-7/enable; \ + fi && mkdir -p build && \ + cd build && \ + cmake3 .. -DBUILD_TEST=true && \ make && \ make install diff --git a/docker/Dockerfile.rpm b/docker/Dockerfile.rpm index 630d778..c8e2b2a 100644 --- a/docker/Dockerfile.rpm +++ b/docker/Dockerfile.rpm @@ -1,36 +1,44 @@ -FROM almalinux:8 +ARG IMAGE=almalinux:8 +FROM $IMAGE + MAINTAINER Sarun Nuntaviriyakul LABEL org.opencontainers.image.source https://github.com/guyzsarun/xrootd-cmsjson WORKDIR /xrootd +ARG IMAGE=almalinux:8 RUN yum -y update && \ - yum install -y dnf \ - https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ - https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el8-release-latest.rpm \ - epel-release + yum install -y --skip-broken \ + dnf \ + https://repo.opensciencegrid.org/osg/3.6/osg-3.6-el$(echo $IMAGE | cut -d ":" -f 2)-release-latest.rpm \ + epel-release \ + centos-release-scl RUN dnf group install -y "Development Tools" # CMS TFC dependency -RUN yum install -y cmake \ - wget \ - xrootd \ - python3-devel \ - python3-xrootd \ - xrootd-devel \ - pcre-devel \ - xerces-c-devel \ - xrootd-devel \ - https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-1.9.4-4.el8s.x86_64.rpm \ - https://cbs.centos.org/kojifiles/packages/jsoncpp/1.9.4/4.el8s/x86_64/jsoncpp-devel-1.9.4-4.el8s.x86_64.rpm +RUN yum install -y --enablerepo=osg-contrib \ + cmake3 \ + xrootd \ + python3-devel \ + python3-xrootd \ + xrootd-devel \ + pcre-devel \ + xerces-c-devel \ + jsoncpp \ + jsoncpp-devel + + +# For Centos 7 +RUN if [[ $(echo $IMAGE | cut -d ":" -f 2) = "7" ]]; then \ + yum install -y devtoolset-7; \ + fi COPY . . RUN mkdir -p /root/rpmbuild/SOURCES -RUN tar -zvcf /root/rpmbuild/SOURCES/xrootd-cmstfc.tar.gz --transform s/xrootd/xrootd-cmstfc-2.0.0/ ../xrootd +RUN tar -zvcf /root/rpmbuild/SOURCES/xrootd-cmstfc.tar.gz --transform s/xrootd/xrootd-cmstfc-2.0.1/ ../xrootd RUN rpmbuild -bb spec/xrootd-cmstfc.spec - -RUN yum install -y /root/rpmbuild/RPMS/x86_64/xrootd-cmstfc-2.0.0-1.el8.x86_64.rpm \ No newline at end of file +RUN yum install -y /root/rpmbuild/RPMS/x86_64/xrootd-cmstfc-2.0.1-1.el$(echo $IMAGE | cut -d ":" -f 2).x86_64.rpm diff --git a/spec/xrootd-cmstfc.spec b/spec/xrootd-cmstfc.spec index e431c4b..39c9192 100644 --- a/spec/xrootd-cmstfc.spec +++ b/spec/xrootd-cmstfc.spec @@ -1,13 +1,18 @@ Name: xrootd-cmstfc -Version: 2.0.0 +Version: 2.0.1 Release: 1%{?dist} Summary: CMS TFC plugin for xrootd Group: System Environment/Daemons License: BSD URL: https://github.com/CMSCompOps/xrootd-cmstfc -# Generated from: -# git-archive master | gzip -7 > ~/rpmbuild/SOURCES/xrootd-lcmaps.tar.gz + +%if %{rhel} == 7 +%define CMAKE cmake3 +%else +%define CMAKE cmake +%endif + Source0: %{name}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -25,16 +30,16 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: xrootd-devel >= 1:%{xrootd_current_major}.0.0-1 BuildRequires: xrootd-devel < 1:%{xrootd_next_major}.0.0-1 -BuildRequires: cmake pcre-devel xerces-c-devel jsoncpp-devel >= 1.9.4 +BuildRequires: %{CMAKE} pcre-devel xerces-c-devel jsoncpp-devel >= 1.9.4 Requires: /usr/bin/xrootd pcre xerces-c jsoncpp >= 1.9.4 -#%if 0%%{?rhel} < 7 -#Requires: xrootd4 >= 1:4.1.0 -#%else +%if %{rhel} == 7 +BuildRequires: devtoolset-7-gcc-c++ devtoolset-7-elfutils devtoolset-7-binutils devtoolset-7-make devtoolset-7-toolchain +%endif + Requires: xrootd >= 1:%{xrootd_current_major}.0.0-1 Requires: xrootd < 1:%{xrootd_next_major}.0.0-1 -#%endif %package devel Summary: Development headers and libraries for Xrootd CMSTFC plugin @@ -51,7 +56,12 @@ Group: System Environment/Development %build cd %{name}-%{version} +%if %{rhel} == 7 +source /opt/rh/devtoolset-7/enable +%cmake3 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=%{_lib} . +%else %cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=%{_lib} . +%endif make VERBOSE=1 %{?_smp_mflags} %install @@ -66,16 +76,15 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,-) %{_libdir}/libXrdCmsTfc.so %{_libdir}/libXrdCmsJson.so -%if 0%{?rhel} < 8 -%{_libdir}/libXrdCmsTfc.so.* -%{_libdir}/libXrdCmsJson.so.* -%endif %files devel %defattr(-,root,root,-) %{_includedir}/XrdCmsTfc.hh %{_includedir}/XrdCmsJson.hh %changelog +* Mon Sep 25 2023 Sarun Nuntaviriyakul - 2.0.1-1 +- Support build for EL7 + * Fri Aug 11 2023 Sarun Nuntaviriyakul - 2.0.0-1 - Add JSON module (libXrdCmsJson.so) @@ -142,4 +151,4 @@ rm -rf $RPM_BUILD_ROOT - Fix for TFC parsing to better respect rule order; request from Florida. * Tue Aug 24 2010 Brian Bockelman 1.4.0-1 -- Break xrootd-cmstfc off into its own standalone RPM. \ No newline at end of file +- Break xrootd-cmstfc off into its own standalone RPM.