<commit_before>

namespace :release do
  VERSION = File.read('VERSION').strip
  NAME = 'kontena-agent'
  DOCKER_NAME = 'kontena/agent'
  DOCKER_VERSIONS = ['latest', VERSION.match(/(\d+\.\d+)/)[1]]

  desc 'Build all'
  task :build => [:build_docker, :build_ubuntu] do

  end

  desc 'Build docker images'
  task :build_docker => :environment do
    sh('docker pull gliderlabs/alpine:edge')
    sh("docker build -f Dockerfile.alpine -t #{DOCKER_NAME}:#{VERSION} .")
    DOCKER_VERSIONS.each do |v|
      sh("docker tag -f #{DOCKER_NAME}:#{VERSION} #{DOCKER_NAME}:#{v}")
    end
  end

  desc 'Build ubuntu packages'
  task :build_ubuntu => :environment do
    rev = ENV['REV']
    raise ArgumentError.new('You must define REV') if rev.blank?

    sh('mkdir -p build')
    sh('rm -rf build/ubuntu/')
    sh('cp -ar packaging/ubuntu build/')
    sh("docker run --rm -v #{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin:/target jpetazzo/nsenter")
    %w( docker-enter importenv ).each{|f| File.unlink("#{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin/#{f}") }
    sh("sed -i \"s/VERSION/#{VERSION}-#{rev}/g\" build/ubuntu/#{NAME}/DEBIAN/control")
    sh("sed -i \"s/VERSION/#{VERSION}/g\" build/ubuntu/#{NAME}/DEBIAN/postinst")
    sh("sed -i \"s/VERSION/#{VERSION}/g\" build/ubuntu/#{NAME}/etc/init/kontena-agent.conf")

    sh("sed -i \"s/VERSION/#{VERSION}-#{rev}/g\" build/ubuntu/kontena-weave/DEBIAN/control")
    sh("sed -i \"s/VERSION/#{VERSION}-#{rev}/g\" build/ubuntu/kontena-etcd/DEBIAN/control")


    Rake::Task["release:build_ubuntu_weave"].invoke
    Rake::Task["release:build_ubuntu_etcd"].invoke

    Dir.chdir("build/ubuntu") do
      sh("dpkg-deb -b #{NAME} .")
      sh("dpkg-deb -b kontena-weave .")
      sh("dpkg-deb -b kontena-etcd .")
    end
  end

  desc 'Build ubuntu weave package'
  task :build_ubuntu_weave => :environment do
    sh("docker run --rm -v #{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin:/target jpetazzo/nsenter")
    %w( docker-enter importenv ).each do |f|
      File.unlink("#{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin/#{f}")
    end
  end

  desc 'Build ubuntu etcd package'
  task :build_ubuntu_etcd => :environment do
    etcd_version = "v2.0.11"
    sh("mkdir -p build/ubuntu/tmp")
    sh("mkdir -p build/ubuntu/kontena-etcd/usr/local/bin")
    sh("mkdir -p build/ubuntu/kontena-etcd/var/lib/kontena-etcd")
    Dir.chdir('build/ubuntu/tmp') do
      sh("curl -qsOL https://github.com/coreos/etcd/releases/download/#{etcd_version}/etcd-#{etcd_version}-linux-amd64.tar.gz")
      sh("tar zxvf etcd-#{etcd_version}-linux-amd64.tar.gz")
    end<commit_msg>upgrade etcd in ubuntu packaging to 2.0.13<commit_after>

namespace :release do
  VERSION = File.read('VERSION').strip
  NAME = 'kontena-agent'
  DOCKER_NAME = 'kontena/agent'
  DOCKER_VERSIONS = ['latest', VERSION.match(/(\d+\.\d+)/)[1]]

  desc 'Build all'
  task :build => [:build_docker, :build_ubuntu] do

  end

  desc 'Build docker images'
  task :build_docker => :environment do
    sh('docker pull gliderlabs/alpine:edge')
    sh("docker build -f Dockerfile.alpine -t #{DOCKER_NAME}:#{VERSION} .")
    DOCKER_VERSIONS.each do |v|
      sh("docker tag -f #{DOCKER_NAME}:#{VERSION} #{DOCKER_NAME}:#{v}")
    end
  end

  desc 'Build ubuntu packages'
  task :build_ubuntu => :environment do
    rev = ENV['REV']
    raise ArgumentError.new('You must define REV') if rev.blank?

    sh('mkdir -p build')
    sh('rm -rf build/ubuntu/')
    sh('cp -ar packaging/ubuntu build/')
    sh("docker run --rm -v #{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin:/target jpetazzo/nsenter")
    %w( docker-enter importenv ).each{|f| File.unlink("#{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin/#{f}") }
    sh("sed -i \"s/VERSION/#{VERSION}-#{rev}/g\" build/ubuntu/#{NAME}/DEBIAN/control")
    sh("sed -i \"s/VERSION/#{VERSION}/g\" build/ubuntu/#{NAME}/DEBIAN/postinst")
    sh("sed -i \"s/VERSION/#{VERSION}/g\" build/ubuntu/#{NAME}/etc/init/kontena-agent.conf")

    sh("sed -i \"s/VERSION/#{VERSION}-#{rev}/g\" build/ubuntu/kontena-weave/DEBIAN/control")
    sh("sed -i \"s/VERSION/#{VERSION}-#{rev}/g\" build/ubuntu/kontena-etcd/DEBIAN/control")


    Rake::Task["release:build_ubuntu_weave"].invoke
    Rake::Task["release:build_ubuntu_etcd"].invoke

    Dir.chdir("build/ubuntu") do
      sh("dpkg-deb -b #{NAME} .")
      sh("dpkg-deb -b kontena-weave .")
      sh("dpkg-deb -b kontena-etcd .")
    end
  end

  desc 'Build ubuntu weave package'
  task :build_ubuntu_weave => :environment do
    sh("docker run --rm -v #{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin:/target jpetazzo/nsenter")
    %w( docker-enter importenv ).each do |f|
      File.unlink("#{Dir.pwd}/build/ubuntu/kontena-weave/usr/local/bin/#{f}")
    end
  end

  desc 'Build ubuntu etcd package'
  task :build_ubuntu_etcd => :environment do
    etcd_version = "v2.0.13"
    sh("mkdir -p build/ubuntu/tmp")
    sh("mkdir -p build/ubuntu/kontena-etcd/usr/local/bin")
    sh("mkdir -p build/ubuntu/kontena-etcd/var/lib/kontena-etcd")
    Dir.chdir('build/ubuntu/tmp') do
      sh("curl -qsOL https://github.com/coreos/etcd/releases/download/#{etcd_version}/etcd-#{etcd_version}-linux-amd64.tar.gz")
      sh("tar zxvf etcd-#{etcd_version}-linux-amd64.tar.gz")
    end
{'fraction_non_alphanumeric': 0.1884856545696371, 'fraction_numerical': 0.004180125403762113, 'mean_word_length': 3.434709351305813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3368320', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1989, 'n_words': 355}