#! /usr/bin/make -f
FUSIONFORGE=FusionForge
-PKGNAME=gforge
+PKGDIR=gforge
+PKGNAME=$(shell head -1 $(PKGDIR)/debian/changelog | sed 's/ .*//')
PKGLETTER=$(shell echo $(PKGNAME) | cut -c1)
ORIGIN=debian.fusionforge.org
+BRANCH=$(shell [ "$(shell echo $(basename $(CURDIR)) | sed 's/.*runk.*/trunk/')" = "trunk" ] && echo svn || echo brc)
BUILDPLACE=$(CURDIR)/builder/buildplace
BUILDFILES=$(CURDIR)/builder/buildfiles
BUILDRESULT=$(CURDIR)/result
TARBALLS=$(CURDIR)/tarballs
APTCACHE=$(CURDIR)/builder/cache
DISTRIB=$(shell echo $(XDISTRIB) | cut -c2-)
-LOCALREPODEB=/var/www/debian-fusionforge
-LOCALREPOUBU=/var/www/ubuntu-fusionforge
+LOCALREPODEB=/var/www/debian-fusionforge-$(BRANCH)
+LOCALREPOUBU=/var/www/ubuntu-fusionforge-$(BRANCH)
+SIGNKEY=yes
DEBIANLIST=1lenny 2squeeze 3sid
DEBIANLISTP=1etch
DEBLIST=$(DEBIANLIST) $(DEBIANLISTP)
-UBUNTULIST=1hardy 1intrepid 1jaunty
+UBUNTULIST=1hardy 1intrepid 1jaunty 1karmic
UBUNTULISTP=1gutsy
UBULIST=$(UBUNTULIST) $(UBUNTULISTP)
# Try if a local mirror is available
-UBUNTUOP=$(shell wget -q -S http://localhost/ubuntu -O /dev/null && echo "--mirror http://localhost/ubuntu" || echo "--mirror http://archive.ubuntu.com/ubuntu") --debootstrap debootstrap
+LOCALMIRROR=http://localhost/ubuntu
+UBUNTUOP=$(shell wget -q -S http://localhost/ubuntu -O /dev/null && echo "--mirror $(LOCALMIRROR)" || echo "--mirror http://archive.ubuntu.com/ubuntu") --debootstrap debootstrap
+
+gfversion=$(shell head -1 $(PKGDIR)/debian/changelog | sed 's/.*(\(.*\)-[^-]*).*/\1/')
+in_svn_repo:= $(wildcard .svn/)
+ifeq ($(strip $(in_svn_repo)),)
+in_bzr_repo:= $(shell bzr info | grep parent | cut -d: -f2-)
+ifeq ($(strip $(in_bzr_repo)),)
+ svnrev=unknown
+else
+ svnrev=$(shell LANG=C svn info $(in_bzr_repo) | grep Revision | cut -d: -f2| sed 's/ //g')
+endif
+else
+ svnrev=$(shell LANG=C svn info | grep Revision | cut -d: -f2| sed 's/ //g')
+endif
+
+MINOR=-1
+MINOR=-$(BRANCH)$(svnrev)+$(XDISTRIB)
-gfversion=$(shell head -1 $(PKGNAME)/debian/changelog | sed 's/.*(\(.[^+-]*\).*).*/\1/')
-gfminor=$(shell head -1 $(PKGNAME)/debian/changelog | sed 's/.*(.[^+-]*[+-]\(.*\)).*/\1/')
-svnrev=$(shell LANG=C svn info | grep Revision | cut -d: -f2| sed 's/ //g')
-MINOR=-svn$(svnrev)+
+DEBUG=--debug
+DEBUG=
+DEBBUILDOPTS=--debbuildopts -sa
+ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
+
+UBUHOOK="--hookdir $(CURDIR)/hook/ubuntu"
+# Some doc found there http://wiki.debian.org/cowbuilder
+# Hook are not anymore necessary, but I keep as an example
+UBUHOOK="--components 'main universe' --debootstrapopts --exclude=udev,pcmciautils,initramfs-tools"
+UBUHOOK=--components "main universe" --hookdir $(CURDIR)/hook/ubuntu
+
+ORIGFILE=$(PKGNAME)_$(gfversion).orig.tar.gz
+DSCFILE=$(PKGNAME)_$(gfversion)$(MINOR).dsc
+PDSCFILE=$(PKGNAME)_$(gfversion)$(MINOR)+p.dsc
+CHANGEFILE=$(PKGNAME)_$(gfversion)$(MINOR)_$(ARCH).changes
+PCHANGEFILE=$(PKGNAME)_$(gfversion)$(MINOR)+p_$(ARCH).changes
+
+# Quite heavy version, but still requires to be root
+COWBUILDERCMD=cd $(BUILDPLACE) && dpkg-source -x $(BUILDFILES)/$(DSCFILE) ; cd $(BUILDPLACE)/$(PKGNAME)-$(gfversion) && pdebuild --pbuilder cowbuilder --buildresult $(BUILDRESULT) -- --basepath $(COWBUILDERBASE)/base-$(DISTRIB).cow --buildplace $(BUILDPLACE) --aptcache $(APTCACHE) ; rm -rf $(BUILDPLACE)/$(PKGNAME)-$(gfversion)
+# This one is with sudo and probably faster
+COWBUILDERCMD=sudo /usr/sbin/cowbuilder --build --basepath $(COWBUILDERBASE)/base-$(DISTRIB).cow --configfile $(COWBUILDERBASE)/config $(BUILDFILES)/$(DSCFILE) $(DEBBUILDOPTS)
+
+# This one is with pbuilder
+PBUILDERCMD=cd $(BUILDFILES) && sudo /usr/sbin/pbuilder --build --basetgz $(PBUILDERTGZ)/base-$(DISTRIB).tgz --configfile $(PBUILDERTGZ)/config $(BUILDFILES)/$(PDSCFILE)
default: list
list:
@echo ======================================================================================
- @echo '= Available target are listed below ='
+ @echo '= Available targets are listed below ($(BRANCH))($(ARCH)) ='
@echo ======================================================================================
@cat Makefile.debian | grep '^.*:.*#$$' | sed 's/FUSIONFORGE/$(FUSIONFORGE)/' | sed 's/^\(.*:\).*#\(.*\)#$$/\1 \2/'
@echo ======================================================================================
#
# Simple targets
#
+#:======== Debian Builds ============#
lenny: # Simply build lenny packages #
- make -f Makefile.debian cowbuilddist XDISTRIB=1lenny
+ make cowbuilddeb DEBIANLIST=1lenny
+
+rlenny: # Make a lenny repository #
+ make repodeb DEBIANLIST=1lenny
+
+squeeze: # Simply build squeeze packages #
+ make cowbuilddeb DEBIANLIST=2squeeze
+
+rsqueeze: # Make a squeeze repository #
+ make repodeb DEBIANLIST=2squeeze
+
+sid: # Simply build sid packages #
+ make cowbuilddeb DEBIANLIST=3sid
+
+rsid: # Make a sid repository #
+ make repodeb DEBIANLIST=3sid
+
+#:======== Ubuntu Builds ============#
+intrepid: # Simply build intrepid packages #
+ make cowbuildubu UBUNTULIST=1intrepid
+
+rintrepid: # Make an intrepid repository #
+ make repoubu UBUNTULIST=1intrepid
-intrepid: # Simply build intrepid packages #
- make -f Makefile.debian cowbuilddist XDISTRIB=1intrepid DISTROOP="$(UBUNTUOP)" HOOK="--hookdir $(CURDIR)/hook/ubuntu"
+jaunty: # Simply build jaunty packages #
+ make cowbuildubu UBUNTULIST=1jaunty
+rjaunty: # Make a jaunty repository #
+ make repoubu UBUNTULIST=1jaunty
+karmic: # Simply build karmic packages #
+ make cowbuildubu UBUNTULIST=1karmic
+
+rkarmic: # Make a karmic repository #
+ make repoubu UBUNTULIST=1karmic
+
+#:======== Other and Multiple Builds ============#
documentor_path=/tmp
documentor_vers=phpdocumentor-1.3.0rc3
# FUSIONFORGE
#
-orig: $(TARBALLS)/$(PKGNAME)_$(gfversion).orig.tar.gz # Make FUSIONFORGE orig file #
+orig: $(TARBALLS)/$(ORIGFILE) # Make FUSIONFORGE orig file #
#
# PHPDOCUMENTOR
#
-phpdoc: phpdocumentor_get phpdocumentor_unpack $(documentor_path)/$(documentor_vers)/patched $(PKGNAME)/docs/phpdoc/docs # Get phpdocumentor, install phpdocumentor, build $(PKGNAME) phpdoc #
-
+phpdoc: phpdocumentor_get phpdocumentor_unpack $(documentor_path)/$(documentor_vers)/patched $(PKGDIR)/docs/phpdoc/docs # Get phpdocumentor, install phpdocumentor, build $(PKGNAME) phpdoc #
+
phpdocumentor_get:
[ ! -f $(documentor_path)/$(documentor_vers).tar.gz ] && cd $(documentor_path) && wget http://heanet.dl.sourceforge.net/sourceforge/phpdocu/$(documentor_vers).tar.gz || true
phpdocumentor_unpack:
[ ! -d $(documentor_path)/$(documentor_vers) ] && cd $(documentor_path) && tar xvzf $(documentor_vers).tar.gz || true
$(documentor_path)/$(documentor_vers)/patched:
- cd $(documentor_path)/ && patch -p2 < $(CURDIR)/$(PKGNAME)/docs/phpdoc/manageclass.patch && touch $(documentor_path)/$(documentor_vers)/patched
-$(PKGNAME)/docs/phpdoc/docs:
- cd $(PKGNAME)/docs/phpdoc/ && ./makedoc.sh
+ cd $(documentor_path)/ && patch -p2 < $(CURDIR)/$(PKGDIR)/docs/phpdoc/manageclass.patch && touch $(documentor_path)/$(documentor_vers)/patched
+$(PKGDIR)/docs/phpdoc/docs:
+ cd $(PKGDIR)/docs/phpdoc/ && ./makedoc.sh
#
# Build with cowbuilder or pbuilder
#
-DEBUG=--debug
-DEBUG=
-DEBBUILDOPTS=--debbuildopts -sa
-DEBBUILDOPTS=
-all: cowbuilddeb cowbuildubu # ***** Build all package for debian and ubuntu ***** #
+all: cleanorig cowbuilddeb cowbuildubu # ***** Build all package for debian and ubuntu ***** #
deploy: repodeb repoubu # ***** Deploy packages in Debian and Ubuntu repositories ***** #
cowbuildubu: # ***** This is the one to cowbuild ubuntu packages ***** #
@for dist in $(UBUNTULIST); do \
- make -f Makefile.debian cowbuilddist XDISTRIB=$$dist DISTROOP="$(UBUNTUOP)" HOOK="--hookdir $(CURDIR)/hook/ubuntu"; \
+ make -f Makefile.debian cowbuilddist XDISTRIB=$$dist DISTROOP="$(UBUNTUOP)" HOOK='$(UBUHOOK)' ; \
done
pbuilddeb: # pbuild debian packages (less recommended) #
make -f Makefile.debian pbuilddist XDISTRIB=$$dist DISTROOP="$(UBUNTUOP)" LOCALREPO=$(LOCALREPOUBU) ; \
done
-cowbuilddist: cowbuilderenv $(BUILDFILES) $(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)_i386.changes
- @echo "Building $(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)_i386.changes"
+cowbuilddist: cowbuilderenv $(BUILDFILES) $(BUILDRESULT)/$(CHANGEFILE)
+ @echo "Building $(BUILDRESULT)/$(CHANGEFILE)"
-pbuilddist: pbuilderenv $(BUILDFILES) $(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)+p_i386.changes
- @echo "Building $(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)+p_i386.changes"
+pbuilddist: pbuilderenv $(BUILDFILES) $(BUILDRESULT)/$(PCHANGEFILE)
+ @echo "Building $(BUILDRESULT)/$(PCHANGEFILE)"
-$(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)_i386.changes: $(BUILDFILES)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB).dsc
- cd $(BUILDFILES) ; sudo /usr/sbin/cowbuilder --build --basepath $(COWBUILDERBASE)/base-$(DISTRIB).cow --configfile $(COWBUILDERBASE)/config $(BUILDFILES)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB).dsc
+$(BUILDRESULT)/$(CHANGEFILE): $(BUILDFILES)/$(DSCFILE)
+ $(COWBUILDERCMD)
-$(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)+p_i386.changes: $(BUILDFILES)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)+p.dsc
- cd $(BUILDFILES) ; sudo /usr/sbin/pbuilder --build --basetgz $(PBUILDERTGZ)/base-$(DISTRIB).tgz --configfile $(PBUILDERTGZ)/config $(BUILDFILES)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)+p.dsc
+$(BUILDRESULT)/$(PCHANGEFILE): $(BUILDFILES)/$(PDSCFILE)
+ $(PBUILDERCMD)
-$(BUILDFILES)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB).dsc: $(BUILDFILES)/$(PKGNAME)_$(gfversion).orig.tar.gz
- cd $(PKGNAME) ; debclean
- find $(PKGNAME) -type f -or -type l | grep -v '/CVS/' | grep -v '/.svn/' | grep -v rpm-specific | grep -v docs/phpdoc/docs | grep -v ^./debian/ | cpio -pdumB $(BUILDFILES)/
+$(BUILDFILES)/$(DSCFILE): $(BUILDFILES)/$(ORIGFILE)
+ cd $(PKGDIR) ; debclean
+ find $(PKGDIR) -type f -or -type l | grep -v '/CVS/' | grep -v '/.svn/' | grep -v '/.testbox/' | grep -v rpm-specific | grep -v docs/phpdoc/docs | grep -v ^./debian/ | cpio -pdumB $(BUILDFILES)/
# Set version for given distrib
- cd $(BUILDFILES)/$(PKGNAME); dch -b -v $(gfversion)$(MINOR)$(XDISTRIB) -D UNRELEASED "This is $(DISTRIB) autobuild"
- perl -pi -e "s/UNRELEASED/$(DISTRIB)/" $(BUILDFILES)/$(PKGNAME)/debian/changelog
- cd $(BUILDFILES) ; dpkg-source -b $(PKGNAME)
- rm -rf $(BUILDFILES)/$(PKGNAME)
-
-$(BUILDFILES)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)+p.dsc: $(BUILDFILES)/$(PKGNAME)_$(gfversion).orig.tar.gz
- cd $(PKGNAME) ; debclean
- find $(PKGNAME) -type f -or -type l | grep -v '/CVS/' | grep -v '/.svn/' | grep -v rpm-specific | grep -v docs/phpdoc/docs | grep -v ^./debian/ | cpio -pdumB $(BUILDFILES)/
+ cd $(BUILDFILES)/$(PKGDIR); dch -b -v $(gfversion)$(MINOR) -D UNRELEASED "This is $(DISTRIB) autobuild"
+ perl -pi -e "s/UNRELEASED/$(DISTRIB)/" $(BUILDFILES)/$(PKGDIR)/debian/changelog
+ cd $(BUILDFILES) ; dpkg-source -b $(PKGDIR)
+ rm -rf $(BUILDFILES)/$(PKGDIR)
+
+$(BUILDFILES)/$(PDSCFILE): $(BUILDFILES)/$(ORIGFILE)
+ cd $(PKGDIR) ; debclean
+ find $(PKGDIR) -type f -or -type l | grep -v '/CVS/' | grep -v '/.svn/' | grep -v '/.testbox/' | grep -v rpm-specific | grep -v docs/phpdoc/docs | grep -v ^./debian/ | cpio -pdumB $(BUILDFILES)/
# Set version for given distrib
- cd $(BUILDFILES)/$(PKGNAME); dch -b -v $(gfversion)$(MINOR)$(XDISTRIB)+p -D UNRELEASED "This is $(DISTRIB) autobuild"
- perl -pi -e "s/UNRELEASED/$(DISTRIB)/" $(BUILDFILES)/$(PKGNAME)/debian/changelog
+ cd $(BUILDFILES)/$(PKGDIR); dch -b -v $(gfversion)$(MINOR)+p -D UNRELEASED "This is $(DISTRIB) autobuild"
+ perl -pi -e "s/UNRELEASED/$(DISTRIB)/" $(BUILDFILES)/$(PKGDIR)/debian/changelog
cd $(BUILDFILES) ; dpkg-source -b $(PKGNAME)
- rm -rf $(BUILDFILES)/$(PKGNAME)
+ rm -rf $(BUILDFILES)/$(PKGDIR)
-$(BUILDFILES)/$(PKGNAME)_$(gfversion).orig.tar.gz: $(TARBALLS)/$(PKGNAME)_$(gfversion).orig.tar.gz
- cp $(TARBALLS)/$(PKGNAME)_$(gfversion).orig.tar.gz $(BUILDFILES)
+$(BUILDFILES)/$(ORIGFILE): $(TARBALLS)/$(ORIGFILE)
+ cp $(TARBALLS)/$(ORIGFILE) $(BUILDFILES)
-$(TARBALLS)/$(PKGNAME)_$(gfversion).orig.tar.gz: $(TARBALLS)
- debclean; find $(PKGNAME) -type f -or -type l | grep -v '/CVS/' | grep -v '/.svn/' | grep -v rpm-specific | grep -v docs/phpdoc/docs | grep -v ^./debian/ | cpio -o -H ustar | gzip > $(TARBALLS)/$(PKGNAME)_$(gfversion).orig.tar.gz
-
+$(TARBALLS)/$(ORIGFILE): $(TARBALLS)
+ cd $(PKGDIR) ; debclean
+ find $(PKGDIR) -type f -or -type l | grep -v '/CVS/' | grep -v '/.svn/' | grep -v '/.testbox/' | grep -v rpm-specific | grep -v docs/phpdoc/docs | grep -v ^./debian/ | cpio -o -H ustar | gzip > $(TARBALLS)/$(ORIGFILE)
pbuilderenv: $(PBUILDERTGZ) $(PBUILDERTGZ)/base-$(DISTRIB).tgz
@echo "Ready for $(DISTRIB)"
cowbuilderenv: $(COWBUILDERBASE) $(COWBUILDERBASE)/base-$(DISTRIB).stamp
@echo "Ready for $(DISTRIB)"
+ sudo /usr/sbin/cowbuilder --update $(HOOK) --distribution $(DISTRIB) --basepath $(COWBUILDERBASE)/base-$(DISTRIB).cow --configfile $(COWBUILDERBASE)/config $(DISTROOP)
$(PBUILDERTGZ)/base-$(DISTRIB).tgz: $(PBUILDERTGZ)/config
sudo /usr/sbin/pbuilder --create --distribution $(DISTRIB) --basetgz $(PBUILDERTGZ)/base-$(DISTRIB).tgz --configfile $(PBUILDERTGZ)/config $(DISTROOP)
sudo apt-get install cowdancer
localrepo: $(LOCALREPO) $(LOCALREPO)/conf $(LOCALREPO)/conf/distributions
-
-reprepro: $(LOCALREPO)/pool/main/$(PKGLETTER)/$(PKGNAME)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB).dsc # Install in repository
-$(LOCALREPO)/pool/main/$(PKGLETTER)/$(PKGNAME)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB).dsc: $(BUILDRESULT)/$(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)_i386.changes
- cd $(BUILDRESULT); reprepro -Vb $(LOCALREPO) include $(DISTRIB) $(PKGNAME)_$(gfversion)$(MINOR)$(XDISTRIB)_i386.changes
+reprepro: $(LOCALREPO)/pool/main/$(PKGLETTER)/$(PKGNAME)/$(DSCFILE) # Install in repository
+
+$(LOCALREPO)/pool/main/$(PKGLETTER)/$(PKGNAME)/$(DSCFILE): $(BUILDRESULT)/$(CHANGEFILE)
+ cd $(BUILDRESULT); reprepro -Vb $(LOCALREPO) include $(DISTRIB) $(CHANGEFILE)
$(LOCALREPO)/conf/distributions:
for xdist in $(DISTRIBLIST) ; do \
echo "Origin: $(ORIGIN)" ; \
echo "Version: 4.7" ; \
echo "Description: My $(FUSIONFORGE) $$dist repository" ; \
- echo "SignWith: yes" ; \
+ echo "SignWith: $(SIGNKEY)" ; \
echo "" ; done >> $(LOCALREPO)/conf/distributions
$(LOCALREPO)/conf:
$(LOCALREPO):
sudo mkdir $(LOCALREPO)
sudo chown `id -u`.`id -g` $(LOCALREPO)
+
+clean: # Clean $(BUILDPLACE) $(BUILDFILES) $(TARBALLS) (intermediate files) #
+ rm -rf $(BUILDPLACE) $(BUILDFILES) $(TARBALLS)
+
+cleanenv: # Clean $(COWBUILDERBASE) $(PBUILDERTGZ) (chroots)#
+ rm -rf $(COWBUILDERBASE) $(PBUILDERTGZ)
+
+cleancache: # Clean $(APTCACHE) (apt cache) #
+ rm -rf $(APTCACHE)
+
+cleanorig: # Clean $(TARBALLS)/$(ORIGFILE) #
+ rm -f $(TARBALLS)/$(ORIGFILE)