Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

This Bash script helps you to replace mirrorlist with baseurl in your mock config files. It selects the first item in the mirrorlist (should be good enough). To update the mirrors, revert config from backup (.bak) and run again.

View mock-mirrorlist2baseurl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#!/usr/bin/env bash
# Copyright (c) 2013, Miro HronĨok <miro@hroncok.cz>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# =============================================================================
#
# This script helps you to replace mirrorlist with baseurl in your mock config
# files. It selects the first item in the mirrorlist (should be good enough).
# To update the mirrors, revert config from backup (.bak) and run again.
 
if [ -z "$1" ]; then
echo "Usage: $0 list of files to modify"
echo "For example: $0 /etc/mock/*.cfg"
fi
 
for FILE in "$@"; do
echo -n "$FILE: "
if [ ! -f "$FILE" ]; then
echo "Not a file"
continue
fi
if [ ! -w "$FILE" ]; then
echo "Cannot write"
continue
fi
BAK=".bak"
grep '^mirrorlist=' "$FILE" | while read URL; do
URL="${URL##mirrorlist=}"
wget -q "$URL" -O /tmp/m2b-mirrorlist
NEWURL="`head -2 /tmp/m2b-mirrorlist | tail -1`"
sed -i$BAK "s|mirrorlist=$URL|baseurl=$NEWURL|" "$FILE"
BAK=""
rm -f /tmp/m2b-mirrorlist
done
echo "Done"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.