switch to git
This commit is contained in:
parent
bb3aebb367
commit
48e1435601
6 changed files with 79 additions and 40 deletions
8
README
8
README
|
@ -24,7 +24,7 @@ To run pan.do/ra you need to install and setup:
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
||||||
2) install all required packages
|
2) install all required packages
|
||||||
apt-get install bzr git subversion mercurial \
|
apt-get install git subversion mercurial \
|
||||||
python-setuptools python-pip python-virtualenv ipython \
|
python-setuptools python-pip python-virtualenv ipython \
|
||||||
python-dev python-imaging python-numpy python-psycopg2 \
|
python-dev python-imaging python-numpy python-psycopg2 \
|
||||||
python-geoip python-html5lib python-lxml \
|
python-geoip python-html5lib python-lxml \
|
||||||
|
@ -54,15 +54,15 @@ You have to use the same password here and in BROKER_URL in local_settings.py
|
||||||
|
|
||||||
=== Install Pan.do/ra ===
|
=== Install Pan.do/ra ===
|
||||||
|
|
||||||
1) Get code from bazzar
|
1) Get code from git
|
||||||
cd /srv/
|
cd /srv/
|
||||||
bzr branch http://code.0x2620.org/pandora pandora
|
git clone https://git.0x260.org/pandora.git pandora
|
||||||
cd pandora
|
cd pandora
|
||||||
virtualenv --system-site-packages .
|
virtualenv --system-site-packages .
|
||||||
./bin/pip install -r requirements.txt
|
./bin/pip install -r requirements.txt
|
||||||
|
|
||||||
cd static
|
cd static
|
||||||
bzr branch http://code.0x2620.org/oxjs
|
git clone https://git.0x2620.org/oxjs.git
|
||||||
|
|
||||||
cd /srv
|
cd /srv
|
||||||
chown -R pandora.pandora pandora
|
chown -R pandora.pandora pandora
|
||||||
|
|
|
@ -5,9 +5,11 @@ from __future__ import division, with_statement
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import thread
|
import thread
|
||||||
import codecs
|
import codecs
|
||||||
|
from os.path import dirname, exists, join
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -26,14 +28,20 @@ RUN_RELOADER = True
|
||||||
NOTIFIER = None
|
NOTIFIER = None
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
info = os.path.join(os.path.dirname(__file__), '..', '..', '.bzr/branch/last-revision')
|
info = join(dirname(dirname(dirname(__file__))), '.bzr', 'branch', 'last-revision')
|
||||||
if os.path.exists(info):
|
git_dir = join(dirname(dirname(dirname(__file__))), '.git')
|
||||||
|
if exists(git_dir):
|
||||||
|
env = {'GIT_DIR': git_dir}
|
||||||
|
cmd = ['git', 'rev-list', 'HEAD', '--count']
|
||||||
|
return subprocess.check_output(cmd, env=env).strip()
|
||||||
|
elif exists(info):
|
||||||
f = open(info)
|
f = open(info)
|
||||||
rev = int(f.read().split()[0])
|
rev = int(f.read().split()[0])
|
||||||
f.close()
|
f.close()
|
||||||
if rev:
|
if rev:
|
||||||
return u'%s' % rev
|
return u'%s' % rev
|
||||||
return u'unknown'
|
else:
|
||||||
|
return u'unknown'
|
||||||
|
|
||||||
def load_config(init=False):
|
def load_config(init=False):
|
||||||
with open(settings.SITE_CONFIG) as f:
|
with open(settings.SITE_CONFIG) as f:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#-e git+https://github.com/django/django.git@stable/1.4.x#egg=django
|
#-e git+https://github.com/django/django.git@stable/1.4.x#egg=django
|
||||||
Django<1.5
|
Django<1.5
|
||||||
-e bzr+http://code.0x2620.org/python-ox/#egg=python-ox
|
-e git+https://git.0x2620.org/python-ox.git#egg=python-ox
|
||||||
-e bzr+http://code.0x2620.org/oxtimelines/#egg=oxtimelines
|
-e git+https://git.0x2620.org/oxtimelines.git#egg=oxtimelines
|
||||||
simplejson
|
simplejson
|
||||||
chardet
|
chardet
|
||||||
celery==3.0.24
|
celery==3.0.24
|
||||||
|
|
85
update.py
85
update.py
|
@ -10,6 +10,7 @@ if os.path.exists(activate_this):
|
||||||
execfile(activate_this, dict(__file__=activate_this))
|
execfile(activate_this, dict(__file__=activate_this))
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib2
|
import urllib2
|
||||||
import json
|
import json
|
||||||
|
@ -29,28 +30,32 @@ def get_json(url):
|
||||||
return json.loads(urllib2.urlopen(url).read())
|
return json.loads(urllib2.urlopen(url).read())
|
||||||
|
|
||||||
def get_release():
|
def get_release():
|
||||||
|
if os.path.exists('.release'):
|
||||||
|
url = open('.release').read().strip()
|
||||||
|
else:
|
||||||
|
url = 'https://pan.do/json/release-stable.json'
|
||||||
try:
|
try:
|
||||||
return get_json('https://pan.do/json/release.json')
|
return get_json(url)
|
||||||
except:
|
except:
|
||||||
print "failed to load https://pan.do/ra, check your internet connection"
|
print "Failed to load %s check your internet connection." % url
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
repos = {
|
repos = {
|
||||||
"pandora": {
|
"pandora": {
|
||||||
"url": "http://code.0x2620.org/pandora/",
|
"url": "https://git.0x2620.org/pandora.git",
|
||||||
"path": ".",
|
"path": ".",
|
||||||
},
|
},
|
||||||
"oxjs": {
|
"oxjs": {
|
||||||
"url": "http://code.0x2620.org/oxjs/",
|
"url": "https://git.0x2620.org/oxjs.git",
|
||||||
"path": "./static/oxjs",
|
"path": "./static/oxjs",
|
||||||
},
|
},
|
||||||
"oxtimelines": {
|
"oxtimelines": {
|
||||||
"url": "http://code.0x2620.org/oxtimelines/",
|
"url": "https://git.0x2620.org/oxtimelines.git",
|
||||||
"path": "./src/oxtimelines",
|
"path": "./src/oxtimelines",
|
||||||
},
|
},
|
||||||
"python-ox": {
|
"python-ox": {
|
||||||
"url": "http://code.0x2620.org/python-ox/",
|
"url": "https://git.0x2620.org/python-ox.git",
|
||||||
"path": "./src/python-ox",
|
"path": "./src/python-ox",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +66,7 @@ def check_services(base):
|
||||||
services = "pandora pandora-tasks pandora-encoding pandora-cron pandora-websocketd".split()
|
services = "pandora pandora-tasks pandora-encoding pandora-cron pandora-websocketd".split()
|
||||||
for service in services:
|
for service in services:
|
||||||
cmd = ['service', service, 'status']
|
cmd = ['service', service, 'status']
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
if subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) != 0:
|
||||||
p.wait()
|
|
||||||
if p.returncode != 0:
|
|
||||||
print 'Please install init script for "%s" service:' % service
|
print 'Please install init script for "%s" service:' % service
|
||||||
if os.path.exists('/etc/init'):
|
if os.path.exists('/etc/init'):
|
||||||
print '\tsudo cp %s/etc/init/%s.conf /etc/init/' % (base, service)
|
print '\tsudo cp %s/etc/init/%s.conf /etc/init/' % (base, service)
|
||||||
|
@ -72,6 +75,14 @@ def check_services(base):
|
||||||
print '\tsudo service %s start' % service
|
print '\tsudo service %s start' % service
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
|
def run_git(path, *args):
|
||||||
|
cmd = ['git'] + list(args)
|
||||||
|
env = {'GIT_DIR': '%s/.git' % path}
|
||||||
|
return subprocess.check_output(cmd, env=env).strip()
|
||||||
|
|
||||||
|
def get_version(path):
|
||||||
|
return run_git(path, 'rev-list', 'HEAD', '--count')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] in ('database', 'db'):
|
if len(sys.argv) == 2 and sys.argv[1] in ('database', 'db'):
|
||||||
os.chdir(join(base, 'pandora'))
|
os.chdir(join(base, 'pandora'))
|
||||||
|
@ -95,8 +106,13 @@ if __name__ == "__main__":
|
||||||
run('./manage.py', 'update_static')
|
run('./manage.py', 'update_static')
|
||||||
elif len(sys.argv) == 4 and sys.argv[1] == 'postupdate':
|
elif len(sys.argv) == 4 and sys.argv[1] == 'postupdate':
|
||||||
os.chdir(base)
|
os.chdir(base)
|
||||||
old = int(sys.argv[2])
|
old = sys.argv[2]
|
||||||
new = int(sys.argv[3])
|
new = sys.argv[3]
|
||||||
|
if old.isdigit():
|
||||||
|
old = int(old)
|
||||||
|
if new.isdigit():
|
||||||
|
new = int(new)
|
||||||
|
print 'Post Update from %d to %d' % (old, new)
|
||||||
if old < 3111:
|
if old < 3111:
|
||||||
run('bzr', 'resolved', 'pandora/monkey_patch', 'pandora/monkey_patch/migrations')
|
run('bzr', 'resolved', 'pandora/monkey_patch', 'pandora/monkey_patch/migrations')
|
||||||
if os.path.exists('pandora/monkey_patch'):
|
if os.path.exists('pandora/monkey_patch'):
|
||||||
|
@ -138,8 +154,24 @@ if __name__ == "__main__":
|
||||||
if old < 4947:
|
if old < 4947:
|
||||||
run('./bin/pip', 'install', 'tornado==4.1')
|
run('./bin/pip', 'install', 'tornado==4.1')
|
||||||
check_services(base)
|
check_services(base)
|
||||||
|
if old < 5074:
|
||||||
|
for component in ('oxtimelines', 'python-ox'):
|
||||||
|
if not os.path.exists('./src/%s/.git' % component):
|
||||||
|
run('./bin/pip', 'install', '-e',
|
||||||
|
'git+https://git.0x2620.org/%s.git#egg=%s' % (component, component),
|
||||||
|
'--exists-action', 'w')
|
||||||
|
if not os.path.exists('./static/oxjs/.git'):
|
||||||
|
if os.path.exists('static/oxjs'):
|
||||||
|
shutil.move('static/oxjs', 'static/oxjs_bzr')
|
||||||
|
run('git', 'clone', 'https://git.0x2620.org/oxjs.git', 'static/oxjs')
|
||||||
|
run('./pandora/manage.py', 'update_static')
|
||||||
|
if os.path.exists('static/oxjs_bzr'):
|
||||||
|
shutil.rmtree('static/oxjs_bzr')
|
||||||
|
if os.path.exists('REPOSITORY_MOVED_TO_GIT'):
|
||||||
|
os.unlink('REPOSITORY_MOVED_TO_GIT')
|
||||||
|
if os.path.exists('.bzr'):
|
||||||
|
shutil.rmtree('.bzr')
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
release = get_release()
|
release = get_release()
|
||||||
repos = release['repositories']
|
repos = release['repositories']
|
||||||
|
@ -156,26 +188,29 @@ if __name__ == "__main__":
|
||||||
path = os.path.join(base, repos[repo]['path'])
|
path = os.path.join(base, repos[repo]['path'])
|
||||||
if exists(path):
|
if exists(path):
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
revno = get('bzr', 'revno')
|
revno = get_version(path)
|
||||||
if repo == 'pandora':
|
if repo == 'pandora':
|
||||||
pandora_old_revno = revno
|
pandora_old_revno = revno
|
||||||
current += revno
|
current += revno
|
||||||
url = repos[repo]['url']
|
url = repos[repo]['url']
|
||||||
if 'revision' in repos[repo]:
|
if 'revision' in repos[repo]:
|
||||||
if int(revno) < repos[repo]['revision']:
|
if revno != repos[repo]['revision']:
|
||||||
run('bzr', 'pull', url, '-r', '%s' % repos[repo]['revision'])
|
run('git', 'fetch')
|
||||||
|
run('git', 'checkout', repos[repo]['commit'])
|
||||||
else:
|
else:
|
||||||
run('bzr', 'pull', url)
|
print 'Checking', repo
|
||||||
revno = get('bzr', 'revno')
|
run('git', 'checkout', 'master', '-q')
|
||||||
|
run('git', 'pull')
|
||||||
|
revno = get_version(path)
|
||||||
new += revno
|
new += revno
|
||||||
if repo == 'pandora':
|
if repo == 'pandora':
|
||||||
pandora_new_revno = revno
|
pandora_new_revno = revno
|
||||||
else:
|
else:
|
||||||
os.chdir(os.path.dirname(path))
|
os.chdir(os.path.dirname(path))
|
||||||
cmd = ['bzr', 'branch', repos[repo]['url']]
|
cmd = ['git', 'clone', repos[repo]['url']]
|
||||||
if 'revision' in repos[repo]:
|
|
||||||
cmd += ['-r', '%s' % repos[repo]['revision']]
|
|
||||||
run(*cmd)
|
run(*cmd)
|
||||||
|
if 'revision' in repos[repo]:
|
||||||
|
run_git(path, 'checkout', repos[repo]['commit'])
|
||||||
setup = os.path.join(base, repos[repo]['path'], 'setup.py')
|
setup = os.path.join(base, repos[repo]['path'], 'setup.py')
|
||||||
if repo in ('python-ox', 'oxtimelines') and os.path.exists(setup):
|
if repo in ('python-ox', 'oxtimelines') and os.path.exists(setup):
|
||||||
os.chdir(os.path.dirname(setup))
|
os.chdir(os.path.dirname(setup))
|
||||||
|
@ -193,6 +228,6 @@ if __name__ == "__main__":
|
||||||
if diff != '-- No differences':
|
if diff != '-- No differences':
|
||||||
print 'Database has changed, please make a backup and run %s db' % sys.argv[0]
|
print 'Database has changed, please make a backup and run %s db' % sys.argv[0]
|
||||||
elif not development:
|
elif not development:
|
||||||
print 'pan.do/ra is at the latest stable release,\nyou can run "%s dev" to update to the development version' % sys.argv[0]
|
print 'pan.do/ra is at the latest release,\nyou can run "%s dev" to update to the development version' % sys.argv[0]
|
||||||
elif current != new:
|
elif current != new:
|
||||||
reload_notice(base)
|
reload_notice(base)
|
||||||
|
|
|
@ -32,9 +32,6 @@ Login via ssh or in terminal as pandora with password pandora
|
||||||
|
|
||||||
ssh pandora@pandora.local
|
ssh pandora@pandora.local
|
||||||
|
|
||||||
Adjust your bzr configuration with bzr whoami:
|
|
||||||
bzr whoami "Pando the Panda <pan.do@pan.do>"
|
|
||||||
|
|
||||||
Pan.do/ra is installed in /srv/pandora and is served with nginx on http://pandora.local
|
Pan.do/ra is installed in /srv/pandora and is served with nginx on http://pandora.local
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ apt-get install -y \
|
||||||
pwgen \
|
pwgen \
|
||||||
nginx \
|
nginx \
|
||||||
rabbitmq-server \
|
rabbitmq-server \
|
||||||
bzr \
|
|
||||||
git \
|
git \
|
||||||
python-setuptools \
|
python-setuptools \
|
||||||
python-pip \
|
python-pip \
|
||||||
|
@ -86,8 +85,8 @@ rabbitmqctl add_vhost /pandora
|
||||||
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
||||||
|
|
||||||
#pandora
|
#pandora
|
||||||
bzr branch http://code.0x2620.org/pandora /srv/pandora
|
git clone https://git.0x2620.org/pandora.git /srv/pandora
|
||||||
bzr branch http://code.0x2620.org/oxjs /srv/pandora/static/oxjs
|
git clone https://git.0x2620.org/oxjs.git /srv/pandora/static/oxjs
|
||||||
virtualenv --system-site-packages /srv/pandora
|
virtualenv --system-site-packages /srv/pandora
|
||||||
cd /srv/pandora
|
cd /srv/pandora
|
||||||
./bin/pip install -r /srv/pandora/requirements.txt
|
./bin/pip install -r /srv/pandora/requirements.txt
|
||||||
|
|
Loading…
Reference in a new issue