github.com/noisysockets/netstack@v0.6.0/scripts/vendor.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  gvisor_dir=/workspace/gvisor
     5  
     6  # List of subdirectories to copy and update
     7  subdirs=(
     8      "atomicbitops"
     9      "bits"
    10      "buffer"
    11      "cleanup"
    12      "compressio"
    13      "context"
    14      "cpuid"
    15      "eventfd"
    16      "gohacks"
    17      "goid"
    18      "linewriter"
    19      "log"
    20      "memutil"
    21      "rand"
    22      "refs"
    23      "sleep"
    24      "sync"
    25      "state"
    26      "tcpip"
    27      "waiter"
    28      "xdp"
    29  )
    30  
    31  rmdirs=(
    32      "tcpip/link/tun"
    33  )
    34  
    35  # Copy directories.
    36  mkdir -p pkg
    37  for subdir in "${subdirs[@]}"; do
    38      cp -r "${gvisor_dir}/pkg/${subdir}" pkg/
    39  done
    40  
    41  # Remove blacklisted directories.
    42  for subdir in "${rmdirs[@]}"; do
    43      rm -rf "pkg/$subdir"
    44  done
    45  
    46  # Rewrite all imports from 'gvisor.dev/gvisor/pkg/' to 'github.com/noisysockets/netstack/'.
    47  for subdir in "${subdirs[@]}"; do
    48      find "pkg/$subdir" -type f -name '*.go' -exec sed -i 's|gvisor.dev/gvisor/|github.com/noisysockets/netstack/|g' {} +
    49  done