summaryrefslogtreecommitdiffstats
path: root/lib/control.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-08-02 00:13:03 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-08-02 00:13:03 (EDT)
commit81a3f1e5ffd4ce73297ab0756ed1231b926b5fc8 (patch)
tree4c602764822e8bc80b0b90540a2293620767fe2d /lib/control.sh
parentade41c6cb8d8692b76b308cf7e1b04a9fb87e98f (diff)
Calculate installed size of packages.
Diffstat (limited to 'lib/control.sh')
-rw-r--r--lib/control.sh35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/control.sh b/lib/control.sh
index e07b04d..6fa8931 100644
--- a/lib/control.sh
+++ b/lib/control.sh
@@ -72,7 +72,8 @@ oh_control_gen_source()
OH_CONTROL_BINARY_FIELD_RECOMMENDS="${OH_CONTROL_SOURCE_FIELD_BUILD_DEPENDS}"
OH_CONTROL_BINARY_FIELD_DESCRIPTION="${OH_SOURCE} source package"
- _control_gen 'SOURCE' "src:${OH_SOURCE}.control/control"
+ _control_gen 'SOURCE' \
+ "src:${OH_SOURCE}.control/control" "src:${OH_SOURCE}.data"
OH_CONTROL_BINARY_FIELD_PACKAGE="${_old_package}"
OH_BINARY_VERSION="${_old_version}"
@@ -83,7 +84,8 @@ oh_control_gen_source()
oh_control_gen_binary()
{
- _control_gen 'BINARY' "${1}.control/control"
+ _control_gen 'BINARY' \
+ "${1}.control/control" "${1}.data"
}
_control_parse()
@@ -179,9 +181,36 @@ _control_gen()
{
_type="${1}"
_control="${2}"
+ _data="${2}"
# TODO: Handle platforms and architectures like "any" and "any-linux-any".
- # TODO: Calculate installed size.
+
+ # Calculate installed size.
+ # Don't use du, since that considers the allocated size of files, symbolic
+ # links, and directories (i.e. actual file sizes plus the filesystem
+ # overhead on the build system).
+ # See the following for more information:
+ # <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/du.html>
+ # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630533>
+ # <https://www.gnu.org/software/coreutils/manual/html_node/du-invocation.html>
+ _sizes="$(find "${_data}" -type f -exec wc -c '{}' ';' | cut -d ' ' -f 1)"
+ _inst_size=0
+ for _size in ${_sizes}; do
+ _inst_size=$(($_inst_size + $_size))
+ done
+ # Convert bytes to kibibytes and round up.
+ # Note: There is an inconsistency between the Debian Policy Manual and opkg
+ # in the units of this field. Debian Policy defines this field in units of
+ # kibibytes:
+ # The disk space is given as the integer value of the estimated installed
+ # size in bytes, divided by 1024 and rounded up.
+ # However, opkg apparently attempts to convert this value from bytes to
+ # kibibytes in its determination of whether the package's data will fit on
+ # the system:
+ # pkg_size_kbs = (pkg->installed_size + 1023)/1024;
+ # TODO: Further investigate opkg's disk space calculation and, if necessary,
+ # patch opkg and submit a bug report.
+ _inst_size=$((($inst_size + 1023) / 1024))
cat >"${_control}" <<EOF
Package: ${OH_CONTROL_BINARY_FIELD_PACKAGE}