Skip to content
Permalink
master/debian/…
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 239 lines (195 sloc) 9.39 KB
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
LSB_DISTRIBUTOR := $(shell lsb_release -is)
NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
VERSION := $(shell dpkg-parsechangelog \
| awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
REVISION := $(shell dpkg-parsechangelog \
| awk '$$1 == "Version:" { print $$2; }' | cut -d- -f2-)
DKMSFILES := module include config zfs.release.in META AUTHORS \
DISCLAIMER COPYRIGHT README.markdown
export SHLIB_MAJOR = 2
ifndef DEB_HOST_ARCH
DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
endif
ifndef KVERS
KVERS=$(shell uname -r | sed -e 's/-$(DEB_HOST_ARCH)//' -e 's/-[a-z].*//')
KARCH=$(shell uname -r | sed "s/.*-\([a-z].*\)/\1/")
endif
ifndef SPL
SPLSRC=/usr/src/spl-$(VERSION)
endif
CFG_OPTS=--with-linux=$(KSRC) \
--with-linux-obj=$(KOBJ) \
--with-spl=$(SPLSRC)
non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
PACKAGE=zfs
pmodules = $(PACKAGE)-modules-$(non_epoch_version)-$(KARCH)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
KIMGVER=$(shell dpkg -s linux-image-$(KVERS)-$(KARCH) | grep ^Version | sed 's/.*: //')
%:
dh $@ --with dkms --parallel
override_dh_prep-base-deb-files:
sed -e 's/##SHLIB_MAJOR##/$(SHLIB_MAJOR)/g' < debian/control.in > debian/control
for templ in $(wildcard $(CURDIR)/debian/*_SHLIB_MAJOR_*.in); do \
cat $$templ > `echo $$templ | sed -e 's/_SHLIB_MAJOR_/$(SHLIB_MAJOR)/g ; s/\.in$$//'`; \
done
for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
sed -e 's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(KARCH)/' \
< $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(KARCH)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
done
override_dh_auto_configure: override_dh_prep-base-deb-files
@# Embed the downstream version in the module.
@sed \
-e 's/^Version:.*/Version: $(VERSION)/' \
-e 's/^Release:.*/Release: $(REVISION)/' \
-i.orig META
touch .nogitrelease
@# Create the makefiles and configure script.
./autogen.sh
@# Build the userland and the modules
dh_auto_configure -- \
--with-config=user \
--bindir=/bin \
--sbindir=/sbin \
--libdir=/lib \
--with-udevdir=/lib/udev \
$(CFG_OPTS)
override_dh_auto_test:
# The dh_auto_test rule is disabled because
# `make check` cannot run in an unprivileged build environment.
override_dh_auto_install:
@# Install the utilities.
$(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
@# Get a bare copy of the source code for DKMS.
@# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
@# contain the userland sources. NB: Remove-userland-dist-rules.patch
$(MAKE) distdir
@# Install the DKMS source.
@# We only want the files needed to build the modules
mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
touch '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/.nogitrelease'
cp '$(CURDIR)/autogen.sh' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/'
( for d in include module config; do \
rm -Rf $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/$$d; \
done)
$(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
@# Hellish awk line:
@# * Deletes from configure.ac the parts not needed for building the kernel module
@# * It deletes from inside AC_CONFIG_FILES([]) everything except:
@# (Makefile$|include/|module/|*.release$)
@# * Takes care of spaces and tabs
awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
'$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
@# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
'$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
@# Sanity test
grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
@# Run autogen on the stripped source tree
cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
@# This shunt allows DKMS to install the Module.symvers and zfs_config.h
@# files to the ${dkms_tree} area through the POST_INSTALL directive.
echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
mkdir -p $(CURDIR)/debian/tmp/usr/lib
for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \
ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \
rm $${i}; \
done
mkdir -p $(CURDIR)/debian/tmp/usr/sbin
mv $(CURDIR)/debian/tmp/bin/*.py $(CURDIR)/debian/tmp/usr/sbin/
mkdir -p $(CURDIR)/debian/tmp/lib/systemd/system
mv $(CURDIR)/debian/tmp/usr/lib/systemd/system/* $(CURDIR)/debian/tmp/lib/systemd/system/
rmdir $(CURDIR)/debian/tmp/usr/lib/systemd/system
find '$(CURDIR)/debian/tmp' -name '*~' | xargs --no-run-if-empty rm
# Fix the includes according to https://github.com/zfsonlinux/zfs/issues/2903
./debian/fix_includes-libspl.sh
@# Duplicate the dkms directory for module-assistant source package
install -d $(CURDIR)/debian/tmp/usr/src/modules
cp -r $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION) $(CURDIR)/debian/tmp/usr/src/modules/$(PACKAGE)
mkdir -p $(CURDIR)/debian/tmp/usr/src/modules/$(PACKAGE)/debian
cp debian/copyright debian/module/* \
$(CURDIR)/debian/tmp/usr/src/modules/$(PACKAGE)/debian/
sed 's/^zfs-linux /zfs-modules /' debian/changelog \
> $(CURDIR)/debian/tmp/usr/src/modules/$(PACKAGE)/debian/changelog
chmod 755 $(CURDIR)/debian/tmp/usr/src/modules/$(PACKAGE)/debian/rules
chown -R root.src $(CURDIR)/debian/tmp
find $(CURDIR)/debian/tmp/usr/src -type d | xargs chmod 755
find $(CURDIR)/debian/tmp/usr/src -type f -perm -100 | xargs chmod 755
find $(CURDIR)/debian/tmp/usr/src -type f -not -perm -100 | xargs chmod 644
chmod 775 $(CURDIR)/debian/tmp/usr/src/modules
cd $(CURDIR)/debian/tmp/usr/src && tar cf $(PACKAGE).tar modules
rm -Rf $(CURDIR)/debian/tmp/usr/src/modules
bzip2 $(CURDIR)/debian/tmp/usr/src/$(PACKAGE).tar
chmod 644 $(CURDIR)/debian/tmp/usr/src/$(PACKAGE).tar.bz2
install -d $(CURDIR)/debian/zfs-modules-source/usr/src
mv $(CURDIR)/debian/tmp/usr/src/$(PACKAGE).tar.bz2 $(CURDIR)/debian/zfs-modules-source/usr/src/
rm -Rf $(CURDIR)/debian/zfs-modules-source/usr/src/$(NAME)-$(VERSION)
override_dh_installinit:
@# Install systemd files
dh_systemd_enable -pzfsutils contrib/systemd/system/zfs.target
@# Install the /etc/default/zfs options file.
install -m 644 $(CURDIR)/contrib/shell-common/zfs $(CURDIR)/debian/zfsutils/etc/default/
chmod -x $(CURDIR)/debian/zfsutils/etc/default/zfs
@# Install the common init script.
install -m 644 $(CURDIR)/contrib/shell-common/zfs-functions $(CURDIR)/debian/zfsutils/etc/zfs/
@# Install the /etc/init.d/zfs-import script.
ifeq ($(LSB_DISTRIBUTOR),Debian)
dh_installinit -pzfsutils --onlyscripts --name=zfs-import \
--no-restart-on-upgrade --no-start -- start 07 S . stop 07 0 1 6 .
else
dh_installinit -pzfsutils --onlyscripts --name=zfs-import \
--no-restart-on-upgrade --no-start
endif
@# Install the /etc/init.d/zfs-mount script.
ifeq ($(LSB_DISTRIBUTOR),Debian)
@# Debian runs local mounts at sysv sequences [10..12] [08..09].
dh_installinit -pzfsutils --onlyscripts --name=zfs-mount \
--no-restart-on-upgrade --no-start -- start 02 2 3 4 5 . stop 06 0 1 6 .
else
dh_installinit -pzfsutils --onlyscripts --name=zfs-mount \
--no-restart-on-upgrade --no-start
endif
@# Install the ZED init file.
dh_installinit -pzfsutils --onlyscripts --name=zfs-zed \
--no-restart-on-upgrade --no-start -- start 07 2 3 4 5 . stop 08 0 1 6 .
@# Install the /etc/init.d/zfs-share script.
ifeq ($(LSB_DISTRIBUTOR),Debian)
@# Debian runs nfs-kernel-server at sysv sequence 17 01.
dh_installinit -pzfsutils --onlyscripts --name=zfs-share \
--no-restart-on-upgrade --no-start -- start 27 2 3 4 5 . stop 05 0 1 6 .
else ifeq ($(LSB_DISTRIBUTOR),Ubuntu)
@# Ubuntu runs nfs-kernel-server at sysv sequence 20 80.
@# iscsitarget at 20 20, and samba through upstart.
dh_installinit -pzfsutils --onlyscripts --name=zfs-share \
--no-restart-on-upgrade --no-start -- defaults 25 15
else
dh_installinit -pzfsutils --onlyscripts --name=zfs-share \
--no-restart-on-upgrade --no-start
endif
@# Add systemd snippets to post/pre inst/rm files
dh_systemd_start --no-restart-on-upgrade --no-start \
-pzfsutils contrib/systemd/system/zfs.target
@# Add a dummy (link to /dev/null) for zfs-import.service
ln -s /dev/null $(CURDIR)/debian/zfsutils/lib/systemd/system/zfs-import.service
override_dh_dkms:
dh_dkms -V $(VERSION)
override_dh_strip:
dh_strip --dbg-package=zfs-dbg
dh_strip --dbg-package=zfsutils
override_dh_auto_clean:
@dh_auto_clean
@if test -e META.orig; then mv META.orig META; fi
debconf-updatepo
override_dh_install:
find . -name lib*.la -delete
if [ ! -d debian/tmp/usr/lib/dracut -a -d debian/tmp/usr/share/dracut ]; then \
mv debian/tmp/usr/share/dracut debian/tmp/usr/lib/; \
fi
dh_installdocs -pzfsutils
dh_link -A
dh_install