diff options
Diffstat (limited to 'src/oh-gencontrol')
-rw-r--r-- | src/oh-gencontrol | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/src/oh-gencontrol b/src/oh-gencontrol index 6407eda..066200b 100644 --- a/src/oh-gencontrol +++ b/src/oh-gencontrol @@ -38,36 +38,8 @@ invalid_pkg_name() exit 2 } -if [ ${#} -eq 0 ]; then - print_usage ${0} >&2 - exit 1 -fi - -is_src=false -opts=$(getopt -n "${0}" -o 's' -- "${@}") -if [ ${?} -ne 0 ]; then - print_usage "${0}" >&2 - exit 1; -fi -eval set -- "${opts}" -while true; do - case "${1}" in - -s) - is_src=true - shift - ;; - --) - shift - break - ;; - *) - print_usage "${0}" >&2 - exit 1 - ;; - esac -done - -if ${is_src}; then +gen_control_src() +{ srcpkg=$(oh_get_field Source) || missing_field Source oh_validate_pkg_name "${srcpkg}" || invalid_pkg_name "${srcpkg}" @@ -88,12 +60,10 @@ if ${is_src}; then { printf 'Maintainer: ' && oh_get_field Maintainer;} >> ${control} [ ${?} -eq 1 ] && missing_field Maintainer { printf 'Homepage: ' && oh_get_field Homepage;} >> ${control} -else - if [ ${#} -ne 1 ]; then - print_usage "${0}" >&2 - exit 1 - fi +} +gen_control_bin() +{ binpkg="${1}" oh_validate_pkg_name "${binpkg}" || invalid_pkg_name "${binpkg}" @@ -148,4 +118,47 @@ else # TODO: Handle links? fi done +} + +if [ ${#} -eq 0 ]; then + print_usage ${0} >&2 + exit 1 +fi + +is_src=false +opts=$(getopt -n "${0}" -o 's' -- "${@}") +if [ ${?} -ne 0 ]; then + print_usage "${0}" >&2 + exit 1; +fi +eval set -- "${opts}" +while true; do + case "${1}" in + -s) + is_src=true + shift + ;; + --) + shift + break + ;; + *) + print_usage "${0}" >&2 + exit 1 + ;; + esac +done + +if ${is_src}; then + gen_control_src +else + if [ ${#} -eq 0 ]; then + print_usage "${0}" >&2 + exit 1 + fi + + while [ ${#} -gt 0 ]; do + gen_control_bin "${1}" + shift + done fi |