Skip to content

Commit 9892cab

Browse files
psafontydirson
authored andcommitted
cli: Make path argument for build optional
Suggested-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech> Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent 0019fcc commit 9892cab

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/xcp_ng_dev/cli.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ def buildparser():
9797
"of the directory passed as parameter, then build the RPM(s). "
9898
"Built RPMs and SRPMs will be in RPMS/ and SRPMS/ subdirectories. "
9999
"Any preexisting BUILD, BUILDROOT, RPMS or SRPMS directories will be removed first.")
100-
parser_build.add_argument('build_local',
101-
help="Root path where SPECS/ and SOURCES are available")
100+
parser_build.add_argument(
101+
'build_local', nargs='?', default='.',
102+
help="Root path where SPECS/ and SOURCES are available. "
103+
"The default is the working directory")
102104
parser_build.add_argument(
103105
'--define',
104106
help="Definitions to be passed to rpmbuild. Example: --define "
@@ -154,9 +156,10 @@ def container(args):
154156
if hasattr(args, 'command') and args.command != []:
155157
docker_args += ["-e", "COMMAND=%s" % ' '.join(args.command)]
156158
if build:
157-
docker_args += ["-v", "%s:/home/builder/rpmbuild" %
158-
os.path.abspath(args.build_local)]
159+
build_dir = os.path.abspath(args.build_local)
160+
docker_args += ["-v", f"{build_dir}:/home/builder/rpmbuild"]
159161
docker_args += ["-e", "BUILD_LOCAL=1"]
162+
print(f"Building directory {build_dir}")
160163
if hasattr(args, 'define') and args.define:
161164
docker_args += ["-e", "RPMBUILD_DEFINE=%s" % args.define]
162165
if hasattr(args, 'rpmbuild_opts') and args.rpmbuild_opts:

0 commit comments

Comments
 (0)