# Functions for parsing, validating, and retrieving metadata for ProteanOS # # Copyright (C) 2012 Patrick McDermott # # This file is part of opkbuild. # # opkbuild 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 3 of the License, or # (at your option) any later version. # # opkbuild 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 opkbuild. If not, see . _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() { 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() { 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() { local version= version="${1}" echo "${version}" | grep -E "${_OB_VERSION_RE_PROTEANOS}" \ >/dev/null 2>&1 return ${?} } _ob_get_upstreamver() { local version= version="${1}" echo "${version%-*}" return 0 } _ob_get_distrev() { local version= version="${1}" echo "${version##*-}" return 0 } _ob_get_system_arch() { cat "${SYSCONFDIR}/proteanos_arch" return 0 } _ob_get_system_plat() { cat "${SYSCONFDIR}/proteanos_plat" return 0 } _ob_get_system_path() { 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 ;; esac return 0 }