[Pkg-voip-commits] r5936 - in /tools/builder: ./ Makefile builder sources

tzafrir-guest at alioth.debian.org tzafrir-guest at alioth.debian.org
Sat Jul 12 20:09:45 UTC 2008


Author: tzafrir-guest
Date: Sat Jul 12 20:09:45 2008
New Revision: 5936

URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=5936
Log:
builder: rebuild pkg-voip into a local reprepro repository.

Added:
    tools/builder/
    tools/builder/Makefile
    tools/builder/builder   (with props)
    tools/builder/sources

Added: tools/builder/Makefile
URL: http://svn.debian.org/wsvn/pkg-voip/tools/builder/Makefile?rev=5936&op=file
==============================================================================
--- tools/builder/Makefile (added)
+++ tools/builder/Makefile Sat Jul 12 20:09:45 2008
@@ -1,0 +1,170 @@
+#
+#
+# pkg-voip builder.
+#
+# This Makefile and script is a mini-buildd for building packages off
+# the pkg-voip SVN repository. 
+#
+# Requirements:
+#
+#   reprepro pbuilder svn-buildpackage
+#
+# If building with pbuilder (the recommended way. building asterisk and
+# such without it on Etch is hopeless) pbuilder should be able to run
+# with 'sudo pbuilder'
+#
+# Usage:
+#
+# edit the file 'sources' to specify what packages exactly you want to
+# build. rem-out ones you don't want. The default included here is
+# "everything' . Then run:
+#
+#   make build_sources
+#
+# This will at first create a local pbuilder root tarball (if one does
+# not exist). It will then start building packages into a local reprepro
+# repository under repo/ .
+
+export ARCH		:= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+export BASE_DISTRO	= etch
+export LOCAL_DISTRO	= unstable
+
+export LOCAL_REPO	= $(PWD)/repo
+
+export BUILD_AREA	= build-area
+export PACKAGE		= $(shell head -n 1 package/debian/changelog | awk '{print $$1}')
+export DEBVERSION	= $(shell head -n 1 package/debian/changelog | sed -e 's/^[^(]*(\([^)]*\)).*/\1/' -e 's/^[^:]*://')
+export CHANGES_FILE	= $(BUILD_AREA)/$(PACKAGE)_$(DEBVERSION)_${ARCH}.changes
+export CD_DIR		= debian-cd
+
+MIRROR_HTTP		= http://ftp.de.debian.org/debian
+PBUILDER_CMD		= sudo pbuilder
+BUILDER			= ./builder
+
+PBUILDER_DEBUG		=
+BUILDROOT_TGZ		= $(LOCAL_REPO)/buildroot.tgz
+export PBUILDER_PARAMS	= --configfile $(PWD)/pbuilderrc $(PBUILDER_DEBUG)
+# /home is bind-mounted in our current pbuilder configuration
+# thus files from it are also availble inside the chroot builder.
+# However if you're not on boole, you'll have to play tricks
+# as your local root has just about zero write access to /home .
+
+SNAPSHOTS_SRC		= deb http://snapshot.debian.net/archive/2008/02/13/debian-security etch/updates main
+LOCAL_APT_SRC		= deb file://$(LOCAL_REPO) $(LOCAL_DISTRO) main|$(SNAPSHOTS_SRC)
+VERSIONS_DEB		= $(BUILD_AREA)/$(PACKAGE)-versions_$(DEBVERSION)_all.deb
+
+PACKAGE_LISTS		= task cd cd2 repo
+PACKAGE_DIR		= package
+DEST_PACKAGES_LISTS	= $(PACKAGE_LISTS:%=$(PACKAGE_DIR)/packages_%)
+PACKAGE_CONFIGS		= $(DEST_PACKAGES_LISTS) $(PACKAGE_DIR)/versions
+
+all:
+	@echo "make build_sources:    Rebuild local repository"
+	@echo "make build_repo:       Rebuild local repository (no pbuilder)"
+	@echo "  add PACKS=\"list of packages\" for a partial build".
+	@echo "make list:             List content of local repository ($(LOCAL_REPO)"
+	@echo "make rm-zaptel:        Remove zaptel packages from local repo."
+	@echo "make update_buildroot  Manually update the pbuilder's root tarball."
+
+everything: clean build merge cdrom
+
+# get the versions of all the packages from the repository
+# (and of the relevant distribution). Should update on any change to the
+# local repository (the 'build_source' target). TODO: sort out dependencies.
+$(PACKAGE_DIR)/versions: $(LOCAL_REPO)/dists/$(LOCAL_DISTRO)/Release
+	make listlocal | grep '^$(LOCAL_DISTRO)|main|$(ARCH):' | cut -d' ' -f 2-3 >$@
+
+# Substitute @X@ to the value of make environment variable X
+$(FINAL_REPO)/conf/distributions: distributions.in Makefile
+	mkdir -p $(@D)
+	perl -p < $< > $@ -e 's/@([^@]+)@/$$ENV{$$1}/'
+
+# Substitute @X@ to the value of make environment variable X
+$(FINAL_REPO)/conf/updates: updates.in Makefile
+	mkdir -p $(@D)
+	perl -p < $< > $@ -e 's/@([^@]+)@/$$ENV{$$1}/'
+
+PACKS_DIR=$(FINAL_REPO)/conf/packages
+
+$(PACKS_DIR)/$(FINAL_DISTRO).%.packages: $(VERSIONS_DEB)
+	mkdir -p $(@D)
+	ar p $< data.tar.gz | tar xOzf - ./usr/share/doc/rapid-versions/rapid_$* >$@
+
+# Substitute @X@ to the value of make environment variable X
+cd-conf: cd-conf.in Makefile
+	perl -p < $@.in > $@ -e 's/@([^@]+)@/$$ENV{$$1}/'
+
+buildconf: cd-conf $(FINAL_REPO)/conf/distributions $(FINAL_REPO)/conf/updates \
+  $(PACKS_DIR)/$(FINAL_DISTRO).cd2.packages     \
+  $(PACKS_DIR)/$(FINAL_DISTRO).cd.packages     \
+  $(PACKS_DIR)/$(FINAL_DISTRO).repo.packages
+	./tools/gen_updates $(FINAL_REPO) $(FINAL_DISTRO)
+
+$(LOCAL_REPO)/conf/distributions: local_distributions
+	mkdir -p $(@D)
+	perl -p < $< > $@ -e 's/@([^@]+)@/$$ENV{$$1}/'
+
+$(LOCAL_REPO)/conf/updates: 
+	mkdir -p $(@D)
+	touch $@
+
+localrepo: $(LOCAL_REPO)/stamp
+$(LOCAL_REPO)/stamp: $(LOCAL_REPO)/conf/updates $(LOCAL_REPO)/conf/distributions
+	# TODO: this target should provide an up-to-date repository.
+	# Currently it only guarantees a valid (possibly empty) one
+	reprepro -b $(LOCAL_REPO) update 
+	touch $@
+
+$(BUILDROOT_TGZ): pbuilderrc $(LOCAL_REPO)/stamp
+	$(PBUILDER_CMD) create $(PBUILDER_PARAMS)
+
+update_buildroot: $(BUILDROOT_TGZ)
+	$(PBUILDER_CMD) update $(PBUILDER_PARAMS)
+
+pbuilder_login: $(BUILDROOT_TGZ)
+	$(PBUILDER_CMD) login $(PBUILDER_PARAMS)
+
+build_sources: $(BUILDROOT_TGZ)
+	USE_PBUILDER=yes $(BUILDER) $(PACKS)
+
+build_repo: localrepo
+	$(BUILDER) $(PACKS)
+
+rm-zaptel:
+	reprepro -b $(LOCAL_REPO) remove $(LOCAL_DISTRO) \
+		zaptel zaptel-source libtonezone1 libtonezone-dev \
+		zaptel-firmware
+	reprepro -b $(LOCAL_REPO) retrack
+	reprepro -b $(LOCAL_REPO) deleteunreferenced
+	@echo "Did you also purge zaptel-firmware?????. Giving an error anyway."
+	exit 1
+
+# Should depend on Makefile. 
+# But I don't want to recreate the build root
+# on every little irrelevant Makefile change.
+pbuilderrc: 
+	#TODO: make this a templated file
+	echo '# generated file.Do not edit. Edit Makefile instead' >$@
+	echo BASETGZ=$(BUILDROOT_TGZ)          >>$@
+	echo BINDMOUNTS=$(LOCAL_REPO)          >>$@
+	echo DISTRIBUTION=$(BASE_DISTRO)       >>$@
+	echo MIRRORSITE=$(MIRROR_HTTP)         >>$@
+	echo "OTHERMIRROR=\"$(LOCAL_APT_SRC)\""  >>$@
+	echo DEBBUILDOPTS=\"-sa -uc -us\"      >>$@
+	echo HOOKDIR=\"$(PWD)/tools/hooks\"    >>$@
+
+createlocalrepo:
+	#@echo "Updating $(PACKAGE) version $(DEBVERSION) into distro $(LOCAL_DISTRO)... '$(CHANGES_FILE)'"
+	#reprepro -b $(LOCAL_REPO) --ignore=wrongdistribution include $(LOCAL_DISTRO) $(CHANGES_FILE)
+
+
+list:
+	@reprepro -b $(LOCAL_REPO) listfilter $(LOCAL_DISTRO) 'Package'
+
+clean: removepackage
+	rm -rf $(BUILD_AREA)
+
+distclean: clean
+	rm -rf $(LOCAL_REPO)
+
+.PHONY: clean distclean buildconf all listlocal update_buildroot localrepo

Added: tools/builder/builder
URL: http://svn.debian.org/wsvn/pkg-voip/tools/builder/builder?rev=5936&op=file
==============================================================================
--- tools/builder/builder (added)
+++ tools/builder/builder Sat Jul 12 20:09:45 2008
@@ -1,0 +1,181 @@
+#!/bin/sh
+
+set -e
+
+# For the 'local' repository:
+BASE_URL=http://server/svn/packs
+
+# we keep a place (on shared NFS) where all the tarballs are saved.
+# may be a useful optimization
+TARBALLS_DIR=/home/svn/tarballs
+BUILD_AREA=build-area
+
+# Variables set in the Makefile:
+# PBUILDER_PARAMS
+# ARCH
+# LOCAL_REPO
+# LOCAL_DISTRO
+REPREPRO="reprepro -b $LOCAL_REPO"
+
+say() {
+  echo >&2 "$0: $@"
+}
+
+mkdir -p $BUILD_AREA
+
+packages_filter='('`echo $* | tr ' ' '|'`')'
+
+get_new_version() {
+	new_rev="$1"
+	dpkg-parsechangelog | awk '/^Version:/{print $2}' | perl -p -e \
+		"s/[0-9]*\$/(\$&-1).'.'.$new_rev/e"
+}
+
+egrep $packages_filter sources | while read package repo branch rev args
+do
+  if [ "$package" = 'quit' ]; then 
+    say "echo Stopping build due to 'quit'"
+    exit 0
+  fi
+  if [ "$rev" = '-1' ]; then rev=''; fi 
+
+  case "$package" in '#'*|'') continue;; esac # ignore blanks and comments
+  rev_arg=''
+  if [ "$rev" != '' ]; then 
+    # TODO: this is the place to optionally fail a build with no explicit 
+    # rev number
+    rev_arg="-r $rev"; 
+  fi
+
+  # In case a package does not reside in the top level under components/ .
+  # Currently this is used for freepbx-modules-*
+  package_full="$package"
+  package=`echo $package_full| sed -e 's|.*/||'`
+
+  say "Checking $package"
+  
+  # don't build a package that is already in the repository
+  # when to build:
+  # * if no version was specificed: check if we have the latest in the 
+  #   specified branch
+  # * If revision was given: check that we have exactly that revision.
+  package_repo_ver=`$REPREPRO -T dsc list $LOCAL_DISTRO $package 2>/dev/null | awk '/\|source:/{print $3}'`
+  expected_package_version=`echo $package_repo_ver | sed -e 's/^.*\.\([^.]*$\)/\1/'`
+  if [ "$rev" != "" ] && [ "$rev" = "$expected_package_version" ]; then 
+    continue
+  fi
+  # Don't check the version of zaptel-modules. Zaptel's addition invalidates 
+  # old versions (see below).
+  if [ "$package" = 'zaptel-modules' ] && \
+    $REPREPRO listfilter $LOCAL_DISTRO Package | grep -q zaptel-modules
+  then
+    continue;
+  fi
+
+  case "$repo" in
+  local)           repo_base=$BASE_URL;;
+  debian-pkg-voip) repo_base=svn://svn.debian.org/pkg-voip;;
+  *) 
+    say "Error: unknown repository $repo (package $package). Aborting"
+    exit 1
+    ;;
+  esac
+  url_with_rev="$rev_arg $repo_base/$package_full/$branch"
+  #ver=`svn cat $url_with_rev/debian/changelog | head -n 1 | cut -d '(' -f 2' | cut -d - -f 1| cut -d ')' -f 1`
+  # IIRC the dir nameneeds tobe of the format '$packge-$version' . I don't 
+  # want to start a complicated parsing to get the version number. Let's just get
+  # it from the dir name.
+  svn_checkout_base=$BUILD_AREA/$package-svn
+  svn_checkout_dir=$svn_checkout_base/svn
+  
+  # Give us a clean start. There will be only one .changes file when we 
+  # finish building
+  rm -rf $svn_checkout_base
+  mkdir -p $svn_checkout_base
+  # Set the stage for svn-buildpackage:
+  ln -s . $svn_checkout_base/build-area
+  ln -s $TARBALLS_DIR $svn_checkout_base/tarballs
+  svn co -q $url_with_rev $svn_checkout_dir
+  # if we did not ask for a specific revision, get the revision number of current
+  if [ "$rev" = '' ]; then
+    rev=`svn info $svn_checkout_dir | awk -F: '/^Last Changed Rev: /{print $2}' | cut -d' ' -f2`
+    if  [ "$rev" = "$expected_package_version" ]; then
+      say "Skipping $package: revision exists in repository."
+      continue
+    fi
+  fi
+  if [ -x tools/hooks/$package/setup ]; then
+    tools/hooks/$package/setup $svn_checkout_dir $args
+  fi
+  
+  # Build:
+  origdir=$PWD
+  cd $svn_checkout_dir
+  case "$branch" in tags/*)
+    tag_ver=`echo $branch | sed -e 's|.*tags/||'`
+    if [ "$tag_ver" = `echo $package_repo_ver | sed -e 's/.*://'`'' ]; then
+      say "Skipping $package: tag exists in repository."
+      cd $origdir
+      continue
+    fi
+    ;; 
+    *)
+    dch "Revision: $rev, Branch: $branch"
+    new_version=`get_new_version $rev`
+    sed -i -e "1s/(\([^)]*\))/($new_version)/" debian/changelog
+    ;;
+  esac
+  full_version=`dpkg-parsechangelog| awk '/^Version:/{print $2}' | sed -e 's/.*://'`
+  version=`echo $full_version | cut -d- -f1`
+
+  # A backporting script:
+  for hook_name in $BASE_DISTRO $BASE_DISTRO.xorcom; do
+    hook=debian/backports/$hook_name
+    if [ -x $hook ]; then
+      $hook
+    fi
+  done
+
+  # svn-buildpackage prompts the user in case of a failure. let's provide 
+  # it with the answer:
+  tarball=../tarballs/${package}_$version.orig.tar.gz
+  if [ ! -r "$tarball" ] && echo $full_version | sed -e 's/.*_//' | grep -q -- - ; then
+    debian/rules get-orig-source
+  fi
+  if [ "$USE_PBUILDER" != '' ]
+  then
+    echo q | svn-buildpackage --svn-dont-clean --svn-dont-purge --svn-ignore-new \
+    --svn-builder="pdebuild $PBUILDER_PARAMS --buildresult $origdir/$svn_checkout_base -- --pkgname-logfile"
+  else
+    echo q | svn-buildpackage -rfakeroot -sa -uc -us --svn-dont-clean --svn-dont-purge --svn-ignore-new
+  fi
+  cd $origdir
+
+  # Commit:
+  changes_file=$svn_checkout_base/${package}_${full_version}_$ARCH.changes
+  # finished building. commit package to repository
+  if [ "$package" = 'zaptel-modules' ]; then
+    # commit the embedded packages rather than the dummy package
+    dummy_deb=$svn_checkout_base/zaptel-modules-dummy_${full_version}_all.deb
+    debs_base=$svn_checkout_base/debs
+    rm -rf $debs_base
+    dpkg -x $dummy_deb $debs_base
+    for changes_file in $debs_base/usr/share/zaptel/*.changes; do
+      $REPREPRO --ignore=wrongdistribution include $LOCAL_DISTRO $changes_file
+    done
+  else
+    $REPREPRO --ignore=wrongdistribution include $LOCAL_DISTRO $changes_file
+  fi
+  # Commiting a new version of zaptel invalidates zaptel-modules
+  if [ "$package" = 'zaptel' ]; then
+  	packs_to_remove=`$REPREPRO listfilter $LOCAL_DISTRO 'Package' | awk '/zaptel-modules/{print $2}'`
+	if [ "$packs_to_remove" != '' ]; then
+		$REPREPRO remove $LOCAL_DISTRO $packs_to_remove
+	fi
+  fi
+  
+  # TODO: update the buildroot after every package built??
+  if [ "$USE_PBUILDER" != '' ]; then
+    make update_buildroot
+  fi
+done

Propchange: tools/builder/builder
------------------------------------------------------------------------------
    svn:executable = *

Added: tools/builder/sources
URL: http://svn.debian.org/wsvn/pkg-voip/tools/builder/sources?rev=5936&op=file
==============================================================================
--- tools/builder/sources (added)
+++ tools/builder/sources Sat Jul 12 20:09:45 2008
@@ -1,0 +1,62 @@
+# sources specification file.
+#
+# It has three required fields and an optional one:
+#
+# name  repo  branch [revision]
+#
+# name::
+#   name of the package to build. This is normally a file under some
+#   subdirectory.
+#
+# repo::
+#   Repository to use. Currently the script only supports "local" which
+#   is some strange local SVN repository) and debian-pkg-voip . Other
+#   SVN repositories may be easily added.
+#
+# branch::
+#   branch / tag to use. Normally this is either 'trunk' or a specific
+#   tag. If this is a tag (that is: begins with 'tags/') the script
+#   knows that the version number is reliable and will not try to create
+#   a lower one.
+#
+# revision::
+#   Optionally: get some specific revision from the branch.
+#
+#zaptel		debian-pkg-voip	tags/1.2.12~dfsg-2
+#zaptel		debian-pkg-voip	tags/1.4.5~dfsg-1
+zaptel		debian-pkg-voip	trunk
+#zaptel		debian-pkg-voip	tags/1.4.7.1~dfsg-1
+zaptel-firmware	debian-pkg-voip	trunk
+#zaptel-firmware	debian-pkg-voip	trunk	-1	1.4.10.1.xpp.r5716
+libpri		debian-pkg-voip	trunk
+#libpri		debian-pkg-voip	tags/1.4.3-2
+#libpri-bristuff	local		trunk
+speex		debian-pkg-voip	tags/1.1.12-3
+#pwlib		debian-pkg-voip	tags/1.10.10-2
+#openh323	debian-pkg-voip	tags/1.18.0.dfsg-9
+#asterisk	debian-pkg-voip tags/1.4.18.1~dfsg-1
+asterisk	debian-pkg-voip trunk
+#asterisk1.2	local		 trunk
+asterisk-addons	debian-pkg-voip	trunk
+
+spandsp		debian-pkg-voip	trunk
+libsupertone	debian-pkg-voip	trunk
+libunucall	debian-pkg-voip	trunk
+
+# This little hack will be included separately. Anyway, there must be
+# better ways to rebuild modules. Half the complexity of the script is
+# special cases for building it.
+# zaptel-modules	local		branches/etch
+
+ari		debian-pkg-voip trunk
+op-panel	debian-pkg-voip trunk
+asterisk-gui	debian-pkg-voip	trunk
+
+freepbx		debian-pkg-voip	trunk
+freepbx-modules	debian-pkg-voip	trunk
+
+
+# Our local variation has also our key in. Maybe just add it in a
+# separate package:
+#debian-archive-keyring	local	trunk
+




More information about the Pkg-voip-commits mailing list