debian-packaging-update-20080220
[openafs.git] / src / packaging / Debian / rules.in
old mode 100755 (executable)
new mode 100644 (file)
similarity index 52%
rename from src/packaging/Debian/rules
rename to src/packaging/Debian/rules.in
index 4de0775..086591b
@@ -1,10 +1,9 @@
 #!/usr/bin/make -f
-# Sample debian/rules that uses debhelper. 
+# Based on the sample debian/rules that uses debhelper. 
 # GNU copyright 1997 by Joey Hess.
-#
-# This version is for a hypothetical package that builds an
-# architecture-dependant package, as well as an architecture-independent
-# package.
+
+# Use quilt to manage patches.
+include /usr/share/quilt/quilt.make
 
 # Uncomment this to turn on verbose mode. 
 #export DH_VERBOSE=1
 # This has to be exported to make some magic below work.
 export DH_OPTIONS
 
+# Tell Autoconf the correct system types.
+DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+    SYSTEM = --build $(DEB_HOST_GNU_TYPE)
+else
+    SYSTEM = --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
+endif
+
+# Determine whether we're building with optimization.  This doesn't really
+# work at the moment due to upstream problems.
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
     DEBIAN_OPT_FLAGS = --disable-optimize --disable-lwp-optimize
     DEBIAN_KERN_FLAGS = --disable-kernel-optimize
@@ -20,23 +30,10 @@ else
     DEBIAN_KERN_FLAGS =
 endif
 
-ifndef KSRC
-    KSRC = /usr/src/linux
-endif
-ifndef KPKG_DEST_DIR
-    KPKG_DEST_DIR = ..
-endif
-KVERS := $(shell perl debian/kernel-version $(KSRC))
-export KSRC 
-export KVERS
-export KPKG_DEST_DIR
-
-SYS_NAME  := $(shell KSRC="$(KSRC)" KVERS="$(KVERS)" sh debian/sysname)
+SYS_NAME  := $(shell sh debian/sysname)
 
 package    = openafs
 srcpkg     = openafs-modules-source
-modulepkg := openafs-modules-$(KVERS)${INT_SUBARCH}
-moduledir := debian/$(modulepkg)/lib/modules/$(KVERS)/fs
 
 # These packages have lintian overrides.
 LINTIAN_PACKAGES = openafs-dbserver openafs-client openafs-fileserver
@@ -49,58 +46,68 @@ DOC_PACKAGES = libpam-openafs-kaserver openafs-dbserver openafs-fileserver \
 
 # These variable is used only by get-orig-source, which will normally only be
 # run by maintainers.
-VERSION   = 1.4.0
+VERSION   = @VERSION@
+DEBVERS   = @VERSION@.dfsg1
 UPSTREAM  = /afs/grand.central.org/software/openafs/$(VERSION)
 
-# Download the upstream source and do the repackaging that we have to do for
-# DFSG reasons.  This assumes AFS is mounted, as it's generally only used by
-# the package maintainers.
+# Download the upstream source, merge in the doc tarball, and do the
+# repackaging that we have to do for DFSG reasons.  This assumes AFS is
+# mounted, as it's generally only used by the package maintainers.
 get-orig-source:
        cp $(UPSTREAM)/openafs-$(VERSION)-src.tar.bz2 .
        tar xjf openafs-$(VERSION)-src.tar.bz2
        rm openafs-$(VERSION)-src.tar.bz2
+       cp $(UPSTREAM)/openafs-$(VERSION)-doc.tar.bz2 .
+       tar xjf openafs-$(VERSION)-doc.tar.bz2
+       rm openafs-$(VERSION)-doc.tar.bz2
        rm -r openafs-$(VERSION)/src/packaging/MacOS
+       rm -r openafs-$(VERSION)/src/platform/DARWIN
        rm -r openafs-$(VERSION)/src/WINNT
-       tar cf openafs_$(VERSION).orig.tar openafs-$(VERSION)
-       rm -r openafs-$(VERSION)
-       gzip -9 openafs_$(VERSION).orig.tar
+       rm openafs-$(VERSION)/src/afs/sysctl.h
+       rm openafs-$(VERSION)/src/util/fstab.c
+       mv openafs-$(VERSION) openafs_$(DEBVERS).orig
+       tar cf openafs_$(DEBVERS).orig.tar openafs_$(DEBVERS).orig
+       rm -r openafs_$(DEBVERS).orig
+       gzip -9 openafs_$(DEBVERS).orig.tar
 
 configure: configure-stamp
-configure-stamp:
+configure-stamp: patch
        @if test x"$(SYS_NAME)" = x"UNKNOWN" ; then exit 1 ; fi
        dh_testdir
-       afslogsdir=/var/log/openafs afslocaldir=/etc/openafs/server-local \
+       sh regen.sh
+       afslogsdir=/var/log/openafs afslocaldir=/var/lib/openafs/local \
            sh configure \
            --with-afs-sysname=$(SYS_NAME) --disable-kernel-module \
-           --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib \
-           --localstatedir=/var/lib --enable-supergroups \
-           --enable-largefile-fileserver --enable-debug --enable-lwp-debug \
-           $(DEBIAN_OPT_FLAGS)
+           --prefix=/usr --mandir=\$${prefix}/share/man \
+           --sysconfdir=/etc --libexecdir=/usr/lib \
+           --localstatedir=/var/lib --with-krb5-conf=/usr/bin/krb5-config \
+           --enable-supergroups --enable-largefile-fileserver \
+           --enable-bos-new-config \
+           --enable-debug --enable-lwp-debug \
+           $(DEBIAN_OPT_FLAGS) $(SYSTEM)
        chmod a+x src/libafs/make_kbuild_makefile.pl         
        touch configure-stamp
 
-build: configure-stamp build-stamp
+build: build-arch build-indep
+build-arch: configure-stamp build-stamp
+build-indep:
 build-stamp:
        dh_testdir
        mkdir -p $(CURDIR)/debian/tmp
        $(MAKE) install_nolibafs DESTDIR=$(CURDIR)/debian/tmp
-       chmod +x debian/afs-rootvol debian/afs-newcell debian/doc/build-man
-       cd debian/doc && ./build-man
+       chmod +x debian/afs-rootvol debian/afs-newcell
        touch build-stamp
 
-clean:
+clean: unpatch
        dh_testdir
        dh_testroot
-       rm -f build-stamp configure-stamp
-       rm -f build-modules-stamp configure-modules-stamp
-ifeq (Makefile,$(wildcard Makefile))
-       $(MAKE) distclean
-endif
-       rm -rf debian/doc/man1 debian/doc/man5 debian/doc/man8
+       rm -f build-stamp configure-stamp install-stamp
+       [ ! -f Makefile ] || $(MAKE) distclean
        dh_clean
 
-install: DH_OPTIONS=
-install: build
+install: install-stamp
+install-stamp: DH_OPTIONS=
+install-stamp: build-stamp
        dh_testdir
        dh_testroot
        dh_installdirs
@@ -130,8 +137,6 @@ install: build
            debian/libpam-openafs-kaserver/lib/security/pam_afs.krb.so
 
        install -d debian/openafs-dbserver/usr/share/man/man8
-       /usr/bin/docbook-to-man debian/pt_util.sgml \
-           >debian/openafs-dbserver/usr/share/man/man8/pt_util.8
        ( cd debian && pod2man --section 8 --center "Debian GNU/Linux" \
            afs-rootvol ) \
            >debian/openafs-dbserver/usr/share/man/man8/afs-rootvol.8
@@ -139,14 +144,52 @@ install: build
            afs-newcell ) \
            >debian/openafs-dbserver/usr/share/man/man8/afs-newcell.8
 
+       touch install-stamp
+
+# Rules for building the openafs-modules-source package.
+binary-source:
+       dh_testdir
+       dh_testroot
+       -rm -rf debian/$(srcpkg) debian/substvars
+       install -d debian/$(srcpkg)/usr/src/modules/$(package)
+       find . \( -name \*.o -o -path ./debian -o -path \*/.svn \
+           -o -path ./src/WINNT -o -path ./doc -o -path ./obj \
+           -o -path ./$(SYS_NAME) -o -path ./.pc \) -prune -o -print | \
+               cpio -admp debian/$(srcpkg)/usr/src/modules/$(package)
+       mkdir -p debian/$(srcpkg)/usr/src/modules/$(package)/debian
+       cp debian/changelog debian/copyright debian/module/* \
+           debian/$(srcpkg)/usr/src/modules/$(package)/debian/
+       chmod 755 debian/$(srcpkg)/usr/src/modules/$(package)/debian/rules
+       rm -f debian/$(srcpkg)/usr/src/modules/$(package)/*-stamp
+       cd debian/$(srcpkg)/usr/src/modules/$(package) && \
+           $(MAKE) distclean
+       -cd debian/$(srcpkg)/usr/src/modules/$(package) && \
+           rm -rf src/libafs/rx src/libafs/afs src/libafs/afsint
+       chown -R root.src debian/$(srcpkg)
+       find debian/$(srcpkg) -type d | xargs chmod 755
+       find debian/$(srcpkg) -type f -perm -100 | xargs chmod 755
+       find debian/$(srcpkg) -type f -not -perm -100 | xargs chmod 644
+       chmod 775 debian/$(srcpkg)/usr/src/modules
+       cd debian/$(srcpkg)/usr/src && \
+           tar cf $(package).tar modules && \
+           rm -r modules
+       gzip -9 debian/$(srcpkg)/usr/src/$(package).tar
+       chmod 644 debian/$(srcpkg)/usr/src/$(package).tar.gz
+
 # Build architecture-independent files here.  Pass -i to all debhelper
 # commands in this target to reduce clutter.
+#
+# Also install debian/openafs-client.NEWS in the openafs-modules-source
+# package.
 binary-indep: DH_OPTIONS=-i
-binary-indep: build install binary-source
+binary-indep: install-stamp binary-source
        dh_testdir
        dh_testroot
        dh_installchangelogs NEWS
-       dh_installdocs
+       install -m 644 debian/openafs-client.NEWS \
+           debian/$(srcpkg)/usr/share/doc/$(srcpkg)/NEWS.Debian
+       dh_installdocs -XAdminReference -XQuickStartWindows -Xwinnotes
+       dh_installexamples
        dh_link
        dh_compress
        dh_fixperms
@@ -157,8 +200,14 @@ binary-indep: build install binary-source
 
 # Build architecture-dependent files here.  Pass -a to all debhelper commands
 # in this target to reduce clutter.
+#
+# We would like to install debugging information for everything, but currently
+# OpenAFS's makefiles strip all binaries when installed except for the
+# fileserver and the volserver.  This is fixed in OpenAFS's development
+# branch.  Until that's released, only retain debugging information for the
+# fileserver and the volserver.
 binary-arch: DH_OPTIONS=-a
-binary-arch: build install
+binary-arch: install-stamp
        dh_testdir
        dh_testroot
        dh_installchangelogs NEWS
@@ -167,13 +216,12 @@ binary-arch: build install
        DH_OPTIONS= dh_installinit -popenafs-client -r -- defaults 25 18
        DH_OPTIONS= dh_installinit -popenafs-fileserver -r
        dh_link
-       dh_strip
+       dh_strip --dbg-package=openafs-dbg
        dh_compress
        dh_fixperms
        chmod 700 debian/openafs-client/var/cache/openafs
        chmod 700 debian/openafs-dbserver/var/lib/openafs/db
        chmod 700 debian/openafs-fileserver/etc/openafs/server
-       chmod 700 debian/openafs-fileserver/var/lib/openafs/cores
        dh_perl
        dh_installdeb
        dh_shlibdeps
@@ -183,99 +231,5 @@ binary-arch: build install
 
 binary: binary-indep binary-arch
 
-#####################  Building openafs-modules-source  ######################
-
-binary-source:
-       dh_testdir
-       dh_testroot
-       -rm -rf debian/$(srcpkg) debian/substvars
-       install -d debian/$(srcpkg)/usr/src/modules/$(package)
-       find . \( -name \*.o -o -path ./debian/$(srcpkg) -o -path \*/CVS \
-           -o -path \*/.svn -o -path ./src/WINNT  \
-           -o -path ./obj -o -path ./$(SYS_NAME)  \
-           -o \( -path ./debian/\* -type d \) \
-           -o -path ./debian/\*debhelper \) -prune -o -print | \
-               cpio -admp debian/$(srcpkg)/usr/src/modules/$(package)
-       cd debian/$(srcpkg)/usr/src/modules/$(package) && \
-           $(MAKE) -f debian/rules clean && \
-           mv debian/kern-sysname debian/sysname
-       -cd debian/$(srcpkg)/usr/src/modules/$(package) && \
-           rm -rf src/libafs/rx src/libafs/afs src/libafs/afsint
-       chown -R root.src debian/$(srcpkg)
-       find debian/$(srcpkg) -type d | xargs chmod 755
-       find debian/$(srcpkg) -type f -perm -100 | xargs chmod 755
-       find debian/$(srcpkg) -type f -not -perm -100 | xargs chmod 644
-       chmod 775 debian/$(srcpkg)/usr/src/modules
-       cd debian/$(srcpkg)/usr/src && \
-           tar cf $(package).tar modules && \
-           rm -r modules
-       gzip -9 debian/$(srcpkg)/usr/src/$(package).tar
-       chmod 644 debian/$(srcpkg)/usr/src/$(package).tar.gz
-
-####################  Module package support (make-kpkg)  ####################
-
-kdist_configure: configure-modules-stamp
-
-kdist_image: build-modules-stamp
-       $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary-modules
-       $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
-
-kdist: build-modules-stamp
-       $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary-modules
-       KSRC="$(KSRC)" KMAINT="$(KMAINT)" KEMAIL="$(KEMAIL)" \
-           sh -v debian/genchanges.sh
-       $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
-
-kdist_clean:
-       $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
-
-########################  Kernel module build rules  #########################
-
-configure-modules: configure-modules-stamp
-configure-modules-stamp:
-       @if test x"$(SYS_NAME)" = x"UNKNOWN" ; then exit 1 ; fi
-       @if test x"$(KVERS)" = x ; then \
-           echo 'No version in $(KSRC)/include/linux/version.h' >&2 ; \
-           exit 1 ; \
-       fi
-       sh debian/prep-modules $(KSRC)
-       sh configure --with-afs-sysname=$(SYS_NAME) \
-           --with-linux-kernel-headers=$(KSRC) --prefix=`pwd`/debian/tmp \
-           --enable-debug --enable-lwp-debug --enable-kernel-debug \
-           $(DEBIAN_OPT_FLAGS) $(DEBIAN_KERN_FLAGS)
-       touch configure-modules-stamp
-
-build-modules: build-modules-stamp
-build-modules-stamp: configure-modules-stamp
-       make only_libafs
-       touch build-modules-stamp
-
-install-modules: build-modules-stamp
-       dh_testdir
-       dh_testroot
-       dh_clean -k
-       cd src/libafs && make install
-       install -d -g root -o root -m 755 $(moduledir)
-       install -g root -o root -m 755 debian/tmp/lib/openafs/*o $(moduledir)/
-       if test -f $(moduledir)/openafs.o \
-               -a ! -f $(moduledir)/openafs.mp.o ; then \
-           ln $(moduledir)/openafs.o $(moduledir)/openafs.mp.o || exit 1 ; \
-       fi
-
-binary-modules: install-modules
-       dh_testdir
-       dh_testroot
-       dh_installchangelogs NEWS
-       dh_installdocs
-       dh_installmodules
-       dh_strip
-       dh_link
-       dh_compress
-       dh_fixperms
-       dh_installdeb
-       dh_gencontrol -- -v`cat debian/VERSION`
-       dh_md5sums
-       dh_builddeb --destdir="$(KPKG_DEST_DIR)"
-
-.PHONY: build clean binary-indep binary-arch binary install configure
-.PHONY: kdist_configure kdist_image kdist kdist_clean binary-source
+.PHONY: binary binary-arch binary-indep binary-source build build-arch
+.PHONY: build-indep clean configure install