[arch-general] [PATCH] Ignore empty lines when grepping host's mirrorlist
--- mkarchroot | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mkarchroot b/mkarchroot index fe436f7..5cb9a0f 100755 --- a/mkarchroot +++ b/mkarchroot @@ -73,7 +73,7 @@ if [ -z "$cache_dir" ]; then fi if [ -f /etc/pacman.d/mirrorlist ]; then - host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') + host_mirror=$(grep -E -v '^(#|$)' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') fi if [ -z "${host_mirror}" ]; then host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch' -- 1.7.2.3
On Sat, Sep 11, 2010 at 01:46:48AM +0300, Evangelos Foutras wrote:
--- mkarchroot | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mkarchroot b/mkarchroot index fe436f7..5cb9a0f 100755 --- a/mkarchroot +++ b/mkarchroot @@ -73,7 +73,7 @@ if [ -z "$cache_dir" ]; then fi
if [ -f /etc/pacman.d/mirrorlist ]; then - host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') + host_mirror=$(grep -E -v '^(#|$)' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') fi if [ -z "${host_mirror}" ]; then host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch' -- 1.7.2.3
Keep in mind this will still catch a line that only has spaces in it. I would suggest using the pattern '^[\t ]*(#|$)' instead to avoid this. d
On Sat, Sep 11, 2010 at 1:59 AM, Dave Reisner <d@falconindy.com> wrote:
On Sat, Sep 11, 2010 at 01:46:48AM +0300, Evangelos Foutras wrote:
--- mkarchroot | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mkarchroot b/mkarchroot index fe436f7..5cb9a0f 100755 --- a/mkarchroot +++ b/mkarchroot @@ -73,7 +73,7 @@ if [ -z "$cache_dir" ]; then fi
if [ -f /etc/pacman.d/mirrorlist ]; then - host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') + host_mirror=$(grep -E -v '^(#|$)' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') fi if [ -z "${host_mirror}" ]; then host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch' -- 1.7.2.3
Keep in mind this will still catch a line that only has spaces in it. I would suggest using the pattern '^[\t ]*(#|$)' instead to avoid this.
d
Now that I think about it, maybe it would be best to just grep for '^Server' instead of discarding irrelevant lines. :p
On Sat, Sep 11, 2010 at 02:55:40AM +0300, Evangelos Foutras wrote:
On Sat, Sep 11, 2010 at 1:59 AM, Dave Reisner <d@falconindy.com> wrote:
On Sat, Sep 11, 2010 at 01:46:48AM +0300, Evangelos Foutras wrote:
--- mkarchroot | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mkarchroot b/mkarchroot index fe436f7..5cb9a0f 100755 --- a/mkarchroot +++ b/mkarchroot @@ -73,7 +73,7 @@ if [ -z "$cache_dir" ]; then fi
if [ -f /etc/pacman.d/mirrorlist ]; then - host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') + host_mirror=$(grep -E -v '^(#|$)' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') fi if [ -z "${host_mirror}" ]; then host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch' -- 1.7.2.3
Keep in mind this will still catch a line that only has spaces in it. I would suggest using the pattern '^[\t ]*(#|$)' instead to avoid this.
d
Now that I think about it, maybe it would be best to just grep for '^Server' instead of discarding irrelevant lines. :p
Even better! Well played. d
On Sat, 11 Sep 2010 01:46:48 +0300, Evangelos Foutras <foutrelis@gmail.com> wrote:
--- mkarchroot | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mkarchroot b/mkarchroot index fe436f7..5cb9a0f 100755 --- a/mkarchroot +++ b/mkarchroot @@ -73,7 +73,7 @@ if [ -z "$cache_dir" ]; then fi
if [ -f /etc/pacman.d/mirrorlist ]; then - host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') + host_mirror=$(grep -E -v '^(#|$)' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') fi if [ -z "${host_mirror}" ]; then host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch'
Please at least at me to CC next time or open a bug report. Otherwise there is a chance I just miss those patches. However, this mirror detections wasn't that great anyway. I am now using pacman to get the used mirror: http://projects.archlinux.org/devtools.git/commit/?id=db7a90ccd280a84bdbdef0... This should always work even if you specify your mirrors directly in pacman.conf or include a mirrorlist with a different name. -- Pierre Schmitz, https://users.archlinux.de/~pierre
On Sat, Sep 11, 2010 at 9:36 PM, Pierre Schmitz <pierre@archlinux.de> wrote:
On Sat, 11 Sep 2010 01:46:48 +0300, Evangelos Foutras <foutrelis@gmail.com> wrote:
--- mkarchroot | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mkarchroot b/mkarchroot index fe436f7..5cb9a0f 100755 --- a/mkarchroot +++ b/mkarchroot @@ -73,7 +73,7 @@ if [ -z "$cache_dir" ]; then fi
if [ -f /etc/pacman.d/mirrorlist ]; then - host_mirror=$(grep -v '^#' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') + host_mirror=$(grep -E -v '^(#|$)' -m1 /etc/pacman.d/mirrorlist | sed -E 's#/os/(i686|x86_64)#/os/\$arch#g') fi if [ -z "${host_mirror}" ]; then host_mirror='Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch'
Please at least at me to CC next time or open a bug report. Otherwise there is a chance I just miss those patches.
I had sent one more patch for devtools before this, but its changes were fully included in another recent commit so it doesn't matter. I'll CC you next time I send a patch.
However, this mirror detections wasn't that great anyway. I am now using pacman to get the used mirror: http://projects.archlinux.org/devtools.git/commit/?id=db7a90ccd280a84bdbdef0...
This should always work even if you specify your mirrors directly in pacman.conf or include a mirrorlist with a different name.
-- Pierre Schmitz, https://users.archlinux.de/~pierre
Neat! :)
participants (3)
-
Dave Reisner
-
Evangelos Foutras
-
Pierre Schmitz