Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # remove tasks that modify the source tree in case externalsrc is inherited |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2 | SRCTREECOVEREDTASKS += "do_validate_branches do_kernel_configcheck do_kernel_checkout do_fetch do_unpack do_patch" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3 | PATCH_GIT_USER_EMAIL ?= "kernel-yocto@oe" |
| 4 | PATCH_GIT_USER_NAME ?= "OpenEmbedded" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 6 | # The distro or local.conf should set this, but if nobody cares... |
| 7 | LINUX_KERNEL_TYPE ??= "standard" |
| 8 | |
| 9 | # KMETA ?= "" |
| 10 | KBRANCH ?= "master" |
| 11 | KMACHINE ?= "${MACHINE}" |
| 12 | SRCREV_FORMAT ?= "meta_machine" |
| 13 | |
| 14 | # LEVELS: |
| 15 | # 0: no reporting |
| 16 | # 1: report options that are specified, but not in the final config |
| 17 | # 2: report options that are not hardware related, but set by a BSP |
| 18 | KCONF_AUDIT_LEVEL ?= "1" |
| 19 | KCONF_BSP_AUDIT_LEVEL ?= "0" |
| 20 | KMETA_AUDIT ?= "yes" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 21 | KMETA_AUDIT_WERROR ?= "" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 22 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | # returns local (absolute) path names for all valid patches in the |
| 24 | # src_uri |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 25 | def find_patches(d,subdir): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | patches = src_patches(d) |
| 27 | patch_list=[] |
| 28 | for p in patches: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | _, _, local, _, _, parm = bb.fetch.decodeurl(p) |
| 30 | # if patchdir has been passed, we won't be able to apply it so skip |
| 31 | # the patch for now, and special processing happens later |
| 32 | patchdir = '' |
| 33 | if "patchdir" in parm: |
| 34 | patchdir = parm["patchdir"] |
| 35 | if subdir: |
| 36 | if subdir == patchdir: |
| 37 | patch_list.append(local) |
| 38 | else: |
| 39 | patch_list.append(local) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | |
| 41 | return patch_list |
| 42 | |
| 43 | # returns all the elements from the src uri that are .scc files |
| 44 | def find_sccs(d): |
| 45 | sources=src_patches(d, True) |
| 46 | sources_list=[] |
| 47 | for s in sources: |
| 48 | base, ext = os.path.splitext(os.path.basename(s)) |
| 49 | if ext and ext in [".scc", ".cfg"]: |
| 50 | sources_list.append(s) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 51 | elif base and 'defconfig' in base: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | sources_list.append(s) |
| 53 | |
| 54 | return sources_list |
| 55 | |
| 56 | # check the SRC_URI for "kmeta" type'd git repositories. Return the name of |
| 57 | # the repository as it will be found in WORKDIR |
| 58 | def find_kernel_feature_dirs(d): |
| 59 | feature_dirs=[] |
| 60 | fetch = bb.fetch2.Fetch([], d) |
| 61 | for url in fetch.urls: |
| 62 | urldata = fetch.ud[url] |
| 63 | parm = urldata.parm |
| 64 | type="" |
| 65 | if "type" in parm: |
| 66 | type = parm["type"] |
| 67 | if "destsuffix" in parm: |
| 68 | destdir = parm["destsuffix"] |
| 69 | if type == "kmeta": |
| 70 | feature_dirs.append(destdir) |
| 71 | |
| 72 | return feature_dirs |
| 73 | |
| 74 | # find the master/machine source branch. In the same way that the fetcher proceses |
| 75 | # git repositories in the SRC_URI we take the first repo found, first branch. |
| 76 | def get_machine_branch(d, default): |
| 77 | fetch = bb.fetch2.Fetch([], d) |
| 78 | for url in fetch.urls: |
| 79 | urldata = fetch.ud[url] |
| 80 | parm = urldata.parm |
| 81 | if "branch" in parm: |
| 82 | branches = urldata.parm.get("branch").split(',') |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 83 | btype = urldata.parm.get("type") |
| 84 | if btype != "kmeta": |
| 85 | return branches[0] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | |
| 87 | return default |
| 88 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 89 | # returns a list of all directories that are on FILESEXTRAPATHS (and |
| 90 | # hence available to the build) that contain .scc or .cfg files |
| 91 | def get_dirs_with_fragments(d): |
| 92 | extrapaths = [] |
| 93 | extrafiles = [] |
| 94 | extrapathsvalue = (d.getVar("FILESEXTRAPATHS") or "") |
| 95 | # Remove default flag which was used for checking |
| 96 | extrapathsvalue = extrapathsvalue.replace("__default:", "") |
| 97 | extrapaths = extrapathsvalue.split(":") |
| 98 | for path in extrapaths: |
| 99 | if path + ":True" not in extrafiles: |
| 100 | extrafiles.append(path + ":" + str(os.path.exists(path))) |
| 101 | |
| 102 | return " ".join(extrafiles) |
| 103 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | do_kernel_metadata() { |
| 105 | set +e |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 106 | |
| 107 | if [ -n "$1" ]; then |
| 108 | mode="$1" |
| 109 | else |
| 110 | mode="patch" |
| 111 | fi |
| 112 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | cd ${S} |
| 114 | export KMETA=${KMETA} |
| 115 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 116 | bbnote "do_kernel_metadata: for summary/debug, set KCONF_AUDIT_LEVEL > 0" |
| 117 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | # if kernel tools are available in-tree, they are preferred |
| 119 | # and are placed on the path before any external tools. Unless |
| 120 | # the external tools flag is set, in that case we do nothing. |
| 121 | if [ -f "${S}/scripts/util/configme" ]; then |
| 122 | if [ -z "${EXTERNAL_KERNEL_TOOLS}" ]; then |
| 123 | PATH=${S}/scripts/util:${PATH} |
| 124 | fi |
| 125 | fi |
| 126 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 127 | # In a similar manner to the kernel itself: |
| 128 | # |
| 129 | # defconfig: $(obj)/conf |
| 130 | # ifeq ($(KBUILD_DEFCONFIG),) |
| 131 | # $< --defconfig $(Kconfig) |
| 132 | # else |
| 133 | # @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" |
| 134 | # $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) |
| 135 | # endif |
| 136 | # |
| 137 | # If a defconfig is specified via the KBUILD_DEFCONFIG variable, we copy it |
| 138 | # from the source tree, into a common location and normalized "defconfig" name, |
| 139 | # where the rest of the process will include and incoroporate it into the build |
| 140 | # |
| 141 | # If the fetcher has already placed a defconfig in WORKDIR (from the SRC_URI), |
| 142 | # we don't overwrite it, but instead warn the user that SRC_URI defconfigs take |
| 143 | # precendence. |
| 144 | # |
| 145 | if [ -n "${KBUILD_DEFCONFIG}" ]; then |
| 146 | if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then |
| 147 | if [ -f "${WORKDIR}/defconfig" ]; then |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 148 | # If the two defconfig's are different, warn that we overwrote the |
| 149 | # one already placed in WORKDIR |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 150 | cmp "${WORKDIR}/defconfig" "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" |
| 151 | if [ $? -ne 0 ]; then |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 152 | bbdebug 1 "detected SRC_URI or unpatched defconfig in WORKDIR. ${KBUILD_DEFCONFIG} copied over it" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 153 | fi |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 154 | cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 155 | else |
| 156 | cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 157 | fi |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 158 | in_tree_defconfig="${WORKDIR}/defconfig" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | else |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 160 | bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree (${S}/arch/${ARCH}/configs/)" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | fi |
| 162 | fi |
| 163 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 164 | if [ "$mode" = "patch" ]; then |
| 165 | # was anyone trying to patch the kernel meta data ?, we need to do |
| 166 | # this here, since the scc commands migrate the .cfg fragments to the |
| 167 | # kernel source tree, where they'll be used later. |
| 168 | check_git_config |
| 169 | patches="${@" ".join(find_patches(d,'kernel-meta'))}" |
| 170 | for p in $patches; do |
| 171 | ( |
| 172 | cd ${WORKDIR}/kernel-meta |
| 173 | git am -s $p |
| 174 | ) |
| 175 | done |
| 176 | fi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 177 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 178 | sccs_from_src_uri="${@" ".join(find_sccs(d))}" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 179 | patches="${@" ".join(find_patches(d,''))}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | feat_dirs="${@" ".join(find_kernel_feature_dirs(d))}" |
| 181 | |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 182 | # a quick check to make sure we don't have duplicate defconfigs If |
| 183 | # there's a defconfig in the SRC_URI, did we also have one from the |
| 184 | # KBUILD_DEFCONFIG processing above ? |
| 185 | src_uri_defconfig=$(echo $sccs_from_src_uri | awk '(match($0, "defconfig") != 0) { print $0 }' RS=' ') |
| 186 | # drop and defconfig's from the src_uri variable, we captured it just above here if it existed |
| 187 | sccs_from_src_uri=$(echo $sccs_from_src_uri | awk '(match($0, "defconfig") == 0) { print $0 }' RS=' ') |
| 188 | |
| 189 | if [ -n "$in_tree_defconfig" ]; then |
| 190 | sccs_defconfig=$in_tree_defconfig |
| 191 | if [ -n "$src_uri_defconfig" ]; then |
| 192 | bbwarn "[NOTE]: defconfig was supplied both via KBUILD_DEFCONFIG and SRC_URI. Dropping SRC_URI defconfig" |
| 193 | fi |
| 194 | else |
| 195 | # if we didn't have an in-tree one, make our defconfig the one |
| 196 | # from the src_uri. Note: there may not have been one from the |
| 197 | # src_uri, so this can be an empty variable. |
| 198 | sccs_defconfig=$src_uri_defconfig |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 199 | fi |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 200 | sccs="$sccs_from_src_uri" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 201 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 202 | # check for feature directories/repos/branches that were part of the |
| 203 | # SRC_URI. If they were supplied, we convert them into include directives |
| 204 | # for the update part of the process |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 205 | for f in ${feat_dirs}; do |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 206 | if [ -d "${WORKDIR}/$f/meta" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 207 | includes="$includes -I${WORKDIR}/$f/kernel-meta" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 208 | elif [ -d "${WORKDIR}/../oe-local-files/$f" ]; then |
| 209 | includes="$includes -I${WORKDIR}/../oe-local-files/$f" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 210 | elif [ -d "${WORKDIR}/$f" ]; then |
| 211 | includes="$includes -I${WORKDIR}/$f" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 212 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 213 | done |
| 214 | for s in ${sccs} ${patches}; do |
| 215 | sdir=$(dirname $s) |
| 216 | includes="$includes -I${sdir}" |
| 217 | # if a SRC_URI passed patch or .scc has a subdir of "kernel-meta", |
| 218 | # then we add it to the search path |
| 219 | if [ -d "${sdir}/kernel-meta" ]; then |
| 220 | includes="$includes -I${sdir}/kernel-meta" |
| 221 | fi |
| 222 | done |
| 223 | |
| 224 | # expand kernel features into their full path equivalents |
| 225 | bsp_definition=$(spp ${includes} --find -DKMACHINE=${KMACHINE} -DKTYPE=${LINUX_KERNEL_TYPE}) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 226 | if [ -z "$bsp_definition" ]; then |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 227 | if [ -z "$sccs_defconfig" ]; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 228 | bbfatal_log "Could not locate BSP definition for ${KMACHINE}/${LINUX_KERNEL_TYPE} and no defconfig was provided" |
| 229 | fi |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 230 | else |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 231 | # if the bsp definition has "define KMETA_EXTERNAL_BSP t", |
| 232 | # then we need to set a flag that will instruct the next |
| 233 | # steps to use the BSP as both configuration and patches. |
| 234 | grep -q KMETA_EXTERNAL_BSP $bsp_definition |
| 235 | if [ $? -eq 0 ]; then |
| 236 | KMETA_EXTERNAL_BSPS="t" |
| 237 | fi |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 238 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 239 | meta_dir=$(kgit --meta) |
| 240 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 241 | KERNEL_FEATURES_FINAL="" |
| 242 | if [ -n "${KERNEL_FEATURES}" ]; then |
| 243 | for feature in ${KERNEL_FEATURES}; do |
| 244 | feature_found=f |
| 245 | for d in $includes; do |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 246 | path_to_check=$(echo $d | sed 's/^-I//') |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 247 | if [ "$feature_found" = "f" ] && [ -e "$path_to_check/$feature" ]; then |
| 248 | feature_found=t |
| 249 | fi |
| 250 | done |
| 251 | if [ "$feature_found" = "f" ]; then |
| 252 | if [ -n "${KERNEL_DANGLING_FEATURES_WARN_ONLY}" ]; then |
| 253 | bbwarn "Feature '$feature' not found, but KERNEL_DANGLING_FEATURES_WARN_ONLY is set" |
| 254 | bbwarn "This may cause runtime issues, dropping feature and allowing configuration to continue" |
| 255 | else |
| 256 | bberror "Feature '$feature' not found, this will cause configuration failures." |
| 257 | bberror "Check the SRC_URI for meta-data repositories or directories that may be missing" |
| 258 | bbfatal_log "Set KERNEL_DANGLING_FEATURES_WARN_ONLY to ignore this issue" |
| 259 | fi |
| 260 | else |
| 261 | KERNEL_FEATURES_FINAL="$KERNEL_FEATURES_FINAL $feature" |
| 262 | fi |
| 263 | done |
| 264 | fi |
| 265 | |
| 266 | if [ "$mode" = "config" ]; then |
| 267 | # run1: pull all the configuration fragments, no matter where they come from |
| 268 | elements="`echo -n ${bsp_definition} $sccs_defconfig ${sccs} ${patches} $KERNEL_FEATURES_FINAL`" |
| 269 | if [ -n "${elements}" ]; then |
| 270 | echo "${bsp_definition}" > ${S}/${meta_dir}/bsp_definition |
| 271 | scc --force -o ${S}/${meta_dir}:cfg,merge,meta ${includes} $sccs_defconfig $bsp_definition $sccs $patches $KERNEL_FEATURES_FINAL |
| 272 | if [ $? -ne 0 ]; then |
| 273 | bbfatal_log "Could not generate configuration queue for ${KMACHINE}." |
| 274 | fi |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 275 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 276 | fi |
| 277 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 278 | # if KMETA_EXTERNAL_BSPS has been set, or it has been detected from |
| 279 | # the bsp definition, then we inject the bsp_definition into the |
| 280 | # patch phase below. we'll piggy back on the sccs variable. |
| 281 | if [ -n "${KMETA_EXTERNAL_BSPS}" ]; then |
| 282 | sccs="${bsp_definition} ${sccs}" |
| 283 | fi |
| 284 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 285 | if [ "$mode" = "patch" ]; then |
| 286 | # run2: only generate patches for elements that have been passed on the SRC_URI |
| 287 | elements="`echo -n ${sccs} ${patches} $KERNEL_FEATURES_FINAL`" |
| 288 | if [ -n "${elements}" ]; then |
| 289 | scc --force -o ${S}/${meta_dir}:patch --cmds patch ${includes} ${sccs} ${patches} $KERNEL_FEATURES_FINAL |
| 290 | if [ $? -ne 0 ]; then |
| 291 | bbfatal_log "Could not generate configuration queue for ${KMACHINE}." |
| 292 | fi |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 293 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 294 | fi |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 295 | |
| 296 | if [ ${KCONF_AUDIT_LEVEL} -gt 0 ]; then |
| 297 | bbnote "kernel meta data summary for ${KMACHINE} (${LINUX_KERNEL_TYPE}):" |
| 298 | bbnote "======================================================================" |
| 299 | if [ -n "${KMETA_EXTERNAL_BSPS}" ]; then |
| 300 | bbnote "Non kernel-cache (external) bsp" |
| 301 | fi |
| 302 | bbnote "BSP entry point / definition: $bsp_definition" |
| 303 | if [ -n "$in_tree_defconfig" ]; then |
| 304 | bbnote "KBUILD_DEFCONFIG: ${KBUILD_DEFCONFIG}" |
| 305 | fi |
| 306 | bbnote "Fragments from SRC_URI: $sccs_from_src_uri" |
| 307 | bbnote "KERNEL_FEATURES: $KERNEL_FEATURES_FINAL" |
| 308 | bbnote "Final scc/cfg list: $sccs_defconfig $bsp_definition $sccs $KERNEL_FEATURES_FINAL" |
| 309 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | do_patch() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 313 | set +e |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 314 | cd ${S} |
| 315 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 316 | check_git_config |
| 317 | meta_dir=$(kgit --meta) |
| 318 | (cd ${meta_dir}; ln -sf patch.queue series) |
| 319 | if [ -f "${meta_dir}/series" ]; then |
| 320 | kgit-s2q --gen -v --patches .kernel-meta/ |
| 321 | if [ $? -ne 0 ]; then |
| 322 | bberror "Could not apply patches for ${KMACHINE}." |
| 323 | bbfatal_log "Patch failures can be resolved in the linux source directory ${S})" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 324 | fi |
| 325 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 326 | |
| 327 | if [ -f "${meta_dir}/merge.queue" ]; then |
| 328 | # we need to merge all these branches |
| 329 | for b in $(cat ${meta_dir}/merge.queue); do |
| 330 | git show-ref --verify --quiet refs/heads/${b} |
| 331 | if [ $? -eq 0 ]; then |
| 332 | bbnote "Merging branch ${b}" |
| 333 | git merge -q --no-ff -m "Merge branch ${b}" ${b} |
| 334 | else |
| 335 | bbfatal "branch ${b} does not exist, cannot merge" |
| 336 | fi |
| 337 | done |
| 338 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | do_kernel_checkout() { |
| 342 | set +e |
| 343 | |
| 344 | source_dir=`echo ${S} | sed 's%/$%%'` |
| 345 | source_workdir="${WORKDIR}/git" |
| 346 | if [ -d "${WORKDIR}/git/" ]; then |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 347 | # case: git repository |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 348 | # if S is WORKDIR/git, then we shouldn't be moving or deleting the tree. |
| 349 | if [ "${source_dir}" != "${source_workdir}" ]; then |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 350 | if [ -d "${source_workdir}/.git" ]; then |
| 351 | # regular git repository with .git |
| 352 | rm -rf ${S} |
| 353 | mv ${WORKDIR}/git ${S} |
| 354 | else |
| 355 | # create source for bare cloned git repository |
| 356 | git clone ${WORKDIR}/git ${S} |
| 357 | rm -rf ${WORKDIR}/git |
| 358 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 359 | fi |
| 360 | cd ${S} |
| 361 | else |
| 362 | # case: we have no git repository at all. |
| 363 | # To support low bandwidth options for building the kernel, we'll just |
| 364 | # convert the tree to a git repo and let the rest of the process work unchanged |
| 365 | |
| 366 | # if ${S} hasn't been set to the proper subdirectory a default of "linux" is |
| 367 | # used, but we can't initialize that empty directory. So check it and throw a |
| 368 | # clear error |
| 369 | |
| 370 | cd ${S} |
| 371 | if [ ! -f "Makefile" ]; then |
| 372 | bberror "S is not set to the linux source directory. Check " |
| 373 | bbfatal "the recipe and set S to the proper extracted subdirectory" |
| 374 | fi |
| 375 | rm -f .gitignore |
| 376 | git init |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 377 | check_git_config |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 378 | git add . |
| 379 | git commit -q -m "baseline commit: creating repo for ${PN}-${PV}" |
| 380 | git clean -d -f |
| 381 | fi |
| 382 | |
| 383 | # convert any remote branches to local tracking ones |
| 384 | for i in `git branch -a --no-color | grep remotes | grep -v HEAD`; do |
| 385 | b=`echo $i | cut -d' ' -f2 | sed 's%remotes/origin/%%'`; |
| 386 | git show-ref --quiet --verify -- "refs/heads/$b" |
| 387 | if [ $? -ne 0 ]; then |
| 388 | git branch $b $i > /dev/null |
| 389 | fi |
| 390 | done |
| 391 | |
| 392 | # Create a working tree copy of the kernel by checking out a branch |
| 393 | machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}" |
| 394 | |
| 395 | # checkout and clobber any unimportant files |
| 396 | git checkout -f ${machine_branch} |
| 397 | } |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 398 | do_kernel_checkout[dirs] = "${S} ${WORKDIR}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 399 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 400 | addtask kernel_checkout before do_kernel_metadata after do_symlink_kernsrc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 401 | addtask kernel_metadata after do_validate_branches do_unpack before do_patch |
| 402 | do_kernel_metadata[depends] = "kern-tools-native:do_populate_sysroot" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 403 | do_kernel_metadata[file-checksums] = " ${@get_dirs_with_fragments(d)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 404 | do_validate_branches[depends] = "kern-tools-native:do_populate_sysroot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 405 | |
William A. Kennington III | 47649fa | 2018-06-28 12:34:29 -0700 | [diff] [blame] | 406 | do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}binutils:do_populate_sysroot" |
| 407 | do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}gcc:do_populate_sysroot" |
| 408 | do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 409 | do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 410 | do_kernel_configme[dirs] += "${S} ${B}" |
| 411 | do_kernel_configme() { |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 412 | do_kernel_metadata config |
| 413 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 414 | # translate the kconfig_mode into something that merge_config.sh |
| 415 | # understands |
| 416 | case ${KCONFIG_MODE} in |
| 417 | *allnoconfig) |
| 418 | config_flags="-n" |
| 419 | ;; |
| 420 | *alldefconfig) |
| 421 | config_flags="" |
| 422 | ;; |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 423 | *) |
| 424 | if [ -f ${WORKDIR}/defconfig ]; then |
| 425 | config_flags="-n" |
| 426 | fi |
| 427 | ;; |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 428 | esac |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 429 | |
| 430 | cd ${S} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 431 | |
| 432 | meta_dir=$(kgit --meta) |
| 433 | configs="$(scc --configs -o ${meta_dir})" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 434 | if [ $? -ne 0 ]; then |
| 435 | bberror "${configs}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 436 | bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)" |
| 437 | fi |
| 438 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 439 | CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" LD="${KERNEL_LD}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1 |
| 440 | if [ $? -ne 0 -o ! -f ${B}/.config ]; then |
| 441 | bberror "Could not generate a .config for ${KMACHINE}-${LINUX_KERNEL_TYPE}" |
| 442 | if [ ${KCONF_AUDIT_LEVEL} -gt 1 ]; then |
| 443 | bbfatal_log "`cat ${meta_dir}/cfg/merge_config_build.log`" |
| 444 | else |
| 445 | bbfatal_log "Details can be found at: ${S}/${meta_dir}/cfg/merge_config_build.log" |
| 446 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 447 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 448 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 449 | if [ ! -z "${LINUX_VERSION_EXTENSION}" ]; then |
| 450 | echo "# Global settings from linux recipe" >> ${B}/.config |
| 451 | echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config |
| 452 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | addtask kernel_configme before do_configure after do_patch |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 456 | addtask config_analysis |
| 457 | |
| 458 | do_config_analysis[depends] = "virtual/kernel:do_configure" |
| 459 | do_config_analysis[depends] += "kern-tools-native:do_populate_sysroot" |
| 460 | |
| 461 | CONFIG_AUDIT_FILE ?= "${WORKDIR}/config-audit.txt" |
| 462 | CONFIG_ANALYSIS_FILE ?= "${WORKDIR}/config-analysis.txt" |
| 463 | |
| 464 | python do_config_analysis() { |
| 465 | import re, string, sys, subprocess |
| 466 | |
| 467 | s = d.getVar('S') |
| 468 | |
| 469 | env = os.environ.copy() |
| 470 | env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") |
| 471 | env['LD'] = d.getVar('KERNEL_LD') |
| 472 | env['CC'] = d.getVar('KERNEL_CC') |
| 473 | env['ARCH'] = d.getVar('ARCH') |
| 474 | env['srctree'] = s |
| 475 | |
| 476 | # read specific symbols from the kernel recipe or from local.conf |
| 477 | # i.e.: CONFIG_ANALYSIS_pn-linux-yocto-dev = 'NF_CONNTRACK LOCALVERSION' |
| 478 | config = d.getVar( 'CONFIG_ANALYSIS' ) |
| 479 | if not config: |
| 480 | config = [ "" ] |
| 481 | else: |
| 482 | config = config.split() |
| 483 | |
| 484 | for c in config: |
| 485 | for action in ["analysis","audit"]: |
| 486 | if action == "analysis": |
| 487 | try: |
| 488 | analysis = subprocess.check_output(['symbol_why.py', '--dotconfig', '{}'.format( d.getVar('B') + '/.config' ), '--blame', c], cwd=s, env=env ).decode('utf-8') |
| 489 | except subprocess.CalledProcessError as e: |
| 490 | bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) |
| 491 | |
| 492 | outfile = d.getVar( 'CONFIG_ANALYSIS_FILE' ) |
| 493 | |
| 494 | if action == "audit": |
| 495 | try: |
| 496 | analysis = subprocess.check_output(['symbol_why.py', '--dotconfig', '{}'.format( d.getVar('B') + '/.config' ), '--summary', '--extended', '--sanity', c], cwd=s, env=env ).decode('utf-8') |
| 497 | except subprocess.CalledProcessError as e: |
| 498 | bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) |
| 499 | |
| 500 | outfile = d.getVar( 'CONFIG_AUDIT_FILE' ) |
| 501 | |
| 502 | if c: |
| 503 | outdir = os.path.dirname( outfile ) |
| 504 | outname = os.path.basename( outfile ) |
| 505 | outfile = outdir + '/'+ c + '-' + outname |
| 506 | |
| 507 | if config and os.path.isfile(outfile): |
| 508 | os.remove(outfile) |
| 509 | |
| 510 | with open(outfile, 'w+') as f: |
| 511 | f.write( analysis ) |
| 512 | |
| 513 | bb.warn( "Configuration {} executed, see: {} for details".format(action,outfile )) |
| 514 | if c: |
| 515 | bb.warn( analysis ) |
| 516 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 517 | |
| 518 | python do_kernel_configcheck() { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 519 | import re, string, sys, subprocess |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 520 | |
| 521 | # if KMETA isn't set globally by a recipe using this routine, we need to |
| 522 | # set the default to 'meta'. Otherwise, kconf_check is not passed a valid |
| 523 | # meta-series for processing |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 524 | kmeta = d.getVar("KMETA") or "meta" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 525 | if not os.path.exists(kmeta): |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 526 | kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S')).decode('utf-8').rstrip() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 527 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 528 | s = d.getVar('S') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 529 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 530 | env = os.environ.copy() |
| 531 | env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 532 | env['LD'] = d.getVar('KERNEL_LD') |
| 533 | env['CC'] = d.getVar('KERNEL_CC') |
| 534 | env['ARCH'] = d.getVar('ARCH') |
| 535 | env['srctree'] = s |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 536 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 537 | try: |
| 538 | configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8') |
| 539 | except subprocess.CalledProcessError as e: |
| 540 | bb.fatal( "Cannot gather config fragments for audit: %s" % e.output.decode("utf-8") ) |
| 541 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 542 | config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0) |
| 543 | bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 544 | kmeta_audit_werror = d.getVar("KMETA_AUDIT_WERROR") or "" |
| 545 | warnings_detected = False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 546 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 547 | # if config check visibility is "1", that's the lowest level of audit. So |
| 548 | # we add the --classify option to the run, since classification will |
| 549 | # streamline the output to only report options that could be boot issues, |
| 550 | # or are otherwise required for proper operation. |
| 551 | extra_params = "" |
| 552 | if config_check_visibility == 1: |
| 553 | extra_params = "--classify" |
| 554 | |
| 555 | # category #1: mismatches |
| 556 | try: |
| 557 | analysis = subprocess.check_output(['symbol_why.py', '--dotconfig', '{}'.format( d.getVar('B') + '/.config' ), '--mismatches', extra_params], cwd=s, env=env ).decode('utf-8') |
| 558 | except subprocess.CalledProcessError as e: |
| 559 | bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) |
| 560 | |
| 561 | if analysis: |
| 562 | outfile = "{}/{}/cfg/mismatch.txt".format( s, kmeta ) |
| 563 | if os.path.isfile(outfile): |
| 564 | os.remove(outfile) |
| 565 | with open(outfile, 'w+') as f: |
| 566 | f.write( analysis ) |
| 567 | |
| 568 | if config_check_visibility and os.stat(outfile).st_size > 0: |
| 569 | with open (outfile, "r") as myfile: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 570 | results = myfile.read() |
| 571 | bb.warn( "[kernel config]: specified values did not make it into the kernel's final configuration:\n\n%s" % results) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 572 | warnings_detected = True |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 573 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 574 | # category #2: invalid fragment elements |
| 575 | extra_params = "" |
| 576 | if bsp_check_visibility > 1: |
| 577 | extra_params = "--strict" |
| 578 | try: |
| 579 | analysis = subprocess.check_output(['symbol_why.py', '--dotconfig', '{}'.format( d.getVar('B') + '/.config' ), '--invalid', extra_params], cwd=s, env=env ).decode('utf-8') |
| 580 | except subprocess.CalledProcessError as e: |
| 581 | bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 582 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 583 | if analysis: |
| 584 | outfile = "{}/{}/cfg/invalid.txt".format(s,kmeta) |
| 585 | if os.path.isfile(outfile): |
| 586 | os.remove(outfile) |
| 587 | with open(outfile, 'w+') as f: |
| 588 | f.write( analysis ) |
| 589 | |
| 590 | if bsp_check_visibility and os.stat(outfile).st_size > 0: |
| 591 | with open (outfile, "r") as myfile: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 592 | results = myfile.read() |
| 593 | bb.warn( "[kernel config]: This BSP contains fragments with warnings:\n\n%s" % results) |
| 594 | warnings_detected = True |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 595 | |
| 596 | # category #3: redefined options (this is pretty verbose and is debug only) |
| 597 | try: |
| 598 | analysis = subprocess.check_output(['symbol_why.py', '--dotconfig', '{}'.format( d.getVar('B') + '/.config' ), '--sanity'], cwd=s, env=env ).decode('utf-8') |
| 599 | except subprocess.CalledProcessError as e: |
| 600 | bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) |
| 601 | |
| 602 | if analysis: |
| 603 | outfile = "{}/{}/cfg/redefinition.txt".format(s,kmeta) |
| 604 | if os.path.isfile(outfile): |
| 605 | os.remove(outfile) |
| 606 | with open(outfile, 'w+') as f: |
| 607 | f.write( analysis ) |
| 608 | |
| 609 | # if the audit level is greater than two, we report if a fragment has overriden |
| 610 | # a value from a base fragment. This is really only used for new kernel introduction |
| 611 | if bsp_check_visibility > 2 and os.stat(outfile).st_size > 0: |
| 612 | with open (outfile, "r") as myfile: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 613 | results = myfile.read() |
| 614 | bb.warn( "[kernel config]: This BSP has configuration options defined in more than one config, with differing values:\n\n%s" % results) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 615 | warnings_detected = True |
| 616 | |
| 617 | if warnings_detected and kmeta_audit_werror: |
| 618 | bb.fatal( "configuration warnings detected, werror is set, promoting to fatal" ) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | # Ensure that the branches (BSP and meta) are on the locations specified by |
| 622 | # their SRCREV values. If they are NOT on the right commits, the branches |
| 623 | # are corrected to the proper commit. |
| 624 | do_validate_branches() { |
| 625 | set +e |
| 626 | cd ${S} |
| 627 | |
| 628 | machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}" |
| 629 | machine_srcrev="${SRCREV_machine}" |
| 630 | |
| 631 | # if SRCREV is AUTOREV it shows up as AUTOINC there's nothing to |
| 632 | # check and we can exit early |
| 633 | if [ "${machine_srcrev}" = "AUTOINC" ]; then |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 634 | linux_yocto_dev='${@oe.utils.conditional("PREFERRED_PROVIDER_virtual/kernel", "linux-yocto-dev", "1", "", d)}' |
| 635 | if [ -n "$linux_yocto_dev" ]; then |
| 636 | git checkout -q -f ${machine_branch} |
| 637 | ver=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//) |
| 638 | patchlevel=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//) |
| 639 | sublevel=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//) |
| 640 | kver="$ver.$patchlevel" |
| 641 | bbnote "dev kernel: performing version -> branch -> SRCREV validation" |
| 642 | bbnote "dev kernel: recipe version ${LINUX_VERSION}, src version: $kver" |
| 643 | echo "${LINUX_VERSION}" | grep -q $kver |
| 644 | if [ $? -ne 0 ]; then |
| 645 | version="$(echo ${LINUX_VERSION} | sed 's/\+.*$//g')" |
| 646 | versioned_branch="v$version/$machine_branch" |
| 647 | |
| 648 | machine_branch=$versioned_branch |
| 649 | force_srcrev="$(git rev-parse $machine_branch 2> /dev/null)" |
| 650 | if [ $? -ne 0 ]; then |
| 651 | bbfatal "kernel version mismatch detected, and no valid branch $machine_branch detected" |
| 652 | fi |
| 653 | |
| 654 | bbnote "dev kernel: adjusting branch to $machine_branch, srcrev to: $force_srcrev" |
| 655 | fi |
| 656 | else |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 657 | bbnote "SRCREV validation is not required for AUTOREV" |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 658 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 659 | elif [ "${machine_srcrev}" = "" ]; then |
| 660 | if [ "${SRCREV}" != "AUTOINC" ] && [ "${SRCREV}" != "INVALID" ]; then |
| 661 | # SRCREV_machine_<MACHINE> was not set. This means that a custom recipe |
| 662 | # that doesn't use the SRCREV_FORMAT "machine_meta" is being built. In |
| 663 | # this case, we need to reset to the give SRCREV before heading to patching |
| 664 | bbnote "custom recipe is being built, forcing SRCREV to ${SRCREV}" |
| 665 | force_srcrev="${SRCREV}" |
| 666 | fi |
| 667 | else |
| 668 | git cat-file -t ${machine_srcrev} > /dev/null |
| 669 | if [ $? -ne 0 ]; then |
| 670 | bberror "${machine_srcrev} is not a valid commit ID." |
| 671 | bbfatal_log "The kernel source tree may be out of sync" |
| 672 | fi |
| 673 | force_srcrev=${machine_srcrev} |
| 674 | fi |
| 675 | |
| 676 | git checkout -q -f ${machine_branch} |
| 677 | if [ -n "${force_srcrev}" ]; then |
| 678 | # see if the branch we are about to patch has been properly reset to the defined |
| 679 | # SRCREV .. if not, we reset it. |
| 680 | branch_head=`git rev-parse HEAD` |
| 681 | if [ "${force_srcrev}" != "${branch_head}" ]; then |
| 682 | current_branch=`git rev-parse --abbrev-ref HEAD` |
| 683 | git branch "$current_branch-orig" |
| 684 | git reset --hard ${force_srcrev} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 685 | # We've checked out HEAD, make sure we cleanup kgit-s2q fence post check |
| 686 | # so the patches are applied as expected otherwise no patching |
| 687 | # would be done in some corner cases. |
| 688 | kgit-s2q --clean |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 689 | fi |
| 690 | fi |
| 691 | } |
| 692 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 693 | OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" |
| 694 | KBUILD_OUTPUT = "${B}" |
| 695 | |
| 696 | python () { |
| 697 | # If diffconfig is available, ensure it runs after kernel_configme |
| 698 | if 'do_diffconfig' in d: |
| 699 | bb.build.addtask('do_diffconfig', None, 'do_kernel_configme', d) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 700 | |
| 701 | externalsrc = d.getVar('EXTERNALSRC') |
| 702 | if externalsrc: |
| 703 | # If we deltask do_patch, do_kernel_configme is left without |
| 704 | # dependencies and runs too early |
| 705 | d.setVarFlag('do_kernel_configme', 'deps', (d.getVarFlag('do_kernel_configme', 'deps', False) or []) + ['do_unpack']) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 706 | } |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 707 | |
| 708 | # extra tasks |
| 709 | addtask kernel_version_sanity_check after do_kernel_metadata do_kernel_checkout before do_compile |
| 710 | addtask validate_branches before do_patch after do_kernel_checkout |
| 711 | addtask kernel_configcheck after do_configure before do_compile |