From 787693500d88102cdff41bb8aa7c11279bf65e1f Mon Sep 17 00:00:00 2001
From: Philip <philm@manjaro.org>
Date: Tue, 3 Sep 2013 17:27:02 +0200
Subject: [PATCH] add pacman-mirrors.conf

---
 Makefile             |  1 +
 mkmanjaroroot.in     |  9 ++++++++-
 pacman-default.conf  |  6 ------
 pacman-mirrors.conf  | 21 +++++++++++++++++++++
 pacman-multilib.conf |  9 ---------
 5 files changed, 30 insertions(+), 16 deletions(-)
 create mode 100644 pacman-mirrors.conf

diff --git a/Makefile b/Makefile
index fa3beea..1f6b1fb 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ CONFIGFILES = \
 	makepkg-i686.conf \
 	makepkg-x86_64.conf \
 	pacman-default.conf \
+	pacman-mirrors.conf \
 	pacman-multilib.conf
 
 MANJAROBUILD_LINKS = \
diff --git a/mkmanjaroroot.in b/mkmanjaroroot.in
index 7c66395..f4b0c25 100644
--- a/mkmanjaroroot.in
+++ b/mkmanjaroroot.in
@@ -28,6 +28,7 @@ usage() {
 	echo '    -u            Update the chroot via pacman'
 	echo '    -C <file>     Location of a pacman config file'
 	echo '    -M <file>     Location of a makepkg config file'
+	echo '    -S <file>     Location of a pacman-mirrors config file'
 	echo '    -n            Do not copy config files into the chroot'
 	echo '    -c <dir>      Set pacman cache'
 	echo '    -b <branch>   Set repository branch'
@@ -35,7 +36,7 @@ usage() {
 	exit 1
 }
 
-while getopts 'r:ufnhC:M:c:b:' arg; do
+while getopts 'r:ufnhC:M:S:c:b:' arg; do
 	case "${arg}" in
 		r) RUN="$OPTARG" ;;
 		u) RUN='pacman -Syu --noconfirm' ;;
@@ -44,6 +45,7 @@ while getopts 'r:ufnhC:M:c:b:' arg; do
 		n) NOCOPY='y' ;;
 		c) cache_dir="$OPTARG" ;;
 		b) branch="$OPTARG" ;;
+		S) mirrors_conf="$OPTARG" ;;
 		h|?) usage ;;
 		*) error "invalid argument '${arg}'"; usage ;;
 	esac
@@ -109,6 +111,11 @@ copy_hostconf () {
 		cp ${makepkg_conf} ${working_dir}/etc/makepkg.conf
 	fi
 
+	if [[ -n $mirrors_conf && $NOCOPY = 'n' ]]; then
+		cp ${mirrors_conf} ${working_dir}/etc/pacman-mirrors.conf
+		sed -i -e "s|^.*Branch=.*|Branch=${branch}|" ${working_dir}/etc/pacman-mirrors.conf
+	fi
+
 	sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i ${working_dir}/etc/pacman.conf
 }
 
diff --git a/pacman-default.conf b/pacman-default.conf
index 45fe03d..8932d82 100644
--- a/pacman-default.conf
+++ b/pacman-default.conf
@@ -69,18 +69,12 @@ LocalFileSigLevel = Optional
 # repo name header and Include lines. You can add preferred servers immediately
 # after the header, and they will be used before the default mirrors.
 
-#[testing]
-#Include = /etc/pacman.d/mirrorlist
-
 [core]
 Include = /etc/pacman.d/mirrorlist
 
 [extra]
 Include = /etc/pacman.d/mirrorlist
 
-#[community-testing]
-#Include = /etc/pacman.d/mirrorlist
-
 [community]
 Include = /etc/pacman.d/mirrorlist
 
diff --git a/pacman-mirrors.conf b/pacman-mirrors.conf
new file mode 100644
index 0000000..86a5545
--- /dev/null
+++ b/pacman-mirrors.conf
@@ -0,0 +1,21 @@
+##
+## /etc/pacman-mirrors.conf
+##
+
+## Branch Pacman should use (stable, testing, unstable)
+Branch=stable
+
+## Generation method
+## 1) rank   - rank mirrors depending on their access time
+## 2) random - randomly generate the output mirrorlist
+Method=rank
+
+## Specify to use only mirrors from a specific country
+## Disabled by default
+# OnlyCountry=Germany
+
+## Input mirrorlist directory
+MirrorlistsDir="/etc/pacman.d/mirrors"
+
+## Output mirrorlist
+OutputMirrorlist="/etc/pacman.d/mirrorlist"
diff --git a/pacman-multilib.conf b/pacman-multilib.conf
index a6511e0..167adc4 100644
--- a/pacman-multilib.conf
+++ b/pacman-multilib.conf
@@ -69,27 +69,18 @@ LocalFileSigLevel = Optional
 # repo name header and Include lines. You can add preferred servers immediately
 # after the header, and they will be used before the default mirrors.
 
-#[testing]
-#Include = /etc/pacman.d/mirrorlist
-
 [core]
 Include = /etc/pacman.d/mirrorlist
 
 [extra]
 Include = /etc/pacman.d/mirrorlist
 
-#[community-testing]
-#Include = /etc/pacman.d/mirrorlist
-
 [community]
 Include = /etc/pacman.d/mirrorlist
 
 # If you want to run 32 bit applications on your x86_64 system,
 # enable the multilib repositories as required here.
 
-#[multilib-testing]
-#Include = /etc/pacman.d/mirrorlist
-
 [multilib]
 Include = /etc/pacman.d/mirrorlist
 
-- 
GitLab