summaryrefslogtreecommitdiffstats
path: root/meta/classes/image-live.bbclass
AgeCommit message (Expand)Author
2021-05-27image-live.bbclass: order do_bootimg after do_rootfsGuillaume Champagne
2021-04-05image-live.bbclass: optional depends when ROOTFS emptyGuillaume Champagne
2021-01-20meta/classes: Add supprot for WIC<>VHD/VHDX conversionSinan Kaya
2020-09-16image-artifact-names: introduce new bbclass and move some variables into itMartin Jansa
2019-09-27classes/image-live.bbclass: Don't hardcode cpio.gzBöszörményi Zoltán via Openembedded-core
2018-07-13image-live: fix check for rootfs size with hddimg imagesAnuj Mittal
2018-06-20image/image-live: Improve handling of live/iso/hddimg types (drop NOISO/NOHDD)Richard Purdie
2018-02-24image-live.bbclass: drop support for compressed ISO imagesAlexander Kanavin
2018-01-02image-live.bbclass: add MLPREFIX to core-image-minimal-initramfsRobert Yang
2018-01-02image-live.bbclass: print warn when initramfs is invalidRobert Yang
2017-09-21classes/image_live: fix using squashfs as image filesystemTomasz Meresiński
2017-07-17live-vm-common: add MKDOSFS_EXTRAOPTS variableEd Bartosh
2017-05-102014-08-02image-vmdk.bbclass: use sda rather than hdaRobert Yang
2014-02-20image*.bbclass, bootimg.bbclass: add image type dependenciesLaurentiu Palcu
2012-11-24image classes: use PN for depends, not IMAGE_BASE_NAMEKoen Kooi
2012-03-01image-live: Allow LABELS to be modifiedSaul Wold
2012-02-23image-live: fix SYSLINUX_TIME and add SYSLINUX_ROOT instead of APPENDSaul Wold
2011-10-14image-live.bbclass: allow override of initrd imageOtavio Salvador
2011-10-04image-live.bbclass: allow images to override ROOTFS and INITRDOtavio Salvador
2011-07-27classes/image*: Revamp creation of live imagesSaul Wold
n>.branches = {} for name in ud.names: branch = branches[ud.names.index(name)] ud.branches[name] = branch gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname) ud.clonedir = os.path.join(data.expand('${GITDIR}', d), gitsrcname) ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git" def localpath(self, url, ud, d): for name in ud.names: if not ud.revisions[name] or ud.revisions[name] == "master": ud.revisions[name] = self.latest_revision(url, ud, d, name) ud.localfile = ud.mirrortarball return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) def forcefetch(self, url, ud, d): for name in ud.names: if not self._contains_ref(ud.revisions[name], d): return True return False def try_premirror(self, u, ud, d): if 'noclone' in ud.parm: return False if os.path.exists(ud.clonedir): return False if os.path.exists(ud.localpath): return False return True def download(self, loc, ud, d): """Fetch url""" if ud.user: username = ud.user + '@' else: username = "" repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) ud.repochanged = not os.path.exists(repofile) # If the checkout doesn't exist and the mirror tarball does, extract it if not os.path.exists(ud.clonedir) and os.path.exists(repofile): bb.mkdirhier(ud.clonedir) os.chdir(ud.clonedir) runfetchcmd("tar -xzf %s" % (repofile), d) # If the repo still doesn't exist, fallback to cloning it if not os.path.exists(ud.clonedir): bb.fetch2.check_network_access(d, "git clone %s%s" % (ud.host, ud.path)) runfetchcmd("%s clone -n %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.clonedir), d) os.chdir(ud.clonedir) # Update the checkout if needed for name in ud.names: if not self._contains_ref(ud.revisions[name], d): # Remove all but the .git directory bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path)) runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name]), d) runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d) runfetchcmd("%s prune-packed" % ud.basecmd, d) runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d) ud.repochanged = True def build_mirror_data(self, url, ud, d): # Generate a mirror tarball if needed repofile = os.path.join(data.getVar("DL_DIR", d, 1), ud.mirrortarball) os.chdir(ud.clonedir) mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) if mirror_tarballs != "0" and ud.repochanged: logger.info("Creating tarball of git repository") runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) def unpack(self, ud, destdir, d): """ unpack the downloaded src to destdir""" subdir = ud.parm.get("subpath", "") if subdir != "": readpathspec = ":%s" % (subdir) else: readpathspec = "" destdir = os.path.join(destdir, "git/") if os.path.exists(destdir): bb.utils.prunedir(destdir) runfetchcmd("git clone -s -n %s %s" % (ud.clonedir, destdir), d) if os.path.exists("%s/.git/refs/remotes/origin" % ud.clonedir): bb.mkdirhier("%s/.git/refs/remotes/origin/" % destdir) runfetchcmd("cp -af %s/.git/refs/remotes/origin/* %s/.git/refs/remotes/origin/" %(ud.clonedir, destdir), d) if os.path.exists("%s/.git/packed-refs" % ud.clonedir): runfetchcmd("cp -af %s/.git/packed-refs %s/.git/" %(ud.clonedir, destdir), d) if not ud.nocheckout: os.chdir(destdir) runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d) runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d) return True def supports_srcrev(self): return True def _contains_ref(self, tag, d): basecmd = data.getVar("FETCHCMD_git", d, True) or "git" output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True) return output.split()[0] != "0" def _revision_key(self, url, ud, d, name): """ Return a unique key for the url """ return "git:" + ud.host + ud.path.replace('/', '.') + ud.branches[name] def _latest_revision(self, url, ud, d, name): """ Compute the HEAD revision for the url """ if ud.user: username = ud.user + '@' else: username = "" bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branches[name])) basecmd = data.getVar("FETCHCMD_git", d, True) or "git" cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name]) output = runfetchcmd(cmd, d, True) if not output: raise bb.fetch2.FetchError("Fetch command %s gave empty output\n" % (cmd)) return output.split()[0] def _build_revision(self, url, ud, d, name): return ud.revisions[name] def _sortable_buildindex_disabled(self, url, ud, d, rev): """ Return a suitable buildindex for the revision specified. This is done by counting revisions using "git rev-list" which may or may not work in different circumstances. """ cwd = os.getcwd() # Check if we have the rev already if not os.path.exists(ud.clonedir): print("no repo") self.download(None, ud, d) if not os.path.exists(ud.clonedir): logger.error("GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value", url, ud.clonedir) return None os.chdir(ud.clonedir) if not self._contains_ref(rev, d): self.download(None, ud, d) output = runfetchcmd("%s rev-list %s -- 2> /dev/null | wc -l" % (ud.basecmd, rev), d, quiet=True) os.chdir(cwd) buildindex = "%s" % output.split()[0] logger.debug(1, "GIT repository for %s in %s is returning %s revisions in rev-list before %s", url, ud.clonedir, buildindex, rev) return buildindex