Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | SLOWTASKS ??= "" |
| 2 | SSTATEVALID ??= "" |
| 3 | |
| 4 | def stamptask(d): |
| 5 | import time |
| 6 | |
| 7 | thistask = d.expand("${PN}:${BB_CURRENTTASK}") |
| 8 | with open(d.expand("${TOPDIR}/%s.run") % thistask, "a+") as f: |
| 9 | f.write("\n") |
| 10 | |
| 11 | if d.getVar("BB_CURRENT_MC") != "default": |
| 12 | thistask = d.expand("${BB_CURRENT_MC}:${PN}:${BB_CURRENTTASK}") |
| 13 | if thistask in d.getVar("SLOWTASKS").split(): |
| 14 | bb.note("Slowing task %s" % thistask) |
| 15 | time.sleep(0.5) |
| 16 | |
| 17 | with open(d.expand("${TOPDIR}/task.log"), "a+") as f: |
| 18 | f.write(thistask + "\n") |
| 19 | |
| 20 | python do_fetch() { |
| 21 | # fetch |
| 22 | stamptask(d) |
| 23 | } |
| 24 | python do_unpack() { |
| 25 | # unpack |
| 26 | stamptask(d) |
| 27 | } |
| 28 | python do_patch() { |
| 29 | # patch |
| 30 | stamptask(d) |
| 31 | } |
| 32 | python do_populate_lic() { |
| 33 | # populate_lic |
| 34 | stamptask(d) |
| 35 | } |
| 36 | python do_prepare_recipe_sysroot() { |
| 37 | # prepare_recipe_sysroot |
| 38 | stamptask(d) |
| 39 | } |
| 40 | python do_configure() { |
| 41 | # configure |
| 42 | stamptask(d) |
| 43 | } |
| 44 | python do_compile() { |
| 45 | # compile |
| 46 | stamptask(d) |
| 47 | } |
| 48 | python do_install() { |
| 49 | # install |
| 50 | stamptask(d) |
| 51 | } |
| 52 | python do_populate_sysroot() { |
| 53 | # populate_sysroot |
| 54 | stamptask(d) |
| 55 | } |
| 56 | python do_package() { |
| 57 | # package |
| 58 | stamptask(d) |
| 59 | } |
| 60 | python do_package_write_ipk() { |
| 61 | # package_write_ipk |
| 62 | stamptask(d) |
| 63 | } |
| 64 | python do_package_write_rpm() { |
| 65 | # package_write_rpm |
| 66 | stamptask(d) |
| 67 | } |
| 68 | python do_packagedata() { |
| 69 | # packagedata |
| 70 | stamptask(d) |
| 71 | } |
| 72 | python do_package_qa() { |
| 73 | # package_qa |
| 74 | stamptask(d) |
| 75 | } |
| 76 | python do_build() { |
| 77 | # build |
| 78 | stamptask(d) |
| 79 | } |
| 80 | do_prepare_recipe_sysroot[deptask] = "do_populate_sysroot" |
| 81 | do_package[deptask] += "do_packagedata" |
| 82 | do_build[recrdeptask] += "do_deploy" |
| 83 | do_build[recrdeptask] += "do_package_write_ipk" |
| 84 | do_build[recrdeptask] += "do_package_write_rpm" |
| 85 | do_package_qa[rdeptask] = "do_packagedata" |
| 86 | do_populate_lic_deploy[recrdeptask] += "do_populate_lic do_deploy" |
| 87 | |
| 88 | DEBIANRDEP = "do_packagedata" |
| 89 | oo_package_write_ipk[rdeptask] = "${DEBIANRDEP}" |
| 90 | do_package_write_rpm[rdeptask] = "${DEBIANRDEP}" |
| 91 | |
| 92 | addtask fetch |
| 93 | addtask unpack after do_fetch |
| 94 | addtask patch after do_unpack |
| 95 | addtask prepare_recipe_sysroot after do_patch |
| 96 | addtask configure after do_prepare_recipe_sysroot |
| 97 | addtask compile after do_configure |
| 98 | addtask install after do_compile |
| 99 | addtask populate_sysroot after do_install |
| 100 | addtask package after do_install |
| 101 | addtask package_write_ipk after do_packagedata do_package |
| 102 | addtask package_write_rpm after do_packagedata do_package |
| 103 | addtask packagedata after do_package |
| 104 | addtask package_qa after do_package |
| 105 | addtask build after do_package_qa do_package_write_rpm do_package_write_ipk do_populate_sysroot |
| 106 | |
| 107 | python do_package_setscene() { |
| 108 | stamptask(d) |
| 109 | } |
| 110 | python do_package_qa_setscene() { |
| 111 | stamptask(d) |
| 112 | } |
| 113 | python do_package_write_ipk_setscene() { |
| 114 | stamptask(d) |
| 115 | } |
| 116 | python do_package_write_rpm_setscene() { |
| 117 | stamptask(d) |
| 118 | } |
| 119 | python do_packagedata_setscene() { |
| 120 | stamptask(d) |
| 121 | } |
| 122 | python do_populate_lic_setscene() { |
| 123 | stamptask(d) |
| 124 | } |
| 125 | python do_populate_sysroot_setscene() { |
| 126 | stamptask(d) |
| 127 | } |
| 128 | |
| 129 | addtask package_setscene |
| 130 | addtask package_qa_setscene |
| 131 | addtask package_write_ipk_setscene |
| 132 | addtask package_write_rpm_setscene |
| 133 | addtask packagedata_setscene |
| 134 | addtask populate_lic_setscene |
| 135 | addtask populate_sysroot_setscene |
| 136 | |
| 137 | BB_SETSCENE_DEPVALID = "setscene_depvalid" |
| 138 | |
| 139 | def setscene_depvalid(task, taskdependees, notneeded, d, log=None): |
| 140 | # taskdependees is a dict of tasks which depend on task, each being a 3 item list of [PN, TASKNAME, FILENAME] |
| 141 | # task is included in taskdependees too |
| 142 | # Return - False - We need this dependency |
| 143 | # - True - We can skip this dependency |
| 144 | import re |
| 145 | |
| 146 | def logit(msg, log): |
| 147 | if log is not None: |
| 148 | log.append(msg) |
| 149 | else: |
| 150 | bb.debug(2, msg) |
| 151 | |
| 152 | logit("Considering setscene task: %s" % (str(taskdependees[task])), log) |
| 153 | |
| 154 | def isNativeCross(x): |
| 155 | return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross") |
| 156 | |
| 157 | # We only need to trigger populate_lic through direct dependencies |
| 158 | if taskdependees[task][1] == "do_populate_lic": |
| 159 | return True |
| 160 | |
| 161 | # We only need to trigger packagedata through direct dependencies |
| 162 | # but need to preserve packagedata on packagedata links |
| 163 | if taskdependees[task][1] == "do_packagedata": |
| 164 | for dep in taskdependees: |
| 165 | if taskdependees[dep][1] == "do_packagedata": |
| 166 | return False |
| 167 | return True |
| 168 | |
| 169 | for dep in taskdependees: |
| 170 | logit(" considering dependency: %s" % (str(taskdependees[dep])), log) |
| 171 | if task == dep: |
| 172 | continue |
| 173 | if dep in notneeded: |
| 174 | continue |
| 175 | # do_package_write_* and do_package doesn't need do_package |
| 176 | if taskdependees[task][1] == "do_package" and taskdependees[dep][1] in ['do_package', 'do_package_write_ipk', 'do_package_write_rpm', 'do_packagedata', 'do_package_qa']: |
| 177 | continue |
| 178 | # do_package_write_* need do_populate_sysroot as they're mainly postinstall dependencies |
| 179 | if taskdependees[task][1] == "do_populate_sysroot" and taskdependees[dep][1] in ['do_package_write_ipk', 'do_package_write_rpm']: |
| 180 | return False |
| 181 | # do_package/packagedata/package_qa don't need do_populate_sysroot |
| 182 | if taskdependees[task][1] == "do_populate_sysroot" and taskdependees[dep][1] in ['do_package', 'do_packagedata', 'do_package_qa']: |
| 183 | continue |
| 184 | # Native/Cross packages don't exist and are noexec anyway |
| 185 | if isNativeCross(taskdependees[dep][0]) and taskdependees[dep][1] in ['do_package_write_ipk', 'do_package_write_rpm', 'do_packagedata', 'do_package', 'do_package_qa']: |
| 186 | continue |
| 187 | |
| 188 | # This is due to the [depends] in useradd.bbclass complicating matters |
| 189 | # The logic *is* reversed here due to the way hard setscene dependencies are injected |
| 190 | if (taskdependees[task][1] == 'do_package' or taskdependees[task][1] == 'do_populate_sysroot') and taskdependees[dep][0].endswith(('shadow-native', 'shadow-sysroot', 'base-passwd', 'pseudo-native')) and taskdependees[dep][1] == 'do_populate_sysroot': |
| 191 | continue |
| 192 | |
| 193 | # Consider sysroot depending on sysroot tasks |
| 194 | if taskdependees[task][1] == 'do_populate_sysroot' and taskdependees[dep][1] == 'do_populate_sysroot': |
| 195 | # Native/Cross populate_sysroot need their dependencies |
| 196 | if isNativeCross(taskdependees[task][0]) and isNativeCross(taskdependees[dep][0]): |
| 197 | return False |
| 198 | # Target populate_sysroot depended on by cross tools need to be installed |
| 199 | if isNativeCross(taskdependees[dep][0]): |
| 200 | return False |
| 201 | # Native/cross tools depended upon by target sysroot are not needed |
| 202 | # Add an exception for shadow-native as required by useradd.bbclass |
| 203 | if isNativeCross(taskdependees[task][0]) and taskdependees[task][0] != 'shadow-native': |
| 204 | continue |
| 205 | # Target populate_sysroot need their dependencies |
| 206 | return False |
| 207 | |
| 208 | |
| 209 | if taskdependees[dep][1] == "do_populate_lic": |
| 210 | continue |
| 211 | |
| 212 | # Safe fallthrough default |
| 213 | logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log) |
| 214 | return False |
| 215 | return True |
| 216 | |
| 217 | BB_HASHCHECK_FUNCTION = "sstate_checkhashes" |
| 218 | |
| 219 | def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=False, *, sq_unihash=None): |
| 220 | |
| 221 | ret = [] |
| 222 | missed = [] |
| 223 | |
| 224 | valid = d.getVar("SSTATEVALID").split() |
| 225 | |
| 226 | for task in range(len(sq_fn)): |
| 227 | n = os.path.basename(sq_fn[task]).rsplit(".", 1)[0] + ":" + sq_task[task] |
| 228 | if n in valid: |
| 229 | bb.note("SState: Found valid sstate for %s" % n) |
| 230 | ret.append(task) |
| 231 | elif os.path.exists(d.expand("${TOPDIR}/%s.run" % n.replace("do_", ""))): |
| 232 | bb.note("SState: Found valid sstate for %s (already run)" % n) |
| 233 | ret.append(task) |
| 234 | else: |
| 235 | missed.append(task) |
| 236 | bb.note("SState: Found no valid sstate for %s" % n) |
| 237 | |
| 238 | if hasattr(bb.parse.siggen, "checkhashes"): |
| 239 | bb.parse.siggen.checkhashes(missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d) |
| 240 | |
| 241 | return ret |
| 242 | |