mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-12 02:00:28 +03:00
Merge branch 'master' of gitorious.org:f-droid/fdroidserver
This commit is contained in:
commit
3d849dccbc
3 changed files with 24 additions and 47 deletions
1
fdroid
1
fdroid
|
|
@ -18,7 +18,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
|
|
||||||
commands = [
|
commands = [
|
||||||
"build",
|
"build",
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
import glob, os, sys, re
|
import glob, os, sys, re
|
||||||
import shutil
|
import shutil
|
||||||
|
import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import operator
|
import operator
|
||||||
|
|
@ -43,6 +44,9 @@ def read_config(opts, config_file='config.py'):
|
||||||
if not os.path.isfile(config_file):
|
if not os.path.isfile(config_file):
|
||||||
print "Missing config file - is this a repo directory?"
|
print "Missing config file - is this a repo directory?"
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
st = os.stat(config_file)
|
||||||
|
if st.st_mode & stat.S_IRWXG or st.st_mode & stat.S_IRWXO:
|
||||||
|
print("WARNING: unsafe permissions on config.py (should be 0600)!")
|
||||||
|
|
||||||
options = opts
|
options = opts
|
||||||
if not hasattr(options, 'verbose'):
|
if not hasattr(options, 'verbose'):
|
||||||
|
|
@ -91,19 +95,14 @@ class vcs:
|
||||||
|
|
||||||
self.sdk_path = sdk_path
|
self.sdk_path = sdk_path
|
||||||
|
|
||||||
# It's possible to sneak a username and password in with
|
# svn, git-svn and bzr may require auth
|
||||||
# the remote address for svn...
|
|
||||||
self.username = None
|
self.username = None
|
||||||
if self.repotype() in ('svn', 'git-svn'):
|
if self.repotype() in ('svn', 'git-svn', 'bzr'):
|
||||||
index = remote.find('@')
|
if '@' in remote:
|
||||||
if index != -1:
|
self.username, remote = remote.split('@')
|
||||||
self.username = remote[:index]
|
if ':' not in self.username:
|
||||||
remote = remote[index+1:]
|
|
||||||
index = self.username.find(':')
|
|
||||||
if index == -1:
|
|
||||||
raise VCSException("Password required with username")
|
raise VCSException("Password required with username")
|
||||||
self.password = self.username[index+1:]
|
self.username, self.password = self.username.split(':')
|
||||||
self.username = self.username[:index]
|
|
||||||
|
|
||||||
self.remote = remote
|
self.remote = remote
|
||||||
self.local = local
|
self.local = local
|
||||||
|
|
@ -318,7 +317,7 @@ class vcs_gitsvn(vcs):
|
||||||
p = subprocess.Popen(['git', 'svn', 'find-rev', 'r' + rev],
|
p = subprocess.Popen(['git', 'svn', 'find-rev', 'r' + rev],
|
||||||
cwd=self.local, stdout=subprocess.PIPE)
|
cwd=self.local, stdout=subprocess.PIPE)
|
||||||
git_rev = p.communicate()[0].rstrip()
|
git_rev = p.communicate()[0].rstrip()
|
||||||
if p.returncode != 0 or len(git_rev) == 0:
|
if p.returncode != 0 or not git_rev:
|
||||||
# Try a plain git checkout as a last resort
|
# Try a plain git checkout as a last resort
|
||||||
p = subprocess.Popen(['git', 'checkout', rev], cwd=self.local,
|
p = subprocess.Popen(['git', 'checkout', rev], cwd=self.local,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
@ -447,27 +446,6 @@ class vcs_bzr(vcs):
|
||||||
cwd=self.local) != 0:
|
cwd=self.local) != 0:
|
||||||
raise VCSException("Bzr revert failed")
|
raise VCSException("Bzr revert failed")
|
||||||
|
|
||||||
def __init__(self, remote, local, sdk_path):
|
|
||||||
|
|
||||||
self.sdk_path = sdk_path
|
|
||||||
|
|
||||||
index = remote.find('@')
|
|
||||||
if index != -1:
|
|
||||||
self.username = remote[:index]
|
|
||||||
remote = remote[index+1:]
|
|
||||||
index = self.username.find(':')
|
|
||||||
if index == -1:
|
|
||||||
raise VCSException("Password required with username")
|
|
||||||
self.password = self.username[index+1:]
|
|
||||||
self.username = self.username[:index]
|
|
||||||
else:
|
|
||||||
self.username = None
|
|
||||||
|
|
||||||
self.remote = remote
|
|
||||||
self.local = local
|
|
||||||
self.refreshed = False
|
|
||||||
self.srclib = None
|
|
||||||
|
|
||||||
def gettags(self):
|
def gettags(self):
|
||||||
p = subprocess.Popen(['bzr', 'tags'],
|
p = subprocess.Popen(['bzr', 'tags'],
|
||||||
stdout=subprocess.PIPE, cwd=self.local)
|
stdout=subprocess.PIPE, cwd=self.local)
|
||||||
|
|
@ -550,7 +528,7 @@ def parse_metadata(metafile):
|
||||||
return thisbuild
|
return thisbuild
|
||||||
|
|
||||||
def add_comments(key):
|
def add_comments(key):
|
||||||
if len(curcomments) == 0:
|
if not curcomments:
|
||||||
return
|
return
|
||||||
for comment in curcomments:
|
for comment in curcomments:
|
||||||
thisinfo['comments'].append((key, comment))
|
thisinfo['comments'].append((key, comment))
|
||||||
|
|
@ -631,7 +609,7 @@ def parse_metadata(metafile):
|
||||||
buildlines = []
|
buildlines = []
|
||||||
|
|
||||||
if mode == 0:
|
if mode == 0:
|
||||||
if len(line) == 0:
|
if not line:
|
||||||
continue
|
continue
|
||||||
if line.startswith("#"):
|
if line.startswith("#"):
|
||||||
curcomments.append(line)
|
curcomments.append(line)
|
||||||
|
|
@ -654,7 +632,7 @@ def parse_metadata(metafile):
|
||||||
if fieldtype == 'multiline':
|
if fieldtype == 'multiline':
|
||||||
mode = 1
|
mode = 1
|
||||||
thisinfo[field] = []
|
thisinfo[field] = []
|
||||||
if len(value) > 0:
|
if value:
|
||||||
raise MetaDataException("Unexpected text on same line as " + field + " in " + metafile.name)
|
raise MetaDataException("Unexpected text on same line as " + field + " in " + metafile.name)
|
||||||
elif fieldtype == 'string':
|
elif fieldtype == 'string':
|
||||||
if field == 'Category' and thisinfo['Categories'] == 'None':
|
if field == 'Category' and thisinfo['Categories'] == 'None':
|
||||||
|
|
@ -716,7 +694,7 @@ def parse_metadata(metafile):
|
||||||
elif mode == 3:
|
elif mode == 3:
|
||||||
raise MetaDataException("Unterminated build in " + metafile.name)
|
raise MetaDataException("Unterminated build in " + metafile.name)
|
||||||
|
|
||||||
if len(thisinfo['Description']) == 0:
|
if not thisinfo['Description']:
|
||||||
thisinfo['Description'].append('No description available')
|
thisinfo['Description'].append('No description available')
|
||||||
|
|
||||||
# Validate archive policy...
|
# Validate archive policy...
|
||||||
|
|
@ -795,7 +773,7 @@ def write_metadata(dest, app):
|
||||||
mf.write('\n')
|
mf.write('\n')
|
||||||
if app['Name']:
|
if app['Name']:
|
||||||
writefield('Name')
|
writefield('Name')
|
||||||
if len(app['Auto Name']) > 0:
|
if app['Auto Name']:
|
||||||
writefield('Auto Name')
|
writefield('Auto Name')
|
||||||
writefield('Summary')
|
writefield('Summary')
|
||||||
writefield('Description', '')
|
writefield('Description', '')
|
||||||
|
|
@ -806,7 +784,7 @@ def write_metadata(dest, app):
|
||||||
if app['Requires Root']:
|
if app['Requires Root']:
|
||||||
writefield('Requires Root', 'Yes')
|
writefield('Requires Root', 'Yes')
|
||||||
mf.write('\n')
|
mf.write('\n')
|
||||||
if len(app['Repo Type']) > 0:
|
if app['Repo Type']:
|
||||||
writefield('Repo Type')
|
writefield('Repo Type')
|
||||||
writefield('Repo')
|
writefield('Repo')
|
||||||
mf.write('\n')
|
mf.write('\n')
|
||||||
|
|
@ -860,11 +838,11 @@ def write_metadata(dest, app):
|
||||||
writefield('Vercode Operation')
|
writefield('Vercode Operation')
|
||||||
if 'Update Check Data' in app:
|
if 'Update Check Data' in app:
|
||||||
writefield('Update Check Data')
|
writefield('Update Check Data')
|
||||||
if len(app['Current Version']) > 0:
|
if app['Current Version']:
|
||||||
writefield('Current Version')
|
writefield('Current Version')
|
||||||
writefield('Current Version Code')
|
writefield('Current Version Code')
|
||||||
mf.write('\n')
|
mf.write('\n')
|
||||||
if len(app['No Source Since']) > 0:
|
if app['No Source Since']:
|
||||||
writefield('No Source Since')
|
writefield('No Source Since')
|
||||||
mf.write('\n')
|
mf.write('\n')
|
||||||
writecomments(None)
|
writecomments(None)
|
||||||
|
|
@ -1014,7 +992,7 @@ class DescriptionFormatter:
|
||||||
|
|
||||||
def parseline(self, line):
|
def parseline(self, line):
|
||||||
self.text_wiki += line + '\n'
|
self.text_wiki += line + '\n'
|
||||||
if len(line) == 0:
|
if not line:
|
||||||
self.endcur()
|
self.endcur()
|
||||||
elif line.startswith('*'):
|
elif line.startswith('*'):
|
||||||
self.endcur([self.stUL])
|
self.endcur([self.stUL])
|
||||||
|
|
@ -1125,7 +1103,7 @@ def version_name(original, app_dir, flavour):
|
||||||
continue
|
continue
|
||||||
xml_dir = os.path.join(f[:-19], 'res', 'values')
|
xml_dir = os.path.join(f[:-19], 'res', 'values')
|
||||||
string = retrieve_string(xml_dir, original)
|
string = retrieve_string(xml_dir, original)
|
||||||
if len(string) > 0:
|
if string:
|
||||||
return string
|
return string
|
||||||
return original
|
return original
|
||||||
|
|
||||||
|
|
@ -1272,10 +1250,9 @@ def parse_srclib(metafile, **kw):
|
||||||
|
|
||||||
for line in metafile:
|
for line in metafile:
|
||||||
line = line.rstrip('\r\n')
|
line = line.rstrip('\r\n')
|
||||||
if len(line) == 0:
|
if not line or line.startswith("#"):
|
||||||
continue
|
|
||||||
if line.startswith("#"):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
index = line.find(':')
|
index = line.find(':')
|
||||||
if index == -1:
|
if index == -1:
|
||||||
raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
|
raise MetaDataException("Invalid metadata in " + metafile.name + " at: " + line)
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ def main():
|
||||||
os.mkdir('repo')
|
os.mkdir('repo')
|
||||||
shutil.copy(os.path.join(examplesdir, 'fdroid-icon.png'), repodir)
|
shutil.copy(os.path.join(examplesdir, 'fdroid-icon.png'), repodir)
|
||||||
shutil.copyfile(os.path.join(examplesdir, 'config.sample.py'), 'config.py')
|
shutil.copyfile(os.path.join(examplesdir, 'config.sample.py'), 'config.py')
|
||||||
|
os.chmod('config.py', 0o0600)
|
||||||
else:
|
else:
|
||||||
print('Looks like this is already an F-Droid repo, cowardly refusing to overwrite it...')
|
print('Looks like this is already an F-Droid repo, cowardly refusing to overwrite it...')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue