Add --offline flag

Allow working offline with pmbootstrap, as long as all packages that
are being used have already been downloaded.
This commit is contained in:
Oliver Smith 2018-09-30 03:53:55 +02:00
parent 5b33eb7520
commit e458b1fdbc
5 changed files with 15 additions and 1 deletions

View File

@ -229,6 +229,8 @@ def install(args, packages, suffix="native", build=True):
["add"] + packages,
["del", ".pmbootstrap"]]
for command in commands:
if args.offline:
command = ["--no-network"] + command
pmb.chroot.root(args, ["apk", "--no-progress"] + command, suffix)

View File

@ -181,4 +181,6 @@ def init(args):
def run(args, parameters):
if args.offline:
parameters = ["--no-network"] + parameters
pmb.helpers.run.root(args, [args.work + "/apk.static"] + parameters)

View File

@ -115,7 +115,8 @@ def add_cache(args):
"apk_min_version_checked": [],
"apk_repository_list_updated": [],
"built": {},
"find_aport": {}})
"find_aport": {},
"offline_msg_shown": False})
def add_deviceinfo(args):

View File

@ -118,6 +118,13 @@ def update(args, arch=None, force=False, existing_only=False):
:returns: True when files have been downloaded, False otherwise
"""
# Skip in offline mode, only show once
if args.offline:
if not args.cache["offline_msg_shown"]:
logging.info("NOTE: skipping package index update (offline mode)")
args.cache["offline_msg_shown"] = True
return False
# Architectures and retention time
architectures = [arch] if arch else pmb.config.build_device_architectures
retention_hours = pmb.config.apkindex_retention_time

View File

@ -281,6 +281,8 @@ def arguments():
" recommended, may screw up your work folders"
" directory permissions!)", dest="as_root",
action="store_true")
parser.add_argument("-o", "--offline", help="Do not attempt to update"
" the package index files", action="store_true")
# Compiler
parser.add_argument("--ccache-disable", action="store_false",