diff mbox series

[ovs-dev,2/2] travis: Make it possible to build against a dpdk branch.

Message ID 1560331280-13588-2-git-send-email-david.marchand@redhat.com
State Superseded
Headers show
Series [ovs-dev,1/2] travis: Do not patch dpdk sources. | expand

Commit Message

David Marchand June 12, 2019, 9:21 a.m. UTC
Rework the build script so that we can pass branches and tags.

With this, DPDK_VER can be passed as:
- a string starting with refs/ which is understood as a git reference.
  This triggers a git clone on DPDK_GIT (default value points to
  https://dpdk.org/git/dpdk) for a single branch pointing to this
  reference (to save some disk),
- else, any other string which is understood as an official release.
  This triggers a tarball download on dpdk.org.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 .travis/linux-build.sh | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Ilya Maximets June 18, 2019, 3:23 p.m. UTC | #1
On 12.06.2019 12:21, David Marchand wrote:
> Rework the build script so that we can pass branches and tags.
> 
> With this, DPDK_VER can be passed as:
> - a string starting with refs/ which is understood as a git reference.
>   This triggers a git clone on DPDK_GIT (default value points to
>   https://dpdk.org/git/dpdk) for a single branch pointing to this
>   reference (to save some disk),
> - else, any other string which is understood as an official release.
>   This triggers a tarball download on dpdk.org.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  .travis/linux-build.sh | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
> index cd8cfcf..ddba2db 100755
> --- a/.travis/linux-build.sh
> +++ b/.travis/linux-build.sh
> @@ -63,10 +63,13 @@ function install_kernel()
>  
>  function install_dpdk()
>  {
> -    if [ -n "$DPDK_GIT" ]; then
> -        git clone $DPDK_GIT dpdk-$1
> -        cd dpdk-$1
> -        git checkout tags/v$1
> +    if [ "${1##refs/*/}" != "${1}" ]; then
> +        DPDK_GIT=${DPDK_GIT:-https://dpdk.org/git/dpdk}
> +        ref="${1##refs/*/}"
> +        git clone --single-branch $DPDK_GIT dpdk-git -b $ref
> +        name=$(git --git-dir=dpdk-git/.git describe)
> +        mv dpdk-git dpdk-$name

Renaming the directory seems redundant.
Also, as you're moving EXTRA_OPTS update to this function we don't need
standardised folder names anymore. So, you could remove the renaming from
the 'else' branch too. Just 'cd dpdk-git' here and 'cd $DIR_NAME' there.
If you want the exact revision of the branch you're right now for debugging
reasons, you may print it to stdout like 'git log -1 --oneline' and it will
be kept in travis logs.

> +        cd dpdk-$name
>      else
>          wget https://fast.dpdk.org/rel/dpdk-$1.tar.xz
>          tar xvf dpdk-$1.tar.xz > /dev/null
> @@ -87,6 +90,7 @@ function install_dpdk()
>      sed -i '/CONFIG_RTE_KNI_KMOD=y/s/=y/=n/' build/.config
>  
>      make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
> +    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
>      echo "Installed DPDK source in $(pwd)"
>      cd ..
>  }
> @@ -109,7 +113,6 @@ if [ "$DPDK" ] || [ "$DPDK_SHARED" ]; then
>          # Disregard cast alignment errors until DPDK is fixed
>          CFLAGS="$CFLAGS -Wno-cast-align"
>      fi
> -    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/dpdk-$DPDK_VER/build"
>  fi
>  
>  OPTS="$EXTRA_OPTS $*"
>
David Marchand June 18, 2019, 4:24 p.m. UTC | #2
On Tue, Jun 18, 2019 at 5:24 PM Ilya Maximets <i.maximets@samsung.com>
wrote:

> On 12.06.2019 12:21, David Marchand wrote:
> > Rework the build script so that we can pass branches and tags.
> >
> > With this, DPDK_VER can be passed as:
> > - a string starting with refs/ which is understood as a git reference.
> >   This triggers a git clone on DPDK_GIT (default value points to
> >   https://dpdk.org/git/dpdk) for a single branch pointing to this
> >   reference (to save some disk),
> > - else, any other string which is understood as an official release.
> >   This triggers a tarball download on dpdk.org.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> >  .travis/linux-build.sh | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
> > index cd8cfcf..ddba2db 100755
> > --- a/.travis/linux-build.sh
> > +++ b/.travis/linux-build.sh
> > @@ -63,10 +63,13 @@ function install_kernel()
> >
> >  function install_dpdk()
> >  {
> > -    if [ -n "$DPDK_GIT" ]; then
> > -        git clone $DPDK_GIT dpdk-$1
> > -        cd dpdk-$1
> > -        git checkout tags/v$1
> > +    if [ "${1##refs/*/}" != "${1}" ]; then
> > +        DPDK_GIT=${DPDK_GIT:-https://dpdk.org/git/dpdk}
> > +        ref="${1##refs/*/}"
> > +        git clone --single-branch $DPDK_GIT dpdk-git -b $ref
> > +        name=$(git --git-dir=dpdk-git/.git describe)
> > +        mv dpdk-git dpdk-$name
>
> Renaming the directory seems redundant.
> Also, as you're moving EXTRA_OPTS update to this function we don't need
> standardised folder names anymore. So, you could remove the renaming from
> the 'else' branch too. Just 'cd dpdk-git' here and 'cd $DIR_NAME' there.
> If you want the exact revision of the branch you're right now for debugging
> reasons, you may print it to stdout like 'git log -1 --oneline' and it will
> be kept in travis logs.
>

I usually don't like to scroll back the whole log to find the revision,
this is why I had put it in the directory name.
But I suppose I should first look at the revision before going to the build
errors ;-)


Ok, I will remove this, anything else?
diff mbox series

Patch

diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh
index cd8cfcf..ddba2db 100755
--- a/.travis/linux-build.sh
+++ b/.travis/linux-build.sh
@@ -63,10 +63,13 @@  function install_kernel()
 
 function install_dpdk()
 {
-    if [ -n "$DPDK_GIT" ]; then
-        git clone $DPDK_GIT dpdk-$1
-        cd dpdk-$1
-        git checkout tags/v$1
+    if [ "${1##refs/*/}" != "${1}" ]; then
+        DPDK_GIT=${DPDK_GIT:-https://dpdk.org/git/dpdk}
+        ref="${1##refs/*/}"
+        git clone --single-branch $DPDK_GIT dpdk-git -b $ref
+        name=$(git --git-dir=dpdk-git/.git describe)
+        mv dpdk-git dpdk-$name
+        cd dpdk-$name
     else
         wget https://fast.dpdk.org/rel/dpdk-$1.tar.xz
         tar xvf dpdk-$1.tar.xz > /dev/null
@@ -87,6 +90,7 @@  function install_dpdk()
     sed -i '/CONFIG_RTE_KNI_KMOD=y/s/=y/=n/' build/.config
 
     make -j4 CC=gcc EXTRA_CFLAGS='-fPIC'
+    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/build"
     echo "Installed DPDK source in $(pwd)"
     cd ..
 }
@@ -109,7 +113,6 @@  if [ "$DPDK" ] || [ "$DPDK_SHARED" ]; then
         # Disregard cast alignment errors until DPDK is fixed
         CFLAGS="$CFLAGS -Wno-cast-align"
     fi
-    EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=$(pwd)/dpdk-$DPDK_VER/build"
 fi
 
 OPTS="$EXTRA_OPTS $*"