diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2010-12-16 17:35:31 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-12-20 14:54:13 +0000 |
commit | 670c18c3ef8f1199b776d5826806e31a827007df (patch) | |
tree | 4f9141665a530a207f103d6e5234cc70506f33f0 /meta | |
parent | 1993ca1f8790ff5bddc347ff22c78fd1c618739a (diff) | |
download | poky-670c18c3ef8f1199b776d5826806e31a827007df.tar.gz |
sanity.bbclass: add check for creation of long filenames
Detect and fail if filesystem in use for TMPDIR or SSTATE_DIR has an
unreasonably short file name length limit (eg. eCryptFS). This can cause
"file name too long" errors during poky builds (e.g. when writing sstate
files for packages with a git revision as the version).
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/sanity.bbclass | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index 969cc2e59b..9d183e352f 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
@@ -21,18 +21,41 @@ def check_conf_exists(fn, data): | |||
21 | return True | 21 | return True |
22 | return False | 22 | return False |
23 | 23 | ||
24 | def check_sanity_sstate_dir_change(): | 24 | def check_sanity_sstate_dir_change(sstate_dir): |
25 | # Sanity checks to be done when the value of SSTATE_DIR changes | 25 | # Sanity checks to be done when the value of SSTATE_DIR changes |
26 | return "" | ||
27 | 26 | ||
28 | def check_sanity_tmpdir_change(): | 27 | # Check that SSTATE_DIR isn't on a filesystem with limited filename length (eg. eCryptFS) |
28 | testmsg = "" | ||
29 | if sstate_dir != "": | ||
30 | testmsg = check_create_long_filename(sstate_dir, "SSTATE_DIR") | ||
31 | return testmsg | ||
32 | |||
33 | def check_sanity_tmpdir_change(tmpdir): | ||
29 | # Sanity checks to be done when the value of TMPDIR changes | 34 | # Sanity checks to be done when the value of TMPDIR changes |
30 | return "" | 35 | |
36 | # Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS) | ||
37 | testmsg = check_create_long_filename(tmpdir, "TMPDIR") | ||
38 | return testmsg | ||
31 | 39 | ||
32 | def check_sanity_version_change(): | 40 | def check_sanity_version_change(): |
33 | # Sanity checks to be done when SANITY_VERSION changes | 41 | # Sanity checks to be done when SANITY_VERSION changes |
34 | return "" | 42 | return "" |
35 | 43 | ||
44 | def check_create_long_filename(filepath, pathname): | ||
45 | testfile = os.path.join(filepath, ''.join([`num`[-1] for num in xrange(1,200)])) | ||
46 | try: | ||
47 | if not os.path.exists(filepath): | ||
48 | bb.utils.mkdirhier(filepath) | ||
49 | f = file(testfile, "w") | ||
50 | f.close() | ||
51 | os.remove(testfile) | ||
52 | except IOError as (errno, strerror): | ||
53 | if errno == 36: # ENAMETOOLONG | ||
54 | return "Failed to create a file with a long name in %s. Please use a filesystem that does not unreasonably limit filename length.\n" % pathname | ||
55 | else: | ||
56 | return "Failed to create a file in %s: %s" % (pathname, strerror) | ||
57 | return "" | ||
58 | |||
36 | def check_sanity(e): | 59 | def check_sanity(e): |
37 | from bb import note, error, data, __version__ | 60 | from bb import note, error, data, __version__ |
38 | 61 | ||
@@ -206,13 +229,13 @@ def check_sanity(e): | |||
206 | sanity_version = int(data.getVar('SANITY_VERSION', e.data, True) or 1) | 229 | sanity_version = int(data.getVar('SANITY_VERSION', e.data, True) or 1) |
207 | if last_sanity_version < sanity_version: | 230 | if last_sanity_version < sanity_version: |
208 | messages = messages + check_sanity_version_change() | 231 | messages = messages + check_sanity_version_change() |
209 | messages = messages + check_sanity_tmpdir_change() | 232 | messages = messages + check_sanity_tmpdir_change(tmpdir) |
210 | messages = messages + check_sanity_sstate_dir_change() | 233 | messages = messages + check_sanity_sstate_dir_change(sstate_dir) |
211 | else: | 234 | else: |
212 | if last_tmpdir != tmpdir: | 235 | if last_tmpdir != tmpdir: |
213 | messages = messages + check_sanity_tmpdir_change() | 236 | messages = messages + check_sanity_tmpdir_change(tmpdir) |
214 | if last_sstate_dir != sstate_dir: | 237 | if last_sstate_dir != sstate_dir: |
215 | messages = messages + check_sanity_sstate_dir_change() | 238 | messages = messages + check_sanity_sstate_dir_change(sstate_dir) |
216 | 239 | ||
217 | if os.path.exists("conf"): | 240 | if os.path.exists("conf"): |
218 | f = file(sanityverfile, 'w') | 241 | f = file(sanityverfile, 'w') |