From 5201163ec2b6dacd904bf3c994b2aaf7bef41a51 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 15 Jul 2019 14:38:28 +0200 Subject: bin/nit-picker,lib/common-functions: separate extract_dependencies_from_package() for external reuse --- lib/common-functions | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'lib') diff --git a/lib/common-functions b/lib/common-functions index 421fe50..f2f1243 100755 --- a/lib/common-functions +++ b/lib/common-functions @@ -1045,3 +1045,42 @@ update_blocked_packages_count() { mysql_run_query 'unimportant' ) } + +# extract_dependencies_from_package $pkgfile $depfile +# extract make-, run- and check-depends from $pkgfile into $depfile +# format: deptype install_target version_relation epoch version +extract_dependencies_from_package() { + mysql_load_min_and_max_versions + { + bsdtar -Oxf "$1" '.PKGINFO' \ + | sed ' + s/^checkdepend = /check / + t + s/^depend = /run / + t + s/^makedepend = /make / + t + d + ' \ + | sed ' + s/\(=\|[<>]=\?\)\([^-]\+\)\(-[^-]\+\)\?$/ \1 \2/ + t + s/$/ >= '"${min_version}"'/ + ' \ + | sed ' + s/:\(\S\+\)$/ \1/ + t + s/ \(\S\+\)$/ 0 \1/ + ' + # inject base & base-devel + printf ' >= %s\n' \ + "${min_version}" \ + | tr ':' ' ' \ + | sed ' + s/^.*$/run base\0\nmake base-devel\0/ + ' + } \ + | tr '[:upper:]' '[:lower:]' \ + | sort -u \ + > "$2" +} -- cgit v1.2.3-70-g09d2