summarylogtreecommitdiffstats
path: root/update-depends.sh
diff options
context:
space:
mode:
authorDavide Depau2020-04-11 18:16:31 +0200
committerDavide Depau2020-04-11 18:16:31 +0200
commit6b3e2021c60ad85e41f44d1b22c62df6820d8ae6 (patch)
tree1001d2c181fab08560dccdd24bbaffe70e3a8b08 /update-depends.sh
parent361cc6c3947f7def5a94c52eda764ae2c2b41494 (diff)
downloadaur-6b3e2021c60ad85e41f44d1b22c62df6820d8ae6.tar.gz
Add script to update dependencies from CI config
Diffstat (limited to 'update-depends.sh')
-rwxr-xr-xupdate-depends.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/update-depends.sh b/update-depends.sh
new file mode 100755
index 000000000000..61fcef6dc0d2
--- /dev/null
+++ b/update-depends.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# This script reads the CI config from xdg-desktop-portal-wlr's git repo
+# and updates depends/makedepends accordingly in the PKGBUILD.
+# It updates the PKGBUILD in place.
+
+# The script must be run from the PKGBUILD directory and it assumes that
+# the sources are located in ./src/xdg-desktop-portal-wlr-git
+
+yml="$(cat src/xdg-desktop-portal-wlr-git/.build.yml | sed 's/ *- //g')"
+
+# Dumb-parse yaml file and get the "packages" section
+pkgs="${yml##*packages:}"
+pkgs="${pkgs%%sources*}"
+
+depends="wlroots"
+makedepends="git"
+
+function move_to_makedepends() {
+ local pkg="$1"
+ pkgs="${pkgs//$pkg}"
+ makedepends="$makedepends $pkg"
+}
+
+# Remove the compilers since they're in base-devel
+pkgs="${pkgs//gcc}"
+pkgs="${pkgs//clang}"
+
+# Try to filter out makedepends and treat them as such
+echo "$pkgs" | grep -q meson && move_to_makedepends meson
+echo "$pkgs" | grep -q wayland-protocols && move_to_makedepends wayland-protocols
+echo "$pkgs" | grep -q wayland && move_to_makedepends wayland
+echo "$pkgs" | grep -q systemd-libs && move_to_makedepends systemd-libs
+
+# Strip out empty lines
+pkgs="$(echo "$pkgs" | sed '/^$/d')"
+
+# Add the rest to depends
+depends="$depends $(echo "$pkgs" | tr '\n' ' ')"
+
+# Trim away extra spaces
+depends="$(echo "$depends" | xargs)"
+makedepends="$(echo "$makedepends" | xargs)"
+
+echo "=> Updated dependencies from CI config:"
+echo "depends=($depends)"
+echo "makedepends=($makedepends)"
+
+sed -i \
+ -e s/'^depends=.*$'/"depends=($depends)"/ \
+ -e s/'^makedepends=.*$'/"makedepends=($makedepends)"/ \
+ PKGBUILD
+
+