Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/8] tools/sppc: build image with custom git repo
Date: Mon,  1 Oct 2018 14:01:41 +0900	[thread overview]
Message-ID: <20181001050148.77373-2-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181001050148.77373-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

SPP container supports to create an image with a custom repository other
than on dpdk.org. However, the name of directory should be the same as
them. For example, the name of custom DPDK repo should also be 'dpdk'.

This patch is for supporting to use any of directory name. The name of
directory is extracted from the git URL. For example, directory name of
'https://github.com/user/custom-dpdk.git' is 'custom-dpdk'.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 tools/sppc/build/main.py | 46 ++++++++++++++++++++++++++++++++++------------
 tools/sppc/conf/env.py   |  1 -
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/tools/sppc/build/main.py b/tools/sppc/build/main.py
index d33a6f2..9618bab 100755
--- a/tools/sppc/build/main.py
+++ b/tools/sppc/build/main.py
@@ -73,14 +73,18 @@ def parse_args():
     return parser.parse_args()
 
 
-def create_env_sh(dst_dir):
+def create_env_sh(dst_dir, rte_sdk, target, target_dir):
     """Create config file for DPDK environment variables
 
     Create 'env.sh' which defines $RTE_SDK and $RTE_TARGET inside a
     container to be referredd from 'run.sh' and Dockerfile.
     """
-    contents = "export RTE_SDK=%s\n" % env.RTE_SDK
-    contents += "export RTE_TARGET=%s" % env.RTE_TARGET
+    contents = "export RTE_SDK=%s\n" % rte_sdk
+    contents += "export RTE_TARGET=%s\n" % env.RTE_TARGET
+    if target == 'pktgen':
+        contents += "export PKTGEN_DIR=%s" % target_dir
+    elif target == 'spp':
+        contents += "export SPP_DIR=%s" % target_dir
 
     f = open('%s/env.sh' % dst_dir, 'w')
     f.write(contents)
@@ -91,7 +95,7 @@ def main():
     args = parse_args()
 
     if args.target is not None:
-        target_dir = '%s/%s/%s' % (  # Dockerfile is contained here
+        dockerfile_dir = '%s/%s/%s' % (  # Dockerfile is contained here
             work_dir, args.dist_name, args.target)
         # Container image name, for exp 'sppc/dpdk-ubuntu:18.04'
         container_image = common.container_img_name(
@@ -103,7 +107,7 @@ def main():
         exit()
 
     # Decide which of Dockerfile with given base image version
-    dockerfile = '%s/Dockerfile.%s' % (target_dir, args.dist_ver)
+    dockerfile = '%s/Dockerfile.%s' % (dockerfile_dir, args.dist_ver)
 
     # Overwrite container's name if it is given.
     if args.container_image is not None:
@@ -125,18 +129,34 @@ def main():
     else:
         spp_branch = ''
 
+    # Setup project directory by extracting from any of git URL.
+    # If DPDK is hosted on 'https://github.com/user/custom-dpdk.git',
+    # the directory is 'custom-dpdk'.
+    dpdk_dir = args.dpdk_repo.split('/')[-1].split('.')[0]
+    pktgen_dir = args.pktgen_repo.split('/')[-1].split('.')[0]
+    spp_dir = args.spp_repo.split('/')[-1].split('.')[0]
+
+    # RTE_SDK is decided with DPDK's dir.
+    rte_sdk = '%s/%s' % (env.HOMEDIR, dpdk_dir)
+
     # Check for just creating env.sh, or run docker build.
     if args.only_envsh is True:
         if args.dry_run is False:
-            create_env_sh(target_dir)
-            print("Info: '%s/env.sh' created." % target_dir)
+            if target == 'pktgen':
+                create_env_sh(dockerfile_dir, rte_sdk, target, pktgen_dir)
+            elif target == 'spp':
+                create_env_sh(dockerfile_dir, rte_sdk, target, spp_dir)
+            print("Info: '%s/env.sh' created." % dockerfile_dir)
             exit()
         else:
             print("Info: Nothin done because you gave %s with %s." % (
                 '--only-envsh', '--dry-run'))
             exit()
     else:
-        create_env_sh(target_dir)
+        if args.target == 'pktgen':
+            create_env_sh(dockerfile_dir, rte_sdk, args.target, pktgen_dir)
+        elif args.target == 'spp':
+            create_env_sh(dockerfile_dir, rte_sdk, args.target, spp_dir)
 
     # Setup environment variables on host to pass 'docker build'.
     env_opts = [
@@ -154,7 +174,7 @@ def main():
 
     docker_cmd += [
         '--build-arg', 'home_dir=%s' % env.HOMEDIR, '\\',
-        '--build-arg', 'rte_sdk=%s' % env.RTE_SDK, '\\',
+        '--build-arg', 'rte_sdk=%s' % rte_sdk, '\\',
         '--build-arg', 'rte_target=%s' % env.RTE_TARGET, '\\',
         '--build-arg', 'dpdk_repo=%s' % args.dpdk_repo, '\\',
         '--build-arg', 'dpdk_branch=%s' % dpdk_branch, '\\']
@@ -162,16 +182,18 @@ def main():
     if args.target == 'pktgen':
         docker_cmd += [
             '--build-arg', 'pktgen_repo=%s' % args.pktgen_repo, '\\',
-            '--build-arg', 'pktgen_branch=%s' % pktgen_branch, '\\']
+            '--build-arg', 'pktgen_branch=%s' % pktgen_branch, '\\',
+            '--build-arg', 'pktgen_dir=%s' % pktgen_dir, '\\']
     elif args.target == 'spp':
         docker_cmd += [
             '--build-arg', 'spp_repo=%s' % args.spp_repo, '\\',
-            '--build-arg', 'spp_branch=%s' % spp_branch, '\\']
+            '--build-arg', 'spp_branch=%s' % spp_branch, '\\',
+            '--build-arg', 'spp_dir=%s' % spp_dir, '\\']
 
     docker_cmd += [
         '-f', '%s' % dockerfile, '\\',
         '-t', container_image, '\\',
-        target_dir]
+        dockerfile_dir]
 
     common.print_pretty_commands(docker_cmd)
 
diff --git a/tools/sppc/conf/env.py b/tools/sppc/conf/env.py
index f6df15a..549b4dc 100644
--- a/tools/sppc/conf/env.py
+++ b/tools/sppc/conf/env.py
@@ -4,7 +4,6 @@
 
 
 HOMEDIR = '/root'
-RTE_SDK = '/root/dpdk'
 RTE_TARGET = 'x86_64-native-linuxapp-gcc'
 
 CONTAINER_IMG_NAME = {
-- 
2.7.4

  reply	other threads:[~2018-10-01  5:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01  5:01 [spp] [PATCH 0/8] Build image with custom repo name ogawa.yasufumi
2018-10-01  5:01 ` ogawa.yasufumi [this message]
2018-10-01  5:01 ` [spp] [PATCH 2/8] tools/sppc: dockerfile for custom SPP repo ogawa.yasufumi
2018-10-01  5:01 ` [spp] [PATCH 3/8] tools/sppc: dockerfile for custom Pktgen repo ogawa.yasufumi
2018-10-01  5:01 ` [spp] [PATCH 4/8] tools/sppc: add paths to Dockerfiles of SPP ogawa.yasufumi
2018-10-01  5:01 ` [spp] [PATCH 5/8] tools/sppc: update app launcer for custom SPP repo ogawa.yasufumi
2018-10-01  5:01 ` [spp] [PATCH 6/8] tools/sppc: add workdir docker option ogawa.yasufumi
2018-10-01  5:01 ` [spp] [PATCH 7/8] tools/sppc: add paths to Dockerfiles of pktgen ogawa.yasufumi
2018-10-01  5:01 ` [spp] [PATCH 8/8] tools/sppc: update launcer for custom pktgen repo ogawa.yasufumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181001050148.77373-2-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).