poudriere icon indicating copy to clipboard operation
poudriere copied to clipboard

swap check for poudriere.conf

Open ohauer opened this issue 6 years ago • 2 comments

swap the check to include poudriere.conf from

  • POUDRIERE_ETC, POUDRIERED to
  • POUDRIERED, POUDRIERE_ETC

reason, if you don't touch POUDRIERE_ETC/poudriere.conf and keep your settings in POUDRIERED/poudriere.conf the config will not be read (e.g. ZPOOL) and most every command will fail with =>> Error: ZPOOL variable is not set

--- src/share/poudriere/common.sh.orig  2018-06-01 18:34:15 UTC
+++ src/share/poudriere/common.sh
@@ -2689,12 +2689,12 @@ include_poudriere_confs() {
                esac
        done

-       if [ -r "${POUDRIERE_ETC}/poudriere.conf" ]; then
-               . "${POUDRIERE_ETC}/poudriere.conf"
-               [ ${debug} -gt 1 ] && msg_debug "Reading ${POUDRIERE_ETC}/poudriere.conf"
-       elif [ -r "${POUDRIERED}/poudriere.conf" ]; then
+       if [ -r "${POUDRIERED}/poudriere.conf" ]; then
                . "${POUDRIERED}/poudriere.conf"
                [ ${debug} -gt 1 ] && msg_debug "Reading ${POUDRIERED}/poudriere.conf"
+       elif [ -r "${POUDRIERE_ETC}/poudriere.conf" ]; then
+               . "${POUDRIERE_ETC}/poudriere.conf"
+               [ ${debug} -gt 1 ] && msg_debug "Reading ${POUDRIERE_ETC}/poudriere.conf"
        else
                err 1 "Unable to find a readable poudriere.conf in ${POUDRIERE_ETC} or ${POUDRIERED}"
        fi

ohauer avatar Jun 30 '18 09:06 ohauer

It is documented that POUDRIERE_ETC is read before POUDRIERED. Flipping the order here isn't right because of that documentation. Usually I just symlink to avoid the problem.

lrwxr-xr-x  1 root  wheel  26 Feb  9 16:43 /usr/local/etc/poudriere.conf@ -> poudriere.d/poudriere.conf

An alternative fix could be to check if poudriere.conf has a size before trying to read it. I think that would cover your specific case.

bdrewery avatar Jun 30 '18 19:06 bdrewery

Thanks, the trick with the link works for me.

What do you think about the following change?

--- src/share/poudriere/common.sh.orig  2018-06-01 18:34:15 UTC
+++ src/share/poudriere/common.sh
@@ -2689,13 +2689,20 @@ include_poudriere_confs() {
                esac
        done

+       found_poudriere_conf=0
        if [ -r "${POUDRIERE_ETC}/poudriere.conf" ]; then
                . "${POUDRIERE_ETC}/poudriere.conf"
                [ ${debug} -gt 1 ] && msg_debug "Reading ${POUDRIERE_ETC}/poudriere.conf"
-       elif [ -r "${POUDRIERED}/poudriere.conf" ]; then
+               found_poudriere_conf=1
+       fi
+
+       if [ -r "${POUDRIERED}/poudriere.conf" ]; then
                . "${POUDRIERED}/poudriere.conf"
                [ ${debug} -gt 1 ] && msg_debug "Reading ${POUDRIERED}/poudriere.conf"
-       else
+               found_poudriere_conf=1
+       fi
+
+       if [ ${found_poudriere_conf} -ne 1 ]; then
                err 1 "Unable to find a readable poudriere.conf in ${POUDRIERE_ETC} or ${POUDRIERED}"
        fi

ohauer avatar Jul 08 '18 10:07 ohauer