How to use _install_from_repo method in lisa

Best Python code snippet using lisa_python

dependencies.py

Source:dependencies.py Github

copy

Full Screen

...87 tdeps.append((sver, dep))88 else:89 tdeps = pkg.makedepends90 return hdeps, tdeps, rdeps91def _install_from_repo(pkg, pkglist, virtn, signkey, cross = False):92 # if installing target deps and we're crossbuilding, target the sysroot93 sroot = cross and pkg.profile().cross94 if pkg.stage == 0 or sroot:95 rootp = paths.bldroot()96 if sroot:97 # pretend we're another arch98 # scripts are already never run in this case99 aarch = pkg.profile().arch100 rootp = rootp / pkg.profile().sysroot.relative_to("/")101 else:102 aarch = None103 ret = apki.call(104 "add", ["--no-scripts", "--virtual", virtn] + pkglist,105 pkg, root = rootp, capture_output = True, arch = aarch,106 allow_untrusted = not signkey, fakeroot = True107 )108 else:109 if virtn:110 aopts = ["--virtual", virtn] + pkglist111 else:112 aopts = pkglist113 ret = apki.call_chroot(114 "add", aopts, pkg, capture_output = True,115 allow_untrusted = not signkey116 )117 if ret.returncode != 0:118 outl = ret.stderr.strip().decode()119 outx = ret.stdout.strip().decode()120 if len(outl) > 0:121 pkg.logger.out_plain(">> stderr:")122 pkg.logger.out_plain(outl)123 if len(outx) > 0:124 pkg.logger.out_plain(">> stdout:")125 pkg.logger.out_plain(outx)126 pkg.error(f"failed to install dependencies")127def _is_available(pkgn, pattern, pkg, host = False):128 if not host and pkg.profile().cross:129 sysp = paths.bldroot() / pkg.profile().sysroot.relative_to("/")130 aarch = pkg.profile().arch131 crossp = True132 else:133 sysp = paths.bldroot()134 aarch = None135 crossp = False136 aout = apki.call(137 "search", ["-e", "-a", pkgn], pkg, root = sysp, capture_output = True,138 arch = aarch, allow_untrusted = True139 )140 if aout.returncode != 0:141 return None142 pn = aout.stdout.strip().decode()143 if len(pn) == 0:144 return None145 pn = pn.split("\n")146 if len(pn) > 1:147 if crossp and pn[0].startswith("base-cross-target-meta"):148 # FIXME: find a way to ignore "installed" packages149 # maybe coordinate this with upstream and add an option150 pn = pn[1]151 else:152 pn = pn[0]153 else:154 pn = pn[0]155 if not pattern or autil.pkg_match(pn, pattern):156 return pn[len(pkgn) + 1:]157 return None158def install(pkg, origpkg, step, depmap, signkey, hostdep):159 style = ""160 if pkg.build_style:161 style = f" [{pkg.build_style}]"162 pprof = pkg.profile()163 tarch = pprof.arch164 if pkg.pkgname != origpkg:165 pkg.log(f"building{style} (dependency of {origpkg}) for {tarch}...")166 else:167 pkg.log(f"building{style} for {tarch}...")168 host_binpkg_deps = []169 binpkg_deps = []170 host_missing_deps = []171 missing_deps = []172 missing_rdeps = []173 log = logger.get()174 ihdeps, itdeps, irdeps = setup_depends(pkg)175 # ensure cross-toolchain is included in hostdeps176 if pprof.cross:177 ihdeps.append((None, f"base-cross-{pprof.arch}"))178 if len(ihdeps) == 0 and len(itdeps) == 0 and len(irdeps) == 0:179 return False180 for sver, pkgn in ihdeps:181 # check if available in repository182 aver = _is_available(183 pkgn, (pkgn + "=" + sver) if sver else None, pkg, host = True184 )185 if aver:186 log.out_plain(f" [host] {pkgn}: found ({aver})")187 host_binpkg_deps.append(pkgn)188 continue189 # dep finder did not previously resolve a template190 if not sver:191 log.out_plain(f" [host] {pkgn}: unresolved build dependency")192 pkg.error(f"host dependency '{pkgn}' does not exist")193 # not found194 log.out_plain(f" [host] {pkgn}: not found")195 # check for loops196 if not pprof.cross and (pkgn == origpkg or pkgn == pkg.pkgname):197 pkg.error(f"[host] build loop detected: {pkgn} <-> {origpkg}")198 # build from source199 host_missing_deps.append(pkgn)200 for sver, pkgn in itdeps:201 # check if available in repository202 aver = _is_available(203 pkgn, (pkgn + "=" + sver) if sver else None, pkg204 )205 if aver:206 log.out_plain(f" [target] {pkgn}: found ({aver})")207 binpkg_deps.append(pkgn)208 continue209 # dep finder did not previously resolve a template210 if not sver:211 log.out_plain(f" [target] {pkgn}: unresolved build dependency")212 pkg.error(f"target dependency '{pkgn}' does not exist")213 # not found214 log.out_plain(f" [target] {pkgn}: not found")215 # check for loops216 if pkgn == origpkg or pkgn == pkg.pkgname:217 pkg.error(f"[target] build loop detected: {pkgn} <-> {origpkg}")218 # build from source219 missing_deps.append(pkgn)220 for origin, dep in irdeps:221 pkgn, pkgv, pkgop = autil.split_pkg_name(dep)222 # sanitize223 if not pkgn:224 pkg.error(f"invalid runtime dependency: {dep}")225 # check special cases if guaranteed not to be a loop226 if pkgn != origin:227 # subpackage depending on parent228 if pkgn == pkg.pkgname:229 log.out_plain(f" [runtime] {dep}: subpackage (ignored)")230 continue231 # parent or another subpackage depending on subpackage232 is_subpkg = False233 for sp in pkg.subpkg_list:234 if sp.pkgname == pkgn:235 is_subpkg = True236 break237 if is_subpkg:238 log.out_plain(f" [runtime] {dep}: subpackage (ignored)")239 continue240 else:241 # if package and its origin are the same, it depends on itself242 pkg.error(f"[runtime] build loop detected: {pkgn} <-> {pkgn}")243 # we're a dependency build but depend on whatever depends on us244 if pkgn == origpkg and pkg.pkgname != origpkg:245 pkg.error(f"[runtime] build loop detected: {pkgn} <-> {pkgn}")246 # check the repository247 aver = _is_available(pkgn, dep, pkg)248 if aver:249 log.out_plain(f" [runtime] {dep}: found ({aver})")250 continue251 # not found252 log.out_plain(f" [runtime] {dep}: not found")253 # consider missing254 missing_rdeps.append(pkgn)255 from cbuild.core import build256 chost = chroot.host_cpu()257 # if this triggers any build of its own, it will return true258 missing = False259 for pn in host_missing_deps:260 try:261 build.build(262 step,263 template.read_pkg(264 pn, chost if pkg.stage > 0 else None, False, pkg.run_check,265 (pkg.conf_jobs, pkg.conf_link_threads, pkg.conf_lto_jobs),266 pkg.build_dbg, pkg.use_ccache, pkg, resolve = pkg,267 force_check = pkg._force_check, stage = pkg.stage,268 autopkg = True269 ),270 depmap, signkey, chost = hostdep or not not pprof.cross,271 no_update = not missing272 )273 missing = True274 except template.SkipPackage:275 pass276 host_binpkg_deps.append(pn)277 for pn in missing_deps:278 try:279 build.build(280 step,281 template.read_pkg(282 pn, tarch if pkg.stage > 0 else None, False, pkg.run_check,283 (pkg.conf_jobs, pkg.conf_link_threads, pkg.conf_lto_jobs),284 pkg.build_dbg, pkg.use_ccache, pkg, resolve = pkg,285 force_check = pkg._force_check, stage = pkg.stage,286 autopkg = True287 ),288 depmap, signkey, chost = hostdep, no_update = not missing289 )290 missing = True291 except template.SkipPackage:292 pass293 binpkg_deps.append(pn)294 for rd in missing_rdeps:295 try:296 build.build(297 step,298 template.read_pkg(299 rd, tarch if pkg.stage > 0 else None, False, pkg.run_check,300 (pkg.conf_jobs, pkg.conf_link_threads, pkg.conf_lto_jobs),301 pkg.build_dbg, pkg.use_ccache, pkg, resolve = pkg,302 force_check = pkg._force_check, stage = pkg.stage,303 autopkg = True304 ),305 depmap, signkey, chost = hostdep, no_update = not missing306 )307 missing = True308 except template.SkipPackage:309 pass310 # reinit after parsings311 chroot.set_target(tarch)312 if len(host_binpkg_deps) > 0:313 pkg.log(f"installing host dependencies: {', '.join(host_binpkg_deps)}")314 _install_from_repo(pkg, host_binpkg_deps, "autodeps-host", signkey)315 if len(binpkg_deps) > 0:316 pkg.log(f"installing target dependencies: {', '.join(binpkg_deps)}")317 _install_from_repo(pkg, binpkg_deps, "autodeps-target", signkey, True)...

Full Screen

Full Screen

docker.py

Source:docker.py Github

copy

Full Screen

...72 self._log.error(73 f"Failed to install docker.io: {e}, trying to install docker from"74 " repo"75 )76 self._install_from_repo()77 elif (78 isinstance(self.node.os, CentOs)79 and self.node.os.information.release >= "8.0"80 ):81 wget_tool = self.node.tools[Wget]82 wget_tool.get(83 "https://get.docker.com",84 filename="get-docker.sh",85 file_path="./",86 executable=True,87 )88 self.node.execute("./get-docker.sh", sudo=True)89 # RHEL 8 and its derivatives don't support docker90 elif isinstance(self.node.os, Redhat):91 if self.node.os.information.version >= "8.0.0":92 self.node.os.install_packages("podman")93 self.node.execute(94 "ln -s /run/podman/podman.sock /var/run/docker.sock",95 sudo=True,96 shell=True,97 )98 self.node.execute(99 "ln -s /bin/podman /bin/docker", sudo=True, shell=True100 )101 else:102 self.node.os.add_repository(103 repo="https://download.docker.com/linux/centos/docker-ce.repo",104 repo_name="docker-ce.repo",105 )106 self.node.os.add_repository(107 repo="http://mirror.centos.org/centos/7/extras/x86_64",108 repo_name="Centos extras",109 )110 self.node.os.add_repository(111 repo="http://mirror.centos.org/centos/7/os/x86_64",112 repo_name="Centos extras",113 )114 gpg_donwload_path = self.node.tools[Wget].get(115 "http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7",116 )117 self.node.execute(f"rpm --import {gpg_donwload_path}", sudo=True)118 self.node.os.install_packages(119 ["docker-ce", "docker-ce-cli", "containerd.io"]120 )121 elif isinstance(self.node.os, CBLMariner):122 self.node.os.install_packages(["moby-engine", "moby-cli"])123 else:124 raise LisaException(f"{self.node.os.information.vendor} not supported")125 self.start()126 return self._check_exists()127 def _install_from_repo(self) -> None:128 if isinstance(self.node.os, Debian):129 self.node.os.install_packages(130 [131 "apt-transport-https",132 "ca-certificates",133 "curl",134 "gnupg2",135 "software-properties-common",136 ]137 )138 self.node.execute(139 "curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key"140 " add -",141 shell=True,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful