Skip to content
Snippets Groups Projects
Commit 00687513 authored by Natanael Copa's avatar Natanael Copa
Browse files

setup-xorg-base: avoid duplicate community repos

simplify and remove duplicate logic of adding community repos.
parent 72aec523
No related branches found
No related tags found
1 merge request!186fix enabling community repos for setup-desktop gnome
...@@ -24,31 +24,15 @@ done ...@@ -24,31 +24,15 @@ done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
# For every main/ repo, enable corresponding community/ repo # For every main/ repo, enable corresponding community/ repo
orig="$ROOT"/etc/apk/repositories for repo in $(grep '^[^#].*/main$' "$ROOT"/etc/apk/repositories 2>/dev/null); do
if test -f "$orig"; then crepo="${repo%%/main}/community"
echo '>> Enabling community repositories' if ! grep -q -x -- "$crepo" "$ROOT"/etc/apk/repositories; then
tmp="$orig".setup-xorg-base.tmp echo ">>> Enabling repository $crepo"
:> "$tmp" echo "$crepo" >> "$ROOT"/etc/apk/repositories
while read line ; do fi
echo "$line" done
nosharp="${line##\#*}"
nomain="${line%%/main}"
if test "$line" = "$nosharp" && test "$line" != "$nomain"; then
echo "$nomain"/community
fi
done < "$orig" >> "$tmp"
mv -f "$tmp" "$orig"
apk update
fi
# enable community repo if [ -n "$crepo" ]; then
if [ -f "$ROOT"/etc/apk/repositories ] && ! grep -q '^[^#].*/community$' "$ROOT"/etc/apk/repositories; then
repo=$(grep '^[^#].*/main$' /etc/apk/repositories | sed 's:/main$:/community:')
escaped_repo=$(echo $repo | sed -e 's:/:\\/:g' -e 's:\.:\\.:g')
sed -i -e "/^[^#].*\/main$/a $repo" \
-e "/^#${escaped_repo}$/d" \
"$ROOT"/etc/apk/repositories \
&& echo ">> Enabling community repository"
apk update apk update
fi fi
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
. $(atf_get_srcdir)/test_env.sh . $(atf_get_srcdir)/test_env.sh
init_tests \ init_tests \
setup_xorg_base_usage \ setup_xorg_base_usage \
setup_xorg_base setup_xorg_base \
setup_xorg_base_community_duplicates
setup_xorg_base_usage_body() { setup_xorg_base_usage_body() {
test_usage setup-xorg-base test_usage setup-xorg-base
...@@ -12,11 +13,42 @@ setup_xorg_base_usage_body() { ...@@ -12,11 +13,42 @@ setup_xorg_base_usage_body() {
setup_xorg_base_body() { setup_xorg_base_body() {
init_env init_env
mkdir -p etc/apk mkdir -p etc/apk
echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > etc/apk/repositories cat > etc/apk/repositories <<-EOF
https://dl-cdn.alpinelinux.org/alpine/edge/main
#https://dl-cdn.alpinelinux.org/alpine/edge/community
EOF
atf_check -s exit:0 \ atf_check -s exit:0 \
-o match:"apk add.*xorg-server.*foobar" \ -o match:"apk add.*xorg-server.*foobar" \
-o match:"Starting udev" \ -o match:"Starting udev" \
-e empty \ -e empty \
setup-xorg-base foobar setup-xorg-base foobar
atf_check \
-o match:"https://dl-cdn.alpinelinux.org/alpine/edge/community" \
cat etc/apk/repositories
}
setup_xorg_base_community_duplicates_body() {
init_env
mkdir -p etc/apk
cat > etc/apk/repositories <<-EOF
https://dl-cdn.alpinelinux.org/alpine/edge/main
https://example.tld/main
https://dl-cdn.alpinelinux.org/alpine/edge/community
EOF
atf_check -s exit:0 \
-o match:"apk update" \
-e empty \
setup-xorg-base
atf_check \
-o match:"https://example.tld/community" \
-o match:"https://dl-cdn.alpinelinux.org/alpine/edge/community" \
cat etc/apk/repositories
atf_check \
-o match:"2" \
grep -c -w "community" etc/apk/repositories
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment