mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 22:40:12 +01: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
@ -401,19 +401,32 @@ the signed output directory were modified, you won't be notified.
|
||||
@node Importing Applications
|
||||
@chapter Importing Applications
|
||||
|
||||
To help with starting work on including a new application, @code{fdroid import}
|
||||
will take a URL and optionally some other parameters, and attempt to construct
|
||||
as much information as possible by analysing the source code. Basic usage is:
|
||||
To help with starting work on including a new application, use
|
||||
@code{fdroid import} to set up a new template project. It has two
|
||||
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
|
||||
fdroid import --url=http://address.of.project
|
||||
@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:
|
||||
|
||||
@enumerate
|
||||
@item
|
||||
GitLab - @code{https://gitlab.com/PROJECTNAME/REPONAME}
|
||||
@item
|
||||
Gitorious - @code{https://gitorious.org/PROJECTNAME/REPONAME}
|
||||
@item
|
||||
Github - @code{https://github.com/USER/PROJECT}
|
||||
|
@ -17,6 +17,7 @@
|
||||
# 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/>.
|
||||
|
||||
import binascii
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
@ -180,12 +181,38 @@ def main():
|
||||
root_dir = None
|
||||
build_dir = None
|
||||
|
||||
if options.url:
|
||||
root_dir, build_dir = get_metadata_from_url(app, options.url)
|
||||
elif os.path.isdir('.git'):
|
||||
if options.url:
|
||||
app.WebSite = options.url
|
||||
local_metadata_files = common.get_local_metadata_files()
|
||||
if local_metadata_files != []:
|
||||
logging.error("This repo already has local metadata: %s" % local_metadata_files[0])
|
||||
sys.exit(1)
|
||||
|
||||
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())
|
||||
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:
|
||||
logging.error("Specify project url.")
|
||||
sys.exit(1)
|
||||
@ -222,29 +249,31 @@ def main():
|
||||
sys.exit(1)
|
||||
|
||||
# Create a build line...
|
||||
build = metadata.Build()
|
||||
build.version = version or '?'
|
||||
build.vercode = vercode or '?'
|
||||
build.commit = '?'
|
||||
build.disable = 'Generated by import.py - check/set version fields and commit id'
|
||||
if options.subdir:
|
||||
build.subdir = options.subdir
|
||||
if os.path.exists(os.path.join(root_dir, 'jni')):
|
||||
build.buildjni = ['yes']
|
||||
|
||||
metadata.post_metadata_parse(app)
|
||||
|
||||
app.builds.append(build)
|
||||
|
||||
# Keep the repo directory to save bandwidth...
|
||||
if not os.path.exists('build'):
|
||||
os.mkdir('build')
|
||||
if build_dir is not None:
|
||||
shutil.move(build_dir, os.path.join('build', package))
|
||||
with open('build/.fdroidvcs-' + package, 'w') as f:
|
||||
f.write(app.RepoType + ' ' + app.Repo)
|
||||
if write_local_file:
|
||||
metadata.write_metadata('.fdroid.yaml', app)
|
||||
else:
|
||||
# Keep the repo directory to save bandwidth...
|
||||
if not os.path.exists('build'):
|
||||
os.mkdir('build')
|
||||
if build_dir is not None:
|
||||
shutil.move(build_dir, os.path.join('build', package))
|
||||
with open('build/.fdroidvcs-' + package, 'w') as f:
|
||||
f.write(app.RepoType + ' ' + app.Repo)
|
||||
|
||||
metadatapath = os.path.join('metadata', package + '.txt')
|
||||
metadata.write_metadata(metadatapath, app)
|
||||
logging.info("Wrote " + metadatapath)
|
||||
metadatapath = os.path.join('metadata', package + '.txt')
|
||||
metadata.write_metadata(metadatapath, app)
|
||||
logging.info("Wrote " + metadatapath)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user