Skip to contentSkip to conversation

sanity-meta-openstack.bbclass: add class for bbappend files checking

PATCH In review [email protected] 2 participants 7 messages Oct 11, 2018 – Oct 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 sanity-meta-openstack.bbclass: add class for bbappend files checking

From: Mingli Yu <[email protected]>

Add a new class sanity-meta-openstack.bbclass, to check whether necessary settings are available for bbappend files and preferred version setting in this layer to be effective and warn users if not.

In addition, a variable SKIP_SANITY_META_OPENSTACK_CHECK is added to enable users to explicitly skip the checking to avoid unwanted warnings.

---
 meta-openstack/README                                | 19 +++++++++++++++++++
 meta-openstack/classes/sanity-meta-openstack.bbclass | 10 ++++++++++
 meta-openstack/conf/layer.conf                       |  4 ++++
 3 files changed, 33 insertions(+)
 create mode 100644 meta-openstack/classes/sanity-meta-openstack.bbclass
meta-openstack/README +19 -0
index 81b843b..8506250 100644
@@ -5,6 +5,25 @@ This layer provides support for building the packages from the OpenStack project
 The layer contains recipes for the nova, glance, keystone, cinder, quantum, swift
 and horizon components.
 
+The bbappend files for some recipes (e.g. postgresql) and preferred version setting
+(e.g. python-networkx)in this layer need to have 'openstack' in DISTRO_FEATURES to
+have effect. To enable them, add in configuration file the following line.
+
+  DISTRO_FEATURES_append = " openstack"
+
+If meta-openstack is included, but openstack is not enabled as a
+distro feature a warning is printed at parse time:
+
+    You have included the meta-openstack layer, but
+    'openstack' has not been enabled in your DISTRO_FEATURES. Some bbappend files
+    and preferred version setting may not take effect. See the meta-openstack README
+    for details on enabling openstack support.
+
+If you know what you are doing, this warning can be disabled by setting the following
+variable in your configuration:
+
+  SKIP_META_OPENSTACK_SANITY_CHECK = 1
+
 Dependencies
 ------------
 
meta-openstack/classes/sanity-meta-openstack.bbclass new file +10 -0
new file mode 100644
index 0000000..3d5e57b
@@ -0,0 +1,10 @@
+addhandler openstack_bbappend_distrocheck
+openstack_bbappend_distrocheck[eventmask] = "bb.event.SanityCheck"
+python openstack_bbappend_distrocheck() {
+    skip_check = e.data.getVar('SKIP_META_OPENSTACK_SANITY_CHECK') == "1"
+    if 'openstack' not in e.data.getVar('DISTRO_FEATURES').split() and not skip_check:
+        bb.warn("You have included the meta-openstack layer, but \
+'openstack' has not been enabled in your DISTRO_FEATURES. Some bbappend files \
+and preferred version setting may not take effect. See the meta-openstack README \
+for details on enabling openstack support.")
+}
meta-openstack/conf/layer.conf +4 -0
index 126f37f..f322bcd 100644
@@ -35,5 +35,9 @@ PREFERRED_VERSION_python-jsonschema = "2.6.0"
 PREFERRED_VERSION_python-networkx = "1.11"
 PREFERRED_VERSION_python-oslo.i18n = "3.17.0+gitAUTOINC+f2729cd36f"
 
+# Sanity check for meta-openstack layer.
+# Setting SKIP_META_OPENSTACK_SANITY_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-openstack"
+
 LICENSE_PATH += "${LAYERDIR}/licenses"
 LAYERRECOMMENDS_openstack-layer = "meta-openstack-dl (= 2.6)"
Signature · 1 line
2.7.4
#1 lore raw

PATCH 3/3 postgresql: make append version independent

From: Mingli Yu <[email protected]>

Make bbappend version independent and only
effective when the openstack distro enabled.

---
 .../recipes-dbs/postgresql/postgresql_%.bbappend   |  1 +
 .../recipes-dbs/postgresql/postgresql_9.%.bbappend | 60 ----------------------
 .../postgresql/postgresql_openstack.inc            | 60 ++++++++++++++++++++++
 3 files changed, 61 insertions(+), 60 deletions(-)
 create mode 100644 meta-openstack/recipes-dbs/postgresql/postgresql_%.bbappend
 delete mode 100644 meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
 create mode 100644 meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc
meta-openstack/recipes-dbs/postgresql/postgresql_%.bbappend new file +1 -0
new file mode 100644
index 0000000..025ee4e
@@ -0,0 +1 @@
+require ${@bb.utils.contains('DISTRO_FEATURES', 'openstack', '${BPN}_openstack.inc', '', d)}
meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend deleted +0 -60

60 lines not on this page · raw message

meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

Re: [meta-openstack][PATCH 3/3] postgresql: make append version independent

merged

Bruce

Quoted 158 lines · On Wed, Oct 10, 2018 at 11:50 PM <[email protected]> wrote:

From: Mingli Yu <[email protected]>

Make bbappend version independent and only
effective when the openstack distro enabled.

---
 .../recipes-dbs/postgresql/postgresql_%.bbappend   |  1 +
 .../recipes-dbs/postgresql/postgresql_9.%.bbappend | 60 ----------------------
 .../postgresql/postgresql_openstack.inc            | 60 ++++++++++++++++++++++
 3 files changed, 61 insertions(+), 60 deletions(-)
 create mode 100644 meta-openstack/recipes-dbs/postgresql/postgresql_%.bbappend
 delete mode 100644 meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend
 create mode 100644 meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc
meta-openstack/recipes-dbs/postgresql/postgresql_%.bbappend new file +1 -0
new file mode 100644
index 0000000..025ee4e
@@ -0,0 +1 @@
+require ${@bb.utils.contains('DISTRO_FEATURES', 'openstack', '${BPN}_openstack.inc', '', d)}
meta-openstack/recipes-dbs/postgresql/postgresql_9.%.bbappend deleted +0 -60
deleted file mode 100644
index 5bf25e1..0000000
@@ -1,60 +0,0 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-
-SRC_URI += " \
-    file://postgresql-init \
-    file://postgresql-init.service \
-    "
-
-inherit identity hosts
-
-SYSTEMD_AUTO_ENABLE_${PN} = "enable"
-
-# default
-DB_DATADIR ?= "/var/lib/postgres/data"
-
-do_install_append() {
-    D_DEST_DIR=${D}${sysconfdir}/postgresql
-
-    install -d ${D_DEST_DIR}
-    install -m 0755 ${WORKDIR}/postgresql-init ${D_DEST_DIR}/postgresql-init
-
-    sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${D_DEST_DIR}/postgresql-init
-
-    sed -e "s:%DB_USER%:${DB_USER}:g" -i ${D_DEST_DIR}/postgresql-init
-    sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${D_DEST_DIR}/postgresql-init
-
-    sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${D_DEST_DIR}/postgresql-init
-    sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${D_DEST_DIR}/postgresql-init
-
-    sed -e "s:%COMPUTE_IP%:${COMPUTE_IP}:g" -i ${D_DEST_DIR}/postgresql-init
-    sed -e "s:%COMPUTE_HOST%:${COMPUTE_HOST}:g" -i ${D_DEST_DIR}/postgresql-init
-
-    install -d ${D}${systemd_unitdir}/system/
-    PG_INIT_SERVICE_FILE=${D}${systemd_unitdir}/system/postgresql-init.service
-    install -m 644 ${WORKDIR}/postgresql-init.service ${PG_INIT_SERVICE_FILE}
-    sed -e "s:%SYSCONFIGDIR%:${sysconfdir}:g" -i ${PG_INIT_SERVICE_FILE}
-
-    # Update PGDATA throughout
-    files="${D}${localstatedir}/lib/${BPN}/.bash_profile"
-    files="$files ${D}${systemd_unitdir}/system/postgresql.service"
-    files="$files ${D}${bindir}/${BPN}-setup"
-    files="$files ${D}${sysconfdir}/init.d/${BPN}-server"
-    for f in $files
-    do
-        sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
-    done
-
-    # Ensure DB is initialize before we attempt to start the service
-    FILE=${D}${systemd_unitdir}/system/postgresql.service
-    sed -e '/ExecStart=.*/i ExecStartPre=-${sysconfdir}/postgresql/postgresql-init initdb' -i $FILE
-    sed -e '/ExecStartPre=.*/i PermissionsStartOnly=true' -i $FILE
-}
-
-PACKAGES += " ${PN}-setup"
-
-SYSTEMD_PACKAGES += "${PN}-setup"
-SYSTEMD_SERVICE_${PN}-setup = "postgresql-init.service"
-
-FILES_${PN}-setup = " \
-    ${systemd_unitdir}/system \
-"
meta-openstack/recipes-dbs/postgresql/postgresql_openstack.inc new file +60 -1
new file mode 100644
index 0000000..5bf25e1
@@ -0,0 +1,60 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += " \
+    file://postgresql-init \
+    file://postgresql-init.service \
+    "
+
+inherit identity hosts
+
+SYSTEMD_AUTO_ENABLE_${PN} = "enable"
+
+# default
+DB_DATADIR ?= "/var/lib/postgres/data"
+
+do_install_append() {
+    D_DEST_DIR=${D}${sysconfdir}/postgresql
+
+    install -d ${D_DEST_DIR}
+    install -m 0755 ${WORKDIR}/postgresql-init ${D_DEST_DIR}/postgresql-init
+
+    sed -e "s:%DB_DATADIR%:${DB_DATADIR}:g" -i ${D_DEST_DIR}/postgresql-init
+
+    sed -e "s:%DB_USER%:${DB_USER}:g" -i ${D_DEST_DIR}/postgresql-init
+    sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${D_DEST_DIR}/postgresql-init
+
+    sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${D_DEST_DIR}/postgresql-init
+    sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${D_DEST_DIR}/postgresql-init
+
+    sed -e "s:%COMPUTE_IP%:${COMPUTE_IP}:g" -i ${D_DEST_DIR}/postgresql-init
+    sed -e "s:%COMPUTE_HOST%:${COMPUTE_HOST}:g" -i ${D_DEST_DIR}/postgresql-init
+
+    install -d ${D}${systemd_unitdir}/system/
+    PG_INIT_SERVICE_FILE=${D}${systemd_unitdir}/system/postgresql-init.service
+    install -m 644 ${WORKDIR}/postgresql-init.service ${PG_INIT_SERVICE_FILE}
+    sed -e "s:%SYSCONFIGDIR%:${sysconfdir}:g" -i ${PG_INIT_SERVICE_FILE}
+
+    # Update PGDATA throughout
+    files="${D}${localstatedir}/lib/${BPN}/.bash_profile"
+    files="$files ${D}${systemd_unitdir}/system/postgresql.service"
+    files="$files ${D}${bindir}/${BPN}-setup"
+    files="$files ${D}${sysconfdir}/init.d/${BPN}-server"
+    for f in $files
+    do
+        sed -e "s:\(PGDATA=\).*$:\1${DB_DATADIR}:g" -i $f
+    done
+
+    # Ensure DB is initialize before we attempt to start the service
+    FILE=${D}${systemd_unitdir}/system/postgresql.service
+    sed -e '/ExecStart=.*/i ExecStartPre=-${sysconfdir}/postgresql/postgresql-init initdb' -i $FILE
+    sed -e '/ExecStartPre=.*/i PermissionsStartOnly=true' -i $FILE
+}
+
+PACKAGES += " ${PN}-setup"
+
+SYSTEMD_PACKAGES += "${PN}-setup"
+SYSTEMD_SERVICE_${PN}-setup = "postgresql-init.service"
+
+FILES_${PN}-setup = " \
+    ${systemd_unitdir}/system \
+"
--

2.7.4

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
#3 lore raw

PATCH v2 2/3 layer.conf: set PREFERRED_VERSION for python-networkx

In reply to [email protected]

From: Mingli Yu <[email protected]>

Only set PREFERRED_VERSION for python-networkx
when the openstack distro is enabled

---
 meta-openstack/conf/layer.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-openstack/conf/layer.conf +1 -1
index f322bcd..598e157 100644
@@ -32,7 +32,7 @@ PREFERRED_VERSION_python-sqlalchemy = "1.0.16"
 PREFERRED_VERSION_python-eventlet = "0.20.0"
 PREFERRED_VERSION_python-warlock = "1.2.0"
 PREFERRED_VERSION_python-jsonschema = "2.6.0"
-PREFERRED_VERSION_python-networkx = "1.11"
+PREFERRED_VERSION_python-networkx = "${@bb.utils.contains('DISTRO_FEATURES', 'openstack', '1.11', '', d)}"
 PREFERRED_VERSION_python-oslo.i18n = "3.17.0+gitAUTOINC+f2729cd36f"
 
 # Sanity check for meta-openstack layer.
Signature · 1 line
2.7.4
#4 lore raw

Re: [meta-openstack][PATCH v2 2/3] layer.conf: set PREFERRED_VERSION for python-networkx

merged

Bruce

Quoted 27 lines · On Wed, Oct 10, 2018 at 11:51 PM <[email protected]> wrote:

From: Mingli Yu <[email protected]>

Only set PREFERRED_VERSION for python-networkx
when the openstack distro is enabled

---
 meta-openstack/conf/layer.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-openstack/conf/layer.conf +1 -2
index f322bcd..598e157 100644
@@ -32,7 +32,7 @@ PREFERRED_VERSION_python-sqlalchemy = "1.0.16"
 PREFERRED_VERSION_python-eventlet = "0.20.0"
 PREFERRED_VERSION_python-warlock = "1.2.0"
 PREFERRED_VERSION_python-jsonschema = "2.6.0"
-PREFERRED_VERSION_python-networkx = "1.11"
+PREFERRED_VERSION_python-networkx = "${@bb.utils.contains('DISTRO_FEATURES', 'openstack', '1.11', '', d)}"
 PREFERRED_VERSION_python-oslo.i18n = "3.17.0+gitAUTOINC+f2729cd36f"
 
 # Sanity check for meta-openstack layer.
--

2.7.4

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
#5 lore raw
In reply to [email protected]

merged.

Note: this doesn't apply to my meta-openstack layer. So it was based on some version that I don't have. But since the change was simple enough, I resolved the issue and did the merge.

Bruce

Quoted 83 lines · On Wed, Oct 10, 2018 at 11:50 PM <[email protected]> wrote:

From: Mingli Yu <[email protected]>

Add a new class sanity-meta-openstack.bbclass, to check whether necessary settings are available for bbappend files and preferred version setting in this layer to be effective and warn users if not.

In addition, a variable SKIP_SANITY_META_OPENSTACK_CHECK is added to enable users to explicitly skip the checking to avoid unwanted warnings.

---
 meta-openstack/README                                | 19 +++++++++++++++++++
 meta-openstack/classes/sanity-meta-openstack.bbclass | 10 ++++++++++
 meta-openstack/conf/layer.conf                       |  4 ++++
 3 files changed, 33 insertions(+)
 create mode 100644 meta-openstack/classes/sanity-meta-openstack.bbclass
meta-openstack/README +19 -0
index 81b843b..8506250 100644
@@ -5,6 +5,25 @@ This layer provides support for building the packages from the OpenStack project
 The layer contains recipes for the nova, glance, keystone, cinder, quantum, swift
 and horizon components.
 
+The bbappend files for some recipes (e.g. postgresql) and preferred version setting
+(e.g. python-networkx)in this layer need to have 'openstack' in DISTRO_FEATURES to
+have effect. To enable them, add in configuration file the following line.
+
+  DISTRO_FEATURES_append = " openstack"
+
+If meta-openstack is included, but openstack is not enabled as a
+distro feature a warning is printed at parse time:
+
+    You have included the meta-openstack layer, but
+    'openstack' has not been enabled in your DISTRO_FEATURES. Some bbappend files
+    and preferred version setting may not take effect. See the meta-openstack README
+    for details on enabling openstack support.
+
+If you know what you are doing, this warning can be disabled by setting the following
+variable in your configuration:
+
+  SKIP_META_OPENSTACK_SANITY_CHECK = 1
+
 Dependencies
 ------------
 
meta-openstack/classes/sanity-meta-openstack.bbclass new file +10 -0
new file mode 100644
index 0000000..3d5e57b
@@ -0,0 +1,10 @@
+addhandler openstack_bbappend_distrocheck
+openstack_bbappend_distrocheck[eventmask] = "bb.event.SanityCheck"
+python openstack_bbappend_distrocheck() {
+    skip_check = e.data.getVar('SKIP_META_OPENSTACK_SANITY_CHECK') == "1"
+    if 'openstack' not in e.data.getVar('DISTRO_FEATURES').split() and not skip_check:
+        bb.warn("You have included the meta-openstack layer, but \
+'openstack' has not been enabled in your DISTRO_FEATURES. Some bbappend files \
+and preferred version setting may not take effect. See the meta-openstack README \
+for details on enabling openstack support.")
+}
meta-openstack/conf/layer.conf +4 -1
index 126f37f..f322bcd 100644
@@ -35,5 +35,9 @@ PREFERRED_VERSION_python-jsonschema = "2.6.0"
 PREFERRED_VERSION_python-networkx = "1.11"
 PREFERRED_VERSION_python-oslo.i18n = "3.17.0+gitAUTOINC+f2729cd36f"
 
+# Sanity check for meta-openstack layer.
+# Setting SKIP_META_OPENSTACK_SANITY_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-openstack"
+
 LICENSE_PATH += "${LAYERDIR}/licenses"
 LAYERRECOMMENDS_openstack-layer = "meta-openstack-dl (= 2.6)"
--

2.7.4

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
author
#6 lore raw
Quoted 5 lines · Bruce Ashfield

merged.

Note: this doesn't apply to my meta-openstack layer. So it was based on some version that I don't have. But since the change was simple enough, I resolved the issue and did the merge.

Thanks Bruce!

Quoted 88 lines

Bruce

Quoted 83 lines · On Wed, Oct 10, 2018 at 11:50 PM <[email protected]> wrote:

From: Mingli Yu <[email protected]>

Add a new class sanity-meta-openstack.bbclass, to check whether necessary settings are available for bbappend files and preferred version setting in this layer to be effective and warn users if not.

In addition, a variable SKIP_SANITY_META_OPENSTACK_CHECK is added to enable users to explicitly skip the checking to avoid unwanted warnings.

---
  meta-openstack/README                                | 19 +++++++++++++++++++
  meta-openstack/classes/sanity-meta-openstack.bbclass | 10 ++++++++++
  meta-openstack/conf/layer.conf                       |  4 ++++
  3 files changed, 33 insertions(+)

create mode 100644 meta-openstack/classes/sanity-meta-openstack.bbclass

meta-openstack/README +19 -0
index 81b843b..8506250 100644
@@ -5,6 +5,25 @@ This layer provides support for building the packages from the OpenStack project
  The layer contains recipes for the nova, glance, keystone, cinder, quantum, swift
  and horizon components.
 
+The bbappend files for some recipes (e.g. postgresql) and preferred version setting
+(e.g. python-networkx)in this layer need to have 'openstack' in DISTRO_FEATURES to
+have effect. To enable them, add in configuration file the following line.
+
+  DISTRO_FEATURES_append = " openstack"
+
+If meta-openstack is included, but openstack is not enabled as a
+distro feature a warning is printed at parse time:
+
+    You have included the meta-openstack layer, but
+    'openstack' has not been enabled in your DISTRO_FEATURES. Some bbappend files
+    and preferred version setting may not take effect. See the meta-openstack README
+    for details on enabling openstack support.
+
+If you know what you are doing, this warning can be disabled by setting the following
+variable in your configuration:
+
+  SKIP_META_OPENSTACK_SANITY_CHECK = 1
+
  Dependencies
  ------------
 
meta-openstack/classes/sanity-meta-openstack.bbclass new file +10 -0
new file mode 100644
index 0000000..3d5e57b
@@ -0,0 +1,10 @@
+addhandler openstack_bbappend_distrocheck
+openstack_bbappend_distrocheck[eventmask] = "bb.event.SanityCheck"
+python openstack_bbappend_distrocheck() {
+    skip_check = e.data.getVar('SKIP_META_OPENSTACK_SANITY_CHECK') == "1"
+    if 'openstack' not in e.data.getVar('DISTRO_FEATURES').split() and not skip_check:
+        bb.warn("You have included the meta-openstack layer, but \
+'openstack' has not been enabled in your DISTRO_FEATURES. Some bbappend files \
+and preferred version setting may not take effect. See the meta-openstack README \
+for details on enabling openstack support.")
+}
meta-openstack/conf/layer.conf +4 -1
index 126f37f..f322bcd 100644
@@ -35,5 +35,9 @@ PREFERRED_VERSION_python-jsonschema = "2.6.0"
  PREFERRED_VERSION_python-networkx = "1.11"
  PREFERRED_VERSION_python-oslo.i18n = "3.17.0+gitAUTOINC+f2729cd36f"
 
+# Sanity check for meta-openstack layer.
+# Setting SKIP_META_OPENSTACK_SANITY_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-openstack"
+
  LICENSE_PATH += "${LAYERDIR}/licenses"
  LAYERRECOMMENDS_openstack-layer = "meta-openstack-dl (= 2.6)"
--

2.7.4