From e8aee2ab910672ac4ef3dcc8d31ca87511762b0b Mon Sep 17 00:00:00 2001 From: Lans Zhang Date: Thu, 20 Jul 2017 15:21:04 +0800 Subject: tpm2.0-tools: update to the latest and code style fixup Signed-off-by: Lans Zhang --- .../0001-Fix-build-failure-with-glib-2.0.patch | 39 +++++++++++ ...tools-use-dynamic-linkage-with-tpm2-abrmd.patch | 80 ---------------------- .../0002-Fix-build-failure-with-glib-2.0.patch | 39 ----------- ...tools-use-dynamic-linkage-with-tpm2-abrmd.patch | 65 ++++++++++++++++++ .../recipes-tpm/tpm2.0-tools/tpm2.0-tools_git.bb | 23 ++++--- 5 files changed, 117 insertions(+), 129 deletions(-) create mode 100644 meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-Fix-build-failure-with-glib-2.0.patch delete mode 100644 meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch delete mode 100644 meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-Fix-build-failure-with-glib-2.0.patch create mode 100644 meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch diff --git a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-Fix-build-failure-with-glib-2.0.patch b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-Fix-build-failure-with-glib-2.0.patch new file mode 100644 index 0000000..80aaa0d --- /dev/null +++ b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-Fix-build-failure-with-glib-2.0.patch @@ -0,0 +1,39 @@ +From 1f8d526bad6a0317bde32a0278fbabe2492e7c62 Mon Sep 17 00:00:00 2001 +From: Lans Zhang +Date: Thu, 20 Jul 2017 14:51:34 +0800 +Subject: [PATCH] Fix build failure with glib-2.0 + +Signed-off-by: Lans Zhang +--- + Makefile.am | 2 +- + configure.ac | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index c40c24b..2f4fa3e 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -35,7 +35,7 @@ ACLOCAL_AMFLAGS = -I m4 + INCLUDE_DIRS = -I$(srcdir)/src -I$(srcdir)/lib + LIB_COMMON := lib/libcommon.a + +-AM_CFLAGS := $(INCLUDE_DIRS) $(TPM20_TSS_CFLAGS) $(EXTRA_CFLAGS) $(TCTI_TABRMD_CFLAGS) $(CRYPTO_CFLAGS) ++AM_CFLAGS := $(INCLUDE_DIRS) $(GLIB_CFLAGS) $(TPM20_TSS_CFLAGS) $(EXTRA_CFLAGS) $(TCTI_TABRMD_CFLAGS) $(CRYPTO_CFLAGS) + AM_LDFLAGS := $(EXTRA_LDFLAGS) + + LDADD = $(LIB_COMMON) $(TPM20_TSS_LIBS) $(TCTI_SOCK_LIBS) $(TCTI_DEV_LIBS) $(TCTI_TABRMD_LIBS) $(CRYPTO_LIBS) +diff --git a/configure.ac b/configure.ac +index 8ef3b17..8db6922 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6,6 +6,7 @@ LT_INIT + AM_INIT_AUTOMAKE([foreign + subdir-objects]) + AC_CONFIG_FILES([Makefile]) ++PKG_CHECK_MODULES([GLIB], [glib-2.0]) + PKG_CHECK_MODULES([SAPI],[sapi]) + # disable libtcti-device selectively (enabled by default) + AC_ARG_WITH( +-- +2.7.5 + diff --git a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch deleted file mode 100644 index 8d91ca0..0000000 --- a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 9aee7b2bc400a336f0a938ce80eba51707662612 Mon Sep 17 00:00:00 2001 -From: Lans Zhang -Date: Mon, 19 Jun 2017 13:52:53 +0800 -Subject: [PATCH 1/2] tpm2-tools: use dynamic linkage with tpm2-abrmd - -tpm2-abrmd has huge dependencies and they are not necessary to be involved -in initramfs. - -Signed-off-by: Lans Zhang ---- - Makefile.am | 2 +- - lib/context-util.c | 22 ++++++++++++++++++++-- - 2 files changed, 21 insertions(+), 3 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index a3c43f8..68ba044 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -38,7 +38,7 @@ LIB_COMMON := lib/libcommon.a - AM_CFLAGS := $(INCLUDE_DIRS) $(TPM20_TSS_CFLAGS) $(EXTRA_CFLAGS) $(TCTI_TABRMD_CFLAGS) - AM_LDFLAGS := $(EXTRA_LDFLAGS) - --LDADD = $(LIB_COMMON) $(TPM20_TSS_LIBS) $(TCTI_SOCK_LIBS) $(TCTI_DEV_LIBS) $(TCTI_TABRMD_LIBS) -+LDADD = $(LIB_COMMON) $(TPM20_TSS_LIBS) $(TCTI_SOCK_LIBS) $(TCTI_DEV_LIBS) $(TCTI_TABRMD_LIBS) -ldl - - sbin_PROGRAMS = \ - tools/tpm2_create \ -diff --git a/lib/context-util.c b/lib/context-util.c -index 7de22ac..2ef181d 100644 ---- a/lib/context-util.c -+++ b/lib/context-util.c -@@ -38,6 +38,7 @@ - #include - #endif - #ifdef HAVE_TCTI_TABRMD -+#include - #include - #endif - -@@ -134,10 +135,27 @@ TSS2_TCTI_CONTEXT* - tcti_tabrmd_init (void) - { - TSS2_TCTI_CONTEXT *tcti_ctx; -+ TSS2_RC (*init)(TSS2_TCTI_CONTEXT *, size_t *); -+ /* -+ * Intend to "forget" the handle in order to make sure libtcti-tabrmd -+ * is unloaded along with the deconstructed functions. -+ */ -+ void *tabrmd_handle; - TSS2_RC rc; - size_t size; - -- rc = tss2_tcti_tabrmd_init(NULL, &size); -+ tabrmd_handle = dlopen("libtcti-tabrmd.so.0", RTLD_LAZY); -+ if (!tabrmd_handle) { -+ fprintf (stderr, -+ "Unable to find out the tabrmd tcti library\n"); -+ return NULL; -+ } -+ -+ init = dlsym(tabrmd_handle, "tss2_tcti_tabrmd_init"); -+ if (!init) -+ return NULL; -+ -+ rc = init(NULL, &size); - if (rc != TSS2_RC_SUCCESS) { - LOG_ERR ("Failed to get size for TABRMD TCTI context: 0x%" PRIx32, rc); - return NULL; -@@ -148,7 +166,7 @@ tcti_tabrmd_init (void) - strerror (errno)); - return NULL; - } -- rc = tss2_tcti_tabrmd_init (tcti_ctx, &size); -+ rc = init (tcti_ctx, &size); - if (rc != TSS2_RC_SUCCESS) { - LOG_ERR ("Failed to initialize TABRMD TCTI context: 0x%" PRIx32, rc); - free (tcti_ctx); --- -2.7.5 - diff --git a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-Fix-build-failure-with-glib-2.0.patch b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-Fix-build-failure-with-glib-2.0.patch deleted file mode 100644 index faeaf2a..0000000 --- a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-Fix-build-failure-with-glib-2.0.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 53f9b2f63c5370f4d269bf08d940cc8576fcbbf4 Mon Sep 17 00:00:00 2001 -From: Lans Zhang -Date: Mon, 19 Jun 2017 13:54:34 +0800 -Subject: [PATCH 2/2] Fix build failure with glib-2.0 - -Signed-off-by: Lans Zhang ---- - Makefile.am | 2 +- - configure.ac | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Makefile.am b/Makefile.am -index 68ba044..e792049 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -35,7 +35,7 @@ ACLOCAL_AMFLAGS = -I m4 - INCLUDE_DIRS = -I$(srcdir)/src -I$(srcdir)/lib - LIB_COMMON := lib/libcommon.a - --AM_CFLAGS := $(INCLUDE_DIRS) $(TPM20_TSS_CFLAGS) $(EXTRA_CFLAGS) $(TCTI_TABRMD_CFLAGS) -+AM_CFLAGS := $(INCLUDE_DIRS) $(GLIB_CFLAGS) $(TPM20_TSS_CFLAGS) $(EXTRA_CFLAGS) $(TCTI_TABRMD_CFLAGS) - AM_LDFLAGS := $(EXTRA_LDFLAGS) - - LDADD = $(LIB_COMMON) $(TPM20_TSS_LIBS) $(TCTI_SOCK_LIBS) $(TCTI_DEV_LIBS) $(TCTI_TABRMD_LIBS) -ldl -diff --git a/configure.ac b/configure.ac -index ce781ea..08fa81c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -6,6 +6,7 @@ LT_INIT - AM_INIT_AUTOMAKE([foreign - subdir-objects]) - AC_CONFIG_FILES([Makefile]) -+PKG_CHECK_MODULES([GLIB], [glib-2.0]) - PKG_CHECK_MODULES([SAPI],[sapi]) - # disable libtcti-device selectively (enabled by default) - AC_ARG_WITH( --- -2.7.5 - diff --git a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch new file mode 100644 index 0000000..994a25a --- /dev/null +++ b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools/0002-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch @@ -0,0 +1,65 @@ +From b328bb108cc926274ca20cc722d8d8ad91f19d60 Mon Sep 17 00:00:00 2001 +From: Lans Zhang +Date: Thu, 20 Jul 2017 15:19:51 +0800 +Subject: [PATCH] tpm2-tools: use dynamic linkage with tpm2-abrmd + +tpm2-abrmd has huge dependencies and they are not necessary to be involved +in initramfs. + +Signed-off-by: Lans Zhang +--- + lib/context-util.c | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +diff --git a/lib/context-util.c b/lib/context-util.c +index 7de22ac..9814548 100644 +--- a/lib/context-util.c ++++ b/lib/context-util.c +@@ -38,6 +38,7 @@ + #include + #endif + #ifdef HAVE_TCTI_TABRMD ++#include + #include + #endif + +@@ -134,10 +135,26 @@ TSS2_TCTI_CONTEXT* + tcti_tabrmd_init (void) + { + TSS2_TCTI_CONTEXT *tcti_ctx; ++ TSS2_RC (*init)(TSS2_TCTI_CONTEXT *, size_t *); ++ /* ++ * Intend to "forget" the handle in order to make sure libtcti-tabrmd ++ * is unloaded along with the deconstructed functions. ++ */ ++ void *tabrmd_handle; + TSS2_RC rc; + size_t size; + +- rc = tss2_tcti_tabrmd_init(NULL, &size); ++ tabrmd_handle = dlopen("libtcti-tabrmd.so.0", RTLD_LAZY); ++ if (!tabrmd_handle) { ++ LOG_ERR ("Unable to find out the tabrmd tcti library"); ++ return NULL; ++ } ++ ++ init = dlsym(tabrmd_handle, "tss2_tcti_tabrmd_init"); ++ if (!init) ++ return NULL; ++ ++ rc = init(NULL, &size); + if (rc != TSS2_RC_SUCCESS) { + LOG_ERR ("Failed to get size for TABRMD TCTI context: 0x%" PRIx32, rc); + return NULL; +@@ -148,7 +165,7 @@ tcti_tabrmd_init (void) + strerror (errno)); + return NULL; + } +- rc = tss2_tcti_tabrmd_init (tcti_ctx, &size); ++ rc = init (tcti_ctx, &size); + if (rc != TSS2_RC_SUCCESS) { + LOG_ERR ("Failed to initialize TABRMD TCTI context: 0x%" PRIx32, rc); + free (tcti_ctx); +-- +2.7.5 + diff --git a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools_git.bb b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools_git.bb index a914c3b..7135fd6 100644 --- a/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools_git.bb +++ b/meta-tpm2/recipes-tpm/tpm2.0-tools/tpm2.0-tools_git.bb @@ -1,36 +1,37 @@ SUMMARY = "Tools for TPM2." DESCRIPTION = "tpm2.0-tools" -SECTION = "tpm" +SECTION = "security/tpm" LICENSE = "BSD" LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=91b7c548d73ea16537799e8060cea819" DEPENDS += "tpm2.0-tss tpm2-abrmd openssl curl autoconf-archive pkgconfig" -RDEPENDS_${PN} += "libtss2 libtctidevice" -SRC_URI = " \ +PV = "2.1.0+git${SRCPV}" + +SRC_URI = "\ git://github.com/01org/tpm2.0-tools.git;branch=master;name=tpm2.0-tools;destsuffix=tpm2.0-tools \ file://ax_check_compile_flag.m4 \ file://ax_check_preproc_flag.m4 \ file://ax_check_link_flag.m4 \ - file://0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch \ - file://0002-Fix-build-failure-with-glib-2.0.patch \ + file://0001-Fix-build-failure-with-glib-2.0.patch \ + file://0002-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch \ " +SRCREV = "97306d6dc1fc5f3142c50efe3189bd46ff35b5a0" S = "${WORKDIR}/${BPN}" -SRCREV = "ada4c20d23d99b4b489c6c793e4132c1d5234b66" -PV = "2.0.0+git${SRCPV}" inherit autotools pkgconfig -EXTRA_OECONF += " \ +EXTRA_OECONF += "\ --with-tcti-device \ --without-tcti-socket \ --with-tcti-tabrmd \ " -EXTRA_OEMAKE += " \ +EXTRA_OEMAKE += "\ CFLAGS="${CFLAGS} -Wno-implicit-fallthrough" \ + LIBS=-ldl \ " do_configure_prepend() { @@ -40,9 +41,11 @@ do_configure_prepend() { cp "${WORKDIR}/ax_check_link_flag.m4" "${S}/m4" # execute the bootstrap script - currentdir=$(pwd) + currentdir="$(pwd)" cd "${S}" ACLOCAL="aclocal --system-acdir=${STAGING_DATADIR}/aclocal" \ ./bootstrap --force cd "${currentdir}" } + +RDEPENDS_${PN} += "libtss2 libtctidevice" -- cgit v1.2.3-54-g00ecf