diff options
-rw-r--r-- | lib/control.sh | 59 | ||||
-rw-r--r-- | src/opkbuild.sh | 8 |
2 files changed, 61 insertions, 6 deletions
diff --git a/lib/control.sh b/lib/control.sh index ca11999..e193d86 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -58,6 +58,25 @@ oh_control_parse_binary() _control_parse "${OH_SOURCE_DIR}/${1}.pkg/control" 'BINARY' } +oh_control_gen_source() +{ + _old_arch="${OH_CONTROL_BINARY_FIELD_ARCHITECTURE}" + _old_desc="${OH_CONTROL_BINARY_FIELD_DESCRIPTION}" + + OH_CONTROL_BINARY_FIELD_ARCHITECTURE='all' + OH_CONTROL_BINARY_FIELD_DESCRIPTION="${OH_SOURCE} source package" + + _control_gen 'SOURCE' "src:${OH_SOURCE}.control/control" + + OH_CONTROL_BINARY_FIELD_ARCHITECTURE="${_old_arch}" + OH_CONTROL_BINARY_FIELD_DESCRIPTION="${_old_desc}" +} + +oh_control_gen_binary() +{ + _control_gen 'BINARY' "${1}.control/control" +} + _control_parse() { _control="${1}" @@ -105,8 +124,8 @@ _control_parse() else _got="${_got}${_field} " fi - _param="OH_CONTROL_${_type}_FIELD_$(LC_CTYPE=C \ - tr '[:lower:]-' '[:upper:]_')" + _param="OH_CONTROL_${_type}_FIELD_$(echo "${_name}" | \ + LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')" eval "${_param}=\"${_value}\"" else # Continuation line. @@ -146,3 +165,39 @@ _control_parse_error() fi oh_warn "${_file_info} ${_error}" "${@}" } + +_control_gen() +{ + _type="${1}" + _control="${2}" + + # TODO: Handle platforms and architectures like "any" and "any-linux-any". + # TODO: Calculate installed size. + + cat >"${_control}" <<EOF +Package: ${OH_CONTROL_BINARY_FIELD_PACKAGE} +Source: ${OH_SOURCE} +Version: ${OH_BINARY_VERSION} +Architecture: ${_arch} +EOF + + for _name in Essential Depends Recommends Suggests Pre-Depends Conflicts \ + Provides Replaces; do + _param="OH_CONTROL_BINARY_FIELD_$(echo "${_name}" | \ + LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')" + _value="$(eval echo \$\{"${param}"\})" + if [ -n "${_value}" ]; then + printf '%s: %s\n' "${_name}" "${_value}" >"${_control}" + fi + done + + cat >"${_control}" <<EOF +Installed-Size: ${_inst_size} +Description:$(echo "${OH_CONTROL_BINARY_FIELD_DESCRIPTION}" | sed 's/^/ /') +EOF + + if [ -n "${OH_CONTROL_SOURCE_FIELD_HOMEPAGE}" ]; then + printf '%s: %s\n' 'Homepage' "${OH_CONTROL_SOURCE_FIELD_HOMEPAGE}" \ + >"${_control}" + fi +} diff --git a/src/opkbuild.sh b/src/opkbuild.sh index 3347b7f..0535095 100644 --- a/src/opkbuild.sh +++ b/src/opkbuild.sh @@ -265,8 +265,8 @@ setup_source_control() oh_control_parse_source for field in ${OH_CONTROL_SOURCE_FIELDS_REQUIRED} \ ${OH_CONTROL_SOURCE_FIELDS_OPTIONAL}; do - param="OH_CONTROL_SOURCE_FIELD_$(LC_CTYPE=C \ - tr '[:lower:]-' '[:upper:]_')" + param="OH_CONTROL_SOURCE_FIELD_$(echo "${field}" | \ + LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')" oh_pv_set 'src:.control' "${field}" "$(eval echo \$\{"${param}"\})" done } @@ -405,8 +405,8 @@ step_bincontrol() oh_control_parse_binary "${pkg}" for field in ${OH_CONTROL_BINARY_FIELDS_REQUIRED} \ ${OH_CONTROL_BINARY_FIELDS_OPTIONAL}; do - param="OH_CONTROL_BINARY_FIELD_$(LC_CTYPE=C \ - tr '[:lower:]-' '[:upper:]_')" + param="OH_CONTROL_BINARY_FIELD_$(echo "${field}" | \ + LC_CTYPE=C tr '[:lower:]-' '[:upper:]_')" oh_pv_set "${pkg}.control" \ "${field}" "$(eval echo \$\{"${param}"\})" done |