diff --git a/.gitignore b/.gitignore index 894a44c..a4499c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,104 +1,3 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ +__pycache__ +.pyc +.idea \ No newline at end of file diff --git a/LICENSE b/LICENSE index 3877ae0..c65825e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - Copyright (C) + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/settings.py b/settings.py index 1ae655b..7dfcb83 100644 --- a/settings.py +++ b/settings.py @@ -14,3 +14,7 @@ gtgithubapiurl = 'https://api.github.com/repos/go-gitea/gitea/releases/latest' gtsystem = 'linux-amd64' # Name and Path of gitea file gtfile = '/home/git/gitea' +# Build new version from source? +build_from_source = None +# Source directroy +source_dir = '/home/git/go/src/code.gitea.io/gitea' \ No newline at end of file diff --git a/updater.py b/updater.py index 3699a30..f0e95a3 100644 --- a/updater.py +++ b/updater.py @@ -19,6 +19,21 @@ def download(url, file_name): # write to file file.write(response.content) +# Function to build the new version from source +def buildFromSource(tag): + # Change to source dir + os.chdir(settings.source_dir) + # Checkout master + os.system("git checkout master") + # Update + os.system("git pull") + # Checkout relase branch + os.system("git checkout "+tag) + # Build from source + os.system('TAGS="bindata sqlite sqlite_unlock_notify" make generate build') + # Move binary + os.system("mv gitea "+settings.gtfile) + # Version from gitea site current_version = requests.get(settings.gtsite).json()['version'] @@ -34,11 +49,18 @@ if github_version > current_version: # Stop systemd service os.system("systemctl stop gitea.service") - # Set download url - gtdownload = 'https://github.com/go-gitea/gitea/releases/download/'+github_version_tag+'/gitea-'+github_version+'-'+settings.gtsystem + # Should the new version be build from source? + if settings.build_from_source: - # Download file - download(gtdownload, settings.gtfile) + buildFromSource(github_version_tag) + + else: + + # Set download url + gtdownload = 'https://github.com/go-gitea/gitea/releases/download/'+github_version_tag+'/gitea-'+github_version+'-'+settings.gtsystem + + # Download file + download(gtdownload, settings.gtfile) # Start systemd service os.system("systemctl start gitea.service")