Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-07-15 14:38:28 +0200
committerErich Eckner <git@eckner.net>2019-07-15 14:38:28 +0200
commit5201163ec2b6dacd904bf3c994b2aaf7bef41a51 (patch)
treefd37139f471d178fdc6caea3f71f1114bfc562c0 /lib
parent2bbdac8e051f2e55d664623e6a67361bc39aeb65 (diff)
bin/nit-picker,lib/common-functions: separate extract_dependencies_from_package() for external reuse
Diffstat (limited to 'lib')
-rwxr-xr-xlib/common-functions39
1 files changed, 39 insertions, 0 deletions
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"
+}