Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions dbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def docker_build(build_dir, build_type, source_dir='source', force_rm=False,
docker_url='unix://var/run/docker.sock', dist='ubuntu',
release='trusty', extra_repos_file='repos',
extra_repo_keys_file='keys', build_cache=True, proxy="",
build_owner=None, parallel=1, **kwargs):
build_owner=None, parallel=1, no_default_sources=False,
**kwargs):
"""
build_dir: build directory, this directory will be mounted to /build in
container
Expand All @@ -119,11 +120,15 @@ def docker_build(build_dir, build_type, source_dir='source', force_rm=False,
otherwise it will be default empty
build_owner: user id which will own all build files
parallel: how many processes to run in parallel
no_default_sources: only use sources from extra_repos_file
kwargs: dict of unknown arguments. Ignored. For forward compatibility.
"""

command = ''

if no_default_sources:
command += '> /etc/apt/sources.list && '

if os.path.exists(os.path.join(build_dir, extra_repos_file)):
command += 'cp /build/%s \
/etc/apt/sources.list.d/dbuild-extra-repos.list && ' % extra_repos_file
Expand Down Expand Up @@ -240,6 +245,9 @@ def main(argv=sys.argv[1:]):
help='uid to reassign everything to')
ap.add_argument('--parallel', '-j', action='store', type=int,
default=1, help='how many processes to run in parallel')
ap.add_argument('--no-default-sources', action='store_true',
help='Discard existing sources, only use the ones '
'passed in')
args = ap.parse_args(argv)

try:
Expand All @@ -250,7 +258,8 @@ def main(argv=sys.argv[1:]):
extra_repos_file=args.extra_repos_file,
extra_repo_keys_file=args.extra_repo_keys_file,
build_cache=args.build_cache, proxy=args.proxy,
build_owner=args.build_owner)
build_owner=args.build_owner,
no_default_sources=args.no_default_sources)
except exceptions.DbuildSourceBuildFailedException:
print('ERROR | Source build failed for build directory: %s'
% args.build_dir)
Expand All @@ -265,7 +274,8 @@ def main(argv=sys.argv[1:]):
extra_repo_keys_file=args.extra_repo_keys_file,
build_cache=args.build_cache, proxy=args.proxy,
build_owner=args.build_owner,
parallel=args.parallel)
parallel=args.parallel,
no_default_sources=args.no_default_sources)
except exceptions.DbuildBinaryBuildFailedException:
print('ERROR | Binary build failed for build directory: %s'
% args.build_dir)
Expand Down
4 changes: 2 additions & 2 deletions dbuild/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ def test_build_cli(self, docker_build):
build_type='source', dist='ubuntu',
docker_url='unix://var/run/docker.sock', extra_repo_keys_file='keys',
extra_repos_file='repos', force_rm=False, proxy='', release='trusty',
source_dir='source'),
source_dir='source', no_default_sources=False),
mock.call(build_cache=True, build_dir='/some/dir', build_owner=None,
build_type='binary', dist='ubuntu',
docker_url='unix://var/run/docker.sock',
extra_repo_keys_file='keys', extra_repos_file='repos',
force_rm=False, proxy='', parallel=1, release='trusty',
source_dir='source')])
source_dir='source', no_default_sources=False)])