mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-29 12:42:50 +00:00
Make the support of RPM and DEB package formats conditional
If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
4df0a4d952
commit
28090bad1b
@ -98,6 +98,12 @@
|
||||
/* Defined to 1 if a C++11 compiler is used */
|
||||
#undef WITH_CXX11
|
||||
|
||||
/* compile the deb package support in abipkgdiff */
|
||||
#undef WITH_DEB
|
||||
|
||||
/* compile the rpm package support in abipkgdiff */
|
||||
#undef WITH_RPM
|
||||
|
||||
/* compile the zip archive support */
|
||||
#undef WITH_ZIP_ARCHIVE
|
||||
|
||||
|
55
configure.ac
55
configure.ac
@ -27,6 +27,18 @@ AC_SUBST(VERSION_MAJOR)
|
||||
AC_SUBST(VERSION_MINOR)
|
||||
AC_SUBST(VERSION_REVISION)
|
||||
|
||||
AC_ARG_ENABLE(rpm,
|
||||
AS_HELP_STRING([--enable-rpm=yes|no|auto],
|
||||
[enable the suppot of rpm in abipkgdiff (default is auto)]),
|
||||
ENABLE_RPM=$enableval,
|
||||
ENABLE_RPM=auto)
|
||||
|
||||
AC_ARG_ENABLE(deb,
|
||||
AS_HELP_STRING([--enable-rpm=yes|no|auto],
|
||||
[enable the suppot of deb in abipkgdiff (default is auto)]),
|
||||
ENABLE_DEB=$enableval,
|
||||
ENABLE_DEB=auto)
|
||||
|
||||
AC_ARG_ENABLE(zip-archive,
|
||||
AS_HELP_STRING([--enable-zip-archive=yes|no|auto],
|
||||
[enable bundling of TUs in zip archives (default is no)]),
|
||||
@ -110,6 +122,47 @@ if test x$HAS_MKDIR = xno; then
|
||||
AC_MSG_ERROR([could not find the program 'mkdir' installed])
|
||||
fi
|
||||
|
||||
dnl Check for the rpm2cpio and cpio programs
|
||||
if test x$ENABLE_RPM = xyes -o x$ENABLE_RPM = xauto; then
|
||||
AC_CHECK_PROG(HAS_RPM2CPIO, rpm2cpio, yes, no)
|
||||
AC_CHECK_PROG(HAS_CPIO, cpio, yes, no)
|
||||
|
||||
if test x$ENABLE_RPM = xauto; then
|
||||
if test x$HAS_RPM2CPIO = xyes -a x$HAS_CPIO = xyes; then
|
||||
ENABLE_RPM=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$ENABLE_RPM = xyes; then
|
||||
AC_DEFINE([WITH_RPM], 1, [compile the rpm package support in abipkgdiff])
|
||||
AC_MSG_NOTICE(rpm support in abipkgdiff is enabled);
|
||||
else
|
||||
AC_MSG_NOTICE(rpm support in abipkgdiff is disabled);
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_RPM, test x$ENABLE_RPM = xyes)
|
||||
|
||||
dnl Check for the dpkg program
|
||||
if test x$ENABLE_DEB = xauto -o x$ENABLE_DEB = xyes; then
|
||||
AC_CHECK_PROG(HAS_DPKG, dpkg, yes, no)
|
||||
|
||||
if test x$ENABLE_DEB = xauto; then
|
||||
if test x$HAS_DPKG = xyes; then
|
||||
ENABLE_DEB=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$ENABLE_DEB = xyes; then
|
||||
AC_DEFINE([WITH_DEB], 1, [compile the deb package support in abipkgdiff])
|
||||
AC_MSG_NOTICE(deb support in abipkgdiff is enabled);
|
||||
else
|
||||
AC_MSG_NOTICE(deb support in abipkgdiff is disabled);
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_DEB, test x$ENABLE_DEB = xyes)
|
||||
|
||||
dnl Check for dependency: libzip
|
||||
LIBZIP_VERSION=0.10.1
|
||||
|
||||
@ -270,6 +323,8 @@ AC_MSG_NOTICE([
|
||||
OPTIONAL FEATURES:
|
||||
Enable zip archives : ${ENABLE_ZIP_ARCHIVE}
|
||||
Use a C++-11 compiler : ${ENABLE_CXX11}
|
||||
Enable rpm support in abipkgdiff : ${ENABLE_RPM}
|
||||
Enable deb support in abipkgdiff : ${ENABLE_DEB}
|
||||
Generate html apidoc : ${ENABLE_APIDOC}
|
||||
Generate html manual : ${ENABLE_MANUAL}
|
||||
])
|
||||
|
@ -29,6 +29,8 @@
|
||||
/// The set of input files and reference reports to consider should be
|
||||
/// present in the source distribution.
|
||||
|
||||
// For package configuration macros.
|
||||
#include "config.h"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
@ -52,6 +54,7 @@ struct InOutSpec
|
||||
|
||||
static InOutSpec in_out_specs[] =
|
||||
{
|
||||
#ifdef WITH_RPM
|
||||
// Two RPM packages with debuginfo available and have ABI changes
|
||||
{
|
||||
"data/test-diff-pkg/dbus-glib-0.80-3.fc12.x86_64.rpm",
|
||||
@ -113,6 +116,9 @@ static InOutSpec in_out_specs[] =
|
||||
"data/test-diff-pkg/test-rpm-report-5.txt",
|
||||
"output/test-diff-pkg/test-rpm-report-5.txt"
|
||||
},
|
||||
#endif //WITH_RPM
|
||||
|
||||
#ifdef WITH_DEB
|
||||
// Two debian packages.
|
||||
{
|
||||
"data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb",
|
||||
@ -123,6 +129,7 @@ static InOutSpec in_out_specs[] =
|
||||
"data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt",
|
||||
"output/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt"
|
||||
},
|
||||
#endif // WITH_DEB
|
||||
// This should be the last entry.
|
||||
{0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
@ -34,6 +34,8 @@
|
||||
/// temporary directory , looks for the ELF binaries in there,
|
||||
/// compares their ABIs and emit a report about the changes.
|
||||
|
||||
// For package configuration macros.
|
||||
#include "config.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
@ -375,6 +377,8 @@ display_usage(const string& prog_name, ostream& out)
|
||||
<< " --help|-h display help message\n";
|
||||
}
|
||||
|
||||
#ifdef WITH_RPM
|
||||
|
||||
/// Extract an RPM package.
|
||||
///
|
||||
/// @param package_path the path to the package to extract.
|
||||
@ -417,6 +421,10 @@ extract_rpm(const string& package_path,
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // WITH_RPM
|
||||
|
||||
#ifdef WITH_DEB
|
||||
|
||||
/// Extract an Debian binary package.
|
||||
///
|
||||
/// @param package_path the path to the package to extract.
|
||||
@ -458,6 +466,8 @@ extract_deb(const string& package_path,
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // WITH_DEB
|
||||
|
||||
/// Erase the temporary directories created for the extraction of two
|
||||
/// packages.
|
||||
///
|
||||
@ -498,20 +508,32 @@ extract_package(const package& package)
|
||||
switch(package.type())
|
||||
{
|
||||
case abigail::tools_utils::FILE_TYPE_RPM:
|
||||
#ifdef WITH_RPM
|
||||
if (!extract_rpm(package.path(), package.extracted_dir_path()))
|
||||
{
|
||||
cerr << "Error while extracting package" << package.path() << "\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
cerr << "Support for rpm hasn't been enabled. Please consider "
|
||||
"enabling it at package configure time\n";
|
||||
return false;
|
||||
#endif // WITH_RPM
|
||||
break;
|
||||
case abigail::tools_utils::FILE_TYPE_DEB:
|
||||
#ifdef WITH_DEB
|
||||
if (!extract_deb(package.path(), package.extracted_dir_path()))
|
||||
{
|
||||
cerr << "Error while extracting package" << package.path() << "\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
cerr << "Support for deb hasn't been enabled. Please consider "
|
||||
"enabling it at package configure time\n";
|
||||
return false;
|
||||
#endif // WITH_DEB
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user