use git branches to track stable release

This commit is contained in:
j 2019-04-30 12:42:28 +02:00
parent 8b92756595
commit 34936d25f0
3 changed files with 25 additions and 27 deletions

8
ctl
View file

@ -11,21 +11,23 @@ if [ "$action" = "init" ]; then
BASE=`pwd` BASE=`pwd`
python3 -m venv --system-site-packages . 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 # Work around broken venv module in Ubuntu 16.04 / Debian 9
if [ ! -e bin/pip ]; then if [ ! -e bin/pip ]; then
bin/python3 -m pip install -U --ignore-installed "pip<9" bin/python3 -m pip install -U --ignore-installed "pip<9"
fi fi
if [ ! -d static/oxjs ]; then 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 fi
mkdir -p src mkdir -p src
if [ ! -d src/oxtimelines ]; then 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 fi
for package in oxtimelines python-ox; do for package in oxtimelines python-ox; do
cd ${BASE} cd ${BASE}
if [ ! -d src/${package} ]; then 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 fi
cd ${BASE}/src/${package} cd ${BASE}/src/${package}
${BASE}/bin/python setup.py develop ${BASE}/bin/python setup.py develop

View file

@ -121,6 +121,11 @@ def run_git(path, *args):
def get_version(path): def get_version(path):
return run_git(path, 'rev-list', 'HEAD', '--count') 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__": if __name__ == "__main__":
base = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) base = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
@ -254,49 +259,38 @@ if __name__ == "__main__":
run('./pandora/manage.py', 'createcachetable') run('./pandora/manage.py', 'createcachetable')
else: else:
if len(sys.argv) == 1: if len(sys.argv) == 1:
release = get_release() branch = get_branch()
repos = release['repositories'] development = branch == 'master'
elif len(sys.argv) == 3 and sys.argv[1] == 'switch':
branch = sys.argv[2]
development = False development = False
else: else:
release = { branch = 'master'
'date': 'development'
}
development = True development = True
os.chdir(base) os.chdir(base)
current = '' current = ''
new = '' 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']): for repo in sorted(repos, key=lambda r: repos[r]['path']):
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)
current_branch = get_branch(path)
if current_branch != branch:
run('git', 'checkout', branch)
revno = get_version(path) 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]: print('Checking', repo)
if revno != repos[repo]['revision']: run('git', 'pull')
run('git', 'fetch')
run('git', 'checkout', repos[repo]['commit'])
else:
print('Checking', repo)
#run('git', 'checkout', 'master', '-q')
run('git', 'pull')
revno = get_version(path) 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))
if 'revision' in repos[repo]: run('git', 'clone', '--depth', '1', repos[repo]['url'])
run('git', 'clone', repos[repo]['url'])
run_git(path, 'checkout', repos[repo]['commit'])
else:
run('git', 'clone', '--depth', '1', repos[repo]['url'])
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))
@ -317,7 +311,7 @@ if __name__ == "__main__":
'BEGIN;\n-- Model missing for table: cache\nCOMMIT;' 'BEGIN;\n-- Model missing for table: cache\nCOMMIT;'
]: ]:
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 branch != 'master':
print('pan.do/ra is at the latest 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 switch master" to switch to the development version' % sys.argv[0])
elif current != new: elif current != new:
reload_notice(base) reload_notice(base)

View file

@ -4,6 +4,7 @@ PANDORA=${PANDORA-pandora}
POSTGRES=${POSTGRES-local} POSTGRES=${POSTGRES-local}
RABBITMQ=${RABBITMQ-local} RABBITMQ=${RABBITMQ-local}
NGINX=${NGINX-local} NGINX=${NGINX-local}
BRANCH=${BRANCH-stable}
echo Installing pandora with user: $PANDORA echo Installing pandora with user: $PANDORA
getent passwd $PANDORA > /dev/null 2>&1 || adduser --disabled-password --gecos "" $PANDORA getent passwd $PANDORA > /dev/null 2>&1 || adduser --disabled-password --gecos "" $PANDORA
@ -111,6 +112,7 @@ fi
#pandora #pandora
git clone https://git.0x2620.org/pandora.git /srv/pandora git clone https://git.0x2620.org/pandora.git /srv/pandora
cd /srv/pandora cd /srv/pandora
git checkout $BRANCH
./ctl init ./ctl init
HOST=$(hostname -s) HOST=$(hostname -s)