# opkbuild # lib/metadata/proteanos # Functions for parsing, validating, and retrieving metadata for ProteanOS. # # Copyright (C) 2012 Patrick "P. J." McDermott # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . [ -n "${_OB_METADATA_PROTEANOS_SM}" ] && return 0 _OB_METADATA_PROTEANOS_SM='true' _OB_NAME_RE_PROTEANOS='^[a-z0-9][a-z0-9+.-]+$' _OB_VERSION_RE_PROTEANOS='^' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'[0-9a-z.~-]+' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(\+sip[1-9][0-9]*)?' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(-[1-9][0-9]*)?' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(\+[a-z0-9]+~[1-9][0-9]*)?' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'$' _ob_validate_source_name_proteanos() { _ob_local _obvsnpro_name _obvsnpro_name="${1}" if echo "${_obvsnpro_name}" | grep -E "${_OB_NAME_RE_PROTEANOS}" \ >/dev/null 2>&1; then case "${_obvsnpro_name}" in src-*) _ob_return 1 return ${?} ;; esac else _ob_return 1 return ${?} fi _ob_return 0 return ${?} } _ob_validate_binary_name_proteanos() { _ob_local _obvbnpro_name _obvbnpro_name="${1}" if echo "${_obvbnpro_name}" | grep -E "${_OB_NAME_RE_PROTEANOS}" \ >/dev/null 2>&1; then case "${_obvbnpro_name}" in src-*) _ob_return 1 return ${?} ;; esac else _ob_return 1 return ${?} fi _ob_return 0 return ${?} } _ob_validate_version_proteanos() { _ob_local _obvvpro_version _obvvpro_version="${1}" echo "${_obvvpro_version}" | grep -E "${_OB_VERSION_RE_PROTEANOS}" \ >/dev/null 2>&1 _ob_return ${?} return ${?} } _ob_get_upstreamver_proteanos() { _ob_local _obguvpro_version _obguvpro_version="${1}" echo "${_obguvpro_version%-*}" _ob_return 0 return ${?} } _ob_get_distrev_proteanos() { _ob_local _obgdrpro_version _obgdrpro_version="${1}" echo "${_obgdrpro_version##*-}" _ob_return 0 return ${?} } _ob_get_system_arch_proteanos() { _ob_local cat '@@SYSCONFDIR@@/proteanos_arch' _ob_return 0 return ${?} } _ob_get_system_plat_proteanos() { _ob_local cat '@@SYSCONFDIR@@/proteanos_plat' _ob_return 0 return ${?} } _ob_get_system_path_proteanos() { _ob_local _obgsppro_path_id _obgsppro_path_id="${1}" shift 1 case "${_obgsppro_path_id}" in 'package-source') # source version if [ ${#} -eq 2 ]; then printf '/usr/src/%s_%s' "${1}" "${2}" else _ob_return 125 return ${?} fi ;; 'package-docs') # source version if [ ${#} -eq 2 ]; then printf '/usr/share/doc/%s' "${1}" else _ob_return 125 return ${?} fi ;; 'archtab') # arch if [ ${#} -eq 1 ]; then printf '@@DATADIR@@/opkbuild/archtab/%s' "${1}" else _ob_return 125 return ${?} fi ;; 'buildflags') # arch if [ ${#} -eq 1 ]; then printf '@@DATADIR@@/opkbuild/buildflags/%s' "${1}" else _ob_return 125 return ${?} fi ;; 'platconf') # source version plat if [ ${#} -eq 3 ]; then printf '@@DATADIR@@/platconf/%s/%s' "${3}" "${1}" else _ob_return 125 return ${?} fi ;; 'build-helper') # helper_package if [ ${#} -eq 1 ]; then case "${1}" in 'opkhelper-3.0') printf '%s' '@@OPKHELPER_3_0@@' ;; *) _ob_return 1 return ${?} ;; esac else _ob_return 125 return ${?} fi ;; esac _ob_return 0 return ${?} }