main/postmarketos-{base-ui-gnome,ui-weston}: fix duplicate dependencies in depends and _pmb_recommends
I noticed that postmarketos-base-ui-gnome had a duplicated dependency on xdg-user-dirs while working on !5120 (merged); then I wondered, "maybe some other packages have this issue as well?", and wrote a little script to find it, which revealed that postmarketos-ui-weston had much of the same.
Some more detailed information:
- main/postmarketos-base-ui-gnome - the direct dependency on xdg-user-dirs was added in commit 679ee536, and the deps in
_pmb_recommends
were added later in commit d680f3eb when moving dependencies to the common package; as such, it's safe to assume that both it and xdg-user-dirs-gtk should be independs
. - main/postmarketos-ui-weston: the weston-clients dependency was there since the beginning, but was moved to _pmb_recommends in commit c759f716; I assume it was mistakenly left in
depends
, so it is now dropped.
The script I used to find these is under the summary. We should probably add it to the CI somehow, but I'm not sure where to do it; CI's APKBUILD linting step just calls pmbootstrap lint, which in turn just calls apkbuild-lint. The main caveat of this script is that it requires bash to be able to parse the lists; a slower solution could theoretically be implemented in pure sh, or it could be entirely replaced by a Python script.
Detection script
#!/bin/bash
# https://stackoverflow.com/questions/8063228/check-if-a-variable-exists-in-a-list-in-bash
contains () { [[ "$1" =~ (^|[[:space:]])"$2"($|[[:space:]]) ]]; }
for apkbuild in $(find -name APKBUILD); do
unset depends, _pmb_recommends
source "$apkbuild"
duplicates=""
for dep in $depends; do
if contains "$_pmb_recommends" "$dep"; then
[[ ! $duplicates ]] && echo "$apkbuild:"
echo "Duplicate dependency: $dep is both in depends and _pmb_recommends"
duplicates+=" $dep"
fi
done
for dep in $_pmb_recommends; do
if contains "$depends" "$dep" && ! contains "$duplicates" "$dep"; then
[[ ! $duplicates ]] && echo "$apkbuild:"
echo "Duplicate dependency: $dep is both in depends and _pmb_recommends"
duplicates+=" $dep"
fi
done
done