Skip to content

Commit

Permalink
Introduce support for packit builds
Browse files Browse the repository at this point in the history
Fixes: #452
Signed-off-by: Martin Perina <mperina@redhat.com>
  • Loading branch information
mwperina committed Aug 23, 2023
1 parent 1817015 commit 3e7be5a
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 29 deletions.
43 changes: 43 additions & 0 deletions .packit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

upstream_project_url: https://github.com/containers/bluechi
issue_repository: https://github.com/containers/bluechi
specfile_path: bluechi.spec
upstream_package_name: bluechi
downstream_package_name: bluechi

update_release: false

srpm_build_deps:
- gcc
- gcc-c++
- git
- jq
- meson
- systemd-devel
- rpm-build

actions:
post-upstream-clone:
- bash -c './build-scripts/create-spec.sh'

get-current-version:
- bash -c './build-scripts/get-version.sh'

create-archive:
- bash -c './build-scripts/create-archive.sh'
- bash -c 'echo bluechi-$PACKIT_PROJECT_VERSION.tar.gz'

jobs:
- job: copr_build
trigger: pull_request
targets:
- epel-9-aarch64
- epel-9-ppc64le
- epel-9-s390x
- epel-9-x86_64
- fedora-rawhide-aarch64
- fedora-rawhide-i386
- fedora-rawhide-ppc64le
- fedora-rawhide-s390x
- fedora-rawhide-x86_64
30 changes: 1 addition & 29 deletions build-scripts/build-srpm.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
#!/bin/bash -xe
# SPDX-License-Identifier: GPL-2.0-or-later

# Parse package version from the project
meson setup builddir
VERSION="$(meson introspect --projectinfo builddir | jq -r '.version')"
source $(dirname "$(readlink -f "$0")")/create-archive.sh

# Mark current directory as safe for git to be able to parse git hash
git config --global --add safe.directory $(pwd)

# Package release
#
# Use following for official releases
#RELEASE="1"
# Use following for nightly builds
RELEASE="0.$(date +%04Y%02m%02d%02H%02M).git$(git rev-parse --short ${GITHUB_SHA:-HEAD})"


# Set version and release
sed \
-e "s|@VERSION@|${VERSION}|g" \
-e "s|@RELEASE@|${RELEASE}|g" \
< bluechi.spec.in \
> bluechi.spec

# Prepare source archive
[[ -d rpmbuild/SOURCES ]] || mkdir -p rpmbuild/SOURCES

git archive --format=tar --prefix=bluechi-$VERSION/ --add-file=bluechi.spec -o bluechi-$VERSION.tar HEAD
git submodule foreach --recursive \
"git archive --prefix=bluechi-$VERSION/\$path/ --output=\$sha1.tar HEAD && \
tar --concatenate --file=$(pwd)/bluechi-$VERSION.tar \$sha1.tar && rm \$sha1.tar"
gzip bluechi-$VERSION.tar
mv bluechi-$VERSION.tar.gz rpmbuild/SOURCES/

# Build source package
Expand Down
13 changes: 13 additions & 0 deletions build-scripts/create-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -xe
# SPDX-License-Identifier: GPL-2.0-or-later

source $(dirname "$(readlink -f "$0")")/create-spec.sh

# Prepare source archive
[[ -d rpmbuild/SOURCES ]] || mkdir -p rpmbuild/SOURCES

git archive --format=tar --prefix=bluechi-$VERSION/ --add-file=bluechi.spec -o bluechi-$VERSION.tar HEAD
git submodule foreach --recursive \
"git archive --prefix=bluechi-$VERSION/\$path/ --output=\$sha1.tar HEAD && \
tar --concatenate --file=$(pwd)/bluechi-$VERSION.tar \$sha1.tar && rm \$sha1.tar"
gzip bluechi-$VERSION.tar
22 changes: 22 additions & 0 deletions build-scripts/create-spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -xe
# SPDX-License-Identifier: GPL-2.0-or-later

VERSION="$($(dirname "$(readlink -f "$0")")/get-version.sh)"

# Mark current directory as safe for git to be able to parse git hash
git config --global --add safe.directory $(pwd)

# Package release
#
# Use following for official releases
#RELEASE="1"
# Use following for nightly builds
RELEASE="0.$(date +%04Y%02m%02d%02H%02M).git$(git rev-parse --short ${GITHUB_SHA:-HEAD})"


# Set version and release
sed \
-e "s|@VERSION@|${VERSION}|g" \
-e "s|@RELEASE@|${RELEASE}|g" \
< bluechi.spec.in \
> bluechi.spec
8 changes: 8 additions & 0 deletions build-scripts/get-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -xe
# SPDX-License-Identifier: GPL-2.0-or-later

# Parse package version from the project
meson setup builddir 1>&2
VERSION="$(meson introspect --projectinfo builddir | jq -r '.version')"

echo ${VERSION}

0 comments on commit 3e7be5a

Please sign in to comment.