Skip to content

Commit cab22d3

Browse files
committed
Added Fedora rpm makefile target
1 parent d140c1f commit cab22d3

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ CMAKE_CXX_FLAGS ?=
2727
CMAKE_EXE_LINKER_FLAGS ?=
2828

2929
GIT_VERSION ?= $(shell git describe --tags --always --abbrev=7)
30+
PKG_VERSION ?= $(shell git describe --tags --always --abbrev=7 | tr - .)
31+
GIT_COMMIT ?= $(shell git rev-parse HEAD)
32+
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
3033

3134
.PHONY: clean
3235
clean:
@@ -104,3 +107,15 @@ iwyu_fixes: debug
104107
python3 $(shell which iwyu_tool.py) -p debug > debug/iwyu.out
105108
python3 $(shell which fix_includes.py) -h --re_only="${PWD}/src/.*" < debug/iwyu.out
106109
python3 $(shell which fix_includes.py) -h --re_only="${PWD}/tests/.*" < debug/iwyu.out
110+
111+
.PHONY: fedora_36
112+
fedora_36:
113+
mkdir -p packaging/_BUILD/fedora/36
114+
git archive --format=tar.gz --prefix=clang-uml-$(PKG_VERSION)/ v$(GIT_VERSION) >packaging/_BUILD/fedora/36/clang-uml-$(PKG_VERSION).tar.gz
115+
docker run --cpus="8" -v $(PWD):$(PWD) fedora:36 sh -c "dnf install -y make git && cd ${PWD} && make OS=fedora DIST=36 VERSION=${PKG_VERSION} COMMIT=${GIT_COMMIT} BRANCH=${GIT_BRANCH} -C packaging rpm"
116+
117+
.PHONY: fedora_37
118+
fedora_37:
119+
mkdir -p packaging/_BUILD/fedora/37
120+
git archive --format=tar.gz --prefix=clang-uml-$(PKG_VERSION)/ v$(GIT_VERSION) >packaging/_BUILD/fedora/37/clang-uml-$(PKG_VERSION).tar.gz
121+
docker run --cpus="8" -v $(PWD):$(PWD) fedora:37 sh -c "dnf install -y make git && cd ${PWD} && make OS=fedora DIST=37 VERSION=${PKG_VERSION} COMMIT=${GIT_COMMIT} BRANCH=${GIT_BRANCH} -C packaging rpm"

packaging/Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ COMMIT ?= $(shell git rev-parse HEAD)
3535
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
3636
SOURCE_ARCHIVE ?= $(NAME)-$(VERSION).tar.$(TAR_EXT)
3737
SOURCE_ARCHIVE_DEB ?= $(NAME)-$(VERSION)-$(REBUILD).tar.$(TAR_EXT)
38+
SOURCE_ARCHIVE_RPM ?= $(NAME)-$(VERSION).tar.$(TAR_EXT)
3839
CONDA_TOKEN ?=
3940

4041
#
@@ -61,11 +62,36 @@ _BUILD/$(SOURCE_ARCHIVE):
6162

6263
_BUILD/$(SOURCE_ARCHIVE_DEB):
6364
echo "############################"
64-
echo "Creating source archive from latest commit $(COMMIT) - $(SOURCE_ARCHIVE)"
65+
echo "Creating source archive for DEB from latest commit $(COMMIT) - $(SOURCE_ARCHIVE)"
6566
echo "############################"
6667
mkdir -p $(build_dir)
6768
git-archive-all --prefix=$(NAME)-$(VERSION)-$(REBUILD)/ _BUILD/$(SOURCE_ARCHIVE_DEB)
6869

70+
_BUILD/$(SOURCE_ARCHIVE_RPM):
71+
echo "############################"
72+
echo "Creating source archive for RPM from latest commit $(COMMIT) - $(SOURCE_ARCHIVE)"
73+
echo "############################"
74+
mkdir -p $(build_dir)
75+
git archive --format=tar.gz --prefix=$(NAME)-$(VERSION)/ v$(VERSION) >_BUILD/$(NAME)-$(VERSION).tar.gz
76+
77+
78+
rpm:
79+
echo "############################"
80+
echo "Creating rpm package for $(OS) $(DIST)"
81+
echo "Creating directory: ", $(build_dir)/$(NAME)-$(VERSION)
82+
echo "Extracting source archive..."
83+
echo "############################"
84+
#rm -rf $(build_dir)
85+
mkdir -p $(build_dir)
86+
dnf install -y fedora-packager rpmdevtools gcc cmake git clang-devel clang-tools-extra ccache yaml-cpp llvm-devel wget yaml-cpp-devel
87+
rpmdev-setuptree
88+
cp $(build_dir)/$(SOURCE_ARCHIVE_RPM) /root/rpmbuild/SOURCES/
89+
cp fedora/clang-uml.spec /root/rpmbuild/SPECS/
90+
rpmbuild -ba --define 'git_version ${VERSION}' /root/rpmbuild/SPECS/clang-uml.spec
91+
cp /root/rpmbuild/RPMS/x86_64/* $(build_dir)
92+
cp /root/rpmbuild/SRPMS/* $(build_dir)
93+
94+
6995
deb: _BUILD/$(SOURCE_ARCHIVE_DEB)
7096
echo "############################"
7197
echo "Creating deb source package for $(OS) $(DIST)"

packaging/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ dput ppa:bkryza/clang-uml *.changes
2525
## Fedora
2626

2727
```bash
28-
docker run -v $PWD:$PWD fedora:37 bash
29-
dnf install fedora-packager rpmdevtools gcc cmake git clang-devel clang-tools-extra ccache yaml-cpp llvm-devel wget yaml-cpp-devel
30-
rpmdev-setuptree
31-
cd /root/rpmbuild/SOURCES
32-
wget https://github.com/bkryza/clang-uml/archive/refs/heads/v0.3.0.zip
33-
cd /root/rpmbuild/SPECS/
34-
wget https://raw.githubusercontent.com/bkryza/clang-uml/v0.3.0/packaging/fedora/clang-uml.spec
35-
rpmbuild -ba clang-uml.spec
28+
cd clang-uml
29+
make fedora_36
30+
make fedora_37
31+
find packaging/_BUILD/fedora
3632
```
3733

3834
## Anaconda

packaging/fedora/clang-uml.spec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
# %define git_version %(git describe --tags --always --abbrev=7)
21
%define _unpackaged_files_terminate_build 0
32

43
Name: clang-uml
5-
Version: 0.3.0
4+
Version: %{?git_version}
65
Release: 1%{?dist}
76
Summary: C++ UML diagram generator based on Clang
87
License: ASL 2.0
98
URL: https://github.com/bkryza/clang-uml
10-
Source0: https://github.com/bkryza/clang-uml/archive/refs/heads/v%{version}.zip
9+
Source0: clang-uml-%{version}.tar.gz
1110

1211
BuildRequires: cmake
1312
BuildRequires: git
@@ -61,7 +60,7 @@ fi
6160
%files
6261
%{_bindir}/clang-uml
6362

64-
%doc CHANGELOG.md README.md AUTHORS.md
63+
%doc CHANGELOG.md README.md AUTHORS.md LICENSE.md
6564
%license LICENSE.md
6665

6766
%changelog

0 commit comments

Comments
 (0)