forked from 0x2620/pandora
use git branches to track stable release
This commit is contained in:
parent
8b92756595
commit
34936d25f0
3 changed files with 25 additions and 27 deletions
8
ctl
8
ctl
|
@ -11,21 +11,23 @@ if [ "$action" = "init" ]; then
|
|||
BASE=`pwd`
|
||||
python3 -m venv --system-site-packages .
|
||||
|
||||
branch=`cat .git/HEAD | sed 's@/@\n@g' | tail -n1`
|
||||
|
||||
# Work around broken venv module in Ubuntu 16.04 / Debian 9
|
||||
if [ ! -e bin/pip ]; then
|
||||
bin/python3 -m pip install -U --ignore-installed "pip<9"
|
||||
fi
|
||||
if [ ! -d static/oxjs ]; then
|
||||
git clone --depth 1 https://git.0x2620.org/oxjs.git static/oxjs
|
||||
git clone --depth 1 -b $branch https://git.0x2620.org/oxjs.git static/oxjs
|
||||
fi
|
||||
mkdir -p src
|
||||
if [ ! -d src/oxtimelines ]; then
|
||||
git clone --depth 1 https://git.0x2620.org/oxtimelines.git src/oxtimelines
|
||||
git clone --depth 1 -b $branch https://git.0x2620.org/oxtimelines.git src/oxtimelines
|
||||
fi
|
||||
for package in oxtimelines python-ox; do
|
||||
cd ${BASE}
|
||||
if [ ! -d src/${package} ]; then
|
||||
git clone --depth 1 https://git.0x2620.org/${package}.git src/${package}
|
||||
git clone --depth 1 -b $branch https://git.0x2620.org/${package}.git src/${package}
|
||||
fi
|
||||
cd ${BASE}/src/${package}
|
||||
${BASE}/bin/python setup.py develop
|
||||
|
|
42
update.py
42
update.py
|
@ -121,6 +121,11 @@ def run_git(path, *args):
|
|||
def get_version(path):
|
||||
return run_git(path, 'rev-list', 'HEAD', '--count')
|
||||
|
||||
def get_branch(path=None):
|
||||
if not path:
|
||||
path = '.'
|
||||
return get('cat', os.path.join(path, '.git/HEAD')).strip().split('/')[-1]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
base = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
|
||||
|
@ -254,49 +259,38 @@ if __name__ == "__main__":
|
|||
run('./pandora/manage.py', 'createcachetable')
|
||||
else:
|
||||
if len(sys.argv) == 1:
|
||||
release = get_release()
|
||||
repos = release['repositories']
|
||||
branch = get_branch()
|
||||
development = branch == 'master'
|
||||
elif len(sys.argv) == 3 and sys.argv[1] == 'switch':
|
||||
branch = sys.argv[2]
|
||||
development = False
|
||||
else:
|
||||
release = {
|
||||
'date': 'development'
|
||||
}
|
||||
branch = 'master'
|
||||
development = True
|
||||
os.chdir(base)
|
||||
current = ''
|
||||
new = ''
|
||||
if development:
|
||||
if get('git', 'symbolic-ref', 'HEAD').strip().split('/')[-1] != 'master':
|
||||
print('update only possible if you are on master branch')
|
||||
sys.exit(1)
|
||||
for repo in sorted(repos, key=lambda r: repos[r]['path']):
|
||||
path = os.path.join(base, repos[repo]['path'])
|
||||
if exists(path):
|
||||
os.chdir(path)
|
||||
current_branch = get_branch(path)
|
||||
if current_branch != branch:
|
||||
run('git', 'checkout', branch)
|
||||
revno = get_version(path)
|
||||
if repo == 'pandora':
|
||||
pandora_old_revno = revno
|
||||
current += revno
|
||||
url = repos[repo]['url']
|
||||
if 'revision' in repos[repo]:
|
||||
if revno != repos[repo]['revision']:
|
||||
run('git', 'fetch')
|
||||
run('git', 'checkout', repos[repo]['commit'])
|
||||
else:
|
||||
print('Checking', repo)
|
||||
#run('git', 'checkout', 'master', '-q')
|
||||
run('git', 'pull')
|
||||
print('Checking', repo)
|
||||
run('git', 'pull')
|
||||
revno = get_version(path)
|
||||
new += revno
|
||||
if repo == 'pandora':
|
||||
pandora_new_revno = revno
|
||||
else:
|
||||
os.chdir(os.path.dirname(path))
|
||||
if 'revision' in repos[repo]:
|
||||
run('git', 'clone', repos[repo]['url'])
|
||||
run_git(path, 'checkout', repos[repo]['commit'])
|
||||
else:
|
||||
run('git', 'clone', '--depth', '1', repos[repo]['url'])
|
||||
run('git', 'clone', '--depth', '1', repos[repo]['url'])
|
||||
setup = os.path.join(base, repos[repo]['path'], 'setup.py')
|
||||
if repo in ('python-ox', 'oxtimelines') and os.path.exists(setup):
|
||||
os.chdir(os.path.dirname(setup))
|
||||
|
@ -317,7 +311,7 @@ if __name__ == "__main__":
|
|||
'BEGIN;\n-- Model missing for table: cache\nCOMMIT;'
|
||||
]:
|
||||
print('Database has changed, please make a backup and run %s db' % sys.argv[0])
|
||||
elif not development:
|
||||
print('pan.do/ra is at the latest release,\nyou can run "%s dev" to update to the development version' % sys.argv[0])
|
||||
elif branch != 'master':
|
||||
print('pan.do/ra is at the latest release,\nyou can run "%s switch master" to switch to the development version' % sys.argv[0])
|
||||
elif current != new:
|
||||
reload_notice(base)
|
||||
|
|
|
@ -4,6 +4,7 @@ PANDORA=${PANDORA-pandora}
|
|||
POSTGRES=${POSTGRES-local}
|
||||
RABBITMQ=${RABBITMQ-local}
|
||||
NGINX=${NGINX-local}
|
||||
BRANCH=${BRANCH-stable}
|
||||
|
||||
echo Installing pandora with user: $PANDORA
|
||||
getent passwd $PANDORA > /dev/null 2>&1 || adduser --disabled-password --gecos "" $PANDORA
|
||||
|
@ -111,6 +112,7 @@ fi
|
|||
#pandora
|
||||
git clone https://git.0x2620.org/pandora.git /srv/pandora
|
||||
cd /srv/pandora
|
||||
git checkout $BRANCH
|
||||
./ctl init
|
||||
|
||||
HOST=$(hostname -s)
|
||||
|
|
Loading…
Reference in a new issue