@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}
# 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
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)
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)
-
- metadatapath = os.path.join('metadata', package + '.txt')
- metadata.write_metadata(metadatapath, app)
- logging.info("Wrote " + metadatapath)
+ 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)
if __name__ == "__main__":