🥍 add fetch_srclibs subcommand

This commit is contained in:
Michael Pöhn 2025-10-31 17:12:01 +01:00 committed by Hans-Christoph Steiner
parent 0075f044f7
commit 5e87f85cf7
2 changed files with 62 additions and 0 deletions

View file

@ -70,6 +70,7 @@ COMMANDS_INTERNAL = [
"exec",
"execute_sudo",
"fetch_repo",
"fetch_srclibs",
"install_ndk",
"make_source_tarball",
"prepare_source",

View file

@ -0,0 +1,61 @@
#!/usr/bin/env python3
#
# fetch_srclibs.py - part of the F-Droid server tools
# Copyright (C) 2024-2025, Michael Pöhn <michael@poehn.at>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
"""Subcommand for setting up source code from srclibs:."""
import argparse
import logging
import os
import sys
import traceback
from fdroidserver import common, metadata
def fetch_srclibs_wrapper(build):
srclib_dir = os.path.join('build', 'srclib')
os.makedirs(srclib_dir, exist_ok=True)
for lib in build.srclibs:
common.getsrclib(lib, srclib_dir, prepare=False, build=build)
def main():
parser = argparse.ArgumentParser(description=__doc__)
common.setup_global_opts(parser)
parser.add_argument(
"APPID:VERCODE",
help="Application ID with Version Code in the form APPID:VERCODE",
)
options = common.parse_args(parser)
common.set_console_logging(options.verbose)
try:
appid, vercode = common.split_pkg_arg(options.__dict__['APPID:VERCODE'])
_ignored, build = metadata.get_single_build(appid, vercode)
fetch_srclibs_wrapper(build)
except Exception as e:
if options.verbose:
logging.error(traceback.format_exc())
else:
logging.error(e)
sys.exit(1)
if __name__ == "__main__":
main()