X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@lists.alpinelinux.org Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by lists.alpinelinux.org (Postfix) with ESMTP id ED2101EBFF8 for ; Sun, 2 Jan 2011 01:48:18 +0000 (UTC) Received: by iyb26 with SMTP id 26so11726555iyb.13 for ; Sat, 01 Jan 2011 17:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=ieT4MBznMm19Ov2SHVP4rw6ESGJZnpUKVNsCOvWVplY=; b=mCEJEjZZpiQJU+qZJqAty0elcxuSmsgJ/Z9fvJdvFDMoYn5h5jScyAQtqGz0SBwzll hAdnOiayf9x2EAYtdDJrmwNBwoGV1KY7D5y/vQC/Ckr8WlhGkMjuIOWzKasIkk/IkItF r3XqlRnSlOgzpzcRxnvcjJx3dpjyl7hztOzr0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=cmho2lEaY4Wd3iyWFHHzTH6j3fv0DpBxx9+/uqopa2hnWrAlGJg7/4Ithil0B9sXHZ IhCaO5IptmAvMXUF/8xpPQt1Z8dMOU5nB1NShsLB9QaSLnTX+wrrY0GnLgY/+a3RdUac dDKpQKZBenbafLPjtB1MQVQJMXkfUO7M4euC4= Received: by 10.42.169.8 with SMTP id z8mr19588788icy.171.1293932897778; Sat, 01 Jan 2011 17:48:17 -0800 (PST) Received: from localhost.localdomain (209.250.132.162.tor.pathcom.com [209.250.132.162]) by mx.google.com with ESMTPS id jv9sm16171428icb.1.2011.01.01.17.48.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 01 Jan 2011 17:48:16 -0800 (PST) From: Jeff Bilyk To: alpine-devel@lists.alpinelinux.org Cc: Jeff Bilyk Subject: [alpine-devel] [PATCH] alpine-conf: modify setup-apkrepos to grab different mirror and automatically retrieve release Date: Sat, 1 Jan 2011 19:48:05 +0000 Message-Id: <1293911285-1654-1-git-send-email-jbilyk@gmail.com> X-Mailer: git-send-email 1.7.3.4 X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: Retrieve MIRRORS.txt and get mirror from there, automatically choose release if possible, and if not prompt for desired release --- setup-apkrepos.in | 63 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 36 insertions(+), 27 deletions(-) diff --git a/setup-apkrepos.in b/setup-apkrepos.in index 1436292..19344bd 100755 --- a/setup-apkrepos.in +++ b/setup-apkrepos.in @@ -5,31 +5,40 @@ PREFIX= . $PREFIX/lib/libalpine.sh -while true; do - printf "Enter repository branch : \n" - printf "1 1.10 \n" - printf "2 2.0\n" - printf "3 2.1\n" - printf "4 edge\n" - default_read REPO "3" - if [ $REPO -gt 0 ] && [ $REPO -lt 5 ]; then - break - fi -done -if [ $REPO == 1 ]; then - echo "v1.10 repos selected" - echo "http://dl-3.alpinelinux.org/alpine/v1.10/packages/main" >> /etc/apk/repositories - apk update -elif [ $REPO == 2 ]; then - echo "v2.0 repos selected"; - echo "http://dl-3.alpinelinux.org/alpine/v2.0/packages/main" >> /etc/apk/repositories - apk update -elif [ $REPO == 3 ]; then - echo "v2.1 repos selected"; - echo "http://dl-3.alpinelinux.org/alpine/v2.1/packages/main" >> /etc/apk/repositories - apk update -elif [ $REPO == 4 ]; then - echo "edge repos selected"; - echo "http://dl-3.alpinelinux.org/alpine/edge/packages/main" >> /etc/apk/repositories - apk update +# TODO: change tail command to a random mirror instead of last one in MIRRORS.txt +MIRROR=`wget -O - http://www.alpinelinux.org/alpine/MIRRORS.txt 2>&1 | grep http | awk -F 'ETA' '{print $NF}' | tail -n 1` + +# Retrieve version from alpine-release if available +if [ -e /etc/alpine-release ]; then + release=$(cut -f1 /etc/alpine-release) + case "$release" in + *_git*) repo="edge";; + [0-9]*.[0-9]*.[0-9]*) + # release in x.y.z format, cut last digit + repo=v${release%.[0-9]*};; + esac + echo "$repo" +else + while true; do + printf "Enter repository branch from list below [v2.2]: \n" + # Retrieve list of versions available on mirror 2.0 and above + wget "$MIRROR" > /dev/null 2>&1 + availablerepos="" + for version in `links ./index.html -dump | grep "v[2-9]" | awk -F '/' '{print $1}'`; do + + availablerepos="$availablerepos $version" + done + rm index.html + availablerepos="$availablerepos edge" + for i in `echo $availablerepos`; do + printf "$i\n" + done + default_read repo "v2.2" + if [ $repo ]; then + break + fi + done fi + +echo "${MIRROR}${repo}/main" >> /etc/apk/repositories +apk update -- 1.7.3.4 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---