From 0bc17f56dba2b1e8bc42fb2197f4361ba0cb46ca Mon Sep 17 00:00:00 2001 From: utahta Date: Thu, 18 Nov 2010 01:29:24 +0900 Subject: [PATCH] update version 0.6.1 --- MANIFEST.in | 1 + pythonbrew-install | 14 +++++++------- pythonbrew/commands/update.py | 14 ++++++++------ pythonbrew/define.py | 12 ++++++------ pythonbrew/downloader.py | 14 ++++++++++---- stable-version.txt | 2 +- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 2a25d02..1c7ec3f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ recursive-include pythonbrew/patches * +include pythonbrew_install.py diff --git a/pythonbrew-install b/pythonbrew-install index d7f82f9..ad06a95 100755 --- a/pythonbrew-install +++ b/pythonbrew-install @@ -57,12 +57,14 @@ fi PATH_DISTS="$ROOT/dists" PATH_ETC="$ROOT/etc" -mkdir -p $PATH_DISTS -rm -rf $PATH_DISTS/pythonbrew.tar.gz -rm -rf $PATH_DISTS/utahta-pythonbrew* +STABLE_VERSION=`curl -sL https://github.com/utahta/pythonbrew/raw/master/stable-version.txt` +TEMP_FILE="pythonbrew-$STABLE_VERSION" +TEMP_TARBALL="$TEMP_FILE.tar.gz" +DOWNLOAD_URL="http://pypi.python.org/packages/source/p/pythonbrew/$TEMP_TARBALL" -TEMP_TARBALL="pythonbrew.tar.gz" -DOWNLOAD_URL="http://github.com/utahta/pythonbrew/tarball/master" +mkdir -p $PATH_DISTS +rm -rf $PATH_DISTS/$TEMP_TARBALL +rm -rf $PATH_DISTS/$TEMP_FILE echo "Downloading $DOWNLOAD_URL" builtin cd $PATH_DISTS ; curl -sL $DOWNLOAD_URL -o "$TEMP_TARBALL" @@ -70,8 +72,6 @@ builtin cd $PATH_DISTS ; curl -sL $DOWNLOAD_URL -o "$TEMP_TARBALL" echo "Extracting $PATH_DISTS/$TEMP_TARBALL" builtin cd $PATH_DISTS ; tar zxf $TEMP_TARBALL -TEMP_FILE=`ls $PATH_DISTS | grep utahta-pythonbrew` - echo "Installing pythonbrew into $ROOT" $PYTHON $PATH_DISTS/$TEMP_FILE/pythonbrew_install.py if [[ $? == 1 ]] ; then diff --git a/pythonbrew/commands/update.py b/pythonbrew/commands/update.py index 6b9930d..a025846 100644 --- a/pythonbrew/commands/update.py +++ b/pythonbrew/commands/update.py @@ -5,8 +5,8 @@ from pythonbrew.define import PATH_DISTS, VERSION, ROOT,\ PATH_BUILD from pythonbrew.log import logger from pythonbrew.downloader import Downloader, get_pythonbrew_update_url,\ - get_response_from_url -from pythonbrew.util import rm_r, is_html, unpack_downloadfile + get_response_from_url, get_stable_version +from pythonbrew.util import rm_r, unpack_downloadfile, Link, is_gzip from pythonbrew.installer import PythonbrewInstaller class UpdateCommand(Command): @@ -15,9 +15,10 @@ class UpdateCommand(Command): summary = "Upgrades pythonbrew to the latest version" def run_command(self, options, args): - version = "head" if args: version = args[0] + else: + version = get_stable_version() # check for latest version if version <= VERSION: @@ -30,11 +31,12 @@ class UpdateCommand(Command): sys.exit(1) resp = get_response_from_url(download_url) content_type = resp.info()['content-type'] - if is_html(content_type): + if not is_gzip(content_type, Link(download_url).filename): logger.error("Invalid content-type: `%s`" % content_type) sys.exit(1) - distname = "pythonbrew.tgz" + filename = "pythonbrew-%s" % version + distname = "%s.tgz" % filename download_file = os.path.join(PATH_DISTS, distname) try: d = Downloader() @@ -43,7 +45,7 @@ class UpdateCommand(Command): logger.error("Failed to download. `%s`" % download_url) sys.exit(1) - extract_dir = os.path.join(PATH_BUILD, "pythonbrew") + extract_dir = os.path.join(PATH_BUILD, filename) rm_r(extract_dir) if not unpack_downloadfile(content_type, download_file, extract_dir): sys.exit(1) diff --git a/pythonbrew/define.py b/pythonbrew/define.py index d2e645c..eea26f9 100644 --- a/pythonbrew/define.py +++ b/pythonbrew/define.py @@ -1,6 +1,6 @@ import os -VERSION = "0.6" +VERSION = "0.6.1" if os.environ.has_key("PYTHONBREW_ROOT"): ROOT = os.environ["PYTHONBREW_ROOT"] @@ -31,11 +31,11 @@ PATH_BIN_PYBREW = os.path.join(PATH_BIN,"pybrew") # pybrew is symlink as pythonb DISTRIBUTE_SETUP_DLSITE = "http://python-distribute.org/distribute_setup.py" # download pythonbrew url -PYTHONBREW_UPDATE_URL = { - "head": "http://github.com/utahta/pythonbrew/tarball/master", - "0.5": "https://github.com/utahta/pythonbrew/tarball/0.5", - "0.6": "https://github.com/utahta/pythonbrew/tarball/0.6", -} +PYTHONBREW_UPDATE_URL_HEAD = "http://github.com/utahta/pythonbrew/tarball/master" +PYTHONBREW_UPDATE_URL_PYPI = "http://pypi.python.org/packages/source/p/pythonbrew/pythonbrew-%s.tar.gz" + +# stable version url +PYTHONBREW_STABLE_VERSION_URL = "https://github.com/utahta/pythonbrew/raw/master/stable-version.txt" # download Python version url PYTHON_VERSION_URL = {} diff --git a/pythonbrew/downloader.py b/pythonbrew/downloader.py index 7bf8bce..a6f472b 100644 --- a/pythonbrew/downloader.py +++ b/pythonbrew/downloader.py @@ -2,7 +2,8 @@ import sys import urllib import urllib2 from pythonbrew.util import size_format -from pythonbrew.define import PYTHON_VERSION_URL, PYTHONBREW_UPDATE_URL +from pythonbrew.define import PYTHON_VERSION_URL, PYTHONBREW_STABLE_VERSION_URL, \ + PYTHONBREW_UPDATE_URL_PYPI, PYTHONBREW_UPDATE_URL_HEAD from pythonbrew.log import logger def get_response_from_url(url): @@ -17,6 +18,10 @@ def get_response_from_url(url): sys.exit(1) return resp +def get_stable_version(): + resp = get_response_from_url(PYTHONBREW_STABLE_VERSION_URL) + return resp.read() + class Downloader(object): def __init__(self): self._msg = "" @@ -43,9 +48,10 @@ class Downloader(object): self._last_msg = now_msg def get_pythonbrew_update_url(version): - if PYTHONBREW_UPDATE_URL.has_key(version): - return PYTHONBREW_UPDATE_URL[version] - return None + if version == "head": + return PYTHONBREW_UPDATE_URL_HEAD + else: + return PYTHONBREW_UPDATE_URL_PYPI % (version) def get_python_version_url(version): if PYTHON_VERSION_URL.has_key(version): diff --git a/stable-version.txt b/stable-version.txt index 490f510..7ceb040 100644 --- a/stable-version.txt +++ b/stable-version.txt @@ -1 +1 @@ -0.6 \ No newline at end of file +0.6.1 \ No newline at end of file