mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
import app into fdroid directly from git clone
This adds a new method for `fdroid import` that will generate the fdroidserver metadata based on a local git repo. This new mode generates the metadata in the new .fdroid.yaml format in the git repo itself. It is intended as a quick way to get starting building apps using the fdroidserver tools.
This commit is contained in:
parent
994488ad47
commit
19189b9b04
3 changed files with 65 additions and 22 deletions
|
@ -401,19 +401,32 @@ the signed output directory were modified, you won't be notified.
|
||||||
@node Importing Applications
|
@node Importing Applications
|
||||||
@chapter Importing Applications
|
@chapter Importing Applications
|
||||||
|
|
||||||
To help with starting work on including a new application, @code{fdroid import}
|
To help with starting work on including a new application, use
|
||||||
will take a URL and optionally some other parameters, and attempt to construct
|
@code{fdroid import} to set up a new template project. It has two
|
||||||
as much information as possible by analysing the source code. Basic usage is:
|
modes of operation, starting with a cloned git repo:
|
||||||
|
|
||||||
|
@example
|
||||||
|
git clone https://gitlab.com/fdroid/fdroidclient
|
||||||
|
cd fdroidclient
|
||||||
|
fdroid import
|
||||||
|
@end example
|
||||||
|
|
||||||
|
Or starting with a URL to a project page:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
fdroid import --url=http://address.of.project
|
fdroid import --url=http://address.of.project
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
For this to work, the URL must point to a project format that the script
|
When a URL is specified using the @code{--url=} flag, @code{fdroid
|
||||||
|
import} will use that URL to find out information about the project,
|
||||||
|
and if it finds a git repo, it will also clone that. For this to
|
||||||
|
work, the URL must point to a project format that the script
|
||||||
understands. Currently this is limited to one of the following:
|
understands. Currently this is limited to one of the following:
|
||||||
|
|
||||||
@enumerate
|
@enumerate
|
||||||
@item
|
@item
|
||||||
|
GitLab - @code{https://gitlab.com/PROJECTNAME/REPONAME}
|
||||||
|
@item
|
||||||
Gitorious - @code{https://gitorious.org/PROJECTNAME/REPONAME}
|
Gitorious - @code{https://gitorious.org/PROJECTNAME/REPONAME}
|
||||||
@item
|
@item
|
||||||
Github - @code{https://github.com/USER/PROJECT}
|
Github - @code{https://github.com/USER/PROJECT}
|
||||||
|
|
|
@ -17,6 +17,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/>.
|
||||||
|
|
||||||
|
import binascii
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -180,12 +181,38 @@ def main():
|
||||||
root_dir = None
|
root_dir = None
|
||||||
build_dir = None
|
build_dir = None
|
||||||
|
|
||||||
if options.url:
|
local_metadata_files = common.get_local_metadata_files()
|
||||||
root_dir, build_dir = get_metadata_from_url(app, options.url)
|
if local_metadata_files != []:
|
||||||
elif os.path.isdir('.git'):
|
logging.error("This repo already has local metadata: %s" % local_metadata_files[0])
|
||||||
if options.url:
|
sys.exit(1)
|
||||||
app.WebSite = options.url
|
|
||||||
|
if options.url is None and os.path.isdir('.git'):
|
||||||
|
app.AutoName = os.path.basename(os.getcwd())
|
||||||
|
app.RepoType = 'git'
|
||||||
|
|
||||||
|
build = {}
|
||||||
root_dir = get_subdir(os.getcwd())
|
root_dir = get_subdir(os.getcwd())
|
||||||
|
if os.path.exists('build.gradle'):
|
||||||
|
build.gradle = ['yes']
|
||||||
|
|
||||||
|
import git
|
||||||
|
repo = git.repo.Repo(root_dir) # git repo
|
||||||
|
for remote in git.Remote.iter_items(repo):
|
||||||
|
if remote.name == 'origin':
|
||||||
|
url = repo.remotes.origin.url
|
||||||
|
if url.startswith('https://git'): # github, gitlab
|
||||||
|
app.SourceCode = url.rstrip('.git')
|
||||||
|
app.Repo = url
|
||||||
|
break
|
||||||
|
# repo.head.commit.binsha is a bytearray stored in a str
|
||||||
|
build.commit = binascii.hexlify(bytearray(repo.head.commit.binsha))
|
||||||
|
write_local_file = True
|
||||||
|
elif options.url:
|
||||||
|
root_dir, build_dir = get_metadata_from_url(app, options.url)
|
||||||
|
build = metadata.Build()
|
||||||
|
build.commit = '?'
|
||||||
|
build.disable = 'Generated by import.py - check/set version fields and commit id'
|
||||||
|
write_local_file = False
|
||||||
else:
|
else:
|
||||||
logging.error("Specify project url.")
|
logging.error("Specify project url.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -222,18 +249,20 @@ def main():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Create a build line...
|
# Create a build line...
|
||||||
build = metadata.Build()
|
|
||||||
build.version = version or '?'
|
build.version = version or '?'
|
||||||
build.vercode = vercode or '?'
|
build.vercode = vercode or '?'
|
||||||
build.commit = '?'
|
|
||||||
build.disable = 'Generated by import.py - check/set version fields and commit id'
|
|
||||||
if options.subdir:
|
if options.subdir:
|
||||||
build.subdir = options.subdir
|
build.subdir = options.subdir
|
||||||
if os.path.exists(os.path.join(root_dir, 'jni')):
|
if os.path.exists(os.path.join(root_dir, 'jni')):
|
||||||
build.buildjni = ['yes']
|
build.buildjni = ['yes']
|
||||||
|
|
||||||
|
metadata.post_metadata_parse(app)
|
||||||
|
|
||||||
app.builds.append(build)
|
app.builds.append(build)
|
||||||
|
|
||||||
|
if write_local_file:
|
||||||
|
metadata.write_metadata('.fdroid.yaml', app)
|
||||||
|
else:
|
||||||
# Keep the repo directory to save bandwidth...
|
# Keep the repo directory to save bandwidth...
|
||||||
if not os.path.exists('build'):
|
if not os.path.exists('build'):
|
||||||
os.mkdir('build')
|
os.mkdir('build')
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -27,6 +27,7 @@ setup(name='fdroidserver',
|
||||||
'examples/fdroid-icon.png']),
|
'examples/fdroid-icon.png']),
|
||||||
],
|
],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
'GitPython',
|
||||||
'mwclient',
|
'mwclient',
|
||||||
'paramiko',
|
'paramiko',
|
||||||
'Pillow',
|
'Pillow',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue