# opkbuild # lib/metadata/proteanos.sh # 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 . [ x"${_OB_METADATA_PROTEANOS_SM+set}" = x'set' ] && return 0 _OB_METADATA_PROTEANOS_SM=1 _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() { local name= name="${1}" if echo "${name}" | grep -E "${_OB_NAME_RE_PROTEANOS}" \ >/dev/null 2>&1; then case "${name}" in src-*) return 1 ;; esac else return 1 fi return 0 } _ob_validate_binary_name_proteanos() { local name= name="${1}" if echo "${name}" | grep -E "${_OB_NAME_RE_PROTEANOS}" \ >/dev/null 2>&1; then case "${name}" in src-*) return 1 ;; esac else return 1 fi return 0 } _ob_validate_version_proteanos() { local version= version="${1}" echo "${version}" | grep -E "${_OB_VERSION_RE_PROTEANOS}" \ >/dev/null 2>&1 return ${?} } _ob_get_upstreamver_proteanos() { local version= version="${1}" echo "${version%-*}" return 0 } _ob_get_distrev_proteanos() { local version= version="${1}" echo "${version##*-}" return 0 } _ob_get_system_arch_proteanos() { cat '@@SYSCONFDIR@@/proteanos_arch' return 0 } _ob_get_system_plat_proteanos() { cat '@@SYSCONFDIR@@/proteanos_plat' return 0 } _ob_get_system_path_proteanos() { local path_id= local pkgver= path_id="${1}" shift 1 case "${path_id}" in 'package-source') # source version if [ ${#} -eq 2 ]; then printf '/usr/src/%s_%s' "${1}" "${2}" else return 125 fi ;; 'package-docs') # source version if [ ${#} -eq 2 ]; then printf '/usr/share/doc/%s' "${1}" else return 125 fi ;; 'buildflags') # arch if [ ${#} -eq 1 ]; then printf '@@DATADIR@@/opkbuild/buildflags/%s' "${1}" else return 125 fi ;; 'platconf') # source version plat if [ ${#} -eq 3 ]; then ob_parse_version -u 'pkgver' "${2}" printf '@@DATADIR@@/platconf/%s/%s\n' "${3}" "${1}" printf '@@DATADIR@@/platconf/%s/%s_%s\n' "${3}" "${1}" \ "${pkgver}" else return 125 fi ;; 'build-helper') # helper_package if [ ${#} -eq 1 ]; then case "${1}" in 'opkhelper-3.0') printf '%s' '@@OPKHELPER_3_0@@' ;; *) return 1 ;; esac else return 125 fi ;; esac return 0 }