From f4b29728150ce8b1be12064e2045717bca1236eb Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 15 Oct 2021 11:26:11 +0000 Subject: [PATCH 01/10] A hook for mounting an extra-patches directory into the jail I've been using this for over two years. It was recently updated based upon suggestions: https://gist.github.com/dlangille/924507ce545de8fbbe78b50b752997ce Background:https://dan.langille.org/2019/08/10/poudriere-hooks/ --- src/etc/poudriere.d/hooks/jail.sh.sample | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/etc/poudriere.d/hooks/jail.sh.sample diff --git a/src/etc/poudriere.d/hooks/jail.sh.sample b/src/etc/poudriere.d/hooks/jail.sh.sample new file mode 100644 index 0000000000..7ebbffcab2 --- /dev/null +++ b/src/etc/poudriere.d/hooks/jail.sh.sample @@ -0,0 +1,20 @@ +#!/bin/sh +# /usr/local/etc/poudriere.d/hooks/jail.sh + +status="$1" + +# NOTE: mount is invoked before start: re https://github.com/freebsd/poudriere/wiki/hooks +if [ "$status" = "mount" ] && [ -d /usr/local/etc/poudriere.d/local-patches ]; then + mntpath="$2" + + # The local-patches directory is created only if it does not already exist. + # If it does not already exist, it means we are doing this on the master jail + if [ ! -d "${mntpath}/local-patches" ]; then + /bin/mkdir "${mntpath}/local-patches" + fi + + # mount our patches to that location + /sbin/mount -t nullfs -o ro /usr/local/etc/poudriere.d/local-patches "${mntpath}/local-patches" +fi + +exit 0 From f83c52e5459e362c587aa085e97936dc7da66f3e Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Fri, 15 Oct 2021 17:21:43 +0000 Subject: [PATCH 02/10] Use mkdir -p which removes the need for the test Change /usr/local/etc/poudriere.d/local-patches to ${POUDRIERED}/local-patches --- src/etc/poudriere.d/hooks/jail.sh.sample | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/etc/poudriere.d/hooks/jail.sh.sample b/src/etc/poudriere.d/hooks/jail.sh.sample index 7ebbffcab2..5bcef6b711 100644 --- a/src/etc/poudriere.d/hooks/jail.sh.sample +++ b/src/etc/poudriere.d/hooks/jail.sh.sample @@ -4,17 +4,15 @@ status="$1" # NOTE: mount is invoked before start: re https://github.com/freebsd/poudriere/wiki/hooks -if [ "$status" = "mount" ] && [ -d /usr/local/etc/poudriere.d/local-patches ]; then +if [ "$status" = "mount" ] && [ -d ${POUDRIERED}/local-patches ]; then mntpath="$2" # The local-patches directory is created only if it does not already exist. # If it does not already exist, it means we are doing this on the master jail - if [ ! -d "${mntpath}/local-patches" ]; then - /bin/mkdir "${mntpath}/local-patches" - fi + /bin/mkdir "${mntpath}/local-patches" # mount our patches to that location - /sbin/mount -t nullfs -o ro /usr/local/etc/poudriere.d/local-patches "${mntpath}/local-patches" + /sbin/mount -t nullfs -o ro ${POUDRIERED}/local-patches "${mntpath}/local-patches" fi exit 0 From c5a5f0b8693d5182463dd9efa194fa06731c918d Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Sat, 16 Oct 2021 11:09:49 +0000 Subject: [PATCH 03/10] Restore check if the directory exists before creating it. This morning my cronjob was spewing errors: mkdir: /usr/local/poudriere/data/.m/122amd64-default-primary/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-primary/01/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-primary/04/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-primary/03/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-primary/02/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-mysql57/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-mysql80/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-pg96/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-pg10/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-pg11/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-pg12/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-pg13/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122amd64-default-unifi/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/122i386-default-primaryi386/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-primary/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-primary/03/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-primary/04/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-primary/01/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-primary/02/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-mysql57/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-mysql80/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-pg96/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-pg10/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-pg11/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-pg12/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-pg13/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13amd64-default-unifi/ref/local-patches: File exists mkdir: /usr/local/poudriere/data/.m/13i386-default-primaryi386/ref/local-patches: File exists --- src/etc/poudriere.d/hooks/jail.sh.sample | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/etc/poudriere.d/hooks/jail.sh.sample b/src/etc/poudriere.d/hooks/jail.sh.sample index 5bcef6b711..a891d89757 100644 --- a/src/etc/poudriere.d/hooks/jail.sh.sample +++ b/src/etc/poudriere.d/hooks/jail.sh.sample @@ -9,7 +9,9 @@ if [ "$status" = "mount" ] && [ -d ${POUDRIERED}/local-patches ]; then # The local-patches directory is created only if it does not already exist. # If it does not already exist, it means we are doing this on the master jail - /bin/mkdir "${mntpath}/local-patches" + if [ ! -d "${mntpath}/local-patches" ]; then + /bin/mkdir "${mntpath}/local-patches" + fi # mount our patches to that location /sbin/mount -t nullfs -o ro ${POUDRIERED}/local-patches "${mntpath}/local-patches" From e2f26538e75e81466f49189f5b6d8c2a4ecdb2a2 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sun, 17 Oct 2021 12:22:14 -0700 Subject: [PATCH 04/10] Fix va_args error on non-amd64 Reported by: Mark Millard --- src/poudriere-sh/helpers.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/poudriere-sh/helpers.h b/src/poudriere-sh/helpers.h index 9a9f151a9e..7bb8656b8e 100644 --- a/src/poudriere-sh/helpers.h +++ b/src/poudriere-sh/helpers.h @@ -107,7 +107,10 @@ void verrorwithstatus(int, const char *, va_list) __printf0like(2, 0) __dead2; #define exit_(...) exit_X(__VA_ARGS__, _1, _0)(__VA_ARGS__) #define exit_X(_0, _1, X, ...) exit ## X #define exit_0(_) return (0) -#define exit_1(_, status) verrorwithstatus(status, NULL, NULL) +#define exit_1(_, status) do { \ + va_list va_empty = {}; \ + verrorwithstatus(status, NULL, va_empty); \ +} while (0) /* Getopt compat */ #include "options.h" From a78fcf1b01ca9f107cc2e793e58f81f63ae868b7 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sun, 17 Oct 2021 12:55:12 -0700 Subject: [PATCH 05/10] enter_interactive: Don't pkg-update. build_repo is currently blocked for dry run modes and building the repo in a test situation does not seem prudent. For now just disable this as it is very new. Fixes 1ee1367219cef7b8 --- src/share/poudriere/common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 502fa68b22..8fea0f1226 100644 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -2006,7 +2006,8 @@ enter_interactive() { enabled: yes } EOF - injail pkg update + # XXX: build_repo ? + #injail pkg update || : msg "Remounting ${PORTSDIR} ${OVERLAYS:+and ${OVERLAYSDIR} }read-write" remount_ports -o rw >/dev/null @@ -2059,8 +2060,7 @@ enter_interactive() { setenv DEVELOPER 1 setenv DEVELOPER_MODE yes - Packages from /packages are loaded into 'pkg' and can be installed - as needed. + Packages from /packages can be installed with 'pkg add' as needed. If building as non-root you will be logged into ${PORTBUILD_USER}. su can be used without password to elevate. From 8d568857e46748f3688020554327188e3068f1c2 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sun, 17 Oct 2021 14:46:27 -0700 Subject: [PATCH 06/10] CCACHE_NON_ROOT: Fix access to /root Reported by: ler --- src/share/poudriere/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 8fea0f1226..5142e5069d 100644 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -2586,7 +2586,7 @@ setup_ccache() { WITH_CCACHE_BUILD=yes CCACHE_DIR=${HOME}/.ccache EOF - chmod 755 "${mnt}${HOME}" + chmod 755 "${tomnt}${HOME}" if [ "${CCACHE_GID}" != "${PORTBUILD_GID}" ]; then injail pw groupadd "${CCACHE_GROUP}" \ -g "${CCACHE_GID}" || \ From eedf4eab736b658614fa8585bd2a22816ab246c0 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Mon, 18 Oct 2021 11:55:07 +0000 Subject: [PATCH 07/10] Remove surounding if and add -p to the mkdir Seems I did not include the -p when I removed the if during my testing. --- src/etc/poudriere.d/hooks/jail.sh.sample | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/etc/poudriere.d/hooks/jail.sh.sample b/src/etc/poudriere.d/hooks/jail.sh.sample index a891d89757..a3cab470ba 100644 --- a/src/etc/poudriere.d/hooks/jail.sh.sample +++ b/src/etc/poudriere.d/hooks/jail.sh.sample @@ -9,9 +9,7 @@ if [ "$status" = "mount" ] && [ -d ${POUDRIERED}/local-patches ]; then # The local-patches directory is created only if it does not already exist. # If it does not already exist, it means we are doing this on the master jail - if [ ! -d "${mntpath}/local-patches" ]; then - /bin/mkdir "${mntpath}/local-patches" - fi + /bin/mkdir -p "${mntpath}/local-patches" # mount our patches to that location /sbin/mount -t nullfs -o ro ${POUDRIERED}/local-patches "${mntpath}/local-patches" From 9a9e7df6cb72f97bd269fbdccd904ff813584f95 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Mon, 18 Oct 2021 12:05:09 +0000 Subject: [PATCH 08/10] Revert "Fix va_args error on non-amd64" This reverts commit e2f26538e75e81466f49189f5b6d8c2a4ecdb2a2. --- src/poudriere-sh/helpers.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/poudriere-sh/helpers.h b/src/poudriere-sh/helpers.h index 7bb8656b8e..9a9f151a9e 100644 --- a/src/poudriere-sh/helpers.h +++ b/src/poudriere-sh/helpers.h @@ -107,10 +107,7 @@ void verrorwithstatus(int, const char *, va_list) __printf0like(2, 0) __dead2; #define exit_(...) exit_X(__VA_ARGS__, _1, _0)(__VA_ARGS__) #define exit_X(_0, _1, X, ...) exit ## X #define exit_0(_) return (0) -#define exit_1(_, status) do { \ - va_list va_empty = {}; \ - verrorwithstatus(status, NULL, va_empty); \ -} while (0) +#define exit_1(_, status) verrorwithstatus(status, NULL, NULL) /* Getopt compat */ #include "options.h" From 7bd03938da444956d7e6b6a658576967c83857a4 Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Mon, 18 Oct 2021 12:05:33 +0000 Subject: [PATCH 09/10] Revert "enter_interactive: Don't pkg-update." This reverts commit a78fcf1b01ca9f107cc2e793e58f81f63ae868b7. --- src/share/poudriere/common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 5142e5069d..8cdb6bc0cc 100644 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -2006,8 +2006,7 @@ enter_interactive() { enabled: yes } EOF - # XXX: build_repo ? - #injail pkg update || : + injail pkg update msg "Remounting ${PORTSDIR} ${OVERLAYS:+and ${OVERLAYSDIR} }read-write" remount_ports -o rw >/dev/null @@ -2060,7 +2059,8 @@ enter_interactive() { setenv DEVELOPER 1 setenv DEVELOPER_MODE yes - Packages from /packages can be installed with 'pkg add' as needed. + Packages from /packages are loaded into 'pkg' and can be installed + as needed. If building as non-root you will be logged into ${PORTBUILD_USER}. su can be used without password to elevate. From 21a6e08fac8fcdfca1db2fdce8df39b9c742e45b Mon Sep 17 00:00:00 2001 From: Dan Langille Date: Mon, 18 Oct 2021 12:05:55 +0000 Subject: [PATCH 10/10] Revert "CCACHE_NON_ROOT: Fix access to /root" This reverts commit 8d568857e46748f3688020554327188e3068f1c2. --- src/share/poudriere/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 8cdb6bc0cc..502fa68b22 100644 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -2586,7 +2586,7 @@ setup_ccache() { WITH_CCACHE_BUILD=yes CCACHE_DIR=${HOME}/.ccache EOF - chmod 755 "${tomnt}${HOME}" + chmod 755 "${mnt}${HOME}" if [ "${CCACHE_GID}" != "${PORTBUILD_GID}" ]; then injail pw groupadd "${CCACHE_GROUP}" \ -g "${CCACHE_GID}" || \