1
0
mirror of https://github.com/CMiksche/gitea-auto-update synced 2025-12-10 07:57:23 +01:00

Merge pull request #11 from iwalton3/master

Fixes: Make binary executable, fix isTool method signature, handle corrupted binary, and README tweaks.
This commit is contained in:
Christoph Daniel Miksche
2019-09-04 15:18:26 +02:00
committed by GitHub
3 changed files with 15 additions and 9 deletions

View File

@@ -38,15 +38,15 @@ apiUrl=https://api.github.com/repos/go-gitea/gitea/releases/latest
system=linux-amd64
file=/usr/local/bin/gitea
tmpDir=/tmp/
buildFromSource=None
sourceDir=/home/git/go/src/code.gitea.io/gitea
buildFromSource=
sourceDir=
logFile=update.log
````
Use the following command to install gitea-auto-update.
```
sudo pip install gitea-auto-update
sudo pip3 install gitea-auto-update
```
Enter the command `gite-auto-update --settings=/path/to/settings.ini` in your commandline.

View File

@@ -28,7 +28,7 @@ class Download:
self.downloadGiteaFiles()
self.checkAndExtract()
def isTool(name):
def isTool(self, name):
# Function to check if tool is available
##Check whether `name` is on PATH and marked as executable.
return which(name) is not None
@@ -67,6 +67,8 @@ class Download:
# moving temp file to gtfile location
cmd = 'mv ' + self.tmpDir + 'gitea-' + self.githubVersion + '-' + self.gtSystem + ' ' + self.gtFile
os.system(cmd)
cmd = 'chmod +x ' + self.gtFile
os.system(cmd)
def checkAndExtract(self):
os.chdir(self.tmpDir)
@@ -74,4 +76,4 @@ class Download:
self.extractFile()
else:
logging.error('Download: error: sha256sum failed')
quit()
quit()

View File

@@ -35,9 +35,13 @@ class Version:
currentVersion = self.getVersionFromFile()
except:
# Get the version via the web api if the file does fail
currentVersion = requests.get(self.gtSite).json()['version']
if currentVersion.status_code != 200:
currentVersion = self.getVersionFromFile()
try:
currentVersion = requests.get(self.gtSite).json()['version']
if currentVersion.status_code != 200:
raise RuntimeError("Could not download version.")
except:
# To allow installation, return a default version of "0.0.0".
currentVersion = "0.0.0"
finally:
logging.info('Version: current_version = %s', currentVersion)
return currentVersion
@@ -45,4 +49,4 @@ class Version:
def getGithubVersionTag(self, apiUrl):
versionTag = requests.get(apiUrl).json()['tag_name']
logging.info('Version: github_version_tag = %s', versionTag)
return versionTag
return versionTag