From ef78ef3792330dfa714a07127d90e74250abe032 Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Thu, 13 Jun 2019 21:23:09 +0300 Subject: [PATCH] Add installation of enterprise-numbers database Download and install the IANA PEN database (enterprise-numbers). The download is performed using either wget or curl, and the database is installed into @IANADIR@. Resolves ipmitool/ipmitool#11 Signed-off-by: Alexander Amelkin --- Makefile.am | 28 +++++++++++++++++++++++++++- configure.ac | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c809131..c018685 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,11 +41,37 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure configure-stamp \ $(distdir).tar.gz $(distdir).tar.bz2 SUBDIRS = lib src include doc contrib control +IANA_PEN = http://www.iana.org/assignments/enterprise-numbers dist-hook: cp control/ipmitool.spec $(distdir) -install-data-local: +.PHONY: install-pen-database + +if DOWNLOAD + +enterprise-numbers: + @echo Downloading IANA PEN database... + @$(DOWNLOAD) "$(IANA_PEN)" > tmpfile.$$PPID || {\ + echo "FAILED to download the IANA PEN database"; \ + rm tmpfile.$$PPID; \ + false; \ + } + @mv tmpfile.$$PPID $@ + +install-pen-database: enterprise-numbers + mkdir -m 755 -p $(IANADIR) + $(INSTALL_DATA) $< -t $(IANADIR)/ + +else + +install-pen-database: + @echo "*** NOT installing the IANA PEN database." + @echo "*** Don't know how to download it." + +endif + +install-data-local: install-pen-database mkdir -p $(DESTDIR)$(DOCDIR) $(INSTALL_DATA) $(DOCLIST) $(DESTDIR)$(DOCDIR) diff --git a/configure.ac b/configure.ac index 6e01d4f..9448a44 100644 --- a/configure.ac +++ b/configure.ac @@ -18,6 +18,8 @@ AC_PROG_LN_S AC_PROG_MAKE_SET AC_CHECK_PROG([RPMBUILD], [rpmbuild], [rpmbuild], [rpm]) AC_CHECK_PROG([SED], [sed], [sed]) +AC_CHECK_PROG([WGET], [wget], [wget]) +AC_CHECK_PROG([CURL], [curl], [curl]) AC_HEADER_STDC AC_CHECK_HEADERS([stdlib.h string.h sys/ioctl.h sys/stat.h unistd.h paths.h]) @@ -54,6 +56,23 @@ if test "x$exec_prefix" = "xNONE"; then exec_prefix="$prefix" fi +if test "x$WGET" = "x"; then + if test "x$CURL" = "x"; then + AC_MSG_WARN([** Neither wget nor curl could be found.]) + AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !]) + else + DOWNLOAD="$CURL -#" + AM_CONDITIONAL([DOWNLOAD], [true]) + fi +else + DOWNLOAD="$WGET -c -nd -O -" + AM_CONDITIONAL([DOWNLOAD], [true]) +fi + +AC_MSG_WARN([** Download is:]) +AC_MSG_WARN($DOWNLOAD) +AC_SUBST(DOWNLOAD, $DOWNLOAD) + dnl dnl set default option values dnl