mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-02 09:10:11 +02:00
Merge branch 'crash-and-standard-imports' into 'master'
Crash and standard imports See merge request fdroid/fdroidserver!445
This commit is contained in:
commit
84262cfead
@ -721,7 +721,7 @@ def read_metadata(xref=True, check_vcs=[], refresh=True, sort_by_time=False):
|
|||||||
exception. So the original .txt format is parsed first, at least until
|
exception. So the original .txt format is parsed first, at least until
|
||||||
newer formats stabilize.
|
newer formats stabilize.
|
||||||
|
|
||||||
check_vcs is the list of packageNames to check for .fdroid.yml in source
|
check_vcs is the list of appids to check for .fdroid.yml in source
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -754,11 +754,11 @@ def read_metadata(xref=True, check_vcs=[], refresh=True, sort_by_time=False):
|
|||||||
for metadatapath in metadatafiles:
|
for metadatapath in metadatafiles:
|
||||||
if metadatapath == '.fdroid.txt':
|
if metadatapath == '.fdroid.txt':
|
||||||
warn_or_exception(_('.fdroid.txt is not supported! Convert to .fdroid.yml or .fdroid.json.'))
|
warn_or_exception(_('.fdroid.txt is not supported! Convert to .fdroid.yml or .fdroid.json.'))
|
||||||
packageName, _ignored = fdroidserver.common.get_extension(os.path.basename(metadatapath))
|
appid, _ignored = fdroidserver.common.get_extension(os.path.basename(metadatapath))
|
||||||
if packageName in apps:
|
if appid in apps:
|
||||||
warn_or_exception(_("Found multiple metadata files for {appid}")
|
warn_or_exception(_("Found multiple metadata files for {appid}")
|
||||||
.format(path=packageName))
|
.format(appid=appid))
|
||||||
app = parse_metadata(metadatapath, packageName in check_vcs, refresh)
|
app = parse_metadata(metadatapath, appid in check_vcs, refresh)
|
||||||
check_metadata(app)
|
check_metadata(app)
|
||||||
apps[app.id] = app
|
apps[app.id] = app
|
||||||
|
|
||||||
@ -818,7 +818,7 @@ def get_default_app_info(metadatapath=None):
|
|||||||
manifestroot = fdroidserver.common.parse_xml(os.path.join(root, 'AndroidManifest.xml'))
|
manifestroot = fdroidserver.common.parse_xml(os.path.join(root, 'AndroidManifest.xml'))
|
||||||
break
|
break
|
||||||
if manifestroot is None:
|
if manifestroot is None:
|
||||||
warn_or_exception(_("Cannot find a packageName for {path}!")
|
warn_or_exception(_("Cannot find an appid for {path}!")
|
||||||
.format(path=metadatapath))
|
.format(path=metadatapath))
|
||||||
appid = manifestroot.attrib['package']
|
appid = manifestroot.attrib['package']
|
||||||
|
|
||||||
@ -906,8 +906,9 @@ def post_metadata_parse(app):
|
|||||||
|
|
||||||
# Parse metadata for a single application.
|
# Parse metadata for a single application.
|
||||||
#
|
#
|
||||||
# 'metadatapath' - the filename to read. The package id for the application comes
|
# 'metadatapath' - the filename to read. The "Application ID" aka
|
||||||
# from this filename. Pass None to get a blank entry.
|
# "Package Name" for the application comes from this
|
||||||
|
# filename. Pass None to get a blank entry.
|
||||||
#
|
#
|
||||||
# Returns a dictionary containing all the details of the application. There are
|
# Returns a dictionary containing all the details of the application. There are
|
||||||
# two major kinds of information in the dictionary. Keys beginning with capital
|
# two major kinds of information in the dictionary. Keys beginning with capital
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from os import remove as rmfile
|
from os.path import isdir, isfile, basename, abspath, expanduser
|
||||||
from os.path import isdir, isfile, join as joinpath, basename, abspath, expanduser
|
|
||||||
import os
|
import os
|
||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
@ -147,10 +146,10 @@ def get_build_vm(srvdir, provider=None):
|
|||||||
logger.debug('could not confirm that either virtualbox or kvm/libvirt are installed')
|
logger.debug('could not confirm that either virtualbox or kvm/libvirt are installed')
|
||||||
|
|
||||||
# try guessing provider from .../srvdir/.vagrant internals
|
# try guessing provider from .../srvdir/.vagrant internals
|
||||||
has_libvirt_machine = isdir(joinpath(abssrvdir, '.vagrant',
|
has_libvirt_machine = isdir(os.path.join(abssrvdir, '.vagrant',
|
||||||
'machines', 'default', 'libvirt'))
|
'machines', 'default', 'libvirt'))
|
||||||
has_vbox_machine = isdir(joinpath(abssrvdir, '.vagrant',
|
has_vbox_machine = isdir(os.path.join(abssrvdir, '.vagrant',
|
||||||
'machines', 'default', 'virtualbox'))
|
'machines', 'default', 'virtualbox'))
|
||||||
if has_libvirt_machine and has_vbox_machine:
|
if has_libvirt_machine and has_vbox_machine:
|
||||||
logger.info('build vm provider lookup found virtualbox and libvirt, defaulting to \'virtualbox\'')
|
logger.info('build vm provider lookup found virtualbox and libvirt, defaulting to \'virtualbox\'')
|
||||||
return VirtualboxBuildVm(abssrvdir)
|
return VirtualboxBuildVm(abssrvdir)
|
||||||
@ -183,7 +182,7 @@ class FDroidBuildVm():
|
|||||||
"""
|
"""
|
||||||
self.srvdir = srvdir
|
self.srvdir = srvdir
|
||||||
self.srvname = basename(srvdir) + '_default'
|
self.srvname = basename(srvdir) + '_default'
|
||||||
self.vgrntfile = joinpath(srvdir, 'Vagrantfile')
|
self.vgrntfile = os.path.join(srvdir, 'Vagrantfile')
|
||||||
self.srvuuid = self._vagrant_fetch_uuid()
|
self.srvuuid = self._vagrant_fetch_uuid()
|
||||||
if not isdir(srvdir):
|
if not isdir(srvdir):
|
||||||
raise FDroidBuildVmException("Can not init vagrant, directory %s not present" % (srvdir))
|
raise FDroidBuildVmException("Can not init vagrant, directory %s not present" % (srvdir))
|
||||||
@ -229,7 +228,7 @@ class FDroidBuildVm():
|
|||||||
logger.debug('vagrant destroy completed')
|
logger.debug('vagrant destroy completed')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.exception('vagrant destroy failed: %s', e)
|
logger.exception('vagrant destroy failed: %s', e)
|
||||||
vgrntdir = joinpath(self.srvdir, '.vagrant')
|
vgrntdir = os.path.join(self.srvdir, '.vagrant')
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(vgrntdir)
|
shutil.rmtree(vgrntdir)
|
||||||
logger.debug('deleted vagrant dir: %s', vgrntdir)
|
logger.debug('deleted vagrant dir: %s', vgrntdir)
|
||||||
@ -253,17 +252,17 @@ class FDroidBuildVm():
|
|||||||
return name.replace('/', '-VAGRANTSLASH-')
|
return name.replace('/', '-VAGRANTSLASH-')
|
||||||
|
|
||||||
def _vagrant_fetch_uuid(self):
|
def _vagrant_fetch_uuid(self):
|
||||||
if isfile(joinpath(self.srvdir, '.vagrant')):
|
if isfile(os.path.join(self.srvdir, '.vagrant')):
|
||||||
# Vagrant 1.0 - it's a json file...
|
# Vagrant 1.0 - it's a json file...
|
||||||
with open(joinpath(self.srvdir, '.vagrant')) as f:
|
with open(os.path.join(self.srvdir, '.vagrant')) as f:
|
||||||
id = json.load(f)['active']['default']
|
id = json.load(f)['active']['default']
|
||||||
logger.debug('vm uuid: %s', id)
|
logger.debug('vm uuid: %s', id)
|
||||||
return id
|
return id
|
||||||
elif isfile(joinpath(self.srvdir, '.vagrant', 'machines',
|
elif isfile(os.path.join(self.srvdir, '.vagrant', 'machines',
|
||||||
'default', self.provider, 'id')):
|
'default', self.provider, 'id')):
|
||||||
# Vagrant 1.2 (and maybe 1.1?) it's a directory tree...
|
# Vagrant 1.2 (and maybe 1.1?) it's a directory tree...
|
||||||
with open(joinpath(self.srvdir, '.vagrant', 'machines',
|
with open(os.path.join(self.srvdir, '.vagrant', 'machines',
|
||||||
'default', self.provider, 'id')) as f:
|
'default', self.provider, 'id')) as f:
|
||||||
id = f.read()
|
id = f.read()
|
||||||
logger.debug('vm uuid: %s', id)
|
logger.debug('vm uuid: %s', id)
|
||||||
return id
|
return id
|
||||||
@ -288,8 +287,8 @@ class FDroidBuildVm():
|
|||||||
_check_call(['vagrant', 'box', 'remove', '--all', '--force', boxname])
|
_check_call(['vagrant', 'box', 'remove', '--all', '--force', boxname])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.debug('tried removing box %s, but is did not exist: %s', boxname, e)
|
logger.debug('tried removing box %s, but is did not exist: %s', boxname, e)
|
||||||
boxpath = joinpath(expanduser('~'), '.vagrant',
|
boxpath = os.path.join(expanduser('~'), '.vagrant',
|
||||||
self._vagrant_file_name(boxname))
|
self._vagrant_file_name(boxname))
|
||||||
if isdir(boxpath):
|
if isdir(boxpath):
|
||||||
logger.info("attempting to remove box '%s' by deleting: %s",
|
logger.info("attempting to remove box '%s' by deleting: %s",
|
||||||
boxname, boxpath)
|
boxname, boxpath)
|
||||||
@ -376,11 +375,11 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
if storagePool:
|
if storagePool:
|
||||||
|
|
||||||
if isfile('metadata.json'):
|
if isfile('metadata.json'):
|
||||||
rmfile('metadata.json')
|
os.remove('metadata.json')
|
||||||
if isfile('Vagrantfile'):
|
if isfile('Vagrantfile'):
|
||||||
rmfile('Vagrantfile')
|
os.remove('Vagrantfile')
|
||||||
if isfile('box.img'):
|
if isfile('box.img'):
|
||||||
rmfile('box.img')
|
os.remove('box.img')
|
||||||
|
|
||||||
logger.debug('preparing box.img for box %s', output)
|
logger.debug('preparing box.img for box %s', output)
|
||||||
vol = storagePool.storageVolLookupByName(self.srvname + '.img')
|
vol = storagePool.storageVolLookupByName(self.srvname + '.img')
|
||||||
@ -430,9 +429,9 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
|
|
||||||
if not keep_box_file:
|
if not keep_box_file:
|
||||||
logger.debug('box packaging complete, removing temporary files.')
|
logger.debug('box packaging complete, removing temporary files.')
|
||||||
rmfile('metadata.json')
|
os.remove('metadata.json')
|
||||||
rmfile('Vagrantfile')
|
os.remove('Vagrantfile')
|
||||||
rmfile('box.img')
|
os.remove('box.img')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.warn('could not connect to storage-pool \'default\',' +
|
logger.warn('could not connect to storage-pool \'default\',' +
|
||||||
|
Loading…
Reference in New Issue
Block a user