Skip to contentSkip to conversation

lxc: fixup 'download' template use

PATCH Applied Sinan Kaya 2 participants 3 messages Oct 11, 2018 – Oct 12, 2018

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

PATCH 1/2 lxc: fixup 'download' template use

From: Mark Asselstine <[email protected]>

We have a new dependency on 'mountpoint' which is now called in the download template script. We also hit an upstream bug due to improper use of 'mktemp', so we apply a patch to fix this and sent the fix upstream as well.

---
 ...ually-create-DOWNLOAD_TEMP-directory.patch | 39 +++++++++++++++++++
 recipes-containers/lxc/lxc_2.0.8.bb           |  2 +
 2 files changed, 41 insertions(+)
 create mode 100644 recipes-containers/lxc/files/templates-actually-create-DOWNLOAD_TEMP-directory.patch
recipes-containers/lxc/files/templates-actually-create-DOWNLOAD_TEMP-directory.patch new file +39 -0
new file mode 100644
index 0000000..2b1ab87
@@ -0,0 +1,39 @@
+From 1d83b86a9bf017257c068c662ec3bf52ec0cfe90 Mon Sep 17 00:00:00 2001
+From: Mark Asselstine <[email protected]>
+Date: Thu, 31 May 2018 16:21:45 -0400
+Subject: [PATCH] templates: actually create DOWNLOAD_TEMP directory
+
+The way 'mktemp' is currently used you will get a temp directory in
+$TMPDIR or '/tmp' and DOWNLOAD_TEMP will not be pointing to an actual
+directory. This will result in the wget operations failing and the
+container will fail to create:
+
+    ERROR: Failed to download http://....
+
+Instead we want to use the '-p' option for mktemp to set the base path
+and this will ensure that the temp directory is created in the correct
+location and DOWNLOAD_TEMP will be consistent with this location.
+
+Upstream-Status: Pending
+
+Signed-off-by: Mark Asselstine <[email protected]>
+---
+ templates/lxc-download.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/templates/lxc-download.in b/templates/lxc-download.in
+index f09475d..d6333ad 100644
+--- a/templates/lxc-download.in
++++ b/templates/lxc-download.in
+@@ -310,7 +310,7 @@ if ! type mktemp >/dev/null 2>&1; then
+     DOWNLOAD_TEMP=/tmp/lxc-download.$$
+     mkdir -p $DOWNLOAD_TEMP
+ else
+-    DOWNLOAD_TEMP=$(mktemp -d)
++    DOWNLOAD_TEMP="$(mktemp -p ${DOWNLOAD_TEMP} -d)"
+ fi
+ 
+ # Simply list images
+-- 
+2.19.0
+
recipes-containers/lxc/lxc_2.0.8.bb +2 -0
index c87b875..facad2e 100644
@@ -23,6 +23,7 @@ RDEPENDS_${PN} = " \
 		libidn \
 		gnutls \
 		nettle \
+		util-linux-mountpoint \
 "
 
 RDEPENDS_${PN}_append_libc-glibc = " glibc-utils"
@@ -38,6 +39,7 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
 	file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
 	file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
 	file://cgroups-work-around-issue-in-gcc-7.patch \
+	file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \
 	file://dnsmasq.conf \
 	"
 
Signature · 1 line
2.19.0
author
#1 lore raw

PATCH 2/2 lxc: use compiled tests instead of copying source building on target

From: Mark Asselstine <[email protected]>

The tests are already built when we do_compile so we only need to copy them to the ptest path and create a wrapper script to run them. This has the added benefit of reducing the size of the lxc package.

We have to manipulate the test sources some to remove gpg validation and a few other minor changes, none of which actually change what is being tested (notes are provided in the associated commit logs).

The following are the ptest results currently acheived:

BEGIN: /usr/lib/lxc/ptest
# Starting LXC ptest ###
./tests/lxc-test-apparmor SKIPPED
./tests/lxc-test-attach FAIL
./tests/lxc-test-automount PASS
./tests/lxc-test-autostart FAIL
./tests/lxc-test-cgpath PASS
./tests/lxc-test-cloneconfig PASS
./tests/lxc-test-clonetest PASS
./tests/lxc-test-concurrent PASS
./tests/lxc-test-console FAIL
./tests/lxc-test-containertests PASS
./tests/lxc-test-createconfig PASS
./tests/lxc-test-createtest FAIL
./tests/lxc-test-destroytest FAIL
./tests/lxc-test-device-add-remove PASS
./tests/lxc-test-get_item PASS
./tests/lxc-test-getkeys PASS
./tests/lxc-test-list PASS
./tests/lxc-test-locktests PASS
./tests/lxc-test-lxcpath PASS
./tests/lxc-test-may-control PASS
./tests/lxc-test-reboot PASS
./tests/lxc-test-saveconfig PASS
./tests/lxc-test-shutdowntest SKIPPED
./tests/lxc-test-snapshot PASS
./tests/lxc-test-startone PASS
./tests/lxc-test-utils PASS

Results:
PASSED = 19
FAILED = 5
SKIPPED = 2
(for details check individual test log in ./logs directory)

### LXC ptest complete ###

---
 ...tomake-ensure-VPATH-builds-correctly.patch | 26 -------
 recipes-containers/lxc/files/run-ptest        | 57 +++++++++++++-
 recipes-containers/lxc/files/runtest.patch    | 32 --------
 ...sybox-template-compatible-with-core-.patch | 60 +++++++++++++++
 ...alidate-when-using-download-template.patch | 74 +++++++++++++++++++
 .../files/tests-our-init-is-not-busybox.patch | 32 ++++++++
 recipes-containers/lxc/lxc_2.0.8.bb           | 13 ++--
 7 files changed, 228 insertions(+), 66 deletions(-)
 delete mode 100644 recipes-containers/lxc/files/automake-ensure-VPATH-builds-correctly.patch
 delete mode 100644 recipes-containers/lxc/files/runtest.patch
 create mode 100644 recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch
 create mode 100644 recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch
 create mode 100644 recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch
recipes-containers/lxc/files/automake-ensure-VPATH-builds-correctly.patch deleted +0 -26
deleted file mode 100644
index 61c0e29..0000000
@@ -1,26 +0,0 @@
-From fe23085d9a40d6d78387d9ce8ddb65785fe8d6e5 Mon Sep 17 00:00:00 2001
-From: Bogdan Purcareata <[email protected]>
-Date: Thu, 2 Oct 2014 18:31:50 -0400
-Subject: [PATCH] automake: ensure VPATH builds correctly
-
-Signed-off-by: Bogdan Purcareata <[email protected]>
----
- src/tests/Makefile.am |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
-index d74c10d..6225f78 100644
---- a/src/tests/Makefile.am
-+++ b/src/tests/Makefile.am
-@@ -66,7 +66,7 @@ buildtest-TESTS: $(TESTS)
- install-ptest:
- 	install -d $(TEST_DIR)
- 	install -D ../lxc/.libs/liblxc.so $(TEST_DIR)/../lxc/liblxc.so
--	install -D ../../config/test-driver $(TEST_DIR)/../../config/test-driver
-+	install -D $(top_srcdir)/config/test-driver $(TEST_DIR)/../../config/test-driver
- 	cp Makefile $(TEST_DIR)
- 	@(for file in $(TESTS); do install $$file $(TEST_DIR);  done;)
- 	sed -i 's|^Makefile:|_Makefile:|' $(TEST_DIR)/Makefile
--- 
-1.7.10.4
-
recipes-containers/lxc/files/run-ptest +55 -2

59 lines not on this page · raw message

recipes-containers/lxc/files/runtest.patch deleted +0 -32
deleted file mode 100644
index 6572265..0000000
@@ -1,32 +0,0 @@
-Add install-ptest rule.
-
-Signed-off-by: Mihaela Sendrea <[email protected]>
-Upstream-status: Pending
-
-diff -uNr a/src/tests/Makefile.am b/src/tests/Makefile.am
---- a/src/tests/Makefile.am	2014-04-07 16:25:59.246238815 +0300
-+++ b/src/tests/Makefile.am	2014-04-10 18:09:43.195772467 +0300
-@@ -54,6 +54,23 @@
- 
- endif
- 
-+TESTS = lxc-test-containertests lxc-test-locktests \
-+        lxc-test-getkeys lxc-test-lxcpath lxc-test-cgpath lxc-test-console \
-+        lxc-test-snapshot lxc-test-concurrent lxc-test-may-control \
-+        lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove
-+
-+buildtest-TESTS: $(TESTS)
-+
-+install-ptest:
-+	install -d $(TEST_DIR)
-+	install -D ../lxc/.libs/liblxc.so $(TEST_DIR)/../lxc/liblxc.so
-+	install -D ../../config/test-driver $(TEST_DIR)/../../config/test-driver
-+	cp Makefile $(TEST_DIR)
-+	@(for file in $(TESTS); do install $$file $(TEST_DIR);  done;)
-+	sed -i 's|^Makefile:|_Makefile:|' $(TEST_DIR)/Makefile
-+	sed -i 's|^all-am:|_all-am:|' $(TEST_DIR)/Makefile
-+	sed -i -e 's|^\(.*\.log:\) \(.*EXEEXT.*\)|\1|g' $(TEST_DIR)/Makefile
-+
- EXTRA_DIST = \
- 	cgpath.c \
- 	clonetest.c \
recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch new file +60 -0

60 lines not on this page · raw message

recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch new file +74 -0

74 lines not on this page · raw message

recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch new file +32 -0
new file mode 100644
index 0000000..2a0113e
@@ -0,0 +1,32 @@
+From 9c973bfaab26426d8dcda8329f93a9af77415d76 Mon Sep 17 00:00:00 2001
+From: Mark Asselstine <[email protected]>
+Date: Thu, 31 May 2018 15:00:34 -0400
+Subject: [PATCH 2/3] tests: our init is not busybox
+
+Since we are using 'bash' as the init (see our updates to the busybox
+template) we can't compare '/sbin/init' and 'busybox'. Actually we are
+really only interested in the fact 'cmp' is being run and not the
+result, so simplify by comparing '/sbin/init' to itself.
+
+Signed-off-by: Mark Asselstine <[email protected]>
+Signed-off-by: Sinan Kaya <[email protected]>
+---
+ src/tests/attach.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/tests/attach.c b/src/tests/attach.c
+index af03862..03c247a 100644
+--- a/src/tests/attach.c
++++ b/src/tests/attach.c
+@@ -248,7 +248,7 @@ static int test_attach_cmd(struct lxc_container *ct)
+ {
+ 	int ret;
+ 	pid_t pid;
+-	char *argv[] = {"cmp", "-s", "/sbin/init", "/bin/busybox", NULL};
++	char *argv[] = {"cmp", "-s", "/sbin/init", "/sbin/init", NULL};
+ 	lxc_attach_command_t command = {"cmp", argv};
+ 	lxc_attach_options_t attach_options = LXC_ATTACH_OPTIONS_DEFAULT;
+ 
+-- 
+2.19.0
+
recipes-containers/lxc/lxc_2.0.8.bb +7 -6
index facad2e..13f3e77 100644
@@ -28,18 +28,19 @@ RDEPENDS_${PN} = " \
 
 RDEPENDS_${PN}_append_libc-glibc = " glibc-utils"
 
-RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash"
+RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash libgcc"
 
 SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
 	file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \
-	file://runtest.patch \
 	file://run-ptest \
-	file://automake-ensure-VPATH-builds-correctly.patch \
 	file://lxc-fix-B-S.patch \
 	file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
 	file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
 	file://cgroups-work-around-issue-in-gcc-7.patch \
 	file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \
+	file://template-make-busybox-template-compatible-with-core-.patch \
+	file://tests-our-init-is-not-busybox.patch \
+	file://tests-add-no-validate-when-using-download-template.patch \
 	file://dnsmasq.conf \
 	"
 
@@ -111,8 +112,6 @@ FILES_${PN}-setup += "/lib/systemd/system"
 FILES_${PN}-setup += "/usr/lib/systemd/system"
 FILES_${PN}-setup += "/etc/init.d"
 
-PRIVATE_LIBS_${PN}-ptest = "liblxc.so.1"
-
 CACHED_CONFIGUREVARS += " \
     ac_cv_path_PYTHON='${STAGING_BINDIR_NATIVE}/python3-native/python3' \
     am_cv_python_pyexecdir='${exec_prefix}/${libdir}/python3.5/site-packages' \
@@ -151,7 +150,9 @@ do_install_append() {
 EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests"
 
 do_install_ptest() {
-	oe_runmake -C src/tests install-ptest
+	# Move tests to the "ptest directory"
+	install -d ${D}/${PTEST_PATH}/tests
+	mv ${D}/usr/bin/lxc-test-* ${D}/${PTEST_PATH}/tests/.
 }
 
 pkg_postinst_${PN}() {
Signature · 1 line
2.19.0
#2 lore raw
In reply to Sinan Kaya

merged to sumo

Bruce

Quoted 82 lines · Sinan Kaya

From: Mark Asselstine <[email protected]>

We have a new dependency on 'mountpoint' which is now called in the download template script. We also hit an upstream bug due to improper use of 'mktemp', so we apply a patch to fix this and sent the fix upstream as well.

---
  ...ually-create-DOWNLOAD_TEMP-directory.patch | 39 +++++++++++++++++++
  recipes-containers/lxc/lxc_2.0.8.bb           |  2 +
  2 files changed, 41 insertions(+)

create mode 100644 recipes-containers/lxc/files/templates-actually-create-DOWNLOAD_TEMP-directory.patch

recipes-containers/lxc/files/templates-actually-create-DOWNLOAD_TEMP-directory.patch new file +39 -0
new file mode 100644
index 0000000..2b1ab87
@@ -0,0 +1,39 @@
+From 1d83b86a9bf017257c068c662ec3bf52ec0cfe90 Mon Sep 17 00:00:00 2001
+From: Mark Asselstine <[email protected]>
+Date: Thu, 31 May 2018 16:21:45 -0400
+Subject: [PATCH] templates: actually create DOWNLOAD_TEMP directory
+
+The way 'mktemp' is currently used you will get a temp directory in
+$TMPDIR or '/tmp' and DOWNLOAD_TEMP will not be pointing to an actual
+directory. This will result in the wget operations failing and the
+container will fail to create:
+
+    ERROR: Failed to download http://....
+
+Instead we want to use the '-p' option for mktemp to set the base path
+and this will ensure that the temp directory is created in the correct
+location and DOWNLOAD_TEMP will be consistent with this location.
+
+Upstream-Status: Pending
+
+Signed-off-by: Mark Asselstine <[email protected]>
+---
+ templates/lxc-download.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/templates/lxc-download.in b/templates/lxc-download.in
+index f09475d..d6333ad 100644
+--- a/templates/lxc-download.in
++++ b/templates/lxc-download.in
+@@ -310,7 +310,7 @@ if ! type mktemp >/dev/null 2>&1; then
+     DOWNLOAD_TEMP=/tmp/lxc-download.$$
+     mkdir -p $DOWNLOAD_TEMP
+ else
+-    DOWNLOAD_TEMP=$(mktemp -d)
++    DOWNLOAD_TEMP="$(mktemp -p ${DOWNLOAD_TEMP} -d)"
+ fi
+
+ # Simply list images
+--
+2.19.0
+
recipes-containers/lxc/lxc_2.0.8.bb +2 -0
index c87b875..facad2e 100644
@@ -23,6 +23,7 @@ RDEPENDS_${PN} = " \
  		libidn \
  		gnutls \
  		nettle \
+		util-linux-mountpoint \
  "
 
  RDEPENDS_${PN}_append_libc-glibc = " glibc-utils"
@@ -38,6 +39,7 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
  	file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
  	file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
  	file://cgroups-work-around-issue-in-gcc-7.patch \
+	file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \
  	file://dnsmasq.conf \
  	"