-
Notifications
You must be signed in to change notification settings - Fork 7
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
package: specfile #15
Changes from 7 commits
8be7470
95ac9df
de640f9
5301de0
09d743b
e1a6eed
3c63497
a904a27
8b8333e
33d65c2
ae6a20b
a17f5eb
2492f56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Basic test trying dependabot | ||
|
||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
time: "04:00" | ||
open-pull-requests-limit: 5 | ||
rebase-strategy: "disabled" | ||
|
||
# Maintain dependencies for Go | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "04:00" | ||
groups: | ||
go-deps: | ||
patterns: | ||
- "*" # group all dependency updates into one PR | ||
open-pull-requests-limit: 1 | ||
rebase-strategy: "auto" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rpmbuild | ||
vendor | ||
release_artifacts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# https://packit.dev/docs/configuration/ | ||
|
||
specfile_path: image-builder-cli.spec | ||
|
||
files_to_sync: | ||
- image-builder-cli.spec | ||
- .packit.yaml | ||
|
||
copy_upstream_release_description: true | ||
|
||
upstream_tag_template: v{version} | ||
|
||
srpm_build_deps: | ||
- make | ||
- golang | ||
|
||
actions: | ||
get-current-version: bash -c "git describe --tags --abbrev=0 | sed 's|v||'" | ||
post-upstream-clone: bash -c "go mod vendor && ./tools/rpm_spec_add_provides_bundle.sh" | ||
create-archive: bash -c "make release_artifacts" | ||
|
||
# Handle only releases without a "dot" (e.g. v88.2), since "dot" releases should never be released to Fedora | ||
upstream_tag_include: 'v\d+' | ||
|
||
jobs: | ||
# image-builder-cli is not yet in Fedora, so we don't need to update it there | ||
# - job: bodhi_update | ||
# trigger: commit | ||
# dist_git_branches: | ||
# - fedora-branched # rawhide updates are created automatically | ||
# - job: koji_build | ||
# trigger: commit | ||
# dist_git_branches: | ||
# - fedora-all | ||
# - job: propose_downstream | ||
# trigger: release | ||
# dist_git_branches: | ||
# - fedora-all | ||
- job: copr_build | ||
trigger: pull_request | ||
targets: &build_targets | ||
- centos-stream-9-aarch64 | ||
- centos-stream-9-s390x | ||
- centos-stream-9-ppc64le | ||
- centos-stream-9-x86_64 | ||
- centos-stream-10-aarch64 | ||
- centos-stream-10-s390x | ||
- centos-stream-10-ppc64le | ||
- centos-stream-10-x86_64 | ||
- fedora-all-aarch64 | ||
- fedora-all-s390x | ||
- fedora-all-ppc64le | ||
- fedora-all | ||
- rhel-9-aarch64 | ||
- rhel-9-x86_64 | ||
- job: copr_build | ||
trigger: commit | ||
branch: main | ||
owner: "@osbuild" # copr repo namespace | ||
project: image-builder-cli # copr repo name so you can consume the builds | ||
targets: *build_targets |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
# | ||
# Maintenance Helpers | ||
# | ||
# This makefile contains targets used for development, as well as helpers to | ||
# aid automatization of maintenance. Unless a target is documented in | ||
# `make help`, it is not supported and is only meant to be used by developers | ||
# to aid their daily development work. | ||
# | ||
# All supported targets honor the `SRCDIR` variable to find the source-tree. | ||
# For most unsupported targets, you are expected to have the source-tree as | ||
# your working directory. To specify a different source-tree, simply override | ||
# the variable via `SRCDIR=<path>` on the commandline. By default, the working | ||
# directory is used for build output, but `BUILDDIR=<path>` allows overriding | ||
# it. | ||
# | ||
|
||
BUILDDIR ?= . | ||
SRCDIR ?= . | ||
|
||
RST2MAN ?= rst2man | ||
|
||
# see https://hub.docker.com/r/docker/golangci-lint/tags | ||
# v1.55 to get golang 1.21 (1.21.3) | ||
# v1.53 to get golang 1.20 (1.20.5) | ||
GOLANGCI_LINT_VERSION=v1.55 | ||
GOLANGCI_LINT_CACHE_DIR=$(HOME)/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION) | ||
GOLANGCI_COMPOSER_IMAGE=composer_golangci | ||
# | ||
# Automatic Variables | ||
# | ||
# This section contains a bunch of automatic variables used all over the place. | ||
# They mostly try to fetch information from the repository sources to avoid | ||
# hard-coding them in this makefile. | ||
# | ||
# Most of the variables here are pre-fetched so they will only ever be | ||
# evaluated once. This, however, means they are always executed regardless of | ||
# which target is run. | ||
# | ||
# VERSION: | ||
# This evaluates the `Version` field of the specfile. Therefore, it will | ||
# be set to the latest version number of this repository without any | ||
# prefix (just a plain number). | ||
# | ||
# COMMIT: | ||
# This evaluates to the latest git commit sha. This will not work if | ||
# the source is not a git checkout. Hence, this variable is not | ||
# pre-fetched but evaluated at time of use. | ||
# | ||
|
||
VERSION := $(shell (cd "$(SRCDIR)" && grep "^Version:" image-builder-cli.spec | sed 's/[^[:digit:]]*\([[:digit:]]\+\).*/\1/')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should take potential "dot" versions into consideration. Such as |
||
COMMIT = $(shell (cd "$(SRCDIR)" && git rev-parse HEAD)) | ||
|
||
# | ||
# Generic Targets | ||
# | ||
# The following is a set of generic targets used across the makefile. The | ||
# following targets are defined: | ||
# | ||
# help | ||
# This target prints all supported targets. It is meant as | ||
# documentation of targets we support and might use outside of this | ||
# repository. | ||
# This is also the default target. | ||
# | ||
# $(BUILDDIR)/ | ||
# $(BUILDDIR)/%/ | ||
# This target simply creates the specified directory. It is limited to | ||
# the build-dir as a safety measure. Note that this requires you to use | ||
# a trailing slash after the directory to not mix it up with regular | ||
# files. Lastly, you mostly want this as order-only dependency, since | ||
# timestamps on directories do not affect their content. | ||
# | ||
|
||
.PHONY: help | ||
help: | ||
@echo "make [TARGETS...]" | ||
@echo | ||
@echo "This is the maintenance makefile of image-builder-cli. The following" | ||
@echo "targets are available:" | ||
@echo | ||
@echo " help: Print this usage information." | ||
@echo " rpm: Build the RPM" | ||
@echo " srpm: Build the source RPM" | ||
@echo " scratch: Quick scratch build of RPM" | ||
@echo " clean: Remove all built binaries" | ||
|
||
$(BUILDDIR)/: | ||
mkdir -p "$@" | ||
|
||
$(BUILDDIR)/%/: | ||
mkdir -p "$@" | ||
|
||
|
||
# | ||
# Maintenance Targets | ||
# | ||
# The following targets are meant for development and repository maintenance. | ||
# They are not supported nor is their use recommended in scripts. | ||
# | ||
|
||
.PHONY: build | ||
build: $(BUILDDIR)/bin/ | ||
go build -o $<image-builder ./cmd/image-builder/ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(BUILDDIR)/bin/ | ||
rm -rf $(CURDIR)/rpmbuild | ||
rm -rf $(CURDIR)/release_artifacts | ||
|
||
# | ||
# Building packages | ||
# | ||
# The following rules build image-builder-cli packages from the current HEAD | ||
# commit, based on the spec file in this directory. The resulting packages | ||
# have the commit hash in their version, so that they don't get overwritten | ||
# when calling `make rpm` again after switching to another branch. | ||
# | ||
# All resulting files (spec files, source rpms, rpms) are written into | ||
# ./rpmbuild, using rpmbuild's usual directory structure. | ||
# | ||
|
||
RPM_SPECFILE=rpmbuild/SPECS/image-builder-cli.spec | ||
RPM_TARBALL=rpmbuild/SOURCES/image-builder-cli-$(COMMIT).tar.gz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tarball should IMO contain also the release version, not just the commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
.PHONY: $(RPM_SPECFILE) | ||
$(RPM_SPECFILE): | ||
mkdir -p $(CURDIR)/rpmbuild/SPECS | ||
git show HEAD:image-builder-cli.spec > $(RPM_SPECFILE) | ||
go mod vendor | ||
./tools/rpm_spec_add_provides_bundle.sh $(RPM_SPECFILE) | ||
|
||
RPM_TARBALL_UNCOMPRESSED=$(RPM_TARBALL:.tar.gz=.tar) | ||
|
||
$(RPM_TARBALL): $(RPM_SPECFILE) | ||
mkdir -p $(CURDIR)/rpmbuild/SOURCES | ||
git archive --prefix=image-builder-cli-$(COMMIT)/ --format=tar.gz HEAD > $(RPM_TARBALL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably consider release tags There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point - I'll align, how this repo will be versioned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
gunzip -f $(RPM_TARBALL) | ||
tar --delete --owner=0 --group=0 --file $(RPM_TARBALL_UNCOMPRESSED) image-builder-cli-$(COMMIT)/$(notdir $(RPM_SPECFILE)) | ||
tar --append --owner=0 --group=0 --transform "s;^;image-builder-cli-$(COMMIT)/;" --file $(RPM_TARBALL_UNCOMPRESSED) $(RPM_SPECFILE) vendor/ | ||
tar --append --owner=0 --group=0 --transform "s;$(dir $(RPM_SPECFILE));image-builder-cli-$(COMMIT)/;" --file $(RPM_TARBALL_UNCOMPRESSED) $(RPM_SPECFILE) | ||
gzip $(RPM_TARBALL_UNCOMPRESSED) | ||
|
||
.PHONY: srpm | ||
srpm: $(RPM_SPECFILE) $(RPM_TARBALL) | ||
rpmbuild -bs \ | ||
--define "_topdir $(CURDIR)/rpmbuild" \ | ||
--define "commit $(COMMIT)" \ | ||
--with tests \ | ||
$(RPM_SPECFILE) | ||
|
||
.PHONY: rpm | ||
rpm: $(RPM_SPECFILE) $(RPM_TARBALL) | ||
rpmbuild -bb \ | ||
--define "_topdir $(CURDIR)/rpmbuild" \ | ||
--define "commit $(COMMIT)" \ | ||
--with tests \ | ||
$(RPM_SPECFILE) | ||
|
||
.PHONY: scratch | ||
scratch: $(RPM_SPECFILE) $(RPM_TARBALL) | ||
rpmbuild -bb \ | ||
--define "_topdir $(CURDIR)/rpmbuild" \ | ||
--define "commit $(COMMIT)" \ | ||
--without tests \ | ||
--nocheck \ | ||
$(RPM_SPECFILE) | ||
|
||
RPM_TARBALL_FILENAME=$(notdir $(RPM_TARBALL)) | ||
|
||
.PHONY: release_artifacts | ||
release_artifacts: $(RPM_TARBALL) | ||
mkdir -p release_artifacts | ||
cp $< release_artifacts/ | ||
# Print the artifact path for Packit | ||
echo "release_artifacts/$(shell basename $<)" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Do not build with tests by default | ||
# Pass --with tests to rpmbuild to override | ||
%bcond_with tests | ||
%bcond_with relax_requires | ||
|
||
# The minimum required osbuild version | ||
%global min_osbuild_version 129 | ||
|
||
%global goipath github.com/osbuild/image-builder-cli | ||
|
||
Version: 0 | ||
|
||
%gometa | ||
|
||
%global common_description %{expand: | ||
A service for building customized OS artifacts, such as VM images and OSTree | ||
commits, that uses osbuild under the hood. Besides building images for local | ||
usage, it can also upload images directly to cloud. | ||
|
||
It is compatible with composer-cli and cockpit-composer clients. | ||
Comment on lines
+16
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was probably not changed when copied over from osbuild-composer. We should update it. |
||
} | ||
|
||
Name: image-builder-cli | ||
Release: 1%{?dist} | ||
Summary: An image building service based on osbuild | ||
ExcludeArch: i686 armv7hl | ||
|
||
# Upstream license specification: Apache-2.0 | ||
License: Apache-2.0 | ||
URL: %{gourl} | ||
Source0: %{gosource} | ||
|
||
|
||
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} | ||
BuildRequires: systemd | ||
BuildRequires: krb5-devel | ||
BuildRequires: python3-docutils | ||
Comment on lines
+35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if they are still relevant, because we do not interact with systemd or Koji (krb5) and I'm not sure about docs... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are likely leftovers from the copy :) |
||
BuildRequires: make | ||
# Build requirements of 'theproglottis/gpgme' package | ||
BuildRequires: gpgme-devel | ||
BuildRequires: libassuan-devel | ||
# Build requirements of 'github.com/containers/storage' package | ||
BuildRequires: device-mapper-devel | ||
%if 0%{?fedora} | ||
BuildRequires: systemd-rpm-macros | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is, in my opinion, not needed because we do not enable/disable/start/stop/restart any services as part of the RPM installation process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are likely leftovers from the copy :) |
||
BuildRequires: git | ||
# Build requirements of 'github.com/containers/storage' package | ||
BuildRequires: btrfs-progs-devel | ||
# DO NOT REMOVE the BUNDLE_START and BUNDLE_END markers as they are used by 'tools/rpm_spec_add_provides_bundle.sh' to generate the Provides: bundled list | ||
# BUNDLE_START | ||
# BUNDLE_END | ||
%endif | ||
|
||
%description | ||
%{common_description} | ||
|
||
%prep | ||
%if 0%{?rhel} | ||
%forgeautosetup -p1 | ||
%else | ||
%goprep -k | ||
%endif | ||
|
||
%build | ||
export GOFLAGS="-buildmode=pie" | ||
%if 0%{?fedora} | ||
# Fedora disables Go modules by default, but we want to use them. | ||
# Undefine the macro which disables it to use the default behavior. | ||
%undefine gomodulesmode | ||
%endif | ||
|
||
# btrfs-progs-devel is not available on RHEL | ||
%if 0%{?rhel} | ||
GOTAGS="exclude_graphdriver_btrfs" | ||
%endif | ||
|
||
%gobuild ${GOTAGS:+-tags=$GOTAGS} -o %{gobuilddir}/bin/image-builder %{goipath}/cmd/image-builder | ||
|
||
%install | ||
install -m 0755 -vd %{buildroot}%{_bindir} | ||
install -m 0755 -vp %{gobuilddir}/bin/image-builder %{buildroot}%{_bindir}/ | ||
|
||
%check | ||
export GOFLAGS="-buildmode=pie" | ||
%gocheck | ||
|
||
%files | ||
%license LICENSE | ||
%doc README.md | ||
%{_bindir}/image-builder | ||
|
||
%changelog | ||
# the changelog is distribution-specific, therefore there's just one entry | ||
# to make rpmlint happy. | ||
|
||
* Wed Sep 11 2019 Image Builder team <osbuilders@redhat.com> - 0-1 | ||
- On this day, this project was born. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/bash | ||
|
||
SPEC_FILE=${1:-"image-builder-cli.spec"} | ||
|
||
# Save the list of bundled packages into a file | ||
WORKDIR=$(mktemp -d) | ||
BUNDLES_FILE=${WORKDIR}/bundles.txt | ||
./tools/rpm_spec_vendor2provides vendor/modules.txt > "${BUNDLES_FILE}" | ||
|
||
# Remove the current bundle lines | ||
sed -i '/^# BUNDLE_START/,/^# BUNDLE_END/{//p;d;}' "${SPEC_FILE}" | ||
# Add the new bundle lines | ||
sed -i "/^# BUNDLE_START/r ${BUNDLES_FILE}" "${SPEC_FILE}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️