From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from avasout04.plus.net (avasout04.plus.net [212.159.14.19]) by mail.openembedded.org (Postfix) with ESMTP id 3CB2D7F30D for ; Tue, 30 Jul 2019 11:01:16 +0000 (UTC) Received: from deneb ([80.229.24.9]) by smtp with ESMTP id sPsahPuJ7gqhnsPsbhBhhE; Tue, 30 Jul 2019 12:01:17 +0100 X-Clacks-Overhead: "GNU Terry Pratchett" X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=QO4WuTDL c=1 sm=1 tr=0 a=E/9URZZQ5L3bK/voZ0g0HQ==:117 a=E/9URZZQ5L3bK/voZ0g0HQ==:17 a=0o9FgrsRnhwA:10 a=-An2I_7KAAAA:8 a=9tZMx2OdbfR6xTYwLlkA:9 a=BExDbS18XfebsyJQ:21 a=oO5vG0sD5rMy1XIu:21 a=Sq34B_EcNBM9_nrAYB9S:22 Received: from mac by deneb with local (Exim 4.92) (envelope-from ) id 1hsPsZ-0006f1-BK; Tue, 30 Jul 2019 12:01:15 +0100 From: Mike Crowe To: openembedded-core@lists.openembedded.org Date: Tue, 30 Jul 2019 12:01:11 +0100 Message-Id: <20190730110111.5143-1-mac@mcrowe.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfLJF7GK9a0XN1gdPPLE2RfK+FyXYOeH+FXHuvMbpeXyCObKzpK9r81+hDmqEI3uuoLVOlPBxf7/hQib2hGa3p3Z+AwBonKUGxEOUd7yzwMPBQJfsg4bt 29XIXr7r2Ukd6P7dHHHGQhtepL+MvlTUTs1MoB25P8fxLl12Is4rpZ36 Cc: Mike Crowe Subject: [PATCH] sstate: Truncate PV in sstate filenames that are too long X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jul 2019 11:01:16 -0000 Content-Transfer-Encoding: 8bit sstate filenames are generated by concatenating a variety of bits of package metadata. Some of these parts could be long, which could cause the filename to be longer than the 255 character maximum for ext4. So, let's try to detect this situation and truncate the PV part of the filename so that it will fit. If this happens, an ellipsis is added to make it clear that the version number is incomplete. SSTATE_PKG needs to be consistent for all tasks so that the hash remains stable. This means that we need to make an assumption for the maximum length of the task name. In this implementation, the task name is limited to 27 characters. This change also results in a sensible error message being emitted if the resulting filename is still too long. Signed-off-by: Mike Crowe diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index 3342c5ef50..6313b1c538 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass @@ -8,6 +8,24 @@ def generate_sstatefn(spec, hash, d): hash = "INVALID" return hash[:2] + "/" + spec + hash +def sstate_path(taskname, d): + max_filename_len = 245 # leave some room for ".siginfo" + max_addendum_len = 32 # '_' + taskname + '.tgz' + sstate_prefix = d.getVar('SSTATE_PKG') + excess = len(os.path.basename(sstate_prefix)) - (max_filename_len - max_addendum_len) + if excess > 0: + pv = d.getVar('PV') + if len(pv) >= excess and len(pv) >= 3: + short_pv = d.getVar('PV')[:-excess-3] + '...' + d2 = d.createCopy() + d2.setVar('PV', short_pv) + sstate_prefix = d2.getVar('SSTATE_PKG') + + sstatepkg = sstate_prefix + '_'+ taskname + ".tgz" + if len(os.path.basename(sstatepkg)) > max_filename_len: + bb.error('Failed to shorten sstate filename') + return sstatepkg + SSTATE_PKGARCH = "${PACKAGE_ARCH}" SSTATE_PKGSPEC = "sstate:${PN}:${PACKAGE_ARCH}${TARGET_VENDOR}-${TARGET_OS}:${PV}:${PR}:${SSTATE_PKGARCH}:${SSTATE_VERSION}:" SSTATE_SWSPEC = "sstate:${PN}::${PV}:${PR}::${SSTATE_VERSION}:" @@ -323,7 +341,7 @@ def sstate_installpkg(ss, d): sstateinst = d.expand("${WORKDIR}/sstate-install-%s/" % ss['task']) sstatefetch = d.getVar('SSTATE_PKGNAME') + '_' + ss['task'] + ".tgz" - sstatepkg = d.getVar('SSTATE_PKG') + '_' + ss['task'] + ".tgz" + sstatepkg = sstate_path(ss['task'], d) if not os.path.exists(sstatepkg): pstaging_fetch(sstatefetch, d) @@ -617,7 +635,7 @@ def sstate_package(ss, d): tmpdir = d.getVar('TMPDIR') sstatebuild = d.expand("${WORKDIR}/sstate-build-%s/" % ss['task']) - sstatepkg = d.getVar('SSTATE_PKG') + '_'+ ss['task'] + ".tgz" + sstatepkg = sstate_path(ss['task'], d) bb.utils.remove(sstatebuild, recurse=True) bb.utils.mkdirhier(sstatebuild) bb.utils.mkdirhier(os.path.dirname(sstatepkg)) @@ -1084,8 +1102,8 @@ python sstate_eventhandler() { if taskname in ["fetch", "unpack", "patch", "populate_lic", "preconfigure"] and swspec: d.setVar("SSTATE_PKGSPEC", "${SSTATE_SWSPEC}") d.setVar("SSTATE_EXTRAPATH", "") - sstatepkg = d.getVar('SSTATE_PKG') - bb.siggen.dump_this_task(sstatepkg + '_' + taskname + ".tgz" ".siginfo", d) + sstateinfo = sstate_path(taskname, d) + ".siginfo" + bb.siggen.dump_this_task(sstateinfo, d) } SSTATE_PRUNE_OBSOLETEWORKDIR ?= "1" -- 2.20.1