Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Build EL7 #6

Merged
merged 17 commits into from
Sep 25, 2023
41 changes: 16 additions & 25 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
49 changes: 30 additions & 19 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
FROM almalinux:8
ARG IMAGE=almalinux:8
FROM $IMAGE

MAINTAINER Sarun Nuntaviriyakul <sarun.nuntaviriyakul@cern.ch>
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

46 changes: 27 additions & 19 deletions docker/Dockerfile.rpm
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
FROM almalinux:8
ARG IMAGE=almalinux:8
FROM $IMAGE

MAINTAINER Sarun Nuntaviriyakul <sarun.nuntaviriyakul@cern.ch>
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
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
35 changes: 22 additions & 13 deletions spec/xrootd-cmstfc.spec
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 <sarun.nuntaviriyakul@cern.ch> - 2.0.1-1
- Support build for EL7

* Fri Aug 11 2023 Sarun Nuntaviriyakul <sarun.nuntaviriyakul@cern.ch> - 2.0.0-1
- Add JSON module (libXrdCmsJson.so)

Expand Down Expand Up @@ -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 <bbockelm@cse.unl.edu> 1.4.0-1
- Break xrootd-cmstfc off into its own standalone RPM.
- Break xrootd-cmstfc off into its own standalone RPM.
Loading