From 7ad30c2bbf9c6d3683374281508a2298d0399343 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Mon, 6 Nov 2023 14:22:55 +0100 Subject: [PATCH] Add packit packaging Signed-off-by: Cristian Le --- .distro/.fmf/version | 1 + .distro/cmake-template.rpmlintrc | 0 .distro/cmake-template.spec | 58 ++++++++++++++++++++++ .distro/plans/main.fmf.dist-git | 4 ++ .distro/plans/package.fmf | 8 +++ .distro/plans/rpminspect.fmf | 7 +++ .distro/plans/rpmlint.fmf | 5 ++ .distro/plans/smoke.fmf | 7 +++ .distro/tests/smoke.fmf | 9 ++++ .packit.yaml | 79 ++++++++++++++++++++++++++++++ test/package/FetchContent/main.fmf | 5 ++ test/package/find_package/main.fmf | 3 ++ test/package/main.fmf | 9 ++++ test/package/pkg-config/main.fmf | 5 ++ test/package/test.sh | 25 ++++++++++ 15 files changed, 225 insertions(+) create mode 100644 .distro/.fmf/version create mode 100644 .distro/cmake-template.rpmlintrc create mode 100644 .distro/cmake-template.spec create mode 100644 .distro/plans/main.fmf.dist-git create mode 100644 .distro/plans/package.fmf create mode 100644 .distro/plans/rpminspect.fmf create mode 100644 .distro/plans/rpmlint.fmf create mode 100644 .distro/plans/smoke.fmf create mode 100644 .distro/tests/smoke.fmf create mode 100644 .packit.yaml create mode 100644 test/package/FetchContent/main.fmf create mode 100644 test/package/find_package/main.fmf create mode 100644 test/package/main.fmf create mode 100644 test/package/pkg-config/main.fmf create mode 100755 test/package/test.sh diff --git a/.distro/.fmf/version b/.distro/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.distro/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.distro/cmake-template.rpmlintrc b/.distro/cmake-template.rpmlintrc new file mode 100644 index 0000000..e69de29 diff --git a/.distro/cmake-template.spec b/.distro/cmake-template.spec new file mode 100644 index 0000000..9aeeced --- /dev/null +++ b/.distro/cmake-template.spec @@ -0,0 +1,58 @@ +Name: cmake-template +Summary: CMake project template +Version: 0.0.0 +Release: %autorelease +License: MIT +URL: https://github.com/LecrisUT/CMake-Template + +Source: https://github.com/LecrisUT/CMake-Template/archive/refs/tags/v%{version}.tar.gz + +BuildRequires: ninja-build +BuildRequires: cmake +BuildRequires: gcc-c++ + +%description +CMake project template + +%package devel +Summary: Development files for cmake-template +Requires: cmake-template%{?_isa} = %{version}-%{release} + +%description devel +This package contains libraries and header files for developing +applications that use cmake-template. + + +%prep +%autosetup -n cmake-template-%{version} + + +%build +%cmake \ + -DTEMPLATE_SHARED_LIBS=ON \ + -DTEMPLATE_TESTS=ON +%cmake_build + + +%install +%cmake_install + + +%check +%ctest + + +%files +%doc README.md +%license LICENSE +%{_libdir}/libtemplate.so.* + +%files devel +%{_libdir}/libtemplate.so +%{_includedir}/template.h +%{_libdir}/cmake/Template +%{_libdir}/pkgconfig/template.pc + + +%changelog +%autochangelog diff --git a/.distro/plans/main.fmf.dist-git b/.distro/plans/main.fmf.dist-git new file mode 100644 index 0000000..795b207 --- /dev/null +++ b/.distro/plans/main.fmf.dist-git @@ -0,0 +1,4 @@ +discover: + how: fmf + dist-git-source: true + dist-git-extract: cmake-template-*/ diff --git a/.distro/plans/package.fmf b/.distro/plans/package.fmf new file mode 100644 index 0000000..b677a81 --- /dev/null +++ b/.distro/plans/package.fmf @@ -0,0 +1,8 @@ +summary: + Test importing package +discover+: + how: fmf + filter: "tag: package" + path: test +execute: + how: tmt diff --git a/.distro/plans/rpminspect.fmf b/.distro/plans/rpminspect.fmf new file mode 100644 index 0000000..878c94e --- /dev/null +++ b/.distro/plans/rpminspect.fmf @@ -0,0 +1,7 @@ +plan: + import: + url: https://github.com/packit/tmt-plans + ref: main + name: /plans/rpminspect +environment: + RPMINSPECT_EXCLUDE: disttag diff --git a/.distro/plans/rpmlint.fmf b/.distro/plans/rpmlint.fmf new file mode 100644 index 0000000..aac0154 --- /dev/null +++ b/.distro/plans/rpmlint.fmf @@ -0,0 +1,5 @@ +plan: + import: + url: https://github.com/packit/tmt-plans + ref: main + name: /plans/rpmlint diff --git a/.distro/plans/smoke.fmf b/.distro/plans/smoke.fmf new file mode 100644 index 0000000..57874e5 --- /dev/null +++ b/.distro/plans/smoke.fmf @@ -0,0 +1,7 @@ +summary: + Basic smoke tests +discover: + how: fmf + filter: "tag: smoke" +execute: + how: tmt diff --git a/.distro/tests/smoke.fmf b/.distro/tests/smoke.fmf new file mode 100644 index 0000000..3f9038e --- /dev/null +++ b/.distro/tests/smoke.fmf @@ -0,0 +1,9 @@ +# Common test variables +tag: + - smoke +tier: 0 +path: / + +# Define tests +/version: + test: hello diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 0000000..47af8c3 --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,79 @@ +specfile_path: .distro/cmake-template.spec + +# add or remove files that should be synced +files_to_sync: + - src: .distro/cmake-template.spec + dest: cmake-template.spec + - .packit.yaml + - src: .distro/cmake-template.rpmlintrc + dest: cmake-template.rpmlintrc + # tmt setup + - src: .distro/.fmf/ + dest: .fmf/ + - src: .distro/plans/ + dest: plans/ + filters: + - "- main.fmf.dist-git" + - src: .distro/plans/main.fmf.dist-git + dest: plans/main.fmf + - .packit.yaml + +upstream_package_name: CMake-Template +downstream_package_name: cmake-template + +update_release: false +upstream_tag_template: v{version} + +jobs: + - job: copr_build + trigger: pull_request + owner: lecris + project: cmake-template + targets: + - fedora-all-x86_64 + - fedora-all-aarch64 + - epel-9-x86_64 + - epel-9-aarch64 + - job: tests + trigger: pull_request + targets: + - fedora-all-x86_64 + - fedora-all-aarch64 + - epel-9-x86_64 + - epel-9-aarch64 + fmf_path: .distro + - job: copr_build + trigger: commit + branch: main + owner: lecris + project: nightly + targets: + - fedora-all-x86_64 + - fedora-all-aarch64 + - epel-9-x86_64 + - epel-9-aarch64 + - job: tests + trigger: commit + branch: main + targets: + - fedora-all-x86_64 + - fedora-all-aarch64 + - epel-9-x86_64 + - epel-9-aarch64 + fmf_path: .distro + ## Uncomment when released downstream +# - job: propose_downstream +# trigger: release +# dist_git_branches: +# - fedora-rawhide +# - epel-9 +# - job: koji_build +# trigger: commit +# dist_git_branches: +# - fedora-all +# - epel-9 +# - job: bodhi_update +# trigger: commit +# dist_git_branches: +# - fedora-branched +# - epel-9 diff --git a/test/package/FetchContent/main.fmf b/test/package/FetchContent/main.fmf new file mode 100644 index 0000000..6827ed6 --- /dev/null +++ b/test/package/FetchContent/main.fmf @@ -0,0 +1,5 @@ +summary: + Test FetchContent +require+: + - git +tag+: [ FetchContent ] diff --git a/test/package/find_package/main.fmf b/test/package/find_package/main.fmf new file mode 100644 index 0000000..763e8e9 --- /dev/null +++ b/test/package/find_package/main.fmf @@ -0,0 +1,3 @@ +summary: + Test find_package +tag+: [ find_package ] diff --git a/test/package/main.fmf b/test/package/main.fmf new file mode 100644 index 0000000..a9c86d5 --- /dev/null +++ b/test/package/main.fmf @@ -0,0 +1,9 @@ +tag: [ cmake, package ] +require: + - cmake + - rsync + - tree + - gcc-c++ +framework: beakerlib +path: / +test: ./package/test.sh diff --git a/test/package/pkg-config/main.fmf b/test/package/pkg-config/main.fmf new file mode 100644 index 0000000..a658eb0 --- /dev/null +++ b/test/package/pkg-config/main.fmf @@ -0,0 +1,5 @@ +summary: + Test pkg-config for C library +require+: + - pkgconf +tag+: [ pkg-config ] diff --git a/test/package/test.sh b/test/package/test.sh new file mode 100755 index 0000000..ceb3fdc --- /dev/null +++ b/test/package/test.sh @@ -0,0 +1,25 @@ +#!/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 .$TMT_TEST_NAME/ $tmp" 0 "Copy example project" + rlRun "pushd $tmp" + rlRun "tree" 0 "Show directory tree" + rlRun "set -o pipefail" + rlPhaseEnd + + rlPhaseStartTest + rlRun "cmake -B ./build" + rlRun "cmake --build ./build" + rlRun "./build/main" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd