Added spec and makefile for rpm builds
This commit is contained in:
81
Makefile
81
Makefile
@@ -1,10 +1,77 @@
|
|||||||
.PHONY: all
|
VERSION:=$(shell if [ -d .git ]; then bash -c 'gitversion.sh | grep "^MAJOR=" | cut -d = -f 2'; else source version.sh && echo $$MAJOR ; fi)
|
||||||
all:
|
RELEASE:=$(shell if [ -d .git ]; then bash -c 'gitversion.sh | grep "^BUILD=" | cut -d = -f 2'; else source version.sh && echo $$BUILD ; fi)
|
||||||
|
DISTFILE=./dist/shunit-$(VERSION)-$(RELEASE).tar.gz
|
||||||
|
SPECFILE=shunit.spec
|
||||||
|
SRPM=shunit-$(VERSION)-$(RELEASE).src.rpm
|
||||||
|
ifndef RHEL_VERSION
|
||||||
|
RHEL_VERSION=5
|
||||||
|
endif
|
||||||
|
RPM=shunit-$(VERSION)-$(RELEASE).noarch.rpm
|
||||||
|
|
||||||
install:
|
ifndef PREFIX
|
||||||
install lib/junit.sh /usr/lib/junit.sh
|
PREFIX=/
|
||||||
install lib/tunit.sh /usr/lib/tunit.sh
|
endif
|
||||||
install shunit /usr/bin/shunit
|
|
||||||
|
DISTFILE_DEPS=$(shell find . -type f | grep -Ev '\.git|\./dist/|$(DISTFILE)')
|
||||||
|
|
||||||
|
all: ./dist/$(RPM)
|
||||||
|
|
||||||
|
# --- PHONY targets
|
||||||
|
|
||||||
|
.PHONY: clean srpm rpm gitclean dist
|
||||||
|
clean:
|
||||||
|
rm -f $(DISTFILE)
|
||||||
|
rm -fr dist/shunit-$(VERSION)-$(RELEASE)*
|
||||||
|
|
||||||
|
dist: $(DISTFILE)
|
||||||
|
|
||||||
|
srpm: ./dist/$(SRPM)
|
||||||
|
|
||||||
|
rpm: ./dist/$(RPM) ./dist/$(SRPM)
|
||||||
|
|
||||||
|
gitclean:
|
||||||
|
git clean -df
|
||||||
|
|
||||||
|
# --- End phony targets
|
||||||
|
|
||||||
|
# This was borrowed from distiller, and I think it's to prevent version.sh
|
||||||
|
# from updating unnecessarily
|
||||||
|
version.sh:
|
||||||
|
if [ ! -d .git ] && [ -f version.sh ]; then echo "No git, keeping old version.sh" ; fi ; \
|
||||||
|
if [ ! -d .git ] && [ ! -f version.sh ]; then echo "No git and no version.sh, you're boned"; exit 1; fi ; \
|
||||||
|
if [ -d .git ] ; then \
|
||||||
|
bash ./gitversion.sh > tmpversion.sh && \
|
||||||
|
VERSIONSHA=$$(openssl sha1 version.sh | cut -d = -f 2) ; \
|
||||||
|
TMPVERSIONSHA=$$(openssl sha1 tmpversion.sh | cut -d = -f 2) ; \
|
||||||
|
if [ ! -e version.sh ] || [ "$$VERSIONSHA" != "$$TMPVERSIONSHA" ]; then \
|
||||||
|
mv tmpversion.sh version.sh; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
$(DISTFILE): version.sh
|
||||||
|
mkdir -p dist/
|
||||||
|
mkdir dist/shunit-$(VERSION)-$(RELEASE) || rm -fr dist/shunit-$(VERSION)-$(RELEASE)
|
||||||
|
rsync -aWH . --exclude=.git --exclude=dist ./dist/shunit-$(VERSION)-$(RELEASE)/
|
||||||
|
cd dist && tar -czvf ../$@ shunit-$(VERSION)-$(RELEASE)
|
||||||
|
|
||||||
|
./dist/$(SRPM): $(DISTFILE)
|
||||||
|
rm -fr ./dist/$(SRPM)
|
||||||
|
mock --buildsrpm --spec $(SPECFILE) --sources ./dist/ --resultdir ./dist/ --define "version $(VERSION)" --define "release $(RELEASE)"
|
||||||
|
|
||||||
|
./dist/$(RPM): ./dist/$(SRPM)
|
||||||
|
rm -fr ./dist/$(RPM)
|
||||||
|
mock -r epel-$(RHEL_VERSION)-noarch ./dist/$(SRPM) --resultdir ./dist/ --define "version $(VERSION)" --define "release $(RELEASE)"
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm /usr/lib/[tj]unit.sh /usr/bin/shunit
|
rm -f $(PREFIX)/usr/lib/shunit.sh
|
||||||
|
rm -f $(PREFIX)/usr/lib/tunit.sh
|
||||||
|
|
||||||
|
install:
|
||||||
|
mkdir -p $(PREFIX)/usr/bin
|
||||||
|
mkdir -p $(PREFIX)/usr/lib
|
||||||
|
install ./lib/shunit.sh $(PREFIX)/usr/lib/shunit.sh
|
||||||
|
install ./lib/tunit.sh $(PREFIX)/usr/lib/tunit.sh
|
||||||
|
|
||||||
|
MANIFEST:
|
||||||
|
echo /usr/lib/shunit.sh >> MANIFEST
|
||||||
|
echo /usr/lib/tunit.sh >> MANIFEST
|
||||||
|
|||||||
29
shunit.spec
Normal file
29
shunit.spec
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
%define __os_install_post %{nil}
|
||||||
|
Summary: Bash unit testing library for junit or tunit
|
||||||
|
Name: shunit
|
||||||
|
Version: %{version}
|
||||||
|
Release: %{release}
|
||||||
|
License: MIT
|
||||||
|
Vendor: Andrew Kesterson
|
||||||
|
Packager: Andrew Kesterson <andrew@aklabs.net>
|
||||||
|
Group: Administration Tools
|
||||||
|
Provides: %{name}
|
||||||
|
BuildArch: noarch
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
|
||||||
|
Source: %{name}-%{version}-%{release}.tar.gz
|
||||||
|
|
||||||
|
Requires: vocalocity-automation-stack
|
||||||
|
Requires: bash
|
||||||
|
Requires: Requires: cmdarg
|
||||||
|
|
||||||
|
%description
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %{buildroot}/usr/src
|
||||||
|
tar -zxvf %{_sourcedir}/%{name}-%{version}-%{release}.tar.gz
|
||||||
|
cd %{name}-%{version}-%{release}
|
||||||
|
PREFIX=%{buildroot} make install
|
||||||
|
PREFIX=%{buildroot} make MANIFEST
|
||||||
|
cp MANIFEST /tmp/
|
||||||
|
|
||||||
|
%files -f /tmp/MANIFEST
|
||||||
Reference in New Issue
Block a user