# Functions for parsing, validating, and retrieving metadata for ProteanOS # # Copyright (C) 2012, 2019-2020 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}'([1-9][0-9]*:)?' _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}'(-[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}'(~bpu[1-9][0-9]*' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'\+[1-9][0-9]*)?' _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'$' _ob_validate_source_name() { local name="${1}" shift 1 || _ob_abort if grep -E "${_OB_NAME_RE_PROTEANOS}" >/dev/null 2>&1 <<-EOF ${name} EOF then case "${name}" in src-*) return 1 ;; esac else return 1 fi return 0 } _ob_validate_binary_name() { local name="${1}" shift 1 || _ob_abort if grep -E "${_OB_NAME_RE_PROTEANOS}" >/dev/null 2>&1 <<-EOF ${name} EOF then case "${name}" in src-*) return 1 ;; esac else return 1 fi return 0 } _ob_validate_version() { local version="${1}" shift 1 || _ob_abort if grep -E "${_OB_VERSION_RE_PROTEANOS}" >/dev/null 2>&1 <<-EOF ${version} EOF then return 0 else return 1 fi } _ob_get_upstreamver() { local version="${1}" shift 1 || _ob_abort printf '%s' "${version%-*}" return 0 } _ob_get_distrev() { local version="${1}" shift 1 || _ob_abort printf '%s' "${version##*-}" return 0 } _ob_get_system_arch() { cat -- "${SYSCONFDIR}/proteanos_arch" 2>/dev/null || return 1 return 0 } _ob_get_system_plat() { cat -- "${SYSCONFDIR}/proteanos_plat" 2>/dev/null || return 1 return 0 } _ob_get_system_path() { local path_id="${1}" shift 1 || _ob_abort local datadir= local pkgver= if [ x"${OB_TEST_DATADIR:+set}" = x'set' ]; then datadir="${OB_TEST_DATADIR}" else datadir="${DATADIR}" fi case "${path_id}" in 'package-source') # source version [ ${#} -eq 2 ] || _ob_abort printf '/usr/src/%s_%s' "${1}" "${2}" ;; 'package-docs') # source version [ ${#} -eq 2 ] || _ob_abort printf '/usr/share/doc/%s' "${1}" ;; 'buildflags') # arch [ ${#} -eq 1 ] || _ob_abort printf '%s/opkbuild/buildflags/%s' "${datadir}" "${1}" ;; 'platconf') # [source version] plat if [ ${#} -eq 1 ]; then printf '%s/platconf/%s\n' "${datadir}" "${1}" return 0 fi [ ${#} -eq 3 ] || _ob_abort # Deprecated: ob_parse_version -u 'pkgver' -- "${2}" printf '%s/platconf/%s/%s\n' "${datadir}" "${3}" "${1}" printf '%s/platconf/%s/%s_%s\n' "${datadir}" \ "${3}" "${1}" "${pkgver}" ;; esac return 0 } _ob_validate_section() { local section="${1}" shift 1 || _ob_abort case "${section}" in boot | dbg | dev | doc | lib | libdev | locale | share | util) return 0 ;; *) return 1 ;; esac } _ob_section_is_coinstallable() { local sect="${1}" shift 1 || _ob_abort case "${sect}" in 'lib') return 0 ;; *) return 1 ;; esac }