Skip to content

Commit

Permalink
Merge pull request #18 from farzadghanei/fix-rpm-v0.1.1
Browse files Browse the repository at this point in the history
Fix RPM packaging, set version to 0.1.1
  • Loading branch information
farzadghanei authored Aug 17, 2020
2 parents 8cf5ea1 + 80794fd commit 32da573
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
SHELL = /bin/sh
makefile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
makefile_dir := $(dir $(makefile_path))
MUTE_LATEST_TAG := $(shell git tag --list | grep --only-matching --line-regexp --perl-regexp '\d+\.\d+\.\d+' | uniq | sort -V | tail -n 1)
MUTE_VERSION := $(MUTE_LATEST_TAG)
MUTE_VERSION := $(shell grep --perl-regex '^\s*const\s+Version\s+string' conf.go | grep --only-matching --perl-regexp '[\d\.]+')
TIMESTAMP_MINUTE := $(shell date -u +%Y%m%d%H%M)

# build
Expand Down Expand Up @@ -57,6 +56,8 @@ DEB_BUILD_GIT_BRANCH := pkg-deb-$(MUTE_DEB_VERSION)-$(TIMESTAMP_MINUTE)
# find rpm version from the spec file. latest version
# should be in the top tags, first matching 'Version: 0.1.0' and sed clears chars not in version
MUTE_RPM_VERSION := $(shell grep --only-matching --max-count 1 --line-regexp --perl-regexp "\s*Version\:\s*.+\s*" packaging/mute.spec | sed 's/[^0-9.]//g')
RPM_DEV_SRC_TGZ = $(RPM_DEV_TREE)/SOURCES/mute-$(MUTE_RPM_VERSION).tar.gz
RPM_DEV_SPEC = $(RPM_DEV_TREE)/SPECS/mute-$(MUTE_RPM_VERSION).spec

# command aliases
cowbuilder = env DISTRIBUTION=$(DIST) ARCH=$(ARCH) BASEPATH=/var/cache/pbuilder/base-$(DIST)-$(ARCH).cow cowbuilder
Expand Down Expand Up @@ -128,9 +129,10 @@ pkg-rpm: export prefix = /usr
# requires golang compiler > 1.13, and rpmdevtools package
pkg-rpm:
(go version | grep -q go1.1[3-9]) || (echo "please install Go lang tools > 1.13. aborting!" && /bin/false)
tar --exclude-vcs -zcf $(RPM_DEV_TREE)/SOURCES/mute-$(MUTE_RPM_VERSION).tar.gz .
cp packaging/mute.spec $(RPM_DEV_TREE)/SPECS/mute-$(MUTE_RPM_VERSION).spec
rpmbuild -bs $(RPM_DEV_TREE)/SPECS/mute-$(MUTE_RPM_VERSION).spec
rm -f $(RPM_DEV_SRC_TGZ)
tar --exclude-vcs -zcf $(RPM_DEV_SRC_TGZ) .
cp packaging/mute.spec $(RPM_DEV_SPEC)
rpmbuild -bs $(RPM_DEV_SPEC)
rpmbuild --rebuild $(RPM_DEV_TREE)/SRPMS/mute-$(MUTE_RPM_VERSION)*.src.rpm
find $(RPM_DEV_TREE)/RPMS -type f -readable -name 'mute-$(MUTE_RPM_VERSION)*.rpm' -exec mv '{}' $(PKG_DIST_DIR) \;

Expand All @@ -151,9 +153,20 @@ pkg-checksum:
&& find . -maxdepth 1 -readable -type f -name 'mute-$(MUTE_RPM_VERSION)*.rpm' \
-exec sha256sum '{}' \; >> $(PKG_CHECKSUM_NAME); fi

# sync version from source code to other files (docs, packaging, etc.)
sync-version:
@ # update first occurrence of version in man page source and regen the man page
@ sed -i 's/^:Version:.*/:Version: $(MUTE_VERSION)/;t' docs/man/mute.rst && $(MAKE) docs
@ # update first occurrence of version in RPM spec
@ sed -i 's/^Version:.*/Version: $(MUTE_VERSION)/;t' packaging/mute.spec
@ (grep --max 1 --only --perl-regexp '^mute.+\(.+\).+' packaging/debian/changelog | grep -q -F $(MUTE_VERSION)) || \
echo -e "\e[33m*** NOTE:\e[m version $(MUTE_VERSION) maybe missing from Debian changelog"
@ (grep --line-regexp '%changelog' -A 50 packaging/mute.spec | grep -q -F $(MUTE_VERSION)) || \
echo -e "\e[33m*** NOTE:\e[m version $(MUTE_VERSION) maybe missing from RPM changelog"

# required: python docutils
docs:
rst2man.py --input-encoding=utf8 --output-encoding=utf8 --strict docs/man/mute.rst docs/man/mute.1

.DEFAULT_GOAL := build
.PHONY: test build test-build install pkg-deb pkg-clean pkg-deb-setup pkg-tgz docs
.PHONY: test build test-build install pkg-deb pkg-clean pkg-deb-setup pkg-tgz pkg-checksum sync-version docs
2 changes: 1 addition & 1 deletion conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// Version is the program version
const Version string = "0.1.0"
const Version string = "0.1.1"
const ENV_CONFIG string = "MUTE_CONFIG"
const ENV_EXIT_CODES string = "MUTE_EXIT_CODES"
const ENV_STDOUT_PATTERN string = "MUTE_STDOUT_PATTERN"
Expand Down
2 changes: 1 addition & 1 deletion docs/man/mute.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH MUTE 1 "2020-02-16" "0.1.0" "General Command Manuals"
.TH MUTE 1 "2020-02-16" "0.1.1" "General Command Manuals"
.SH NAME
MUTE \- runs other programs and prevents the output under configured criteria
.
Expand Down
2 changes: 1 addition & 1 deletion docs/man/mute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs other programs and prevents the output under configured criteria
:Author: Farzad Ghanei <[email protected]>
:Date: 2020-02-16
:Copyright: Copyright (c) 2019 Farzad Ghanei. mute is an open source project released under the terms of the MIT license.
:Version: 0.1.0
:Version: 0.1.1
:Manual section: 1
:Manual group: General Command Manuals

Expand Down
11 changes: 11 additions & 0 deletions packaging/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
mute (0.1.1-1) UNRELEASED; urgency=low

[ Farzad Ghanei ]

* Fix missing new line at the end of the help message (Closes: #15)
* Fix formatting issues in README
* Redo Debian packaging, support Debian buster, use gbp (Closes: #12)
* Add RPM packaging

-- Farzad Ghanei <[email protected]> Sun, 16 Aug 2020 12:20:40 +0200

mute (0.1.0-1) UNRELEASED; urgency=low

[ Farzad Ghanei ]
Expand Down
22 changes: 19 additions & 3 deletions packaging/mute.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: mute
Version: 0.1.0
Version: 0.1.1
Release: 1%{?dist}
Summary: Run other programs muting the output when configured

Expand All @@ -15,9 +15,15 @@ mute runs other programs and mutes the output under configured
conditions. A good use case is to keep cron jobs silenced and avoid receiving
emails for known conditions.

%prep
echo 'no prep needed!'

# go toolchain stores go build id in a different ELF note than GNU toolchain
# so RPM can't find the build id from the binaries after build.
# https://github.com/rpm-software-management/rpm/issues/367
%global _missing_build_ids_terminate_build 0
%define debug_package %{nil}

%prep
%setup -c -q

%build
%make_build
Expand All @@ -30,6 +36,10 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
cp -a docs/man/mute.1 $RPM_BUILD_ROOT/usr/share/man/man1/%{name}.1


%clean
rm -rf $RPM_BUILD_ROOT


%files
%license LICENSE
%doc README.rst
Expand All @@ -38,6 +48,12 @@ cp -a docs/man/mute.1 $RPM_BUILD_ROOT/usr/share/man/man1/%{name}.1


%changelog
* Sun Aug 16 2020 Farzad Ghanei <[email protected]> 0.1.1-1
- Fix missing new line at the end of the help message (Closes: #15)
- Fix formatting issues in README
- Redo Debian packaging, support Debian buster, use gbp (Closes: #12)
- Add RPM packaging

* Sun Jan 05 2020 Farzad Ghanei <[email protected]> 0.1.0-1
- Handle signals (Closes: #4)
- Use environment variables to configure current run
Expand Down

0 comments on commit 32da573

Please sign in to comment.