Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Infer the community repo from the main repo URL
Browse files Browse the repository at this point in the history
Adds a default dl-cdn community repo if main is absent, based on
/etc/alpine-release

Signed-off-by: Joe Groocock <[email protected]>
  • Loading branch information
frebib committed Jul 9, 2018
1 parent ac1a6ff commit 2f8587b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libmachine/provision/alpine.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ func (provisioner *AlpineProvisioner) Provision(swarmOptions swarm.Options, auth
}

log.Debug("Add Community repo")
if _, err := provisioner.SSHCommand("if ! which docker >/dev/null && ! apk info docker >/dev/null; then ver=$(awk '{split($1,a,\".\"); print a[1]\".\"a[2]}' /etc/alpine-release); echo \"http://dl-cdn.alpinelinux.org/alpine/v$ver/community\" >> /etc/apk/repositories; apk update; fi"); err != nil {
if _, err := provisioner.SSHCommand(`
if ! grep -q '^[[:blank:]]*[^#].*community$' /etc/apk/repositories; then
if ! grep -q '^[[:blank:]]*[^#].*main$' /etc/apk/repositories; then
echo "http://dl-cdn.alpinelinux.org/alpine/v$(cut -d. -f1-2 /etc/alpine-release)/community" >> /etc/apk/repositories;
else
sed -i '/^\\s*[^#].*main/{p;s/main/community/;}' /etc/apk/repositories;
fi
fi;
apk update`); err != nil {
return err
}

Expand Down

0 comments on commit 2f8587b

Please sign in to comment.