From: Jackie Huang Date: Fri, 4 Jun 2021 07:49:39 +0000 (+0800) Subject: Add a method to re-use meta data from stx repo X-Git-Tag: f-release~108 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=c29ccf4387a39def332fa26014f019039eaba96e;p=pti%2Frtp.git Add a method to re-use meta data from stx repo StarlingX has many repos to maintain meta data (patches and config files) for packages, previously we added a local copy of those files as bitbake's metadata for each recipe which may cause maintenance issue. So add a method to avoid that, which includes: * Add new recipes stx-${STX_REPO}-source for thoes stx git repo and put them into the work-shared directory so they can be used by other recipes that need the stx meta data, so it will reduce downloads and increase re-use. * Add stx-source.bbclass for easily creating the work-shared recipes * Add stx-metadata.bbclass for those recipes that need the stx meta data, it will add dependency on the stx-${STX_REPO}-source and redefine the SRC_URI before do_patch, so it can find the patches in stx repo in work-shard and do the patch, and other meta data like config files can be used in do_install, then the local copy of those meta data can be removed, and for the future upgrade, we don't need to manually check and update those meta data any more. Issue-ID: INF-215 Signed-off-by: Jackie Huang Change-Id: Ieb27b4886e3cd9ccb4a9cbf63085bf28dda29549 --- diff --git a/meta-starlingx/meta-stx-distro/classes/stx-metadata.bbclass b/meta-starlingx/meta-stx-distro/classes/stx-metadata.bbclass new file mode 100644 index 0000000..6242af4 --- /dev/null +++ b/meta-starlingx/meta-stx-distro/classes/stx-metadata.bbclass @@ -0,0 +1,41 @@ +# This class is intended to help apply the patches and install +# config files fetched from stx git repo defined in STX_REPO so to +# avoid maintaining a local copy in the recipe's metadata. +# +# This adds dependency on stx-${STX_REPO}-source which +# fetches the stx source code and is used as a shared work +# directory, and the search path of patches and config files +# for the recipe will be added in FILESEXTRAPATHS so the +# patches will be found and applied in do_patch, and STX_METADATA_PATH +# can be used to locate config files to be installed. +# +# Please set the following variables correctly after inherit +# this bbclass: +# - STX_REPO: the StarlingX repo name, default is 'integ' +# - STX_SUBPATH: the subpath for the patches in the work-shard +# directory of stx-${STX_REPO}-source +# - SRC_URI_STX: the patch list in stx-${STX_REPO}-source +# +# e.g. +# STX_REPO = "integ" +# STX_SUBPATH = "config/puppet-modules/openstack/${BP}/centos/patches" +# SRC_URI_STX = "file://0001-Remove-log_dir-from-conf-files.patch" + +STX_REPO ?= "integ" +STX_SUBPATH ?= "" +SRC_URI_STX ?= "" + +STX_METADATA_PATH = "${TMPDIR}/work-shared/stx-${STX_REPO}-source/git/${STX_SUBPATH}" +FILESEXTRAPATHS_prepend = "${STX_METADATA_PATH}:" + +do_patch[depends] += "stx-${STX_REPO}-source:do_patch" + +do_patch_prepend() { + bb.build.exec_func('add_stx_patch', d) +} + +python add_stx_patch() { + src_uri = d.getVar('SRC_URI', False) + src_uri_stx = d.getVar('SRC_URI_STX', False) + d.setVar('SRC_URI', src_uri_stx + " " + src_uri) +} diff --git a/meta-starlingx/meta-stx-distro/classes/stx-source.bbclass b/meta-starlingx/meta-stx-distro/classes/stx-source.bbclass new file mode 100644 index 0000000..202b03c --- /dev/null +++ b/meta-starlingx/meta-stx-distro/classes/stx-source.bbclass @@ -0,0 +1,36 @@ +# This class is usd for creating source recipe for StarlingX repos, +# which will be used as a shared work directory with other recipes + +STX_REPO ?= "integ" +OVERRIDES .= ":${STX_REPO}" + +PROTOCOL = "https" +STX_URI = "git://opendev.org/starlingx/${STX_REPO}.git" + +S = "${WORKDIR}/git" +PV = "1.0.0+git${SRCPV}" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +SRC_URI = "${STX_URI};protocol=${PROTOCOL};rev=${SRCREV};branch=${BRANCH}" + +deltask do_configure +deltask do_compile +deltask do_install +deltask do_populate_sysroot +deltask do_populate_lic + +inherit nopackages + +WORKDIR = "${TMPDIR}/work-shared/${PN}" + +STAMP = "${STAMPS_DIR}/work-shared/${PN}" +STAMPCLEAN = "${STAMPS_DIR}/work-shared/${PN}-*" + +INHIBIT_DEFAULT_DEPS = "1" +DEPENDS = "" +PACKAGES = "" + +EXCLUDE_FROM_WORLD = "1" +RM_WORK_EXCLUDE += "${PN}" diff --git a/meta-starlingx/meta-stx-flock/stx-integ/stx-integ-source_git.bb b/meta-starlingx/meta-stx-flock/stx-integ/stx-integ-source_git.bb new file mode 100644 index 0000000..e78bd9e --- /dev/null +++ b/meta-starlingx/meta-stx-flock/stx-integ/stx-integ-source_git.bb @@ -0,0 +1,8 @@ +DESCRIPTION = "The source recipe for StarlingX Integration repo" + +inherit stx-source + +STX_REPO = "integ" + +BRANCH = "r/stx.5.0" +SRCREV = "821de96615cb6f93fbc39f4baaa769029328d34d" diff --git a/meta-starlingx/meta-stx-flock/stx-upstream/stx-upstream-source_git.bb b/meta-starlingx/meta-stx-flock/stx-upstream/stx-upstream-source_git.bb new file mode 100644 index 0000000..f40a917 --- /dev/null +++ b/meta-starlingx/meta-stx-flock/stx-upstream/stx-upstream-source_git.bb @@ -0,0 +1,8 @@ +DESCRIPTION = "The source recipe for StarlingX Upstream Packages repo" + +inherit stx-source + +STX_REPO = "upstream" + +BRANCH = "r/stx.5.0" +SRCREV = "1eff6b5ab36a814debb6ed563a3999548a2643e6"