# # Copyright (C) 2008, Thomas Harding # # This Makefile allows to release versions of your package from # an anonymous CVS repository, # and upload them to whatever sftp server you like # # USAGE: "make upload VERSION=foo" # ! YOU NEED TO SET UP SOME VARIABLES BELOW # Required programs: # - ssh-agent # - sftp # - cvs (client) # - gpg # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither my name nor the names of the contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY ME AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL ME OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # ################################################################### # VARIABLES YOU NEED TO SET UP ################################################################### EDITOR=vi# something suitable to edit CHANGES file KEY=your_gpg_key_id # gpg --list-secret-keys PACKAGE=yourpakage CVS_ROOT=-d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/$(PACKAGE) # hack to always have the latest version, feel free to change that :) CVSVERSION="-D $$(date -d'+1day' '+%m/%d/%y')" # set to 1 for GNU projects with automatic upload only (not tested: I have not) AUTO=0 # SSH id key, server and path (for non-GNU projects) LOGIN=yourlogin IDENTITYFILE=$$HOME/.ssh/id_dsa SFTPSERVER=dl.sv.nongnu.org:/releases/ ###################################### # END OF VARIABLES ###################### # # TARGETS # download: $(PACKAGE)-$(VERSION) archive: $(PACKAGE)_$(VERSION).tar.gz.sig changes: .$(PACKAGE)_$(VERSION)_commitchanges upload: .$(PACKAGE)_$(VERSION)_upload clean: almostclean distclean: clean almostdistclean ####################### # # RULES # $(PACKAGE)_$(VERSION).tar.gz.sig: $(PACKAGE)-$(VERSION) echo $<-$(VERSION) tar --gzip -chf $<.tar.gz $< gpg -b --local-user $(KEY) $<.tar.gz gpg --verify $<.tar.gz.sig test $(AUTO) -eq 1 && \ echo "version: 1.1" > "$<.tar.gz.directive" \ || true test $(AUTO) -eq 1 && \ echo "rmsymlink: $(PACKAGE)-latest.tar.gz" >> "$<.tar.gz.directive"\ || true test $(AUTO) -eq 1 && \ echo "symlink: $<.tar.gz $(PACKAGE)-latest.tar.gz" >> "$<.tar.gz.directive" \ || true test $(AUTO) -eq 1 && \ echo "directory: $(PACKAGE)" >> "$<.tar.gz.directive" \ || true test $(AUTO) -eq 1 && \ echo "filename: $<.tar.gz" >> "$<.tar.gz.directive" \ || true test $(AUTO) -eq 1 && \ test -n "$(COMMENT)" && \ echo "comment: $(COMMENT)" >> "$<.tar.gz.directive" \ || true test $(AUTO) -eq 1 && \ gpg --clearsign --local-user $(KEY) $<.tar.gz.directive \ || true test $(AUTO) -eq 1 && \ rm $<.tar.gz.directive \ || true test $(AUTO) -eq 1 && \ gpg --verify $<.tar.gz.directive.asc \ || true $(PACKAGE): touch $(PACKAGE) .$(PACKAGE)_$(VERSION)_commitchanges: $(PACKAGE) if test -z "$(VERSION)" ; then \ echo "please run 'make VERSION=foo'"; \ false; \ fi test -d $(PACKAGE) && cd $(PACKAGE) && $(EDITOR) CHANGES || true if test -d $(PACKAGE) ; then \ cd $(PACKAGE) && cvs commit ;\ fi touch .$(PACKAGE)_$(VERSION)_commitchanges $(PACKAGE)-$(VERSION): $(PACKAGE) .$(PACKAGE)_$(VERSION)_commitchanges if test -z "$(VERSION)" ; then \ echo "please run 'make xxx VERSION=foo'"; \ false; \ fi cvs -z3 $(CVS_ROOT) export $(CVSVERSION) -d $<-$(VERSION) $< .$(PACKAGE)_$(VERSION)_upload: $(PACKAGE) $(PACKAGE)_$(VERSION).tar.gz.sig if test -z "$(VERSION)" ; then \ echo "please run 'make xxx VERSION=foo'"; \ false;\ fi echo progress > $<-$(VERSION)_batch echo put $<-$(VERSION).tar.gz >> $<-$(VERSION)_batch echo put $<-$(VERSION).tar.gz.sig >> $<-$(VERSION)_batch echo -rm $<-CURRENT.tar.gz >> $<-$(VERSION)_batch echo -rm $<-CURRENT.tar.gz.sig >> $<-$(VERSION)_batch echo symlink $<-$(VERSION).tar.gz $<-CURRENT.tar.gz >> $<-$(VERSION)_batch echo symlink $<-$(VERSION).tar.gz.sig $<-CURRENT.tar.gz.sig >> $<-$(VERSION)_batch echo '-chmod 664 *.tar.gz*' >> $<-$(VERSION)_batch echo quit >> $<-$(VERSION)_batch echo "to make upload working" echo "you must ensure that ssh-agent is active and shell configured" echo "see http://sial.org/howto/openssh/publickey-auth/" ssh-add -t 300 $(IDENTITYFILE) sftp \ -o "IdentityFile $(IDENTITYFILE)" \ -b $<-$(VERSION)_batch \ $(LOGIN)@$(SFTPSERVER)$< touch .$(PACKAGE)_$(VERSION)_upload almostclean: if test -z "$(VERSION)" ; then \ echo "please run 'make xxx VERSION=foo'"; \ false;\ fi rm -rf $(PACKAGE)-$(VERSION) rm -f .$(PACKAGE)_$(VERSION)_upload rm -f .$(PACKAGE)_$(VERSION)_commitchanges rm -f $(PACKAGE)-$(VERSION)_batch almostdistclean: if test -z "$(VERSION)" ; then \ echo "please run 'make xxx VERSION=foo'"; \ false;\ fi rm -f $(PACKAGE)-$(VERSION).tar.gz rm -f $(PACKAGE)-$(VERSION).tar.gz.sig rm -f $(PACKAGE)-$(VERSION).tar.gz.directive.asc