From 0ddc5ca8ab7ad7b6534077760f81605eb0df7f5f Mon Sep 17 00:00:00 2001 From: Gavin Romig-Koch Date: Mon, 17 Aug 2009 15:42:23 -0400 Subject: RPM based install - add install rules to Makefile - get config file from /etc - add dist rules to Makefile - have fastback-check use fastback and fastback-unload-receipt from PATH - add spec file --- Makefile | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fastback-check | 4 +- fastback.cpp | 2 +- fastback.spec | 44 +++++++++++++++++++ 4 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 fastback.spec diff --git a/Makefile b/Makefile index d20c072..271ea76 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,15 @@ +NAME=fastback + +ifndef DESTDIR +DESTDIR=/ +endif + + +# +# RPM specific setup stuff +# + default: fastback fastback: fastback.o @@ -7,3 +18,124 @@ fastback: fastback.o fastback.o: fastback.cpp g++ -g -c -o $$(curl-config --cflags) $@ $< +install: + install -d $(DESTDIR)/bin/ $(DESTDIR)/etc + install fastback fastback-unload-receipt $(DESTDIR)/bin/ + install fastback.conf $(DESTDIR)/etc + +uninstall: + rm -rf $(DESTDIR)/bin/{fastback,fastback-unload-receipt} + rm -rf $(DESTDIR)/etc/fastback.conf + +clean: + rm -rf fastback.o fastback + + + + +# +# Maintainer +# + +# +# RPM Setup stuff +# + + +SPECFILE=$(NAME).spec + +## a base directory where we'll put as much temporary working stuff as we can +ifndef WORKDIR +WORKDIR := $(shell pwd) +endif +## of course all this can also be overridden in your RPM macros file, +## but this way you can separate your normal RPM setup from your CVS +## setup. Override RPM_WITH_DIRS in ~/.cvspkgsrc to avoid the usage of +## these variables. +SRCRPMDIR ?= $(WORKDIR)/SRPMS +BUILDDIR ?= $(WORKDIR)/BUILD +RPMDIR ?= $(WORKDIR)/RPMS +MOCKDIR ?= $(WORKDIR) + +## SOURCEDIR is special; it has to match the CVS checkout directory, +## because the CVS checkout directory contains the patch files. So it basically +## can't be overridden without breaking things. But we leave it a variable +## for consistency, and in hopes of convincing it to work sometime. +ifndef SOURCEDIR +SOURCEDIR := $(shell pwd) +endif +ifndef SPECDIR +SPECDIR := $(shell pwd) +endif + +# --define "_builddir $(BUILDDIR)" \ + +ifndef RPM_DEFINES +RPM_DEFINES := --define "_sourcedir $(SOURCEDIR)" \ + --define "_specdir $(SPECDIR)" \ + --define "_srcrpmdir $(SRCRPMDIR)" \ + --define "_rpmdir $(RPMDIR)" +endif + +# Initialize the variables that we need, but are not defined +# the version of the package + +VER_REL := $(shell rpm $(RPM_DEFINES) -q --qf "%{VERSION} %{RELEASE}\n" --specfile $(SPECFILE)| head -1) + +ifndef NAME +$(error "You can not run this Makefile without having NAME defined") +endif +ifndef VERSION +VERSION := $(word 1, $(VER_REL)) +endif +# the release of the package +ifndef RELEASE +RELEASE := $(word 2, $(VER_REL)) +endif + +# RPM with all the overrides in place; you can override this in your +# .cvspkgsrc also, to use a default rpm setup +# the rpm build command line +ifndef RPM +RPM := rpmbuild +endif +ifndef RPM_WITH_DIRS +RPM_WITH_DIRS = $(RPM) $(RPM_DEFINES) +endif + +# +# Actual Maintainer rules +# + +TARFILES=fastback.cpp Makefile fastback.conf fastback-check test fastback-unload-receipt +TARFILENAME=$(NAME)-$(VERSION).tar.gz + +# This should be changed to build on dist, when I build a dist +$(TARFILENAME): $(SPECFILE) $(TARFILES) + rm -rf $(NAME)-$(VERSION) + mkdir $(NAME)-$(VERSION) + cp -r $(TARFILES) $(NAME)-$(VERSION) + tar zcf $@ $(NAME)-$(VERSION) + rm -rf $(NAME)-$(VERSION) + +dist: $(TARFILENAME) + +maintainer-clean: clean + rm -rf $(TARFILENAME) + +# +# RPM install +# + +rpm-ver-rel: + @echo $(VERSION) $(RELEASE) + +srpm: $(SPECFILE) $(NAME)-$(VERSION).tar.gz + $(RPM_WITH_DIRS) -bs $< + +rpm: $(SPECFILE) $(NAME)-$(VERSION).tar.gz + $(RPM_WITH_DIRS) -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log ; exit $${PIPESTATUS[0]} + +rpm-clean: maintainer-clean + rm -rf RPMS SRPMS rpmbuild + diff --git a/fastback-check b/fastback-check index 4d41532..4e8b549 100755 --- a/fastback-check +++ b/fastback-check @@ -23,7 +23,7 @@ else fi RECEIPT=GLRK-receipt -./fastback $DO_TICKET $DO_ENCRYPT $ORIG >$RECEIPT +fastback $DO_TICKET $DO_ENCRYPT $ORIG >$RECEIPT if [ ! -e $RECEIPT ]; then echo >&2 "Error: no such file $RECEIPT" @@ -50,7 +50,7 @@ cat $RECEIPT | while read FIRST REST ; do ./fetch-from-indus $FILE - ./unload-receipt $RECEIPT + fastback-unload-receipt $RECEIPT FETCHED=${FILE%.aes} diff --git a/fastback.cpp b/fastback.cpp index 5377121..747566f 100644 --- a/fastback.cpp +++ b/fastback.cpp @@ -573,7 +573,7 @@ main(int argc, char** argv) exit(2); } - if (parse_config("fastback.conf")) + if (parse_config("/etc/fastback.conf")) exit(2); if (fastback_conf_LOGFILE) diff --git a/fastback.spec b/fastback.spec new file mode 100644 index 0000000..f3a89a1 --- /dev/null +++ b/fastback.spec @@ -0,0 +1,44 @@ +Name: fastback +Version: 1 +Release: 1%{?dist} +Summary: File uploader, configureable file uploader + +Group: support +License: GPL +URL: http://fedorahosted.org/fastback +Source0: fastback-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +%description +Fastback is a command line tool to upload files to a ticketing system, or +other configurable URL (FTP,SCP,...). + +%prep +%setup -q + + +%build +make %{?_smp_mflags} + + +%install +rm -rf $RPM_BUILD_ROOT +make install DESTDIR=$RPM_BUILD_ROOT + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files +%defattr(-,root,root,-) +%doc +/bin/fastback +/bin/fastback-unload-receipt +/etc/fastback.conf + + +%changelog +* Mon Aug 17 2009 Gavin Romig-Koch 0.1-1 +- Initial version. + -- cgit