stx tool: Add sub-command to download debian binary and source recipe

Now we support the new stx sub-command to download debian binary
packages and STX source recipes instead of the command debdownloader.
These two local mirrors will be created by this sub-command.

We can use the following sub-commands to finish the download work:
 $stx build download -s          [download source recipes]
 $stx build download -b          [download binary debs]
 $stx build download             [both source and binary]

Below are the default things in the host environment:
STX_MIRROR: $STX_BUILD_HOME/mirrors/starlingx
mirror for STX source: $STX_BUILD_HOME/mirrors/starlingx/sources
mirror for binary packages: $STX_BUILD_HOME/mirrors/starlingx/binaries

Story: 2008862
Task: 44243

Depends-On: https://review.opendev.org/c/starlingx/root/+/822699

Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
Change-Id: Ieafd545cd5b0be75cdf6078ecbe2aaf6b9e3ba14
This commit is contained in:
Zhixiong Chi 2022-01-05 16:22:39 +08:00
parent d860631738
commit 7fbe548e48
2 changed files with 29 additions and 12 deletions

View File

@ -85,10 +85,21 @@ class HandleBuildTask:
cmd = prefixcmd + '". /usr/local/bin/stx/stx-cleanup"\''
return cmd
def buildDebdownloaderCMD(self, prefixcmd):
def buildDownloadCMD(self, args, prefixcmd):
cmd = prefixcmd + '"debdownloader ' + \
'$STX_BINARYLIST_DIR/common/base-bullseye.lst"\''
cmd = prefixcmd + '"downloader '
if args.download_binary:
cmd = cmd + '--download_binary '
elif args.download_source:
cmd = cmd + '--download_source '
else:
cmd = cmd + '--download_binary --download_source '
if args.force:
cmd = cmd + '--clean_mirror '
cmd = cmd + '"\''
return cmd
def buildPackageCMD(self, args, prefixcmd, world):
@ -157,9 +168,9 @@ class HandleBuildTask:
cmd = self.buildCleanupCMD(prefix_cmd)
self.logger.debug('Execute the cleanup command: [%s].', cmd)
elif args.build_task == 'debdownloader':
cmd = self.buildDebdownloaderCMD(prefix_cmd)
self.logger.debug('Execute the debdownloader command: [%s].', cmd)
elif args.build_task == 'download':
cmd = self.buildDownloadCMD(args, prefix_cmd)
self.logger.debug('Execute the download command: [%s].', cmd)
elif args.build_task == 'world':
cmd = self.buildPackageCMD(args, prefix_cmd, True)

View File

@ -93,27 +93,33 @@ settings.\t\teg: [ --show|--get|--add|--unset|--remove-section ]')
build_subparser = subparsers.add_parser('build',
help='Run to build packages or\
image.\t\teg: [ prepare|layer|image|debdownloader|world|${pkgname}]')
image.\t\teg: [ prepare|layer|image|download|world|${pkgname}]')
build_subparser.add_argument('build_task',
help='[ prepare|cleanup|layer|image|' +
'debdownloader|world|${pkgname} ]:\
'download|world|${pkgname} ]:\
Prepare for building enviroment and \
build packages, distro layer or image.\
\n\n')
build_subparser.add_argument('-b', '--download-binary',
help="download binary debs",
action='store_true', required=False)
build_subparser.add_argument('-e', '--exit-on-fail',
help="Exit for any fail.",
help="Exit for any failure.",
action='store_true', required=False)
build_subparser.add_argument('-f', '--force',
help='Force to compile the package again.\
', action='store_true', required=False)
help='Force to execute the task again.',
action='store_true', required=False)
build_subparser.add_argument('-l', '--layers',
help='[ flock|distro ]: Compile the \
packages for the layer.', required=False)
build_subparser.add_argument('-s', '--download-source',
help="download starlingx source recipes",
action='store_true', required=False)
build_subparser.add_argument('-t', '--buildtype',
help='[ rt|std ]: Select the build type.\
', required=False)
build_subparser.add_argument('--enable-test',
help='Enable the automatical test for \
help='Enable the automatic test for \
the package building.',
action='store_true', required=False)
build_subparser.set_defaults(handle=self.handlebuild.handleBuild)