summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-18 01:03:09 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-18 01:03:09 (EDT)
commit7dd51941cbc007321e3ad1d793bdf3774c9af021 (patch)
treeb8b4b1942ded29536931a4c5d66f68c094decbd0 /src
parent362fdf512ac720a50a1c1a49bc4637cc16f63d19 (diff)
ob-gencontrol: Declare local variables and wrap long lines
Diffstat (limited to 'src')
-rw-r--r--src/ob-gencontrol.sh93
1 files changed, 59 insertions, 34 deletions
diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh
index 9411ed4..eeb8e47 100644
--- a/src/ob-gencontrol.sh
+++ b/src/ob-gencontrol.sh
@@ -1,4 +1,4 @@
-# Generates a control directory with a control file and scripts
+# Generate a control directory with a control file and scripts
#
# Copyright (C) 2012 Patrick McDermott
#
@@ -21,17 +21,24 @@ set -eu
gen_control()
{
- binary="${1}"
- version="${2}"
- arch="${3}"
- plat="${4}"
- desc="${5}"
- gen_rel="${6}"
+ local binary="${1}"
+ local version="${2}"
+ local arch="${3}"
+ local plat="${4}"
+ local desc="${5}"
+ local gen_rel="${6}"
+ shift 6
+ local sizes=
+ local inst_size=
+ local size=
+ local name=
+ local value=
+ local homepage=
# 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).
+ # 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>
@@ -43,17 +50,17 @@ gen_control()
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.
+ # 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:
+ # 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.
+ # TODO: Further investigate opkg's disk space calculation and, if
+ # necessary, patch opkg and submit a bug report.
inst_size=$(((${inst_size} + 1023) / 1024))
mkdir -p -- "${binary}.control"
@@ -76,15 +83,22 @@ gen_control()
case "${name}" in
'Essential')
;;
- 'Depends'|'Recommends'|'Suggests'|'Pre-Depends')
- value="$(ob_reduce_deps -a "${OPK_HOST_ARCH}" \
- -p "${OPK_HOST_PLAT}" "${value}")"
- value="$(ob_substvars "${value}")"
+ 'Depends' | 'Recommends' | \
+ 'Suggests' | 'Pre-Depends')
+ value="$(ob_reduce_deps \
+ -a "${OPK_HOST_ARCH}" \
+ -p "${OPK_HOST_PLAT}" \
+ "${value}")"
+ value="$(ob_substvars \
+ "${value}")"
;;
'Conflicts'|'Provides'|'Replaces')
- value="$(ob_reduce_deps -a "${OPK_HOST_ARCH}" \
- -p "${OPK_HOST_PLAT}" -u "${value}")"
- value="$(ob_substvars "${value}")"
+ value="$(ob_reduce_deps \
+ -a "${OPK_HOST_ARCH}" \
+ -p "${OPK_HOST_PLAT}" \
+ -u "${value}")"
+ value="$(ob_substvars \
+ "${value}")"
;;
esac
printf '%s: %s\n' "${name}" "${value}" | \
@@ -113,7 +127,10 @@ gen_control()
install_maintainer_scripts()
{
- binary="${1}"
+ local binary="${1}"
+ shift 1
+ local script=
+ local target=
for script in preinst postinst prerm postrm; do
if [ -L "../${binary}.pkg/${script}" ]; then
@@ -121,7 +138,8 @@ install_maintainer_scripts()
target="${target#* -> }"
ln -s -- "${target}" "${binary}.control/${script}"
elif [ -r "../${binary}.pkg/${script}" ]; then
- cp "../${binary}.pkg/${script}" "${binary}.control/${script}"
+ cp "../${binary}.pkg/${script}" \
+ "${binary}.control/${script}"
chmod 755 "${binary}.control/${script}"
fi
done
@@ -131,7 +149,8 @@ install_maintainer_scripts()
gen_conffiles()
{
- binary="${1}"
+ local binary="${1}"
+ shift 1
if [ -d "${binary}.data/etc" ]; then
find "${binary}.data/etc" -type f | sed "s@^${binary}.data@@" \
@@ -148,7 +167,8 @@ gen_conffiles()
gen_md5sums()
{
- binary="${1}"
+ local binary="${1}"
+ shift 1
find "${binary}.data" -type f | sort | xargs md5sum | \
sed "s@ ${binary}.data@ @" \
@@ -164,6 +184,11 @@ gen_md5sums()
main()
{
+ local pkg=
+ local arch=
+ local plat=
+ local desc=
+
if ! ob_set_text_domain 'opkbuild'; then
printf '%s: Error: Failed to load locale messages\n' \
"${0##*/}" >&2
@@ -173,8 +198,8 @@ main()
ob_init_package '..' || return 1
if [ x"${OB_DO_SOURCE:+set}" = x'set' ]; then
- gen_control "src-${OPK_SOURCE}" "${OPK_SOURCE_VERSION}" 'src' 'all' \
- "${OPK_SOURCE} source package" 'false'
+ gen_control "src-${OPK_SOURCE}" "${OPK_SOURCE_VERSION}" \
+ 'src' 'all' "${OPK_SOURCE} source package" 'false'
gen_md5sums "src-${OPK_SOURCE}"
else
for pkg in ${OPK_PACKAGES_REDUCED}; do
@@ -185,8 +210,8 @@ main()
[ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}"
desc="$(ob_get_binary_parameter "${pkg}" 'Description')"
desc="$(ob_substvars "${desc}")"
- gen_control "${pkg}" "${OPK_BINARY_VERSION}" "${arch}" "${plat}" \
- "${desc}" 'true'
+ gen_control "${pkg}" "${OPK_BINARY_VERSION}" \
+ "${arch}" "${plat}" "${desc}" 'true'
install_maintainer_scripts "${pkg}"
gen_conffiles "${pkg}"
gen_md5sums "${pkg}"