[lxc-devel] [lxc/master] lxc-alpine: few modifications

jirutka on Github lxc-bot at linuxcontainers.org
Tue Mar 14 16:51:08 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170314/b4010153/attachment.bin>
-------------- next part --------------
From 288142218ae6cc24bf084fdd5768ad2c83086fb1 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub at jirutka.cz>
Date: Tue, 14 Mar 2017 17:28:47 +0100
Subject: [PATCH 1/2] lxc-alpine: add community repository to default
 repositories

Signed-off-by: Jakub Jirutka <jakub at jirutka.cz>
---
 templates/lxc-alpine.in | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in
index 06616b3..fd281f8 100644
--- a/templates/lxc-alpine.in
+++ b/templates/lxc-alpine.in
@@ -236,7 +236,6 @@ install() {
 	local branch="$3"
 	local extra_packages="$4"
 	local apk_cache="$LXC_CACHE_DIR/apk/$arch"
-	local repo_url="$MIRROR_URL/$branch/main"
 
 	if [ "$FLUSH_CACHE" = 'yes' ] && [ -d "$apk_cache" ]; then
 		einfo "Cleaning cached APK packages for $arch"
@@ -249,7 +248,10 @@ install() {
 
 	mkdir -p etc/apk
 	ln -s "$apk_cache" etc/apk/cache
-	echo "$repo_url" > etc/apk/repositories
+
+	local repo; for repo in main community; do
+		echo "$MIRROR_URL/$branch/$repo" >> etc/apk/repositories
+	done
 
 	install_packages "$arch" "alpine-base $extra_packages"
 	make_dev_nodes

From 382d98324801b4ea44ec2207d9fc12f52776ff3d Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub at jirutka.cz>
Date: Tue, 14 Mar 2017 17:35:46 +0100
Subject: [PATCH 2/2] lxc-alpine: use dl-cdn.a.o as default mirror instead of
 random one

Some mirrors from the mirrors list are not very reliable and it seems
that no one really wants to use some random mirror as the default
option.

Signed-off-by: Jakub Jirutka <jakub at jirutka.cz>
---
 templates/lxc-alpine.in | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in
index fd281f8..0440d6d 100644
--- a/templates/lxc-alpine.in
+++ b/templates/lxc-alpine.in
@@ -46,7 +46,7 @@ ebf31683b56410ecc4c00acd9f6e2839e237a3b62b5ae7ef686705c7ba0396a9  alpine-devel at l
 12f899e55a7691225603d6fb3324940fc51cd7f133e7ead788663c2b7eecb00c  alpine-devel at lists.alpinelinux.org-5261cecb.rsa.pub"
 
 readonly APK_KEYS_URI='http://alpinelinux.org/keys'
-readonly MIRRORS_LIST_URL='http://rsync.alpinelinux.org/alpine/MIRRORS.txt'
+readonly DEFAULT_MIRROR_URL='http://dl-cdn.alpinelinux.org'
 
 : ${APK_KEYS_DIR:=/etc/apk/keys}
 if ! ls "$APK_KEYS_DIR"/alpine* >/dev/null 2>&1; then
@@ -76,7 +76,7 @@ usage() {
 		                          to the host arch.
 		   -d, --debug            Run this script in a debug mode (set -x and wget w/o -q).
 		   -F, --flush-cache      Remove cached files before build.
-		   -m URL --mirror=URL    The Alpine mirror to use; defaults to random mirror.
+		   -m URL --mirror=URL    The Alpine mirror to use; defaults to $DEFAULT_MIRROR_URL.
 		   -r VER, --release=VER  The Alpine release branch to install; default is the
 		                          latest stable.
 
@@ -130,11 +130,6 @@ parse_arch() {
 	esac
 }
 
-random_mirror_url() {
-	local url=$(fetch "$MIRRORS_LIST_URL" | shuf -n 1)
-	[ -n "$url" ] && echo "$url"
-}
-
 run_exclusively() {
 	local lock_name="$1"
 	local timeout=$2
@@ -477,7 +472,7 @@ extra_packages="$@"
 # Set global variables.
 readonly DEBUG="$debug"
 readonly FLUSH_CACHE="$flush_cache"
-readonly MIRROR_URL="${mirror_url:-$(random_mirror_url)}"
+readonly MIRROR_URL="${mirror_url:-$DEFAULT_MIRROR_URL}"
 
 # Validate options.
 [ -n "$name" ] || die 1 'Missing required option --name'


More information about the lxc-devel mailing list