| Summary: | PKGSIZE double counts hard linked files | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] OE-Core | Reporter: | Len Sorensen <lsorense> |
| Component: | core | Assignee: | Ross Burton <ross.burton> |
| Status: | RESOLVED FIXED | QA Contact: | David Lopez Barriba <davidx.lopez.barriba> |
| Severity: | normal | ||
| Priority: | Medium+ | CC: | jose.perez.carranza, joshuagloe, meta.mr.watcher, meta.watcher |
| Version: | unspecified | ||
| Target Milestone: | 2.3 M1 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Don't know | |
|
Description
Len Sorensen
2016-10-12 19:41:20 UTC
A simple fix is to revert most of the fix for Bug 5334 (leaving the change in scripts/oe-pkgdata-util) and changing the du command from 'du -sk' to 'du -sb'. The results are then accurate and account for hard links. $ ls -l total 8 -rw-r--r-- 2 ross ross 10 Dec 15 12:10 hard-link-to-test -rw-r--r-- 2 ross ross 10 Dec 15 12:10 test $ du -sb . 4106 . Using du still doesn't solve the problem that PKGSIZE was dependent on the file system type and directory overhead. Yes it does, since -b works in bytes rather than block size, and also implies --apparent-size which means it uses the file size rather than the space used in the filesystem. The fact it adds 4k for a directory is a bit of a problem perhaps but it is still way more accurate than the current code that double counts hard links. Certainly in all the packages I looked at, the result was essentially the same as the current code except for the packages with hard links where it was much more accurate. Most packages the noise from directories is dwarfed by the files. If you want to skip the directories, this seems to work for giving exactly the right size:
find <directory> -type f -print0 | du -sb --files0-from=- | awk '{s+=$1} END {printf "%.0f\n", s}'
Merged in oe-core e82a7f879419828b42b5cc71e6229c8235090f21. Thanks. I like the solution. Nice and clean. |