Skip to content

Commit

Permalink
Fedora packaging
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Jun 24, 2024
1 parent ef03aef commit 969454f
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 0 deletions.
1 change: 1 addition & 0 deletions .distro/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
7 changes: 7 additions & 0 deletions .distro/plans/full.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
summary:
Test the bundled ctests and pytest
discover+:
how: fmf
path: test-suite
execute:
how: tmt
6 changes: 6 additions & 0 deletions .distro/plans/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
adjust+:
# Cannot use initiator: fedora-ci reliably yet
when: initiator is not defined or initiator != packit
discover:
how: fmf
dist-git-source: true
5 changes: 5 additions & 0 deletions .distro/plans/rpminspect.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plan:
import:
url: https://github.com/packit/tmt-plans
ref: main
name: /plans/rpminspect
10 changes: 10 additions & 0 deletions .distro/plans/rpmlint.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prepare:
- how: shell
script: cp ./*.rpmlintrc $TMT_PLAN_DATA/
discover:
how: fmf
filter: "tag: rpmlint"
url: https://github.com/packit/tmt-plans
ref: main
execute:
how: tmt
Empty file added .distro/wannier90.rpmlintrc
Empty file.
159 changes: 159 additions & 0 deletions .distro/wannier90.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
Name: wannier90
Summary: Maximally-Localised Generalised Wannier Functions Code
Version: 0.0.0
Release: %autorelease
License: GPLv2
URL: https://www.wannier.org/

Source: https://github.com/wannier-developers/wannier90/archive/refs/tags/v%{version}.tar.gz

BuildRequires: ninja-build
BuildRequires: cmake
BuildRequires: gcc-fortran
BuildRequires: flexiblas-devel
# Required for testing
BuildRequires: gcc-c++
BuildRequires: python3

%global _description %{expand:
Maximally-Localised Generalised Wannier Functions Code.}

%description
%{_description}

%package devel
Summary: Development files for wannier90
Requires: wannier90%{?_isa} = %{version}-%{release}

%description devel
This package contains the development files for the wannier90 library.

%package openmpi
Summary: Maximally-Localised Generalised Wannier Functions Code - OpenMPI version
BuildRequires: openmpi-devel

%description openmpi
%{_description}

This package contains the OpenMPI parallel version.

%package openmpi-devel
Summary: Development files for wannier90 - OpenMPI version
Requires: wannier90-openmpi%{?_isa} = %{version}-%{release}

%description openmpi-devel
This package contains the development files for the wannier90 (OpenMPI) library.

%package mpich
Summary: Maximally-Localised Generalised Wannier Functions Code - MPICH version
BuildRequires: mpich-devel

%description mpich
%{_description}

This package contains the MPICH parallel version.

%package mpich-devel
Summary: Development files for wannier90 - MPICH version
Requires: wannier90-mpich%{?_isa} = %{version}-%{release}

%description mpich-devel
This package contains the development files for the wannier90 (MPICH) library.


%prep
%autosetup -n wannier90-%{version}

# $MPI_SUFFIX will be evaluated in the loops below, set by mpi modules
%global _vpath_builddir %{_vendor}-%{_target_os}-build${MPI_SUFFIX:-_serial}
# We are running the module load/unload manually until there is a macro-like way to expand this
. /etc/profile.d/modules.sh


%build
cmake_common_args=(
"-G Ninja"
"-DWANNIER90_SHARED_LIBS=ON"
"-DWANNIER90_TEST=ON"
)
for mpi in '' mpich openmpi ; do
if [ -n "$mpi" ]; then
module load mpi/${mpi}-%{_arch}
cmake_mpi_args=(
"-DCMAKE_INSTALL_PREFIX=${MPI_HOME}"
"-DWANNIER90_MPI=ON"
"-DCMAKE_INSTALL_MODULEDIR=${MPI_FORTRAN_MOD_DIR}"
"-DCMAKE_INSTALL_LIBDIR=lib"
)
else
cmake_mpi_args=(
"-DWANNIER90_MPI=OFF"
"-DCMAKE_INSTALL_MODULEDIR=%{_fmoddir}"
)
fi

%cmake \
${cmake_common_args[@]} \
${cmake_mpi_args[@]}
%cmake_build

[ -n "$mpi" ] && module unload mpi/${mpi}-%{_arch}
done


%install
for mpi in '' mpich openmpi ; do
[ -n "$mpi" ] && module load mpi/${mpi}-%{_arch}
%cmake_install
[ -n "$mpi" ] && module unload mpi/${mpi}-%{_arch}
done


%check
for mpi in '' mpich %{?with_openmpi:openmpi} ; do
[ -n "$mpi" ] && module load mpi/${mpi}-%{_arch}
%ctest
[ -n "$mpi" ] && module unload mpi/${mpi}-%{_arch}
done


%files
%doc README.rst
%license LICENSE
%{_libdir}/libwannier90.so.*
%{_bindir}/wannier90.x
%{_bindir}/postw90.x

%files devel
%{_includedir}/wannier90.hh
%{_libdir}/libwannier90.so
%{_fmoddir}/Wannier90/
%{_libdir}/cmake/Wannier90
%{_libdir}/pkgconfig/wannier90.pc

%files openmpi
%{_libdir}/openmpi/bin/wannier90.x
%{_libdir}/openmpi/bin/postw90.x
%{_libdir}/openmpi/lib/libwannier90.so.*

%files openmpi-devel
%{_libdir}/openmpi/include/wannier90.hh
%{_libdir}/openmpi/lib/libwannier90.so
%{_fmoddir}/openmpi/Wannier90/
%{_libdir}/openmpi/lib/cmake/Wannier90
%{_libdir}/openmpi/lib/pkgconfig/wannier90.pc

%files mpich
%{_libdir}/mpich/bin/wannier90.x
%{_libdir}/mpich/bin/postw90.x
%{_libdir}/mpich/lib/libwannier90.so.*

%files mpich-devel
%{_libdir}/mpich/include/wannier90.hh
%{_libdir}/mpich/lib/libwannier90.so
%{_fmoddir}/mpich/Wannier90/
%{_libdir}/mpich/lib/cmake/Wannier90
%{_libdir}/mpich/lib/pkgconfig/wannier90.pc

%changelog
%autochangelog
57 changes: 57 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
specfile_path: .distro/wannier90.spec
files_to_sync:
- src: .distro/
dest: ./
delete: true
filters:
- "protect .git*"
- "protect sources"
- "protect changelog"
- "- plans/rpminspect.fmf"
- "- plans/rpmlint.fmf"
- .packit.yaml

upstream_package_name: wannier90
downstream_package_name: wannier90
upstream_tag_template: v{version}

targets:
- fedora-all-x86_64
- fedora-all-aarch64

jobs:
- &copr_build
job: copr_build
trigger: release
owner: lecris
project: release
update_release: false
- <<: *copr_build
trigger: commit
branch: develop
project: nightly
update_release: true
- &tests
job: tests
trigger: commit
branch: develop
targets:
- fedora-all-x86_64
- fedora-all-aarch64
fmf_path: .distro
- job: copr_build
trigger: pull_request
- <<: *tests
trigger: pull_request
- job: propose_downstream
trigger: release
dist_git_branches:
- fedora-rawhide
- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all
- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-branched
1 change: 1 addition & 0 deletions test-suite/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
26 changes: 26 additions & 0 deletions test-suite/ctest.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
tag: [ cmake ]
require:
- cmake
- rsync
- gcc
- gcc-c++
- gcc-fortran
- pkgconf
- git
# For test-suite
- bzip2
# For testing FetchContent
- flexiblas-devel
framework: beakerlib
path: /
test: ./ctest.sh

/serial:
environment:
MPI_VARIANT: serial
/OpenMPI:
environment:
MPI_VARIANT: openmpi
/MPICH:
environment:
MPI_VARIANT: mpich
26 changes: 26 additions & 0 deletions test-suite/ctest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# shellcheck disable=all
source /usr/share/beakerlib/beakerlib.sh || exit 1

rlJournalStart
rlPhaseStartSetup
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "rsync -rL ./ $tmp" 0 "Copy test-suite project"
rlRun "pushd $tmp"
rlRun "set -o pipefail"
[[ -z "${MPI_VARIANT}" ]] && rlDie "MPI_VARIANT was not provided"
rlPhaseEnd

rlPhaseStartTest
[[ "${MPI_VARIANT}" != "serial" ]] && rlRun "module load mpi/${MPI_VARIANT}" 0 "Load MPI"
rlRun "cmake -B ./build" 0 "CMake configure"
rlRun "cmake --build ./build" 0 "CMake build"
rlRun "ctest --test-dir ./build --output-on-failure" 0 "Run CTest"
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd

0 comments on commit 969454f

Please sign in to comment.