Skip to content

Commit

Permalink
add specfile to build srpm (#41)
Browse files Browse the repository at this point in the history
* add specfile to build srpm

Signed-off-by: Janine Olear <[email protected]>

* Update collector.spec description

Co-authored-by: Ben B. <[email protected]>

* Update collector.spec summary

Co-authored-by: Ben B. <[email protected]>

* propagate version and project name

Signed-off-by: Janine Olear <[email protected]>

* add source/rpm rule to ci workflow

Signed-off-by: Janine Olear <[email protected]>

* fix ci build

Signed-off-by: Janine Olear <[email protected]>

* remove srpm build step for now

Signed-off-by: Janine Olear <[email protected]>

* remove unnecessary parts in specfile

Signed-off-by: Janine Olear <[email protected]>

* spec: remove make dependency

Signed-off-by: Benedikt Bongartz <[email protected]>

* fix vendor rule in Makefile

Signed-off-by: Benedikt Bongartz <[email protected]>

* ci: register fedora test build

Signed-off-by: Benedikt Bongartz <[email protected]>

---------

Signed-off-by: Janine Olear <[email protected]>
Signed-off-by: Benedikt Bongartz <[email protected]>
Co-authored-by: Ben B. <[email protected]>
  • Loading branch information
miyunari and frzifus authored Feb 13, 2024
1 parent ca4ce68 commit 4f9e11b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ jobs:

- name: Verify
run: make build

- name: Set up Docker
uses: docker/setup-buildx-action@v3

- name: Verify srpm
run: make rpm/fedora-testbuild
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ GO=$(shell which go)
OTELCOL_VERSION ?= 0.93.0
OTELCOL_BUILDER_DIR ?= ${PWD}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb
PROJECT ?= redhat-otel-collector
PROJECT ?= redhat-opentelemetry-collector
RPM_BUILDER ?= fedpkg
RELEASE ?= epel7

build: ocb
mkdir -p _build
Expand Down Expand Up @@ -33,11 +35,11 @@ endif
.PHONY: vendor
vendor:
@echo "Downloading dependencies of the custom collector..."
cd ./_build && $(GO) mod tidy && $(GO) mod vendor
cd ./_build && $(GO) go mod tidy && $(GO) go mod vendor

# Archive the source code with all dependencies in a tarball.
.PHONY: archive
archive:
archive: vendor
mkdir -p dist/

@echo "Creating a tarball with the source code..."
Expand All @@ -54,3 +56,15 @@ archive:

@echo "The archives are available at dist/:"
@find dist/*.tar.gz

# Build the collector as RPM.
.PHONY:rpm/source
rpm/source: collector.spec archive
cp *.spec ./dist && cd dist/ && $(RPM_BUILDER) --release "$(RELEASE)" srpm

.PHONY: collector.spec
collector.spec: collector.spec.in
sed -e "s/%%PROJECT%%/$(PROJECT)/" -e "s/%%VERSION%%/$(OTELCOL_VERSION)/" < $< > $@

rpm/fedora-testbuild:
docker run --rm -v ${PWD}:/src:z fedora:39 /bin/bash -c 'dnf install -y git make curl gzip tar rpm-build golang fedpkg && git config --global --add safe.directory /src && pushd src && export GOPROXY=https://proxy.golang.org,direct && make rpm/source && popd'
49 changes: 49 additions & 0 deletions collector.spec.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
%global goipath github.com/os-observability/redhat-opentelemetry-collector

Version: %%VERSION%%
ExcludeArch: %{ix86} s390 ppc ppc64 aarch64

%gometa

%global common_description %{expand:
Collector with the supported components for a Red Hat build of OpenTelemetry product}

%global golicenses LICENSE
%global godocs README.md

Name: %%PROJECT%%
Release: 1%{?dist}
Summary: Red Hat build of OpenTelemetry

License: Apache-2.0

Source0: %{name}-%{version}.tar.gz
Source1: %{name}-deps-%{version}.tar.gz

BuildRequires: go-toolset-1.20
BuildRequires: git

%description
%{common_description}

%prep
%goprep -k

%build
go build -buildmode pie -mod vendor

%install
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/

%check
%gocheck

%files
%license %{golicenses}
%doc %{godocs}
%{_bindir}/*

%changelog
* Thu Feb 1 21:59:10 CET 2024 Nina Olear <[email protected]> - 0.93.4
- First package for Copr

0 comments on commit 4f9e11b

Please sign in to comment.