code:
#!/bin/bash

# ndk version
read -d '' p << 'EOF' || true
if (m/^\\s*NDK_VERSION\\s*=\\s*"(.+)"/) {
  print $1;
  exit;
}
EOF
needed=$(cat python/mozboot/mozboot/android.py | perl -ne "$p")
current='r[% pc("android-toolchain", "var/android_ndk_version") %][% pc("android-toolchain", "var/android_ndk_revision") %]'
check_update_needed ndk_version "$needed" "$current"

# rust
read -d '' p << 'EOF' || true
my $d = YAML::XS::LoadFile('taskcluster/ci/toolchain/rust.yml');
foreach my $t (keys %$d) {
  if ($d->{$t}{run}{'toolchain-alias'} eq 'linux64-rust-android') {
    my $channel;
    foreach my $arg (@{$d->{$t}{run}{arguments}}) {
      if ($arg eq '--channel') {
        $channel = 1;
        next;
      }
      if ($channel) {
        print $arg;
        exit;
      }
    }
  }
}
EOF
needed=$(perl -MYAML::XS -e "$p")
current='[% pc("rust", "version") %]'
check_update_needed rust "$needed" "$current"

# build_tools
read -d '' p << 'EOF' || true
if (m/build_tools_version\\s*=\\s*"([^"]+)"/) {
  print $1;
  exit;
}
EOF
needed=$(cat build/moz.configure/android-sdk.configure | perl -ne "$p")
current='[% pc("android-toolchain", "var/version_31") %]'
check_update_needed build_tools "$needed" "$current"

# target_sdk
read -d '' p << 'EOF' || true
if (m/target_sdk_version\\s*=\\s*"(.+)"/) {
  print $1;
  exit;
}
EOF
needed=$(cat build/moz.configure/android-sdk.configure | perl -ne "$p")
current='[% pc("android-toolchain", "var/android_api_level") %]'
check_update_needed target_sdk "$needed" "$current"

# cmdline-tools
read -d '' p << 'EOF' || true
my $v, $s;
while (<>) {
  if (m/^\\s*CMDLINE_TOOLS_VERSION_STRING\\s*=\\s*"(.+)"/) {
    $s = $1;
  }
  if (m/^\\s*CMDLINE_TOOLS_VERSION\\s*=\\s*"(.+)"/) {
    $v = $1;
  }
  if ($v && $s) {
    print "$s-$v";
    exit;
  }
}
EOF
needed=$(cat python/mozboot/mozboot/android.py | perl -e "$p")
current='[% pc("android-toolchain", "var/commandlinetools_version_string") %]-[% pc("android-toolchain", "var/commandlinetools_version") %]'
check_update_needed cmdline-tools "$needed" "$current"

# min-android
read -d '' p << 'EOF' || true
use Path::Tiny;
use Digest::SHA qw(sha256_hex);
my $f;
my $min_indent;
foreach (path('build/moz.configure/android-ndk.configure')->lines_utf8) {
  if ($_ eq "def min_android_version(target):\\n") {
    $f = $_;
    next;
  } else {
    next unless $f;
  }
  m/^(\\s*)/;
  my $indent = length $1;
  $min_indent = $indent unless $min_indent;
  last if $indent < $min_indent;
  $f .= $_;
}
print substr(sha256_hex($f), 0, 10);
EOF
needed=$(perl -e "$p")
# We can't easily parse the min_android_version function.
# Instead we get a checksum of the function, and manually check it when
# it was updated.
# Current value of min_android_version is:
#  21 on aarch64, x86_64
#  16 on other archs
current=303de6de36
check_update_needed min-android "$needed" "$current"

# min_sdk
read -d '' p << 'EOF' || true
if (m/^\\s*MOZ_ANDROID_MIN_SDK_VERSION\\s*=\\s*([^\\s]+)/) {
  print $1;
  exit;
}
EOF
needed=$(cat mobile/android/confvars.sh | perl -ne "$p")
current=16
check_update_needed min_sdk "$needed" "$current"

# gradle
read -d '' p << 'EOF' || true
if (m|distributionUrl=https\\\\://services.gradle.org/distributions/gradle-(.*)-all.zip|) {
  print $1;
  exit;
}
EOF
needed=$(cat gradle/wrapper/gradle-wrapper.properties | perl -ne "$p")
current='[% c("var/gradle_version") %]'
check_update_needed gradle "$needed" "$current"

# cbindgen
read -d '' p << 'EOF' || true
if (m/^\\s*cbindgen_min_version\\s*=\\s*Version\\("([^"]+)"\\)/) {
  print $1;
  exit;
}
EOF
needed=$(cat build/moz.configure/bindgen.configure | perl -ne "$p")
current='[% pc("cbindgen", "version") %]'
check_update_needed cbindgen "$needed" "$current"

# nasm
read -d '' p << 'EOF' || true
if (m/^\\s*MODERN_NASM_VERSION\\s*=\\s*LooseVersion\\("([^"]+)"\\)/) {
  print $1;
  exit;
}
EOF
needed=$(cat python/mozboot/mozboot/base.py | perl -ne "$p")
current='2.14'
check_update_needed nasm "$needed" "$current"

# clang
read -d '' p << 'EOF' || true
my $d = YAML::XS::LoadFile('taskcluster/ci/toolchain/clang.yml');
my $clang_toolchain;
TOOLCHAIN: foreach my $t (keys %$d) {
  foreach my $alias (@{$d->{$t}{run}{'toolchain-alias'}}) {
    if ($alias eq 'linux64-clang') {
      foreach my $fetch (@{$d->{$t}{fetches}{toolchain}}) {
        $clang_toolchain = $fetch if $fetch =~ m/^.*-clang-.*/;
      }
      last TOOLCHAIN;
    }
  }
}

if (!$clang_toolchain) {
  print STDERR "Error: could not find clang toolchain\\n";
  exit 1;
}

my $clang_fetch;
foreach my $fetch (@{$d->{$clang_toolchain}{fetches}{fetch}}) {
  $clang_fetch = $fetch if $fetch =~ m/^clang-.*/;
}

if (!$clang_fetch) {
  print STDERR "Error: could not find clang fetch\\n";
  exit 1;
}

my $fetch = YAML::XS::LoadFile('taskcluster/ci/fetch/toolchains.yml');
print $fetch->{$clang_fetch}{fetch}{revision};
EOF
needed=$(perl -MYAML::XS -e "$p")
current='[% pc("llvm-project", "git_hash") %]'
check_update_needed clang "$needed" "$current"

# node
read -d '' p << 'EOF' || true
sub l {
  ref $_[0] eq 'ARRAY' ? $_[0] : [ $_[0] ];
}

my $d = YAML::XS::LoadFile('taskcluster/ci/toolchain/node.yml');
my $node_toolchain;
T: foreach my $t (keys %$d) {
  foreach my $alias (@{l($d->{$t}{run}{'toolchain-alias'})}) {
    if ($alias eq 'linux64-node') {
      foreach my $fetch (@{$d->{$t}{fetches}{fetch}}) {
        if ($fetch =~ m/^nodejs-.*/) {
          $node_toolchain = $fetch;
          last T;
        }
      }
    }
  }
}

exit 1 unless $node_toolchain;

my $fetch = YAML::XS::LoadFile('taskcluster/ci/fetch/toolchains.yml');
my ($version) = $fetch->{$node_toolchain}{fetch}{url} =~ m|^https://nodejs.org/dist/v([^/]+)/|;
print "$version\\n";
EOF
needed=$(perl -MYAML::XS -e "$p")
current='[% pc("node", "version") %]'
check_update_needed node "$needed" "$current"

# python
read -d '' p << 'EOF' || true
if (m/find_python3_executable\\(min_version\\s*=\\s*"([^"]+)"/) {
  print $1;
  exit;
}
EOF
needed=$(cat build/moz.configure/init.configure | perl -ne "$p")
current=3.6.0
check_update_needed python "$needed" "$current"

repo_name: JeremyRand/tor

license: mit


code:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-aarch64-linux-android
mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
export MOZILLA_OFFICIAL=1
CC="clang"
CXX="clang++"

ac_add_options --with-android-min-sdk=21

ac_add_options --enable-optimize
ac_add_options --enable-rust-simd
ac_add_options --enable-official-branding

ac_add_options --enable-application=mobile/android
ac_add_options --target=aarch64-linux-android
ac_add_options --with-android-ndk=/var/tmp/dist/android-toolchain/android-sdk-linux/ndk/android-ndk-r21d
ac_add_options --with-android-sdk=/var/tmp/dist/android-toolchain/android-sdk-linux
ac_add_options --with-gradle=/var/tmp/dist/android-toolchain/gradle/gradle/bin/gradle

# https://bugzilla.mozilla.org/show_bug.cgi?id=1758568
ac_add_options --enable-minify=properties

# We do not use Tor Launcher on Android:
ac_add_options --disable-tor-launcher

ac_add_options --disable-tor-browser-update
ac_add_options --disable-verify-mar

# We only use beta GeckoView for now; use default for local builds
ac_add_options --enable-update-channel=beta

ac_add_options --enable-strip
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-rust-debug
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
ac_add_options --disable-parental-controls

ac_add_options --enable-proxy-bypass-protection

# Disable telemetry
ac_add_options MOZ_TELEMETRY_REPORTING=


code:
export MOZILLA_OFFICIAL=1

ac_add_options --enable-application=mobile/android
ac_add_options --disable-compile-environment
# We want to have a similar fat .aar versioning as Mozilla and make it clear we
# are on the beta channel for GeckoView
ac_add_options --enable-update-channel=beta

ac_add_options --with-android-sdk=/var/tmp/dist/android-toolchain/android-sdk-linux
ac_add_options --with-gradle=/var/tmp/dist/android-toolchain/gradle/gradle/bin/gradle

# https://bugzilla.mozilla.org/show_bug.cgi?id=1758568
ac_add_options --enable-minify=properties


code:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-arm-linux-androideabi
mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
export MOZILLA_OFFICIAL=1
CC="clang"
CXX="clang++"

ac_add_options --with-android-min-sdk=21

ac_add_options --enable-optimize
ac_add_options --enable-rust-simd
ac_add_options --enable-official-branding

ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
ac_add_options --with-android-ndk=/var/tmp/dist/android-toolchain/android-sdk-linux/ndk/android-ndk-r21d
ac_add_options --with-android-sdk=/var/tmp/dist/android-toolchain/android-sdk-linux
ac_add_options --with-gradle=/var/tmp/dist/android-toolchain/gradle/gradle/bin/gradle

# https://bugzilla.mozilla.org/show_bug.cgi?id=1758568
ac_add_options --enable-minify=properties

# We do not use Tor Launcher on Android:
ac_add_options --disable-tor-launcher

ac_add_options --disable-tor-browser-update
ac_add_options --disable-verify-mar

# We only use beta GeckoView for now; use default for local builds
ac_add_options --enable-update-channel=beta

ac_add_options --enable-strip
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-rust-debug
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
ac_add_options --disable-parental-controls

ac_add_options --enable-proxy-bypass-protection

# Disable telemetry
ac_add_options MOZ_TELEMETRY_REPORTING=


code:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-i386-linux-android
mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
export MOZILLA_OFFICIAL=1
CC="clang"
CXX="clang++"

ac_add_options --with-android-min-sdk=21

ac_add_options --enable-optimize
ac_add_options --enable-rust-simd
ac_add_options --enable-official-branding

ac_add_options --enable-application=mobile/android
ac_add_options --target=i686-linux-android
ac_add_options --with-android-ndk=/var/tmp/dist/android-toolchain/android-sdk-linux/ndk/android-ndk-r21d
ac_add_options --with-android-sdk=/var/tmp/dist/android-toolchain/android-sdk-linux
ac_add_options --with-gradle=/var/tmp/dist/android-toolchain/gradle/gradle/bin/gradle

# https://bugzilla.mozilla.org/show_bug.cgi?id=1758568
ac_add_options --enable-minify=properties

# We do not use Tor Launcher on Android:
ac_add_options --disable-tor-launcher

ac_add_options --disable-tor-browser-update
ac_add_options --disable-verify-mar

# We only use beta GeckoView for now; use default for local builds
ac_add_options --enable-update-channel=beta

ac_add_options --enable-strip
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-rust-debug
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
ac_add_options --disable-parental-controls

ac_add_options --enable-proxy-bypass-protection

# Disable telemetry
ac_add_options MOZ_TELEMETRY_REPORTING=


code:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-x86_64-linux-android
mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
export MOZILLA_OFFICIAL=1
CC="clang"
CXX="clang++"

ac_add_options --with-android-min-sdk=21

ac_add_options --enable-optimize
ac_add_options --enable-rust-simd
ac_add_options --enable-official-branding

ac_add_options --enable-application=mobile/android
ac_add_options --target=x86_64-linux-android
ac_add_options --with-android-ndk=/var/tmp/dist/android-toolchain/android-sdk-linux/ndk/android-ndk-r21d
ac_add_options --with-android-sdk=/var/tmp/dist/android-toolchain/android-sdk-linux
ac_add_options --with-gradle=/var/tmp/dist/android-toolchain/gradle/gradle/bin/gradle

# https://bugzilla.mozilla.org/show_bug.cgi?id=1758568
ac_add_options --enable-minify=properties

# We do not use Tor Launcher on Android:
ac_add_options --disable-tor-launcher

ac_add_options --disable-tor-browser-update
ac_add_options --disable-verify-mar

# We only use beta GeckoView for now; use default for local builds
ac_add_options --enable-update-channel=beta

ac_add_options --enable-strip
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-rust-debug
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
ac_add_options --disable-parental-controls

ac_add_options --enable-proxy-bypass-protection

# Disable telemetry
ac_add_options MOZ_TELEMETRY_REPORTING=


code:
# vim: filetype=yaml sw=2
git_hash: 'v[% c("version") %]'
git_url:  https://github.com/mozilla/glean.git
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
version: '[% pc(c("origin_project"), "var/glean_version", { step => "list_toolchain_updates" }) %]'

src: |
  #!/bin/bash
  mv -f [% project %]-[% c('version') %].tar.gz [% dest_dir %]/[% c('filename') %]

var:
  # The `container-image` project looks at the deps list in origin_project
  # in the same step (build), so we cannot put this inside the
  # `create_glean_deps_tarball` step.
  # rbm#40020 should allow us to fix that.
  deps:
    - python3
    - python3-pip
    - torsocks
    - xz-utils
  glean_wheels_sha256sum:
    3.4.0: 6bbf3a9ffa939ca87e00b486f2020ab5cf9dea772f1d37b048f666fed38f98c1
    4.0.0: c974113bd8671364c592fea9b64bac660b59d4f03a7dcecd4dd4e0c355431db8
    4.2.0: 09cda9fb155e4987bdc03b702219960e9729c448146f023f8c93de57836edf31
    4.4.0: afc0eb6497413eab8e5cf95cf9bbfe4dc1cc53a208b9b66572cfde752f3023e9
    5.0.1: 289b843af3d0f4bd5fbdc77c94c7e1b2830bcbbf7e43786d30b2bd02f85b4a1a
  glean_wheels_url:
    3.4.0: https://people.torproject.org/~boklm/mirrors/sources/glean-wheels-3.4.0-build2.tar.xz
    4.0.0: https://people.torproject.org/~boklm/mirrors/sources/glean-wheels-4.0.0.tar.xz
    4.2.0: https://people.torproject.org/~pierov/tbb_files/glean-wheels-4.2.0.tar.xz
    4.4.0: https://people.torproject.org/~boklm/mirrors/sources/glean-wheels-4.4.0.tar.xz
    5.0.1: https://people.torproject.org/~aguestuser/mirrors/sources/glean-wheels-5.0.1.tar.xz

steps:
  create_glean_deps_tarball:
    git_url: ''
    version: 5.0.1
    filename: 'glean-wheels-[% c("version") %].tar.xz'
    build_log: '-'
    container:
      use_container: 1
    create_glean_deps_tarball: |
      #!/bin/bash
      [% c("var/set_default_env") -%]
      mkdir glean-wheels
      cd glean-wheels
      [% IF c("var/use_torsocks") %]torsocks [% END%]python3 -m pip download glean_parser==[% c("version") %]
      # Get pyyaml, needed for building application-services
      [% IF c("var/use_torsocks") %]torsocks [% END%]python3 -m pip download pyyaml==5.3.1
      cd ..
      [% c('tar', {
          tar_src => [ 'glean-wheels' ],
          tar_args => '-cJf ' _ dest_dir _ '/' _ c('filename'),
          }) %]
      cd '[% dest_dir %]'
      sha256sum [% c('filename') %]
      echo 'The file is ready to be uploaded:'
      echo '  scp -p out/glean/[% c("filename") %] people.torproject.org:public_html/mirrors/sources/'
    input_files:
      - project: container-image
        pkg_type: build

targets:
  with_torsocks:
      use_torsocks: 1

path: projects/glean/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/pmezard/go-difflib
git_hash: 792786c7400a136282c1664665ae0a8db921c6c2 # v1.0.0
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/pmezard/go-difflib
  go_lib_install:
    - github.com/pmezard/go-difflib/difflib

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/go-difflib/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/davecgh/go-spew
git_hash: 8991bc29aa16c548c550c7ff78260e27b9ab7c73 # v1.1.1
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/davecgh/go-spew
  go_lib_install:
    - github.com/davecgh/go-spew/spew

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/go-spew/config


code:
From 958f724b1b434702c3d44ceaca646791674d07b1 Mon Sep 17 00:00:00 2001
From: Georg Koppen <gk@torproject.org>
Date: Fri, 17 Apr 2020 10:24:23 +0000
Subject: [PATCH] Use fixed go-build tmp directory

Use fixed go-build tmp directory, when the directory does not exist, in
order to avoid some reproducibility issues where build directory gets
embedded in generated binaries.

diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
index 33b7818fb2..5e369d0f53 100644
--- a/src/cmd/go/internal/work/action.go
+++ b/src/cmd/go/internal/work/action.go
@@ -252,9 +252,13 @@ func (b *Builder) Init() {
 	if cfg.BuildN {
 		b.WorkDir = "$WORK"
 	} else {
-		tmp, err := os.MkdirTemp(cfg.Getenv("GOTMPDIR"), "go-build")
-		if err != nil {
-			base.Fatalf("go: creating work dir: %v", err)
+		tmp := filepath.Join(cfg.Getenv("GOTMPDIR"), "go-build-workdir")
+		_, err := os.Stat(tmp)
+		if !os.IsNotExist(err) {
+			tmp, err = os.MkdirTemp(cfg.Getenv("GOTMPDIR"), "go-build")
+			if err != nil {
+				base.Fatalf("go: creating work dir: %v", err)
+			}
 		}
 		if !filepath.IsAbs(tmp) {
 			abs, err := filepath.Abs(tmp)
--
2.26.1


code:
#!/bin/bash
[% c("var/set_default_env") -%]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/dist

[% IF c("var/linux") %]
  # Config options for hardening-wrapper
  export DEB_BUILD_HARDENING=1
  export DEB_BUILD_HARDENING_STACKPROTECTOR=1
  export DEB_BUILD_HARDENING_FORTIFY=1
  export DEB_BUILD_HARDENING_FORMAT=1
  export DEB_BUILD_HARDENING_PIE=1
[% END %]

mkdir -p /var/tmp/build

# Building go 1.4.x
# This is needed to bootstrap the go that we actually use
# https://golang.org/doc/install/source#go14
tar -C /var/tmp/build --transform='s,^go\>,go1.4,' -xf $rootdir/[% c('input_files_by_name/go14') %]
cd /var/tmp/build/go1.4/src
# Disable cgo to avoid conflicts with newer GCC. cgo is not needed for the bootstrap go.
# https://github.com/golang/go/issues/13114#issuecomment-186922245
# Disable CC etc. that are set up for cross builds.
CGO_ENABLED=0 CC= CFLAGS= LDFLAGS= ./make.bash
export GOROOT_BOOTSTRAP="/var/tmp/build/go1.4"

cd $rootdir
[% IF ! c("var/linux") %]
  [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  # http://golang.org/doc/install/source#environment
  export GOOS=[% c("var/GOOS") %]
  export GOARCH=[% c("var/GOARCH") %]
[% END %]

# Building go
# http://golang.org/doc/install/source#environment
tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/go') %]
export GOROOT="$distdir"
cd /var/tmp/dist/go/src
[% IF c("var/linux") -%]
  ./make.bash
[% ELSIF c("var/osx") -%]
  unset LDFLAGS
  rm -Rf $clangdir/helpers
  export CC="$clangdir/bin/clang [% c("var/FLAGS") %]"
  # Create a cc-for-target script that closes over CC, CFLAGS, and LDFLAGS.
  # Go's CC_FOR_TARGET only allows a command name, not a command with arguments.
  # https://github.com/golang/go/issues/15457
  CC_FOR_TARGET="$(pwd)/cc-for-target"
  echo "#!/bin/sh" > "$CC_FOR_TARGET"
  echo "exec $CC $CFLAGS $LDFLAGS \"\$@\"" >> "$CC_FOR_TARGET"
  chmod +x "$CC_FOR_TARGET"
  CGO_ENABLED=1 CC_FOR_TARGET="$CC_FOR_TARGET" CC= CFLAGS= LDFLAGS= ./make.bash
[% ELSIF c("var/windows") -%]
  # Create a cc-for-target script that closes over CC, CFLAGS, and LDFLAGS.
  # Go's CC_FOR_TARGET only allows a command name, not a command with arguments.
  # https://github.com/golang/go/issues/15457
  CC_FOR_TARGET="$(pwd)/cc-for-target"
  echo "#!/bin/sh" > "$CC_FOR_TARGET"
  echo "exec [% c("arch") %]-w64-mingw32-gcc [% c("var/CFLAGS") %] [% c("var/LDFLAGS") %] \"\$@\"" >> "$CC_FOR_TARGET"
  chmod +x "$CC_FOR_TARGET"
  CGO_ENABLED=1 CC_FOR_TARGET="$CC_FOR_TARGET" CC= CFLAGS= LDFLAGS= ./make.bash
[% ELSIF c("var/android") -%]
  patch -p2 < $rootdir/0001-Use-fixed-go-build-tmp-directory.patch
  CGO_ENABLED=1 CC_FOR_TARGET=[% c("var/CC") %] CC= CFLAGS= LDFLAGS= ./make.bash
[% END -%]

# This directory is non-reproducible and doesn't exist in official Go releases,
# so remove it to preserve reproducibility of the output.
rm -rf /var/tmp/dist/go/pkg/obj/go-build/

cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/go/build


code:
# vim: filetype=yaml sw=2
version: 1.17.11
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

var:
  go14_version: 1.4.3

  setup: |
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf $rootdir/[% c("go_tarfile") %]
    [% IF pc(c("origin_project"), "var/no_crosscompile") -%]
      export GOOS=linux
      export GOARCH=amd64
    [% ELSE -%]
      export GOOS=[% c("var/GOOS") %]
      export GOARCH=[% c("var/GOARCH") %]
    [% END -%]
    # Run in GOPATH mode: https://golang.org/cmd/go/#hdr-Module_support. (see:
    # #32027)
    export GO111MODULE=off
    export GOPATH=/var/tmp/dist/gopath
    export PATH=/var/tmp/dist/go/bin:/var/tmp/dist/gopath/bin:"$PATH"
    [% IF c("var/linux") -%]
      export CGO_LDFLAGS_ALLOW="-z|noexecstack"
      export CGO_LDFLAGS="-z noexecstack"
    [% END -%]
    [% IF c("var/linux-i686") -%]
      export CGO_ENABLED=1
    [% END -%]
    export GOTMPDIR=/var/tmp/build/go-tmp
    mkdir -p "$GOTMPDIR"

  # Template build script for building a go library.
  # This can be called as projects/go/var/build_go_lib.
  # You need to define /var/go_lib, and optionally var/go_lib_install as
  # a list of install targets.
  build_go_lib: |
    #!/bin/bash
    [% c("var/set_default_env") -%]
    [% pc('go', 'var/setup', { go_tarfile => c('input_files_by_name/go') }) %]
    distdir=/var/tmp/dist/[% project %]
    mkdir -p /var/tmp/build
    tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
    [% FOREACH dep = c("var/go_lib_deps") -%]
      tar -C /var/tmp/dist -xf [% c('input_files_by_name/' _ dep) %]
    [% END -%]
    mkdir -p $(dirname "$GOPATH/src/[% c("var/go_lib") %]")
    mv /var/tmp/build/[% project %]-[% c('version') %] "$GOPATH/src/[% c("var/go_lib") %]"
    cd "$GOPATH/src/[% c("var/go_lib") %]"
    for p in $(ls -1 $rootdir/*.patch 2> /dev/null | sort)
    do
      patch -p1 < $p
    done
    # Run in GOPATH mode: https://golang.org/cmd/go/#hdr-Module_support. (see:
    # #32027)
    export GO111MODULE=off
    [% IF c("var/build_go_lib_pre"); GET c("var/build_go_lib_pre"); END; -%]
    [% IF c("var/go_lib_install") -%]
      [% FOREACH inst IN c("var/go_lib_install") %]
        go install [% inst %]
      [% END %]
    [% ELSE %]
      go install [% c("var/go_lib") %]
    [% END %]
    cd /var/tmp/dist
    [% c('tar', {
            tar_src => [ 'gopath' ],
            tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
        }) %]

targets:
  windows:
    var:
      GOOS: windows
  windows-i686:
    var:
      GOARCH: 386
  windows-x86_64:
    var:
      GOARCH: amd64
  osx-x86_64:
    var:
      GOOS: darwin
      GOARCH: amd64
  linux:
    var:
      GOOS: linux
  linux-x86_64:
    var:
      GOARCH: amd64
  linux-i686:
    var:
      GOARCH: 386
  android:
    version: 1.18.3
    var:
      GOOS: android
  android-x86:
    var:
      GOARCH: 386
  android-x86_64:
    var:
      GOARCH: amd64
  android-armv7:
    var:
      GOARCH: arm
  android-aarch64:
    var:
      GOARCH: arm64

input_files:
  - project: container-image
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    enable: '[% ! c("var/linux") %]'
  - URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
    enable: '[% ! c("var/android") %]'
    name: go
    sha256sum: ac2649a65944c6a5abe55054000eee3d77196880da36a3555f62e06540e8eb54
  - URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
    enable: '[% c("var/android") %]'
    name: go
    sha256sum: 0012386ddcbb5f3350e407c679923811dbd283fcdc421724931614a842ecbc2d
  - URL: 'https://golang.org/dl/go[% c("var/go14_version") %].src.tar.gz'
    name: go14
    sha256sum: 9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
  - filename: 0001-Use-fixed-go-build-tmp-directory.patch
    enable: '[% c("var/android") %]'

path: projects/go/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/shiena/ansicolor.git
git_hash: a422bbe96644373c5753384a59d678f7d261ff10
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/shiena/ansicolor

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goansicolor/config


code:
# vim: filetype=yaml sw=2
git_url: https://gitlab.com/yawning/bsaes.git
version: '[% c("abbrev") %]'
git_hash: 0a714cd429ec754482b4001e918db30cd2094405
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gitlab.com/yawning/bsaes.git
  go_lib_deps:
    - goxsys

targets:
  android:
    var:
      build_go_lib_pre: |
        [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxsys
    project: goxsys
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    enable: '[% c("var/android") %]'

path: projects/gobsaes/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/namecoin/btcd.git
git_hash: 6cfad711d4ee7367b3ab9dc572097438dbca56eb
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/namecoin/btcd
  go_lib_install:
    - github.com/namecoin/btcd/btcjson
    - github.com/namecoin/btcd/rpcclient
  go_lib_deps:
    - gobtclog
    - gobtcutil
    - gosocks
    - gowebsocket

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gobtclog
    project: gobtclog
  - name: gobtcutil
    project: gobtcutil
  - name: gosocks
    project: gosocks
  - name: gowebsocket
    project: gowebsocket

path: projects/gobtcd/config


code:
# vim: filetype=yaml sw=2

# You're probably wondering why gobtcd2 is a thing, rather than being part of
# gobtcd.  gobtcd builds the btcjson and rpcclient subpackages of btcd.
# gobtcd2 builds the btcec, chaincfg, chaincfg/chainhash, and wire subpackages
# of btcd.  The former set depends on gobtcutil, which depends on the latter
# set.  This is fine for the dependency management done by "go get", which
# operates on a per-package level rather than a per-repo level.  Alas, since
# rbm instead operates on a per-repo level (since each project is one repo),
# splitting it up was necessary.

version: '[% c("abbrev") %]'
git_url: '[% pc("gobtcd", "git_url") %]'
git_hash: '[% pc("gobtcd", "git_hash") %]'
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/btcsuite/btcd
  go_lib_install:
    - github.com/btcsuite/btcd/btcec
    - github.com/btcsuite/btcd/chaincfg
    - github.com/btcsuite/btcd/chaincfg/chainhash
    - github.com/btcsuite/btcd/wire

input_files:
  - project: container-image
  - name: go
    project: go


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/btcsuite/btclog.git
git_hash: 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/btcsuite/btclog

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gobtclog/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/btcsuite/btcutil.git
git_hash: 9e5f4b9a998d263e3ce9c56664a7816001ac8000
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/btcsuite/btcutil
  go_lib_deps:
    - gobtcd2
    - goxcryptoripemd160

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gobtcd2
    project: gobtcd2
  - name: goxcryptoripemd160
    project: goxcryptoripemd160

path: projects/gobtcutil/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/hlandau/buildinfo.git
git_hash: 337a29b5499734e584d4630ce535af64c5fe7813
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/hlandau/buildinfo
  go_lib_deps:
    - goeasyconfig
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils
  - name: goeasyconfig
    project: goeasyconfig

path: projects/gobuildinfo/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://gopkg.in/check.v1
git_hash: 41f04d3bba152ddec2103e299fed053415705330 # v1.0.0
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/check.v1
  go_lib_deps:
    - pretty

input_files:
  - project: container-image
  - name: go
    project: go
  - name: pretty
    project: pretty

path: projects/gocheck/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/dsnet/compress
git_hash: cc9eb1d7ad760af14e8f918698f745e80377af4f
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/dsnet/compress

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gocompress/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/hlandau/configurable.git
git_hash: 34642c4c8cbf56801d0e34f0e82187305983ac26
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/hlandau/configurable.v1

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goconfigurable/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/hlandau/degoutils.git
git_hash: 8fa2440b63444dad556d76366f1c3ee070c8a577
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/hlandau/degoutils
  go_lib_install:
    - github.com/hlandau/degoutils/net
  go_lib_deps:
    - goxnet

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxnet
    project: goxnet

path: projects/godegoutils/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/hlandau/dexlogconfig.git
git_hash: 244f29bd260884993b176cd14ef2f7631f6f3c18
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/hlandau/dexlogconfig
  go_lib_deps:
    - gobuildinfo
    - goeasyconfig
    - gosystemd
    - goxlog
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils
  - name: goxlog
    project: goxlog
  - name: goeasyconfig
    project: goeasyconfig
  - name: gosystemd
    project: gosystemd
  - name: gobuildinfo
    project: gobuildinfo

path: projects/godexlogconfig/config


code:
# vim: filetype=yaml sw=2
version: 1.1.22
git_url:  https://github.com/miekg/dns.git
git_hash: 1e224ff5dead8366ed6fcdcb832794be42e73f0e
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/miekg/dns
  go_lib_deps:
    - goxcryptoed25519
    - goxnetip
    - goxsysunix

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxcryptoed25519
    project: goxcryptoed25519
  - name: goxnetip
    project: goxnetip
  - name: goxsysunix
    project: goxsysunix

path: projects/godns/config


code:
# vim: filetype=yaml sw=2
version: 1.0.17
git_url:  https://github.com/hlandau/easyconfig.git
git_hash: c31249162931b4963bbe6e501cccb60d23271a3f
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/hlandau/easyconfig.v1
  go_lib_deps:
    - goconfigurable
    - gosvcutils
    - gotoml
    - gopflag
    - gokingpin
  go_lib_install:
    - gopkg.in/hlandau/easyconfig.v1
    - gopkg.in/hlandau/easyconfig.v1/cflag

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goconfigurable
    project: goconfigurable
  - name: gosvcutils
    project: gosvcutils
  - name: gotoml
    project: gotoml
  - name: gopflag
    project: gopflag
  - name: gokingpin
    project: gokingpin

path: projects/goeasyconfig/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/pkg/errors
git_hash: 614d223910a179a466c1767a985424175c39b465 # v0.9.1
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/pkg/errors

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goerrors/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/golang/groupcache.git
git_hash: 611e8accdfc92c4187d399e95ce826046d4c8d73
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/golang/groupcache
  go_lib_install:
    - github.com/golang/groupcache/lru

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gogroupcache/config


code:
# vim: filetype=yaml sw=2
version: 0.0.10
git_url:  https://github.com/mattn/go-isatty.git
git_hash: 88ba11cfdc67c7588b30042edf244b2875f892b6
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/mattn/go-isatty
  go_lib_deps:
    - goxsysunix

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxsysunix
    project: goxsysunix

path: projects/goisatty/config


code:
# vim: filetype=yaml sw=2
version: 2.2.6
git_url:  https://github.com/alecthomas/kingpin.git
git_hash: 947dcec5ba9c011838740e680966fd7087a71d0d
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/alecthomas/kingpin.v2
  go_lib_deps:
    - gotemplate
    - gounits

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gotemplate
    project: gotemplate
  - name: gounits
    project: gounits

path: projects/gokingpin/config


code:
# vim: filetype=yaml sw=2
version: 2.0.1
git_url:  https://github.com/hlandau/madns.git
git_hash: 26979b3e4b5aa3e0bd53cf0a014f9eaf43b578e3
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/hlandau/madns.v2
  go_lib_deps:
    - godns
    - gobuildinfo
    - goxlog
  go_lib_install:
    - gopkg.in/hlandau/madns.v2
    - gopkg.in/hlandau/madns.v2/merr
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils
  - name: godns
    project: godns
  - name: gobuildinfo
    project: gobuildinfo
  - name: goxlog
    project: goxlog

path: projects/gomadns/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/golang/mock
git_hash: 51421b967af1f557f93a59e0057aaf15ca02e29c # v1.2.0
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/golang/mock
  go_lib_install:
    - github.com/golang/mock/gomock

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gomock/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/namecoin/ncbtcjson.git
git_hash: 0d2f400334751d149ca21bfd4535c9d2274f7264
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/namecoin/ncbtcjson
  go_lib_deps:
    - gobtcd

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gobtcd
    project: gobtcd

path: projects/goncbtcjson/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/namecoin/ncrpcclient.git
git_hash: 858e1a5acd8b2da56462f50323633cdf2fe80977
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/namecoin/ncrpcclient
  go_lib_deps:
    - gobtcd
    - goncbtcjson

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gobtcd
    project: gobtcd
  - name: goncbtcjson
    project: goncbtcjson

path: projects/goncrpcclient/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/ogier/pflag.git
git_hash: 45c278ab3607870051a2ea9040bb85fcb8557481
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/ogier/pflag

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gopflag/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/kr/pretty.git
git_hash: 71e7e49937503c662b9b636fd6b2c14b1aa818a5
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/kr/pretty
  go_lib_deps:
    - gotext

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gotext
    project: gotext

path: projects/gopretty/config


code:
# vim: filetype=yaml sw=2
version: v1.1.0
git_url: https://git.torproject.org/pluggable-transports/goptlib.git
git_hash: '[% c("version") %]'
tag_gpg_id: 1
gpg_keyring: goptlib.gpg
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: git.torproject.org/pluggable-transports/goptlib.git

targets:
  nightly:
    version: main
    tag_gpg_id: 0

  android:
    var:
      build_go_lib_pre: |
        [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    enable: '[% c("var/android") %]'

path: projects/goptlib/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/hlandau/service.git
git_hash: 0496f910e39ef577ba805f512f6e1b80d652c4b9
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/hlandau/service.v2
  go_lib_deps:
    - gosvcutils
    - goeasyconfig
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

targets:
  linux-i686:
    var:
      arch_deps:
        - libcap-dev:i386
  linux-x86_64:
    var:
      arch_deps:
        - libcap-dev

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils
  - name: gosvcutils
    project: gosvcutils
  - name: goeasyconfig
    project: goeasyconfig

path: projects/goservice/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/btcsuite/go-socks.git
git_hash: 4720035b7bfd2a9bb130b1c184f8bbe41b6f0d0f
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/btcsuite/go-socks
  go_lib_install:
    - github.com/btcsuite/go-socks/socks

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gosocks/config


code:
# vim: filetype=yaml sw=2
version: 1.0.10
git_url:  https://github.com/hlandau/svcutils.git
git_hash: c25dac49e50cbbcbef8c81b089f56156f4067729
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/hlandau/svcutils.v1
  go_lib_install:
    - gopkg.in/hlandau/svcutils.v1
    - gopkg.in/hlandau/svcutils.v1/caps
    - gopkg.in/hlandau/svcutils.v1/chroot
    - gopkg.in/hlandau/svcutils.v1/dupfd
    - gopkg.in/hlandau/svcutils.v1/exepath
    - gopkg.in/hlandau/svcutils.v1/passwd
    - gopkg.in/hlandau/svcutils.v1/pidfile
    - gopkg.in/hlandau/svcutils.v1/setuid
    - gopkg.in/hlandau/svcutils.v1/systemd
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

targets:
  linux-i686:
    var:
      arch_deps:
        - libcap-dev:i386
  linux-x86_64:
    var:
      arch_deps:
        - libcap-dev

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils

path: projects/gosvcutils/config


code:
# vim: filetype=yaml sw=2
version: 21
git_url:  https://github.com/coreos/go-systemd.git
git_hash: d3cd4ed1dbcf5835feba465b180436db54f20228
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/coreos/go-systemd
  go_lib_install:
    - github.com/coreos/go-systemd/journal
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils

path: projects/gosystemd/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/alecthomas/template.git
git_hash: fb15b899a75114aa79cc930e33c46b577cc664b1
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/alecthomas/template

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gotemplate/config


code:
# vim: filetype=yaml sw=2
version: 0.1.0
git_url:  https://github.com/kr/text.git
git_hash: e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/kr/text

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gotext/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/BurntSushi/toml.git
git_hash: 3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/BurntSushi/toml

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gotoml/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/alecthomas/units.git
git_hash: f65c72e2690dc4b403c8bd637baf4611cd4c069b
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/alecthomas/units

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gounits/config


code:
# vim: filetype=yaml sw=2
git_url: https://gitlab.com/yawning/utls.git
version: 0.0.12-1
git_hash: 'v[% c("version") %]'
tag_gpg_id: 1
gpg_keyring: yawning.gpg
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gitlab.com/yawning/utls.git
  go_lib_deps:
    - goxcrypto
    - gocompress
    - gobsaes

targets:
  android:
    var:
      build_go_lib_pre: |
        [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxcrypto
    project: goxcrypto
  - name: gocompress
    project: gocompress
  - name: gobsaes
    project: gobsaes
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    enable: '[% c("var/android") %]'

path: projects/goutls/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url:  https://github.com/btcsuite/websocket.git
git_hash: 31079b6807923eb23992c421b114992b95131b55
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/btcsuite/websocket

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/gowebsocket/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://go.googlesource.com/crypto
git_hash: 69ecbb4d6d5dab05e49161c6e77ea40a030884e1
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/crypto
  go_lib_install:
    - golang.org/x/crypto/chacha20poly1305
    - golang.org/x/crypto/cryptobyte
    - golang.org/x/crypto/curve25519
    - golang.org/x/crypto/hkdf
    - golang.org/x/crypto/nacl/secretbox
  go_lib_deps:
    - goxsys

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxsys
    project: goxsys

path: projects/goxcrypto/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: '[% pc("goxcrypto", "git_url") %]'
git_hash: '[% pc("goxcrypto", "git_hash") %]'
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/crypto
  go_lib_install:
    - golang.org/x/crypto/ed25519

input_files:
  - project: container-image
  - name: go
    project: go


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: '[% pc("goxcrypto", "git_url") %]'
git_hash: '[% pc("goxcrypto", "git_hash") %]'
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/crypto
  go_lib_install:
    - golang.org/x/crypto/ripemd160

input_files:
  - project: container-image
  - name: go
    project: go


code:
# vim: filetype=yaml sw=2
version: 1.0.0
git_url:  https://github.com/hlandau/xlog.git
git_hash: 197ef798aed28e08ed3e176e678fda81be993a31
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/hlandau/xlog
  go_lib_deps:
    - goisatty
    - goansicolor

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goisatty
    project: goisatty
  - name: goansicolor
    project: goansicolor

path: projects/goxlog/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://go.googlesource.com/net
git_hash: da137c7871d730100384dbcf36e6f8fa493aef5b
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/net
  go_lib_install:
    - golang.org/x/net/ipv4
    - golang.org/x/net/ipv6
    - golang.org/x/net/proxy
    - golang.org/x/net/dns/dnsmessage
  go_lib_deps:
    - goxsys

targets:
  android:
    var:
      build_go_lib_pre: |
        [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxsys
    project: goxsys
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
    enable: '[% c("var/android") %]'

path: projects/goxnet/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: '[% pc("goxnet", "git_url") %]'
git_hash: '[% pc("goxnet", "git_hash") %]'
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/net
  go_lib_install:
    - golang.org/x/net/ipv4
    - golang.org/x/net/ipv6
  go_lib_deps:
    - goxsysunix

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goxsysunix
    project: goxsysunix

path: projects/goxnetip/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/golang/sys
git_hash: fae7ac547cb717d141c433a2a173315e216b64c4
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/sys
  go_lib_install:
    - golang.org/x/sys/cpu
    - golang.org/x/sys/unix

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goxsys/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: '[% pc("goxsys", "git_url") %]'
git_hash: '[% pc("goxsys", "git_hash") %]'
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/sys
  go_lib_install:
    - golang.org/x/sys/unix

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goxsysunix/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/golang/text
# v0.3.3
git_hash: 23ae387dee1f90d29a23c0e87ee0b46038fbed0e
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/text

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goxtext/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://go.googlesource.com/xerrors
git_hash: 5ec99f83aff198f5fbd629d6c8d8eb38a04218ca
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: golang.org/x/xerrors

input_files:
  - project: container-image
  - name: go
    project: go

path: projects/goxxerrors/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://gopkg.in/yaml.v3
git_hash: 9f266ea9e77c4c7aab4cf02650570e7c7b3031a5 # v3.0.0
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: gopkg.in/yaml.v3
  go_lib_deps:
    - gocheck

input_files:
  - project: container-image
  - name: go
    project: go
  - name: gocheck
    project: gocheck

path: projects/goyaml/config


code:
#!/bin/bash
[% c("var/set_default_env") -%]
unzip -qq [% c("input_files_by_name/gradle") %]
mv [% project %]-[% c("version") %] [% project %]
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/gradle/build


code:
#!/bin/bash
[% c("var/set_default_env") -%]
tar xf [% project %]-[% c('version') %].tar.gz
cd [% project %]-[% c('version') %]
./make.sh
# Since 5.0.2 a .xpi for AMO is built, too. We don't need it.
rm pkg/*-amo.xpi
mv pkg/*.xpi [% dest_dir _ '/' _ c('filename') %]

path: projects/https-everywhere/build


code:
# vim: filetype=yaml sw=2
version: 2021.7.13
git_url: https://github.com/EFForg/https-everywhere.git
git_hash: '[% c("version") %]'
git_submodule: 1
gpg_keyring: https-everywhere.gpg
tag_gpg_id: 1
filename: "[% project %]-[% c('version') %]-[% c('var/build_id') %].xpi"
container:
  use_container: 1
var:
  # HTTPS Everywhere is expected to be the same on all platforms. To avoid
  # building the same thing 4 times, using 4 different container images
  # (each one with a different suite or architecture), we set the container
  # to bullseye/amd64 for all platforms. This allows us to create only one
  # container image, and also build the extension only one time as the
  # filename does not contain the platform, and var/build_id should be
  # the same since there is now nothing platform specific in the build
  # inputs. This allows us to save a little time and disk space.
  container:
    suite: bullseye
    arch: amd64
  deps:
    - git
    - libxslt1.1
    - libxml2-utils
    - sqlite3
    - rsync
    - zip
    - unzip
    - python3
    - python3-distutils
  pre_pkginst: ''

input_files:
  - project: container-image

path: projects/https-everywhere/config


code:
#!/bin/bash
[% c("var/set_default_env") -%]

tar xvf [% project %]-[% c('version') %].tar.gz

mkdir -p /var/tmp/dist/
cd /var/tmp/dist/

cp -a $rootdir/[% project %]*/[% project %] ./[% project %]

[% c('tar', {
        tar_src => '.',
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
        }) %]

path: projects/idna/build


code:
# vim: filetype=yaml sw=2
version: 2.8
git_url: https://github.com/kjd/idna.git
git_hash: 1cdf175e259b299be76f49c3ddc8794214f9931f
# TODO: This Git repo doesn't use GPG sigs.  We should pester them about that.
filename: "[% project %]-[% c('version') %]-[% c('var/build_id') %].tar.gz"
container:
  use_container: 1
input_files:
  - project: container-image

path: projects/idna/config


code:
#!/bin/bash
[% c("var/set_default_env") -%]

tar xvf [% project %]-[% c('version') %].tar.gz

mkdir -p /var/tmp/dist/
cd /var/tmp/dist/

cp -a $rootdir/[% project %]*/[% project %].py ./[% project %].py

[% c('tar', {
        tar_src => '.',
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
        }) %]


code:
# vim: filetype=yaml sw=2
version: 1.1.0
git_url: https://github.com/aio-libs/idna-ssl.git
git_hash: 1ab8304810f8bd9a880c0a013276cddd3c6e9551
# TODO: This Git repo uses GPG sigs; we should switch from commit hash to GPG verification.
filename: "[% project %]-[% c('version') %]-[% c('var/build_id') %].tar.gz"
container:
  use_container: 1
input_files:
  - project: container-image


path: projects/jsonrpclib/build


code:
# vim: filetype=yaml sw=2
version: 0.4.0
git_url: https://github.com/tcalmant/jsonrpclib.git
git_hash: fe9fcf2c99973507f7055d6c9e05e155957c2549
# TODO: This Git repo doesn't use GPG sigs.  We should pester them about that.
filename: "[% project %]-[% c('version') %]-[% c('var/build_id') %].tar.gz"
container:
  use_container: 1
input_files:
  - project: container-image

path: projects/jsonrpclib/config


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/xtaci/kcp-go
git_hash: 831b5b267373f6fbd3548849a3925c4e70806de2 # v5.5.11
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  go_lib: github.com/xtaci/kcp-go
  go_lib_deps:
    - goerrors
    - goxnet

input_files:
  - project: container-image
  - name: go
    project: go
  - name: goerrors
    project: goerrors
  - name: goxnet
    project: goxnet
  - filename: remove-crypt-fec.patch

path: projects/kcp-go/config


code:
From 0b9d0759f979a5d828b747ea51771f307c53d221 Mon Sep 17 00:00:00 2001
From: David Fifield <david@bamsoftware.com>
Date: Thu, 9 Apr 2020 11:27:44 -0600
Subject: [PATCH] Remove crypt and FEC dependencies.

---
 crypt.go   | 618 -----------------------------------------------------
 fec.go     | 337 -----------------------------
 removed.go |  29 +++
 3 files changed, 29 insertions(+), 955 deletions(-)
 delete mode 100644 crypt.go
 delete mode 100644 fec.go
 create mode 100644 removed.go

diff --git a/crypt.go b/crypt.go
deleted file mode 100644
index d882852..0000000
--- a/crypt.go
+++ /dev/null
@@ -1,618 +0,0 @@
-package kcp
-
-import (
-	"crypto/aes"
-	"crypto/cipher"
-	"crypto/des"
-	"crypto/sha1"
-	"unsafe"
-
-	xor "github.com/templexxx/xorsimd"
-	"github.com/tjfoc/gmsm/sm4"
-
-	"golang.org/x/crypto/blowfish"
-	"golang.org/x/crypto/cast5"
-	"golang.org/x/crypto/pbkdf2"
-	"golang.org/x/crypto/salsa20"
-	"golang.org/x/crypto/tea"
-	"golang.org/x/crypto/twofish"
-	"golang.org/x/crypto/xtea"
-)
-
-var (
-	initialVector = []byte{167, 115, 79, 156, 18, 172, 27, 1, 164, 21, 242, 193, 252, 120, 230, 107}
-	saltxor       = `sH3CIVoF#rWLtJo6`
-)
-
-// BlockCrypt defines encryption/decryption methods for a given byte slice.
-// Notes on implementing: the data to be encrypted contains a builtin
-// nonce at the first 16 bytes
-type BlockCrypt interface {
-	// Encrypt encrypts the whole block in src into dst.
-	// Dst and src may point at the same memory.
-	Encrypt(dst, src []byte)
-
-	// Decrypt decrypts the whole block in src into dst.
-	// Dst and src may point at the same memory.
-	Decrypt(dst, src []byte)
-}
-
-type salsa20BlockCrypt struct {
-	key [32]byte
-}
-
-// NewSalsa20BlockCrypt https://en.wikipedia.org/wiki/Salsa20
-func NewSalsa20BlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(salsa20BlockCrypt)
-	copy(c.key[:], key)
-	return c, nil
-}
-
-func (c *salsa20BlockCrypt) Encrypt(dst, src []byte) {
-	salsa20.XORKeyStream(dst[8:], src[8:], src[:8], &c.key)
-	copy(dst[:8], src[:8])
-}
-func (c *salsa20BlockCrypt) Decrypt(dst, src []byte) {
-	salsa20.XORKeyStream(dst[8:], src[8:], src[:8], &c.key)
-	copy(dst[:8], src[:8])
-}
-
-type sm4BlockCrypt struct {
-	encbuf [sm4.BlockSize]byte // 64bit alignment enc/dec buffer
-	decbuf [2 * sm4.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewSM4BlockCrypt https://github.com/tjfoc/gmsm/tree/master/sm4
-func NewSM4BlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(sm4BlockCrypt)
-	block, err := sm4.NewCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *sm4BlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *sm4BlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type twofishBlockCrypt struct {
-	encbuf [twofish.BlockSize]byte
-	decbuf [2 * twofish.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewTwofishBlockCrypt https://en.wikipedia.org/wiki/Twofish
-func NewTwofishBlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(twofishBlockCrypt)
-	block, err := twofish.NewCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *twofishBlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *twofishBlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type tripleDESBlockCrypt struct {
-	encbuf [des.BlockSize]byte
-	decbuf [2 * des.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewTripleDESBlockCrypt https://en.wikipedia.org/wiki/Triple_DES
-func NewTripleDESBlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(tripleDESBlockCrypt)
-	block, err := des.NewTripleDESCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *tripleDESBlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *tripleDESBlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type cast5BlockCrypt struct {
-	encbuf [cast5.BlockSize]byte
-	decbuf [2 * cast5.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewCast5BlockCrypt https://en.wikipedia.org/wiki/CAST-128
-func NewCast5BlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(cast5BlockCrypt)
-	block, err := cast5.NewCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *cast5BlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *cast5BlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type blowfishBlockCrypt struct {
-	encbuf [blowfish.BlockSize]byte
-	decbuf [2 * blowfish.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewBlowfishBlockCrypt https://en.wikipedia.org/wiki/Blowfish_(cipher)
-func NewBlowfishBlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(blowfishBlockCrypt)
-	block, err := blowfish.NewCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *blowfishBlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *blowfishBlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type aesBlockCrypt struct {
-	encbuf [aes.BlockSize]byte
-	decbuf [2 * aes.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewAESBlockCrypt https://en.wikipedia.org/wiki/Advanced_Encryption_Standard
-func NewAESBlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(aesBlockCrypt)
-	block, err := aes.NewCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *aesBlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *aesBlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type teaBlockCrypt struct {
-	encbuf [tea.BlockSize]byte
-	decbuf [2 * tea.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewTEABlockCrypt https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
-func NewTEABlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(teaBlockCrypt)
-	block, err := tea.NewCipherWithRounds(key, 16)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *teaBlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *teaBlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type xteaBlockCrypt struct {
-	encbuf [xtea.BlockSize]byte
-	decbuf [2 * xtea.BlockSize]byte
-	block  cipher.Block
-}
-
-// NewXTEABlockCrypt https://en.wikipedia.org/wiki/XTEA
-func NewXTEABlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(xteaBlockCrypt)
-	block, err := xtea.NewCipher(key)
-	if err != nil {
-		return nil, err
-	}
-	c.block = block
-	return c, nil
-}
-
-func (c *xteaBlockCrypt) Encrypt(dst, src []byte) { encrypt(c.block, dst, src, c.encbuf[:]) }
-func (c *xteaBlockCrypt) Decrypt(dst, src []byte) { decrypt(c.block, dst, src, c.decbuf[:]) }
-
-type simpleXORBlockCrypt struct {
-	xortbl []byte
-}
-
-// NewSimpleXORBlockCrypt simple xor with key expanding
-func NewSimpleXORBlockCrypt(key []byte) (BlockCrypt, error) {
-	c := new(simpleXORBlockCrypt)
-	c.xortbl = pbkdf2.Key(key, []byte(saltxor), 32, mtuLimit, sha1.New)
-	return c, nil
-}
-
-func (c *simpleXORBlockCrypt) Encrypt(dst, src []byte) { xor.Bytes(dst, src, c.xortbl) }
-func (c *simpleXORBlockCrypt) Decrypt(dst, src []byte) { xor.Bytes(dst, src, c.xortbl) }
-
-type noneBlockCrypt struct{}
-
-// NewNoneBlockCrypt does nothing but copying
-func NewNoneBlockCrypt(key []byte) (BlockCrypt, error) {
-	return new(noneBlockCrypt), nil
-}
-
-func (c *noneBlockCrypt) Encrypt(dst, src []byte) { copy(dst, src) }
-func (c *noneBlockCrypt) Decrypt(dst, src []byte) { copy(dst, src) }
-
-// packet encryption with local CFB mode
-func encrypt(block cipher.Block, dst, src, buf []byte) {
-	switch block.BlockSize() {
-	case 8:
-		encrypt8(block, dst, src, buf)
-	case 16:
-		encrypt16(block, dst, src, buf)
-	default:
-		panic("unsupported cipher block size")
-	}
-}
-
-// optimized encryption for the ciphers which works in 8-bytes
-func encrypt8(block cipher.Block, dst, src, buf []byte) {
-	tbl := buf[:8]
-	block.Encrypt(tbl, initialVector)
-	n := len(src) / 8
-	base := 0
-	repeat := n / 8
-	left := n % 8
-	ptr_tbl := (*uint64)(unsafe.Pointer(&tbl[0]))
-
-	for i := 0; i < repeat; i++ {
-		s := src[base:][0:64]
-		d := dst[base:][0:64]
-		// 1
-		*(*uint64)(unsafe.Pointer(&d[0])) = *(*uint64)(unsafe.Pointer(&s[0])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[0:8])
-		// 2
-		*(*uint64)(unsafe.Pointer(&d[8])) = *(*uint64)(unsafe.Pointer(&s[8])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[8:16])
-		// 3
-		*(*uint64)(unsafe.Pointer(&d[16])) = *(*uint64)(unsafe.Pointer(&s[16])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[16:24])
-		// 4
-		*(*uint64)(unsafe.Pointer(&d[24])) = *(*uint64)(unsafe.Pointer(&s[24])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[24:32])
-		// 5
-		*(*uint64)(unsafe.Pointer(&d[32])) = *(*uint64)(unsafe.Pointer(&s[32])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[32:40])
-		// 6
-		*(*uint64)(unsafe.Pointer(&d[40])) = *(*uint64)(unsafe.Pointer(&s[40])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[40:48])
-		// 7
-		*(*uint64)(unsafe.Pointer(&d[48])) = *(*uint64)(unsafe.Pointer(&s[48])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[48:56])
-		// 8
-		*(*uint64)(unsafe.Pointer(&d[56])) = *(*uint64)(unsafe.Pointer(&s[56])) ^ *ptr_tbl
-		block.Encrypt(tbl, d[56:64])
-		base += 64
-	}
-
-	switch left {
-	case 7:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 6:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 5:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 4:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 3:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 2:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 1:
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *ptr_tbl
-		block.Encrypt(tbl, dst[base:])
-		base += 8
-		fallthrough
-	case 0:
-		xorBytes(dst[base:], src[base:], tbl)
-	}
-}
-
-// optimized encryption for the ciphers which works in 16-bytes
-func encrypt16(block cipher.Block, dst, src, buf []byte) {
-	tbl := buf[:16]
-	block.Encrypt(tbl, initialVector)
-	n := len(src) / 16
-	base := 0
-	repeat := n / 8
-	left := n % 8
-	for i := 0; i < repeat; i++ {
-		s := src[base:][0:128]
-		d := dst[base:][0:128]
-		// 1
-		xor.Bytes16Align(d[0:16], s[0:16], tbl)
-		block.Encrypt(tbl, d[0:16])
-		// 2
-		xor.Bytes16Align(d[16:32], s[16:32], tbl)
-		block.Encrypt(tbl, d[16:32])
-		// 3
-		xor.Bytes16Align(d[32:48], s[32:48], tbl)
-		block.Encrypt(tbl, d[32:48])
-		// 4
-		xor.Bytes16Align(d[48:64], s[48:64], tbl)
-		block.Encrypt(tbl, d[48:64])
-		// 5
-		xor.Bytes16Align(d[64:80], s[64:80], tbl)
-		block.Encrypt(tbl, d[64:80])
-		// 6
-		xor.Bytes16Align(d[80:96], s[80:96], tbl)
-		block.Encrypt(tbl, d[80:96])
-		// 7
-		xor.Bytes16Align(d[96:112], s[96:112], tbl)
-		block.Encrypt(tbl, d[96:112])
-		// 8
-		xor.Bytes16Align(d[112:128], s[112:128], tbl)
-		block.Encrypt(tbl, d[112:128])
-		base += 128
-	}
-
-	switch left {
-	case 7:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 6:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 5:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 4:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 3:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 2:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 1:
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		block.Encrypt(tbl, dst[base:])
-		base += 16
-		fallthrough
-	case 0:
-		xorBytes(dst[base:], src[base:], tbl)
-	}
-}
-
-// decryption
-func decrypt(block cipher.Block, dst, src, buf []byte) {
-	switch block.BlockSize() {
-	case 8:
-		decrypt8(block, dst, src, buf)
-	case 16:
-		decrypt16(block, dst, src, buf)
-	default:
-		panic("unsupported cipher block size")
-	}
-}
-
-// decrypt 8 bytes block, all byte slices are supposed to be 64bit aligned
-func decrypt8(block cipher.Block, dst, src, buf []byte) {
-	tbl := buf[0:8]
-	next := buf[8:16]
-	block.Encrypt(tbl, initialVector)
-	n := len(src) / 8
-	base := 0
-	repeat := n / 8
-	left := n % 8
-	ptr_tbl := (*uint64)(unsafe.Pointer(&tbl[0]))
-	ptr_next := (*uint64)(unsafe.Pointer(&next[0]))
-
-	for i := 0; i < repeat; i++ {
-		s := src[base:][0:64]
-		d := dst[base:][0:64]
-		// 1
-		block.Encrypt(next, s[0:8])
-		*(*uint64)(unsafe.Pointer(&d[0])) = *(*uint64)(unsafe.Pointer(&s[0])) ^ *ptr_tbl
-		// 2
-		block.Encrypt(tbl, s[8:16])
-		*(*uint64)(unsafe.Pointer(&d[8])) = *(*uint64)(unsafe.Pointer(&s[8])) ^ *ptr_next
-		// 3
-		block.Encrypt(next, s[16:24])
-		*(*uint64)(unsafe.Pointer(&d[16])) = *(*uint64)(unsafe.Pointer(&s[16])) ^ *ptr_tbl
-		// 4
-		block.Encrypt(tbl, s[24:32])
-		*(*uint64)(unsafe.Pointer(&d[24])) = *(*uint64)(unsafe.Pointer(&s[24])) ^ *ptr_next
-		// 5
-		block.Encrypt(next, s[32:40])
-		*(*uint64)(unsafe.Pointer(&d[32])) = *(*uint64)(unsafe.Pointer(&s[32])) ^ *ptr_tbl
-		// 6
-		block.Encrypt(tbl, s[40:48])
-		*(*uint64)(unsafe.Pointer(&d[40])) = *(*uint64)(unsafe.Pointer(&s[40])) ^ *ptr_next
-		// 7
-		block.Encrypt(next, s[48:56])
-		*(*uint64)(unsafe.Pointer(&d[48])) = *(*uint64)(unsafe.Pointer(&s[48])) ^ *ptr_tbl
-		// 8
-		block.Encrypt(tbl, s[56:64])
-		*(*uint64)(unsafe.Pointer(&d[56])) = *(*uint64)(unsafe.Pointer(&s[56])) ^ *ptr_next
-		base += 64
-	}
-
-	switch left {
-	case 7:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 6:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 5:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 4:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 3:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 2:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 1:
-		block.Encrypt(next, src[base:])
-		*(*uint64)(unsafe.Pointer(&dst[base])) = *(*uint64)(unsafe.Pointer(&src[base])) ^ *(*uint64)(unsafe.Pointer(&tbl[0]))
-		tbl, next = next, tbl
-		base += 8
-		fallthrough
-	case 0:
-		xorBytes(dst[base:], src[base:], tbl)
-	}
-}
-
-func decrypt16(block cipher.Block, dst, src, buf []byte) {
-	tbl := buf[0:16]
-	next := buf[16:32]
-	block.Encrypt(tbl, initialVector)
-	n := len(src) / 16
-	base := 0
-	repeat := n / 8
-	left := n % 8
-	for i := 0; i < repeat; i++ {
-		s := src[base:][0:128]
-		d := dst[base:][0:128]
-		// 1
-		block.Encrypt(next, s[0:16])
-		xor.Bytes16Align(d[0:16], s[0:16], tbl)
-		// 2
-		block.Encrypt(tbl, s[16:32])
-		xor.Bytes16Align(d[16:32], s[16:32], next)
-		// 3
-		block.Encrypt(next, s[32:48])
-		xor.Bytes16Align(d[32:48], s[32:48], tbl)
-		// 4
-		block.Encrypt(tbl, s[48:64])
-		xor.Bytes16Align(d[48:64], s[48:64], next)
-		// 5
-		block.Encrypt(next, s[64:80])
-		xor.Bytes16Align(d[64:80], s[64:80], tbl)
-		// 6
-		block.Encrypt(tbl, s[80:96])
-		xor.Bytes16Align(d[80:96], s[80:96], next)
-		// 7
-		block.Encrypt(next, s[96:112])
-		xor.Bytes16Align(d[96:112], s[96:112], tbl)
-		// 8
-		block.Encrypt(tbl, s[112:128])
-		xor.Bytes16Align(d[112:128], s[112:128], next)
-		base += 128
-	}
-
-	switch left {
-	case 7:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 6:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 5:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 4:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 3:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 2:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 1:
-		block.Encrypt(next, src[base:])
-		xor.Bytes16Align(dst[base:], src[base:], tbl)
-		tbl, next = next, tbl
-		base += 16
-		fallthrough
-	case 0:
-		xorBytes(dst[base:], src[base:], tbl)
-	}
-}
-
-// per bytes xors
-func xorBytes(dst, a, b []byte) int {
-	n := len(a)
-	if len(b) < n {
-		n = len(b)
-	}
-	if n == 0 {
-		return 0
-	}
-
-	for i := 0; i < n; i++ {
-		dst[i] = a[i] ^ b[i]
-	}
-	return n
-}
diff --git a/fec.go b/fec.go
deleted file mode 100644
index 97cd40b..0000000
--- a/fec.go
+++ /dev/null
@@ -1,337 +0,0 @@
-package kcp
-
-import (
-	"encoding/binary"
-	"sync/atomic"
-
-	"github.com/klauspost/reedsolomon"
-)
-
-const (
-	fecHeaderSize      = 6
-	fecHeaderSizePlus2 = fecHeaderSize + 2 // plus 2B data size
-	typeData           = 0xf1
-	typeParity         = 0xf2
-	fecExpire          = 60000
-)
-
-// fecPacket is a decoded FEC packet
-type fecPacket []byte
-
-func (bts fecPacket) seqid() uint32 { return binary.LittleEndian.Uint32(bts) }
-func (bts fecPacket) flag() uint16  { return binary.LittleEndian.Uint16(bts[4:]) }
-func (bts fecPacket) data() []byte  { return bts[6:] }
-
-// fecElement has auxcilliary time field
-type fecElement struct {
-	fecPacket
-	ts uint32
-}
-
-// fecDecoder for decoding incoming packets
-type fecDecoder struct {
-	rxlimit      int // queue size limit
-	dataShards   int
-	parityShards int
-	shardSize    int
-	rx           []fecElement // ordered receive queue
-
-	// caches
-	decodeCache [][]byte
-	flagCache   []bool
-
-	// zeros
-	zeros []byte
-
-	// RS decoder
-	codec reedsolomon.Encoder
-}
-
-func newFECDecoder(rxlimit, dataShards, parityShards int) *fecDecoder {
-	if dataShards <= 0 || parityShards <= 0 {
-		return nil
-	}
-	if rxlimit < dataShards+parityShards {
-		return nil
-	}
-
-	dec := new(fecDecoder)
-	dec.rxlimit = rxlimit
-	dec.dataShards = dataShards
-	dec.parityShards = parityShards
-	dec.shardSize = dataShards + parityShards
-	codec, err := reedsolomon.New(dataShards, parityShards)
-	if err != nil {
-		return nil
-	}
-	dec.codec = codec
-	dec.decodeCache = make([][]byte, dec.shardSize)
-	dec.flagCache = make([]bool, dec.shardSize)
-	dec.zeros = make([]byte, mtuLimit)
-	return dec
-}
-
-// decode a fec packet
-func (dec *fecDecoder) decode(in fecPacket) (recovered [][]byte) {
-	// insertion
-	n := len(dec.rx) - 1
-	insertIdx := 0
-	for i := n; i >= 0; i-- {
-		if in.seqid() == dec.rx[i].seqid() { // de-duplicate
-			return nil
-		} else if _itimediff(in.seqid(), dec.rx[i].seqid()) > 0 { // insertion
-			insertIdx = i + 1
-			break
-		}
-	}
-
-	// make a copy
-	pkt := fecPacket(xmitBuf.Get().([]byte)[:len(in)])
-	copy(pkt, in)
-	elem := fecElement{pkt, currentMs()}
-
-	// insert into ordered rx queue
-	if insertIdx == n+1 {
-		dec.rx = append(dec.rx, elem)
-	} else {
-		dec.rx = append(dec.rx, fecElement{})
-		copy(dec.rx[insertIdx+1:], dec.rx[insertIdx:]) // shift right
-		dec.rx[insertIdx] = elem
-	}
-
-	// shard range for current packet
-	shardBegin := pkt.seqid() - pkt.seqid()%uint32(dec.shardSize)
-	shardEnd := shardBegin + uint32(dec.shardSize) - 1
-
-	// max search range in ordered queue for current shard
-	searchBegin := insertIdx - int(pkt.seqid()%uint32(dec.shardSize))
-	if searchBegin < 0 {
-		searchBegin = 0
-	}
-	searchEnd := searchBegin + dec.shardSize - 1
-	if searchEnd >= len(dec.rx) {
-		searchEnd = len(dec.rx) - 1
-	}
-
-	// re-construct datashards
-	if searchEnd-searchBegin+1 >= dec.dataShards {
-		var numshard, numDataShard, first, maxlen int
-
-		// zero caches
-		shards := dec.decodeCache
-		shardsflag := dec.flagCache
-		for k := range dec.decodeCache {
-			shards[k] = nil
-			shardsflag[k] = false
-		}
-
-		// shard assembly
-		for i := searchBegin; i <= searchEnd; i++ {
-			seqid := dec.rx[i].seqid()
-			if _itimediff(seqid, shardEnd) > 0 {
-				break
-			} else if _itimediff(seqid, shardBegin) >= 0 {
-				shards[seqid%uint32(dec.shardSize)] = dec.rx[i].data()
-				shardsflag[seqid%uint32(dec.shardSize)] = true
-				numshard++
-				if dec.rx[i].flag() == typeData {
-					numDataShard++
-				}
-				if numshard == 1 {
-					first = i
-				}
-				if len(dec.rx[i].data()) > maxlen {
-					maxlen = len(dec.rx[i].data())
-				}
-			}
-		}
-
-		if numDataShard == dec.dataShards {
-			// case 1: no loss on data shards
-			dec.rx = dec.freeRange(first, numshard, dec.rx)
-		} else if numshard >= dec.dataShards {
-			// case 2: loss on data shards, but it's recoverable from parity shards
-			for k := range shards {
-				if shards[k] != nil {
-					dlen := len(shards[k])
-					shards[k] = shards[k][:maxlen]
-					copy(shards[k][dlen:], dec.zeros)
-				} else if k < dec.dataShards {
-					shards[k] = xmitBuf.Get().([]byte)[:0]
-				}
-			}
-			if err := dec.codec.ReconstructData(shards); err == nil {
-				for k := range shards[:dec.dataShards] {
-					if !shardsflag[k] {
-						// recovered data should be recycled
-						recovered = append(recovered, shards[k])
-					}
-				}
-			}
-			dec.rx = dec.freeRange(first, numshard, dec.rx)
-		}
-	}
-
-	// keep rxlimit
-	if len(dec.rx) > dec.rxlimit {
-		if dec.rx[0].flag() == typeData { // track the unrecoverable data
-			atomic.AddUint64(&DefaultSnmp.FECShortShards, 1)
-		}
-		dec.rx = dec.freeRange(0, 1, dec.rx)
-	}
-
-	// timeout policy
-	current := currentMs()
-	numExpired := 0
-	for k := range dec.rx {
-		if _itimediff(current, dec.rx[k].ts) > fecExpire {
-			numExpired++
-			continue
-		}
-		break
-	}
-	if numExpired > 0 {
-		dec.rx = dec.freeRange(0, numExpired, dec.rx)
-	}
-	return
-}
-
-// free a range of fecPacket
-func (dec *fecDecoder) freeRange(first, n int, q []fecElement) []fecElement {
-	for i := first; i < first+n; i++ { // recycle buffer
-		xmitBuf.Put([]byte(q[i].fecPacket))
-	}
-
-	if first == 0 && n < cap(q)/2 {
-		return q[n:]
-	}
-	copy(q[first:], q[first+n:])
-	return q[:len(q)-n]
-}
-
-// release all segments back to xmitBuf
-func (dec *fecDecoder) release() {
-	if n := len(dec.rx); n > 0 {
-		dec.rx = dec.freeRange(0, n, dec.rx)
-	}
-}
-
-type (
-	// fecEncoder for encoding outgoing packets
-	fecEncoder struct {
-		dataShards   int
-		parityShards int
-		shardSize    int
-		paws         uint32 // Protect Against Wrapped Sequence numbers
-		next         uint32 // next seqid
-
-		shardCount int // count the number of datashards collected
-		maxSize    int // track maximum data length in datashard
-
-		headerOffset  int // FEC header offset
-		payloadOffset int // FEC payload offset
-
-		// caches
-		shardCache  [][]byte
-		encodeCache [][]byte
-
-		// zeros
-		zeros []byte
-
-		// RS encoder
-		codec reedsolomon.Encoder
-	}
-)
-
-func newFECEncoder(dataShards, parityShards, offset int) *fecEncoder {
-	if dataShards <= 0 || parityShards <= 0 {
-		return nil
-	}
-	enc := new(fecEncoder)
-	enc.dataShards = dataShards
-	enc.parityShards = parityShards
-	enc.shardSize = dataShards + parityShards
-	enc.paws = 0xffffffff / uint32(enc.shardSize) * uint32(enc.shardSize)
-	enc.headerOffset = offset
-	enc.payloadOffset = enc.headerOffset + fecHeaderSize
-
-	codec, err := reedsolomon.New(dataShards, parityShards)
-	if err != nil {
-		return nil
-	}
-	enc.codec = codec
-
-	// caches
-	enc.encodeCache = make([][]byte, enc.shardSize)
-	enc.shardCache = make([][]byte, enc.shardSize)
-	for k := range enc.shardCache {
-		enc.shardCache[k] = make([]byte, mtuLimit)
-	}
-	enc.zeros = make([]byte, mtuLimit)
-	return enc
-}
-
-// encodes the packet, outputs parity shards if we have collected quorum datashards
-// notice: the contents of 'ps' will be re-written in successive calling
-func (enc *fecEncoder) encode(b []byte) (ps [][]byte) {
-	// The header format:
-	// | FEC SEQID(4B) | FEC TYPE(2B) | SIZE (2B) | PAYLOAD(SIZE-2) |
-	// |<-headerOffset                |<-payloadOffset
-	enc.markData(b[enc.headerOffset:])
-	binary.LittleEndian.PutUint16(b[enc.payloadOffset:], uint16(len(b[enc.payloadOffset:])))
-
-	// copy data from payloadOffset to fec shard cache
-	sz := len(b)
-	enc.shardCache[enc.shardCount] = enc.shardCache[enc.shardCount][:sz]
-	copy(enc.shardCache[enc.shardCount][enc.payloadOffset:], b[enc.payloadOffset:])
-	enc.shardCount++
-
-	// track max datashard length
-	if sz > enc.maxSize {
-		enc.maxSize = sz
-	}
-
-	//  Generation of Reed-Solomon Erasure Code
-	if enc.shardCount == enc.dataShards {
-		// fill '0' into the tail of each datashard
-		for i := 0; i < enc.dataShards; i++ {
-			shard := enc.shardCache[i]
-			slen := len(shard)
-			copy(shard[slen:enc.maxSize], enc.zeros)
-		}
-
-		// construct equal-sized slice with stripped header
-		cache := enc.encodeCache
-		for k := range cache {
-			cache[k] = enc.shardCache[k][enc.payloadOffset:enc.maxSize]
-		}
-
-		// encoding
-		if err := enc.codec.Encode(cache); err == nil {
-			ps = enc.shardCache[enc.dataShards:]
-			for k := range ps {
-				enc.markParity(ps[k][enc.headerOffset:])
-				ps[k] = ps[k][:enc.maxSize]
-			}
-		}
-
-		// counters resetting
-		enc.shardCount = 0
-		enc.maxSize = 0
-	}
-
-	return
-}
-
-func (enc *fecEncoder) markData(data []byte) {
-	binary.LittleEndian.PutUint32(data, enc.next)
-	binary.LittleEndian.PutUint16(data[4:], typeData)
-	enc.next++
-}
-
-func (enc *fecEncoder) markParity(data []byte) {
-	binary.LittleEndian.PutUint32(data, enc.next)
-	binary.LittleEndian.PutUint16(data[4:], typeParity)
-	// sequence wrap will only happen at parity shard
-	enc.next = (enc.next + 1) % enc.paws
-}
diff --git a/removed.go b/removed.go
new file mode 100644
index 0000000..5ecf446
--- /dev/null
+++ b/removed.go
@@ -0,0 +1,29 @@
+package kcp
+
+// Dummy implementations for types from crypt.go and fec.go, removed to reduce
+// dependencies.
+
+const (
+	fecHeaderSize      = 6
+	fecHeaderSizePlus2 = fecHeaderSize + 2
+	typeData           = 0xf1
+	typeParity         = 0xf2
+)
+
+type (
+	BlockCrypt interface {
+		Encrypt(_, _ []byte)
+		Decrypt(_, _ []byte)
+	}
+	fecDecoder struct{}
+	fecEncoder struct{}
+	fecPacket  []byte
+)
+
+func newFECDecoder(rxlimit, dataShards, parityShards int) *fecDecoder { return nil }
+func newFECEncoder(dataShards, parityShards, offset int) *fecEncoder  { return nil }
+
+func (_ *fecDecoder) decode(in fecPacket) [][]byte { panic("disabled") }
+func (_ *fecDecoder) release()                     { panic("disabled") }
+func (_ *fecEncoder) encode(b []byte) [][]byte     { panic("disabled") }
+func (_ fecPacket) flag() uint16                   { panic("disabled") }
--
2.20.1


code:
#!/bin/bash
[% c("var/set_default_env") -%]
distdir=$(pwd)/dist
mkdir -p $distdir/[% project %]
tar xf [% project %]-[% c('version') %].tar.gz
cd [% project %]-[% c('version') %]
patch -p1 < ../libdmg.patch
cmake -DCMAKE_INSTALL_PREFIX:PATH=$distdir/[% project %] CMakeLists.txt
cd dmg
make -j[% c("num_procs") %]
make install
cd $distdir
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
        }) %]

path: projects/libdmg-hfsplus/build


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/vasi/libdmg-hfsplus
git_hash: dfd5e5cc3dc1191e37d3c3a6118975afdd1d7014
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1
var:
  deps:
    - build-essential
    - cmake
    - zlib1g-dev
    - libbz2-dev
input_files:
  - project: container-image
  - filename: libdmg.patch

path: projects/libdmg-hfsplus/config


code:
From d1a5eca891f32103ccda80ee75e158dfc7ece70d Mon Sep 17 00:00:00 2001
From: Mike Perry <mikeperry-git@torproject.org>
Date: Thu, 6 Mar 2014 19:47:05 -0800
Subject: [PATCH] Memset a UDIF header to ensure archive reproducibility.

Some of the struct padding and fields contained unitialized memory, which
caused two successive invocations to produce archives that differed in some
bytes.
---
 dmg/dmglib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dmg/dmglib.c b/dmg/dmglib.c
index f481b1f..b74e50b 100644
--- a/dmg/dmglib.c
+++ b/dmg/dmglib.c
@@ -108,7 +108,8 @@ int buildDmg(AbstractFile* abstractIn, AbstractFile* abstractOut) {
 	ChecksumToken dataForkToken;

 	UDIFResourceFile koly;
-
+	memset(&koly, 0, sizeof(koly));
+
 	off_t plistOffset;
 	uint32_t plistSize;
 	uint32_t dataForkChecksum;
@@ -284,7 +285,8 @@ int convertToDMG(AbstractFile* abstractIn, AbstractFile* abstractOut) {
 	uint64_t numSectors;

 	UDIFResourceFile koly;
-
+	memset(&koly, 0, sizeof(koly));
+
 	char partitionName[512];

 	off_t fileLength;
--
1.8.1.2


code:
#!/bin/bash
[% c("var/set_default_env") -%]
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
cd /var/tmp/build/[% project %]-[% c('version') %]
./autogen.sh
./configure [% c("var/configure_opt") %] --disable-libevent-regress --disable-samples --disable-openssl --prefix=$distdir
[% IF c("var/osx") -%]
  export LD_PRELOAD=[% c("var/faketime_path") %]
  export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
[% END -%]
make -j[% c("num_procs") %]
make install
cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/libevent/build


code:
# vim: filetype=yaml sw=2
version: 2.1.12
git_url: https://github.com/libevent/libevent.git
git_hash: 'release-[% c("version") %]-stable'
tag_gpg_id: 1
gpg_keyring: libevent.gpg
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
container:
  use_container: 1

var:
  configure_opt_project: --disable-static

targets:
  osx-x86_64:
    var:
      arch_deps:
        - faketime
  android:
    var:
      configure_opt_project: --disable-shared

input_files:
  - project: container-image
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'

path: projects/libevent/config


code:
#!/bin/bash
[% c("var/set_default_env") -%]
builddir=/var/tmp/build/[% project %]-[% c('version') %]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/dist
tar -C /var/tmp/dist -xf [% c('input_files_by_name/clang') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/ninja') %]

# We don't export the path to clang here to follow Mozilla's build script at
# taskcluster/scripts/misc/build-cctools-port.sh more closely.
export PATH="/var/tmp/dist/cmake/bin:/var/tmp/dist/ninja:$PATH"
export CLANG_DIR=/var/tmp/dist/clang
mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
export CC=$CLANG_DIR/bin/clang
export CXX=$CLANG_DIR/bin/clang++
# We also need this LD_LIBRARY_PATH at build time, since tapi builds bits of
# clang build tools, and then executes those tools.
export LD_LIBRARY_PATH=$CLANG_DIR/lib

cd $builddir
mkdir build
cd build
# Values taken from build.sh
TAPI_REPOSITORY=tapi-1000.10.8
TAPI_VERSION=10.0.0

INCLUDE_FIX="-I $builddir/src/llvm/projects/clang/include -I $PWD/projects/clang/include"

cmake $builddir/src/llvm \
      -GNinja \
      -DCMAKE_CXX_FLAGS="$INCLUDE_FIX" \
      -DLLVM_INCLUDE_TESTS=OFF \
      -DCMAKE_BUILD_TYPE=RELEASE \
      -DCMAKE_INSTALL_PREFIX=$distdir \
      -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
      -DTAPI_REPOSITORY_STRING=$TAPI_REPOSITORY \
      -DTAPI_FULL_VERSION=$TAPI_VERSION \
      -DPYTHON_EXECUTABLE=/usr/bin/python3

ninja clangBasic
ninja libtapi install-libtapi install-tapi-headers

cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/libtapi/build


code:
# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
version: '[% c("abbrev") %]'
# This can be found in
# taskcluster/ci/fetch/toolchains.yml
git_hash: b4f141a16c7c82f75973429c92242a8c7de3ddb1
git_url: https://github.com/tpoechtrager/apple-libtapi

container:
  use_container: 1

input_files:
  - project: container-image
  - name: clang
    project: clang
  - name: cmake
    project: cmake
  - name: ninja
    project: ninja

path: projects/libtapi/config


code:
#!/bin/bash
[% c("var/set_default_env") -%]
tar xf [% project %]-[% c("version") %].tar.gz
mv [% project %]-[% c("version") %] [% project %]
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/llvm-mingw/build


code:
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_hash: 9f8e5cebd6dbbb7546e8917e6c59284699a48d26
git_url: https://github.com/mstorsjo/llvm-mingw.git
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'

path: projects/llvm-mingw/config


code:
#!/bin/bash
[% c("var/set_default_env") -%]
tar xf [% project %]-[% c("version") %].tar.gz
mv [% project %]-[% c("version") %] clang-source
[% c('tar', {
        tar_src => [ 'clang-source' ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/llvm-project/build


code:
# vim: filetype=yaml sw=2
version: 12.0.0
git_hash: d28af7c654d8db0b68c175db5ce212d74fb5e9bc
git_url: https://github.com/llvm/llvm-project
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'

targets:
  android:
    version: 13.0.1
    git_hash: 75e33f71c2dae584b13a7d1186ae0a038ba98838

path: projects/llvm-project/config


code:
From ce82762aef3f8cdbdd340f39f95d2491f69a7da0 Mon Sep 17 00:00:00 2001
From: Nicolas Vigier <boklm@torproject.org>
Date: Mon, 29 Mar 2021 13:42:48 +0200
Subject: [PATCH] Remove -march=native from COMMON_CFLAGS

The -march=native flag is causing an error on some hardware. It can also
make the build non-reproducible when not building on the same hardware.
---
 lucet-builtins/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lucet-builtins/Makefile b/lucet-builtins/Makefile
index 6ddbcfd..de7e540 100644
--- a/lucet-builtins/Makefile
+++ b/lucet-builtins/Makefile
@@ -7,7 +7,7 @@ LIBBUILTINS_OBJS:=$(addprefix build/, \
 	strcmp.o \
 	strlen.o )

-COMMON_CFLAGS:= --std=gnu99 -Ofast -Wall -Werror -march=native -fPIC \
+COMMON_CFLAGS:= --std=gnu99 -Ofast -Wall -Werror -fPIC \
 	-I../lucet-runtime/include

 default: build/libbuiltins.so


code:
#!/bin/bash
[% c("var/set_default_env") -%]
# XXX: Do we need the GCC part here if we set CC to clang anyway?
[% IF c("var/linux") %]
  # We need a link to our GCC, otherwise the system cc gets used which points to
  # /usr/bin/gcc.
  [% pc('gcc', 'var/setup', { compiler_tarfile => c('input_files_by_name/gcc'),
                              hardened_gcc => 0 }) %]
  ln -s gcc /var/tmp/dist/gcc/bin/cc
  tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
  export PATH="/var/tmp/dist/binutils/bin:$PATH"
[% END -%]
distdir=/var/tmp/dist
builddir=/var/tmp/build/[% project %]

mkdir -p $distdir
tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/clang') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/rust') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/wasi-sysroot') %]
export PATH="/var/tmp/dist/cmake/bin:/var/tmp/dist/clang/bin:/var/tmp/dist/rust/bin:$PATH"
export CC=$distdir/clang/bin/clang
export CFLAGS="-L$distdir/clang/lib"
export CXX=$distdir/clang/bin/clang++
export CXXFLAGS=$CFLAGS
export AR=$distdir/clang/bin/llvm-ar
export RUSTFLAGS="-C linker=$CXX -C link-arg=$CXXFLAGS"
export LUCET_PREFIX=$distdir/[% project %]
# XXX: Why do we need that when Mozilla doesn't? See: taskcluster/scripts/misc/build-lucetc.sh
export WASI_SYSROOT=$distdir/wasi-sysroot

mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz

# Now prepare the offline build
# Move the directory for hardcoding the path in .cargo/config
mv /var/tmp/build/[% project %]-[% c('version') %] $builddir
tar -C $builddir -xf [% c('input_files_by_name/lucetc-vendor') %]
cd $builddir
# .cargo exists already, let's just add to it
cat >> .cargo/config << 'EOF'

[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "/var/tmp/build/lucetc/vendor"
EOF

patch -p1 < $rootdir/Remove-march-native-from-COMMON_CFLAGS.patch

make -j[% c("num_procs") %] build
# XXX: Should not be needed, just the lucetc binary, see: taskcluster/scripts/misc/build-lucetc.sh
make install

cd $distdir
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]

path: projects/lucetc/build


code:
# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
version: '[% c("abbrev") %]'
git_hash: d582d76bf0d17984501f3933688bf7a1eb5cf208
git_url: https://github.com/PLSysSec/lucet_sandbox_compiler/
git_submodule: 1

container:
  use_container: 1

input_files:
  - project: container-image
  - name: binutils
    project: binutils
    enable: '[% c("var/linux") %]'
  # Our clang still needs GCC parts (libstdc++ for instance) so we include that
  # one here even though compilation gets done solely by clang.
  - project: '[% c("var/compiler") %]'
    name: '[% c("var/compiler") %]'
    enable: '[% c("var/linux") %]'
  - name: cmake
    project: cmake
  - name: clang
    project: clang
  - name: rust
    project: rust
  - name: wasi-sysroot
    project: wasi-sysroot
  # Use `make cargo_vendor-lucetc` to re-generate the vendor tarball
  - name: lucetc-vendor
    URL: 'https://people.torproject.org/~boklm/mirrors/sources/lucetc-vendor-[% c("version") %].tar.bz2'
    sha256sum: 6b044ed76bc8870040174c8fbfa49c3a791b3aba7d32dd00cad541025eb16077
  - filename: Remove-march-native-from-COMMON_CFLAGS.patch

steps:
  cargo_vendor:
    filename: '[% project %]-vendor-[% c("version") %].tar.bz2'
    input_files:
      - project: container-image
        pkg_type: build
      - project: rust
        name: rust
        pkg_type: build

path: projects/lucetc/config