From 0f237a437966a4d1024c1d721f70158d9144a449 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 27 Jul 2010 16:45:36 -0700 Subject: [PATCH] Add Debian and Slackware style packaging via alien The long term fix for Debian and Slackware style packaging is to add native support for building these packages. Unfortunately, that is a large chunk of work I don't have time for right now. That said it would be nice to have at least basic packages for these distributions. As a quick short/medium term solution I've settled on using alien to convert the RPM packages to DEB or TGZ style packages. The build system has been updated with the following build targets which will first build RPM packages and then convert them as needed to the target package type: make rpm: Create .rpm packages make deb: Create .deb packages make tgz: Create .tgz packages make pkg: Create the right package type for your distribution The solution comes with lot of caveats and your mileage may vary. But basically the big limitations are that the resulting packages: 1) Will not have the correct dependency information. 2) Will not include the kernel version in the release. 3) Will not handle all differences between distributions. But the resulting packages should be easy to install and remove from your system and take care of running 'depmod -a' and such. As I said at the top this is not the right long term solution. If any of the upstream distribution maintainers want to jump in and help do this right for their distribution I'd love the help. --- Makefile.am | 29 +++------- config/deb.am | 37 ++++++++++++ config/rpm.am | 35 ++++++++++-- config/tgz.am | 30 ++++++++++ config/zfs-build.m4 | 133 ++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + 6 files changed, 240 insertions(+), 25 deletions(-) create mode 100644 config/deb.am create mode 100644 config/tgz.am diff --git a/Makefile.am b/Makefile.am index 642254d32e..6984d5bd0b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,6 @@ include $(top_srcdir)/config/rpm.am +include ${top_srcdir}/config/deb.am +include ${top_srcdir}/config/tgz.am if CONFIG_USER USER_DIR = config etc man scripts lib cmd @@ -9,10 +11,11 @@ endif SUBDIRS = $(USER_DIR) $(KERNEL_DIR) AUTOMAKE_OPTIONS = foreign dist-zip -EXTRA_DIST = autogen.sh config/config.awk -EXTRA_DIST += zfs.spec.in zfs-modules.spec.in +EXTRA_DIST = autogen.sh zfs.spec.in zfs-modules.spec.in +EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am EXTRA_DIST += META DISCLAIMER COPYRIGHT GIT README.markdown EXTRA_DIST += OPENSOLARIS.LICENSE ZFS.RELEASE + noinst_HEADERS = zfs_config.h distclean-local:: @@ -48,22 +51,6 @@ etags: tags: ctags etags -srpm-modules: - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common - -srpm-utils: - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common - -srpm: srpm-modules srpm-utils - -rpm-modules: srpm-modules - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common - -rpm-utils: srpm-utils - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common - -rpm-modules: srpm-modules - -rpm-utils: srpm-utils - -rpm: rpm-modules rpm-utils +pkg: @DEFAULT_PACKAGE@ +pkg-modules: @DEFAULT_PACKAGE@-modules +pkg-utils: @DEFAULT_PACKAGE@-utils diff --git a/config/deb.am b/config/deb.am new file mode 100644 index 0000000000..f836a3cf1b --- /dev/null +++ b/config/deb.am @@ -0,0 +1,37 @@ +deb-local: + @(if test "${HAVE_DPKGBUILD}" = "no"; then \ + echo -e "\n" \ + "*** Required util ${DPKGBUILD} missing. Please install the\n" \ + "*** package for your distribution which provides ${DPKGBUILD},\n" \ + "*** re-run configure, and try again.\n"; \ + exit 1; \ + fi; \ + if test "${HAVE_ALIEN}" = "no"; then \ + echo -e "\n" \ + "*** Required util ${ALIEN} missing. Please install the\n" \ + "*** package for your distribution which provides ${ALIEN},\n" \ + "*** re-run configure, and try again.\n"; \ + exit 1; \ + fi) + +deb-modules: deb-local rpm-modules + name=${PACKAGE}-modules; \ + version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ + release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \ + arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \ + pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \ + pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \ + fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2; \ + $(RM) $$pkg1 $$pkg2 + +deb-utils: deb-local rpm-utils + name=${PACKAGE}; \ + version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ + arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \ + pkg1=$${name}-$${version}.$${arch}.rpm; \ + pkg2=$${name}-devel-$${version}.$${arch}.rpm; \ + pkg3=$${name}-test-$${version}.$${arch}.rpm; \ + fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2 $$pkg3; \ + $(RM) $$pkg1 $$pkg2 $$pkg3 + +deb: deb-modules deb-utils diff --git a/config/rpm.am b/config/rpm.am index 09a6e9cc10..c352fc582c 100644 --- a/config/rpm.am +++ b/config/rpm.am @@ -1,10 +1,37 @@ +srpm-modules: + $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common + +srpm-utils: + $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common + +srpm: srpm-modules srpm-utils + +rpm-modules: srpm-modules + $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common + +rpm-utils: srpm-utils + $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common + +rpm-modules: srpm-modules + +rpm: rpm-modules rpm-utils + rpm-local: + @(if test "${HAVE_RPMBUILD}" = "no"; then \ + echo -e "\n" \ + "*** Required util ${RPMBUILD} missing. Please install the\n" \ + "*** package for your distribution which provides ${RPMBUILD},\n" \ + "*** re-run configure, and try again.\n"; \ + exit 1; \ + fi; \ mkdir -p $(rpmbuild)/TMP && \ mkdir -p $(rpmbuild)/BUILD && \ mkdir -p $(rpmbuild)/RPMS && \ mkdir -p $(rpmbuild)/SRPMS && \ - mkdir -p $(rpmbuild)/SPECS && cp $(rpmspec) $(rpmbuild)/SPECS && \ - mkdir -p $(rpmbuild)/SOURCES && cp $(distdir).tar.gz $(rpmbuild)/SOURCES + mkdir -p $(rpmbuild)/SPECS && \ + cp $(rpmspec) $(rpmbuild)/SPECS && \ + mkdir -p $(rpmbuild)/SOURCES && \ + cp $(distdir).tar.gz $(rpmbuild)/SOURCES) srpm-common: dist rpmpkg=$(pkg)-$(ZFS_META_VERSION)-$(ZFS_META_RELEASE).src.rpm; \ @@ -14,7 +41,7 @@ srpm-common: dist rpmbuild="$$rpmbuild" \ rpmspec="$$rpmspec" \ rpm-local || exit 1; \ - /usr/bin/rpmbuild \ + $(RPMBUILD) \ --define "_tmppath $$rpmbuild/TMP" \ --define "_topdir $$rpmbuild" \ --define "build_src_rpm 1" \ @@ -31,7 +58,7 @@ rpm-common: rpmbuild="$$rpmbuild" \ rpmspec="$$rpmspec" \ rpm-local || exit 1; \ - /usr/bin/rpmbuild \ + $(RPMBUILD) \ --define "_tmppath $$rpmbuild/TMP" \ --define "_topdir $$rpmbuild" \ --define "dist %{nil}" \ diff --git a/config/tgz.am b/config/tgz.am new file mode 100644 index 0000000000..625d7a370f --- /dev/null +++ b/config/tgz.am @@ -0,0 +1,30 @@ +tgz-local: + @(if test "${HAVE_ALIEN}" = "no"; then \ + echo -e "\n" \ + "*** Required util ${ALIEN} missing. Please install the\n" \ + "*** package for your distribution which provides ${ALIEN},\n" \ + "*** re-run configure, and try again.\n"; \ + exit 1; \ + fi) + +tgz-modules: tgz-local rpm-modules + name=${PACKAGE}-modules; \ + version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ + release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \ + arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \ + pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \ + pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \ + fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2; \ + $(RM) $$pkg1 $$pkg2 + +tgz-utils: tgz-local rpm-utils + name=${PACKAGE}; \ + version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \ + arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch}`; \ + pkg1=$${name}-$${version}.$${arch}.rpm; \ + pkg2=$${name}-devel-$${version}.$${arch}.rpm; \ + pkg3=$${name}-test-$${version}.$${arch}.rpm; \ + fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2 $$pkg3; \ + $(RM) $$pkg1 $$pkg2 $$pkg3 + +tgz: tgz-modules tgz-utils diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index d40b6e53c9..58540c349f 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -140,3 +140,136 @@ AC_DEFUN([ZFS_AC_CONFIG], [ ZFS_AC_CONFIG_SCRIPT ]) + +dnl # +dnl # Check for rpm+rpmbuild to build RPM packages. If these tools +dnl # are missing it is non-fatal but you will not be able to build +dnl # RPM packages and will be warned if you try too. +dnl # +AC_DEFUN([ZFS_AC_RPM], [ + RPM=rpm + RPMBUILD=rpmbuild + + AC_MSG_CHECKING([whether $RPM is available]) + AS_IF([tmp=$($RPM --version 2>/dev/null)], [ + RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') + HAVE_RPM=yes + AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) + ],[ + HAVE_RPM=no + AC_MSG_RESULT([$HAVE_RPM]) + ]) + + AC_MSG_CHECKING([whether $RPMBUILD is available]) + AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ + RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') + HAVE_RPMBUILD=yes + AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) + ],[ + HAVE_RPMBUILD=no + AC_MSG_RESULT([$HAVE_RPMBUILD]) + ]) + + AC_SUBST(HAVE_RPM) + AC_SUBST(RPM) + AC_SUBST(RPM_VERSION) + + AC_SUBST(HAVE_RPMBUILD) + AC_SUBST(RPMBUILD) + AC_SUBST(RPMBUILD_VERSION) +]) + +dnl # +dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these +dnl # tools are missing it is non-fatal but you will not be able to build +dnl # DEB packages and will be warned if you try too. +dnl # +AC_DEFUN([ZFS_AC_DPKG], [ + DPKG=dpkg + DPKGBUILD=dpkg-buildpackage + + AC_MSG_CHECKING([whether $DPKG is available]) + AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ + DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') + HAVE_DPKG=yes + AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) + ],[ + HAVE_DPKG=no + AC_MSG_RESULT([$HAVE_DPKG]) + ]) + + AC_MSG_CHECKING([whether $DPKGBUILD is available]) + AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ + DPKGBUILD_VERSION=$(echo $tmp | \ + $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') + HAVE_DPKGBUILD=yes + AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) + ],[ + HAVE_DPKGBUILD=no + AC_MSG_RESULT([$HAVE_DPKGBUILD]) + ]) + + AC_SUBST(HAVE_DPKG) + AC_SUBST(DPKG) + AC_SUBST(DPKG_VERSION) + + AC_SUBST(HAVE_DPKGBUILD) + AC_SUBST(DPKGBUILD) + AC_SUBST(DPKGBUILD_VERSION) +]) + +dnl # +dnl # Until native packaging for various different packing systems +dnl # can be added the least we can do is attempt to use alien to +dnl # convert the RPM packages to the needed package type. This is +dnl # a hack but so far it has worked reasonable well. +dnl # +AC_DEFUN([ZFS_AC_ALIEN], [ + ALIEN=alien + + AC_MSG_CHECKING([whether $ALIEN is available]) + AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ + ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') + HAVE_ALIEN=yes + AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) + ],[ + HAVE_ALIEN=no + AC_MSG_RESULT([$HAVE_ALIEN]) + ]) + + AC_SUBST(HAVE_ALIEN) + AC_SUBST(ALIEN) + AC_SUBST(ALIEN_VERSION) +]) + +dnl # +dnl # Using the VENDOR tag from config.guess set the default +dnl # package type for 'make pkg': (rpm | deb | tgz) +dnl # +AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ + VENDOR=$(echo $ac_build_alias | cut -f2 -d'-') + + AC_MSG_CHECKING([default package type]) + case "$VENDOR" in + fedora) DEFAULT_PACKAGE=rpm ;; + redhat) DEFAULT_PACKAGE=rpm ;; + sles) DEFAULT_PACKAGE=rpm ;; + ubuntu) DEFAULT_PACKAGE=deb ;; + debian) DEFAULT_PACKAGE=deb ;; + slackware) DEFAULT_PACKAGE=tgz ;; + *) DEFAULT_PACKAGE=rpm ;; + esac + + AC_MSG_RESULT([$DEFAULT_PACKAGE]) + AC_SUBST(DEFAULT_PACKAGE) +]) + +dnl # +dnl # Default ZFS package configuration +dnl # +AC_DEFUN([ZFS_AC_PACKAGE], [ + ZFS_AC_RPM + ZFS_AC_DPKG + ZFS_AC_ALIEN + ZFS_AC_DEFAULT_PACKAGE +]) diff --git a/configure.ac b/configure.ac index 0d30f5e70a..7265a99db2 100644 --- a/configure.ac +++ b/configure.ac @@ -49,6 +49,7 @@ AC_PROG_LIBTOOL AM_PROG_AS ZFS_AC_LICENSE +ZFS_AC_PACKAGE ZFS_AC_CONFIG ZFS_AC_DEBUG