<NME> gitlab-rails.rb
<BEF> #
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# Copyright:: Copyright (c) 2014-2022 GitLab Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name "gitlab-rails"
default_version "83028dff1eaa091f6f121686b7cc50efbd21c65d" # v7.13.4

EE = system("#{Omnibus::Config.project_root}/support/is_gitlab_ee.sh")

software_name = EE ? 'gitlab-rails-ee' : 'gitlab-rails'
version = Gitlab::Version.new(software_name)
gitlab_bundle_gemfile = Gitlab::Util.get_env('GITLAB_BUNDLE_GEMFILE') || 'Gemfile'

name 'gitlab-rails'

default_version version.print
source git: version.remote

combined_licenses_file = "#{install_dir}/embedded/lib/ruby/gems/gitlab-gem-licenses"

license 'MIT'
license_file 'LICENSE'

# TODO: Compare contents of this file with the output of license_finder and
# tackle the missing ones and stop using this workaround.
# https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6517
license_file combined_licenses_file

dependency 'pkg-config-lite'
dependency 'ruby'
dependency 'bundler'
dependency 'libxml2'
dependency 'libxslt'
dependency 'curl'
dependency 'rsync'
dependency 'libicu'
dependency 'postgresql'
dependency 'postgresql_new'
dependency 'python-docutils'
dependency 'krb5'
dependency 'registry'
dependency 'unzip'
dependency 'libre2'
dependency 'gpgme'
dependency 'graphicsmagick'
dependency 'exiftool'

if EE
  dependency 'pgbouncer'
  dependency 'patroni'
end

# libatomic is a runtime_dependency of the grpc gem for armhf/aarch64 platforms
whitelist_file /grpc_c\.so/ if OhaiHelper.arm?

build do
  env = with_standard_compiler_flags(with_embedded_path)

  # Exclude rails directory from cache
  cache_dir = File.join('/var/cache/omnibus/cache/git_cache', install_dir, 'info/exclude')
  command "echo '/embedded/service/gitlab-rails' >> #{cache_dir}"

  command "echo $(git log --pretty=format:'%h' --abbrev=11 -n 1) > REVISION"
  # Set installation type to omnibus
  command "echo 'omnibus-gitlab' > INSTALLATION_TYPE"

  make "install -C workhorse PREFIX=#{install_dir}/embedded"

  bundle_without = %w(development test)

  if Build::Check.use_system_ssl?
    env['CMAKE_FLAGS'] = OpenSSLHelper.cmake_flags
    env['PKG_CONFIG_PATH'] = OpenSSLHelper.pkg_config_dirs
  end

  bundle "config set --local gemfile #{gitlab_bundle_gemfile}" if gitlab_bundle_gemfile != 'Gemfile'
  bundle 'config force_ruby_platform true', env: env if OhaiHelper.ruby_native_gems_unsupported?
  bundle 'config build.gpgme --use-system-libraries', env: env
  bundle "config build.nokogiri --use-system-libraries --with-xml2-include=#{install_dir}/embedded/include/libxml2 --with-xslt-include=#{install_dir}/embedded/include/libxslt", env: env
  bundle 'config build.grpc --with-ldflags=-Wl,--no-as-needed --with-dldflags=-latomic', env: env if OhaiHelper.os_platform == 'raspbian'
  bundle "config set --local frozen 'true'"
  bundle "install --without #{bundle_without.join(' ')} --jobs #{workers} --retry 5", env: env

  block 'correct omniauth-jwt permissions' do
    # omniauth-jwt has some of its files 0600, make them 0644
    show = shellout!("#{embedded_bin('bundle')} show omniauth-jwt", env: env, returns: [0, 7])
    if show.exitstatus.zero?
      path = show.stdout.strip
      command "chmod -R g=u-w,o=u-w #{path}"
    end
  end

  # One of our gems, google-protobuf is known to have issues with older gcc versions
  # when using the pre-built extensions. We will remove it and rebuild it here.
  block 'reinstall google-protobuf gem' do
    require 'fileutils'

    unless OhaiHelper.ruby_native_gems_unsupported?
      current_gem = shellout!("#{embedded_bin('bundle')} show | grep google-protobuf", env: env).stdout
      protobuf_version = current_gem[/google-protobuf \((.*)\)/, 1]
      shellout!("#{embedded_bin('gem')} uninstall --force google-protobuf", env: env)
      shellout!("#{embedded_bin('gem')} install google-protobuf --version #{protobuf_version} --platform=ruby", env: env)
    end

    # Delete unused shared objects included in grpc gem
    grpc_path = shellout!("#{embedded_bin('bundle')} show grpc", env: env).stdout.strip
    ruby_ver = shellout!("#{embedded_bin('ruby')} -e 'puts RUBY_VERSION.match(/\\d+\\.\\d+/)[0]'", env: env).stdout.chomp
    command "find #{File.join(grpc_path, 'src/ruby/lib/grpc')} ! -path '*/#{ruby_ver}/*' -name 'grpc_c.so' -type f -print -delete"
  end

  # In order to compile the assets, we need to get to a state where rake can
  # load the Rails environment.
  copy 'config/gitlab.yml.example', 'config/gitlab.yml'
  copy 'config/secrets.yml.example', 'config/secrets.yml'

  block 'render database.yml' do
    database_yml = YAML.safe_load(File.read("#{Omnibus::Config.source_dir}/gitlab-rails/config/database.yml.postgresql"))
    database_yml.each { |_, databases| databases.delete('geo') unless EE }

    File.write("#{Omnibus::Config.source_dir}/gitlab-rails/config/database.yml", YAML.dump(database_yml))
  end

  # Copy asset cache and node modules from cache location to source directory
  move "#{Omnibus::Config.project_root}/assets_cache", "#{Omnibus::Config.source_dir}/gitlab-rails/tmp/cache"
  move "#{Omnibus::Config.project_root}/node_modules", "#{Omnibus::Config.source_dir}/gitlab-rails"

  assets_compile_env = {
    'NODE_ENV' => 'production',
    'RAILS_ENV' => 'production',
    'PATH' => "#{install_dir}/embedded/bin:#{Gitlab::Util.get_env('PATH')}",
    'USE_DB' => 'false',
    'SKIP_STORAGE_VALIDATION' => 'true',
    'NODE_OPTIONS' => '--max_old_space_size=3584'
  }
  assets_compile_env['NO_SOURCEMAPS'] = 'true' if Gitlab::Util.get_env('NO_SOURCEMAPS')
  command 'yarn install --pure-lockfile --production'

  # process PO files and generate MO and JSON files
  bundle 'exec rake gettext:compile', env: assets_compile_env

  # By default, copy assets from the fetch-assets job
  # Compile from scratch if the COMPILE_ASSETS variable is set to to true
  if Gitlab::Util.get_env('COMPILE_ASSETS').eql?('true')
    # Up the default timeout from 10min to 4hrs for this command so it has the
    # opportunity to complete on the pi
    bundle 'exec rake gitlab:assets:compile', timeout: 14400, env: assets_compile_env
  else
    # Copy the asset files
    sync "#{Gitlab::Util.get_env('CI_PROJECT_DIR')}/#{Gitlab::Util.get_env('ASSET_PATH')}", 'public/assets/'
  end

  bundle "exec license_finder report --project_path=#{File.dirname(gitlab_bundle_gemfile)} --decisions-file=config/dependency_decisions.yml --format=json --columns name version licenses texts notice --save=rails-license.json", env: env
  command "license_finder report --decisions-file=#{Omnibus::Config.project_root}/support/dependency_decisions.yml --format=json --columns name version licenses texts notice --save=workhorse-license.json", cwd: "#{Omnibus::Config.source_dir}/gitlab-rails/workhorse"

  # Merge rails and workhorse license files.
  block "Merge license files of rails and workhorse" do
    require 'json'
    rails_licenses = JSON.parse(File.read("#{Omnibus::Config.source_dir}/gitlab-rails/rails-license.json"))['dependencies']
    workhorse_licenses = JSON.parse(File.read("#{Omnibus::Config.source_dir}/gitlab-rails/workhorse/workhorse-license.json"))['dependencies']
    output = { dependencies: rails_licenses.concat(workhorse_licenses).uniq }
    File.write("#{install_dir}/licenses/gitlab-rails.json", JSON.pretty_generate(output))
  end

  # Move folders for caching. GitLab CI permits only relative path for Cache
  # and Artifacts. So we need these folder in the root directory.
  move "#{Omnibus::Config.source_dir}/gitlab-rails/tmp/cache", "#{Omnibus::Config.project_root}/assets_cache"
  move "#{Omnibus::Config.source_dir}/gitlab-rails/node_modules", Omnibus::Config.project_root.to_s

  # Tear down now that gitlab:assets:compile is done.
  delete 'config/gitlab.yml'
  delete 'config/database.yml'
  delete 'config/secrets.yml'

  # Remove auto-generated files
  delete '.secret'
  delete '.gitlab_shell_secret'
  delete '.gitlab_workhorse_secret'
  delete '.gitlab_pages_secret'
  delete '.gitlab_kas_secret'
  delete '.gitlab_incoming_email_secret'
  delete '.gitlab_service_desk_email_secret'

  # Remove directories that will be created by `gitlab-ctl reconfigure`
  delete 'log'
  delete 'tmp'
  delete 'public/uploads'

  # Drop uncompressed sourcemap files. We will keep the gziped versions.
  command "find public/assets/webpack -name '*.map' -type f -print -delete"

  # Cleanup after bundle
  # Delete all .gem archives
  command "find #{install_dir} -name '*.gem' -type f -print -delete"
  # Delete all docs
  command "find #{install_dir}/embedded/lib/ruby/gems -name 'doc' -type d -print -exec rm -r {} +"

  # Because db/structure.sql is modified by `rake db:migrate` after installation,
  # keep a copy of structure.sql around in case we need it. (I am looking at you,
  # mysql-postgresql-converter.)
  copy 'db/structure.sql', 'db/structure.sql.bundled'
  copy 'ee/db/geo/structure.sql', 'ee/db/geo/structure.sql.bundled' if EE

  mkdir "#{install_dir}/embedded/service/gitlab-rails"
  sync './', "#{install_dir}/embedded/service/gitlab-rails/", exclude: %w(
    .git
    .gitignore
    spec
    ee/spec
    features
    qa
    rubocop
    app/assets
    vendor/assets
    ee/app/assets
    workhorse
  )

  mkdir "#{install_dir}/bin/"
  mkdir "#{install_dir}/embedded/bin/"
  # Create a wrapper for the rake tasks of the Rails app
  erb dest: "#{install_dir}/bin/gitlab-rake",
      source: 'bundle_exec_wrapper.erb',
      mode: 0755,
      vars: { command: 'rake "$@"', install_dir: install_dir }

  # Create a wrapper for the rails command, useful for e.g. `rails console`
  erb dest: "#{install_dir}/bin/gitlab-rails",
      source: 'bundle_exec_wrapper.erb',
      mode: 0755,
      vars: { command: 'rails "$@"', install_dir: install_dir }

  # Create a wrapper for the rake command for backup and restore
  erb dest: "#{install_dir}/bin/gitlab-backup",
      source: 'rake_backup_wrapper.erb',
      mode: 0755,
      vars: { install_dir: install_dir }

  # Create a wrapper for the ruby command, useful for e.g. `ruby -e 'command'`
  erb dest: "#{install_dir}/bin/gitlab-ruby",
      source: 'bundle_exec_wrapper.erb',
      mode: 0755,
      vars: { command: 'ruby "$@"', install_dir: install_dir }

  # Generate the combined license file for all gems GitLab is using
  erb dest: "#{install_dir}/embedded/bin/gitlab-gem-license-generator",
      source: 'gem_license_generator.erb',
      mode: 0755,
      vars: { install_dir: install_dir, license_file: combined_licenses_file }

  command "#{install_dir}/embedded/bin/ruby #{install_dir}/embedded/bin/gitlab-gem-license-generator"
  delete "#{install_dir}/embedded/bin/gitlab-gem-license-generator"
end

<MSG> Build GitLab CE/CI 7.13.5

<DFF> @@ -17,7 +17,7 @@
 #
 
 name "gitlab-rails"
-default_version "83028dff1eaa091f6f121686b7cc50efbd21c65d" # v7.13.4
+default_version "744bd9834fcf29258599a20757e076b5658210ce" # v7.13.5
 
 EE = system("#{Omnibus::Config.project_root}/support/is_gitlab_ee.sh")
 

{'commit': 'diff --git a/config/software/gitlab-ci.rb b/config/software/gitlab-ci.rb\nindex 2b3286652..48500bbf8 100644\n--- a/config/software/gitlab-ci.rb\n+++ b/config/software/gitlab-ci.rb\n@@ -16,7 +16,7 @@\n #\n \n name "gitlab-ci"\n-default_version "bc78ae8e299e682aefa5fc60918ef02e35e13af0" # v7.13.4\n+default_version "57b5c7ab2796a054a383c345cf72be7618004cc6" # v7.13.5\n \n EE = system("#{Omnibus::Config.project_root}/support/is_gitlab_ee.sh")\n \ndiff --git a/config/software/gitlab-rails.rb b/config/software/gitlab-rails.rb\nindex 8758676cf..87a62cac7 100644\n--- a/config/software/gitlab-rails.rb\n+++ b/config/software/gitlab-rails.rb\n@@ -17,7 +17,7 @@\n #\n \n name "gitlab-rails"\n-default_version "83028dff1eaa091f6f121686b7cc50efbd21c65d" # v7.13.4\n+default_version "744bd9834fcf29258599a20757e076b5658210ce" # v7.13.5\n \n EE = system("#{Omnibus::Config.project_root}/support/is_gitlab_ee.sh")\n \n', 'commit_subject': 'Build GitLab CE/CI 7.13.5', 'repo_name': 'gitlabhq/omnibus-gitlab', 'committer': {'name': 'Jacob Vosmaer', 'email': '1a73af9e7ae00182733b2292511b814be66f065f@jacobvosmaer.nl', 'time_sec': '1439393424', 'tz_offset': '120', 'date': {'seconds': '1439393424'}}, 'commit_tree': 'ff90c13bb06431409191fb3d465988bf5c45b09c', 'commit_message': 'Build GitLab CE/CI 7.13.5\n', 'language_name': 'Ruby', 'license': 'apache-2.0', 'hunks': '@@ -17,7 +17,7 @@\n #\n \n name "gitlab-rails"\n-default_version "83028dff1eaa091f6f121686b7cc50efbd21c65d" # v7.13.4\n+default_version "744bd9834fcf29258599a20757e076b5658210ce" # v7.13.5\n \n EE = system("#{Omnibus::Config.project_root}/support/is_gitlab_ee.sh")\n \n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/config/software/gitlab-rails.rb', 'tgt_file': 'b/config/software/gitlab-rails.rb', 'file_extension': '.rb', 'before_file': '#\n# Copyright:: Copyright (c) 2012 Opscode, Inc.\n# Copyright:: Copyright (c) 2014-2022 GitLab Inc.\n# License:: Apache License, Version 2.0\n#\n# Licensed under the Apache License, Version 2.0 (the "License");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an "AS IS" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\nname "gitlab-rails"\ndefault_version "83028dff1eaa091f6f121686b7cc50efbd21c65d" # v7.13.4\n\nEE = system("#{Omnibus::Config.project_root}/support/is_gitlab_ee.sh")\n\nsoftware_name = EE ? \'gitlab-rails-ee\' : \'gitlab-rails\'\nversion = Gitlab::Version.new(software_name)\ngitlab_bundle_gemfile = Gitlab::Util.get_env(\'GITLAB_BUNDLE_GEMFILE\') || \'Gemfile\'\n\nname \'gitlab-rails\'\n\ndefault_version version.print\nsource git: version.remote\n\ncombined_licenses_file = "#{install_dir}/embedded/lib/ruby/gems/gitlab-gem-licenses"\n\nlicense \'MIT\'\nlicense_file \'LICENSE\'\n\n# TODO: Compare contents of this file with the output of license_finder and\n# tackle the missing ones and stop using this workaround.\n# https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6517\nlicense_file combined_licenses_file\n\ndependency \'pkg-config-lite\'\ndependency \'ruby\'\ndependency \'bundler\'\ndependency \'libxml2\'\ndependency \'libxslt\'\ndependency \'curl\'\ndependency \'rsync\'\ndependency \'libicu\'\ndependency \'postgresql\'\ndependency \'postgresql_new\'\ndependency \'python-docutils\'\ndependency \'krb5\'\ndependency \'registry\'\ndependency \'unzip\'\ndependency \'libre2\'\ndependency \'gpgme\'\ndependency \'graphicsmagick\'\ndependency \'exiftool\'\n\nif EE\n  dependency \'pgbouncer\'\n  dependency \'patroni\'\nend\n\n# libatomic is a runtime_dependency of the grpc gem for armhf/aarch64 platforms\nwhitelist_file /grpc_c\\.so/ if OhaiHelper.arm?\n\nbuild do\n  env = with_standard_compiler_flags(with_embedded_path)\n\n  # Exclude rails directory from cache\n  cache_dir = File.join(\'/var/cache/omnibus/cache/git_cache\', install_dir, \'info/exclude\')\n  command "echo \'/embedded/service/gitlab-rails\' >> #{cache_dir}"\n\n  command "echo $(git log --pretty=format:\'%h\' --abbrev=11 -n 1) > REVISION"\n  # Set installation type to omnibus\n  command "echo \'omnibus-gitlab\' > INSTALLATION_TYPE"\n\n  make "install -C workhorse PREFIX=#{install_dir}/embedded"\n\n  bundle_without = %w(development test)\n\n  if Build::Check.use_system_ssl?\n    env[\'CMAKE_FLAGS\'] = OpenSSLHelper.cmake_flags\n    env[\'PKG_CONFIG_PATH\'] = OpenSSLHelper.pkg_config_dirs\n  end\n\n  bundle "config set --local gemfile #{gitlab_bundle_gemfile}" if gitlab_bundle_gemfile != \'Gemfile\'\n  bundle \'config force_ruby_platform true\', env: env if OhaiHelper.ruby_native_gems_unsupported?\n  bundle \'config build.gpgme --use-system-libraries\', env: env\n  bundle "config build.nokogiri --use-system-libraries --with-xml2-include=#{install_dir}/embedded/include/libxml2 --with-xslt-include=#{install_dir}/embedded/include/libxslt", env: env\n  bundle \'config build.grpc --with-ldflags=-Wl,--no-as-needed --with-dldflags=-latomic\', env: env if OhaiHelper.os_platform == \'raspbian\'\n  bundle "config set --local frozen \'true\'"\n  bundle "install --without #{bundle_without.join(\' \')} --jobs #{workers} --retry 5", env: env\n\n  block \'correct omniauth-jwt permissions\' do\n    # omniauth-jwt has some of its files 0600, make them 0644\n    show = shellout!("#{embedded_bin(\'bundle\')} show omniauth-jwt", env: env, returns: [0, 7])\n    if show.exitstatus.zero?\n      path = show.stdout.strip\n      command "chmod -R g=u-w,o=u-w #{path}"\n    end\n  end\n\n  # One of our gems, google-protobuf is known to have issues with older gcc versions\n  # when using the pre-built extensions. We will remove it and rebuild it here.\n  block \'reinstall google-protobuf gem\' do\n    require \'fileutils\'\n\n    unless OhaiHelper.ruby_native_gems_unsupported?\n      current_gem = shellout!("#{embedded_bin(\'bundle\')} show | grep google-protobuf", env: env).stdout\n      protobuf_version = current_gem[/google-protobuf \\((.*)\\)/, 1]\n      shellout!("#{embedded_bin(\'gem\')} uninstall --force google-protobuf", env: env)\n      shellout!("#{embedded_bin(\'gem\')} install google-protobuf --version #{protobuf_version} --platform=ruby", env: env)\n    end\n\n    # Delete unused shared objects included in grpc gem\n    grpc_path = shellout!("#{embedded_bin(\'bundle\')} show grpc", env: env).stdout.strip\n    ruby_ver = shellout!("#{embedded_bin(\'ruby\')} -e \'puts RUBY_VERSION.match(/\\\\d+\\\\.\\\\d+/)[0]\'", env: env).stdout.chomp\n    command "find #{File.join(grpc_path, \'src/ruby/lib/grpc\')} ! -path \'*/#{ruby_ver}/*\' -name \'grpc_c.so\' -type f -print -delete"\n  end\n\n  # In order to compile the assets, we need to get to a state where rake can\n  # load the Rails environment.\n  copy \'config/gitlab.yml.example\', \'config/gitlab.yml\'\n  copy \'config/secrets.yml.example\', \'config/secrets.yml\'\n\n  block \'render database.yml\' do\n    database_yml = YAML.safe_load(File.read("#{Omnibus::Config.source_dir}/gitlab-rails/config/database.yml.postgresql"))\n    database_yml.each { |_, databases| databases.delete(\'geo\') unless EE }\n\n    File.write("#{Omnibus::Config.source_dir}/gitlab-rails/config/database.yml", YAML.dump(database_yml))\n  end\n\n  # Copy asset cache and node modules from cache location to source directory\n  move "#{Omnibus::Config.project_root}/assets_cache", "#{Omnibus::Config.source_dir}/gitlab-rails/tmp/cache"\n  move "#{Omnibus::Config.project_root}/node_modules", "#{Omnibus::Config.source_dir}/gitlab-rails"\n\n  assets_compile_env = {\n    \'NODE_ENV\' => \'production\',\n    \'RAILS_ENV\' => \'production\',\n    \'PATH\' => "#{install_dir}/embedded/bin:#{Gitlab::Util.get_env(\'PATH\')}",\n    \'USE_DB\' => \'false\',\n    \'SKIP_STORAGE_VALIDATION\' => \'true\',\n    \'NODE_OPTIONS\' => \'--max_old_space_size=3584\'\n  }\n  assets_compile_env[\'NO_SOURCEMAPS\'] = \'true\' if Gitlab::Util.get_env(\'NO_SOURCEMAPS\')\n  command \'yarn install --pure-lockfile --production\'\n\n  # process PO files and generate MO and JSON files\n  bundle \'exec rake gettext:compile\', env: assets_compile_env\n\n  # By default, copy assets from the fetch-assets job\n  # Compile from scratch if the COMPILE_ASSETS variable is set to to true\n  if Gitlab::Util.get_env(\'COMPILE_ASSETS\').eql?(\'true\')\n    # Up the default timeout from 10min to 4hrs for this command so it has the\n    # opportunity to complete on the pi\n    bundle \'exec rake gitlab:assets:compile\', timeout: 14400, env: assets_compile_env\n  else\n    # Copy the asset files\n    sync "#{Gitlab::Util.get_env(\'CI_PROJECT_DIR\')}/#{Gitlab::Util.get_env(\'ASSET_PATH\')}", \'public/assets/\'\n  end\n\n  bundle "exec license_finder report --project_path=#{File.dirname(gitlab_bundle_gemfile)} --decisions-file=config/dependency_decisions.yml --format=json --columns name version licenses texts notice --save=rails-license.json", env: env\n  command "license_finder report --decisions-file=#{Omnibus::Config.project_root}/support/dependency_decisions.yml --format=json --columns name version licenses texts notice --save=workhorse-license.json", cwd: "#{Omnibus::Config.source_dir}/gitlab-rails/workhorse"\n\n  # Merge rails and workhorse license files.\n  block "Merge license files of rails and workhorse" do\n    require \'json\'\n    rails_licenses = JSON.parse(File.read("#{Omnibus::Config.source_dir}/gitlab-rails/rails-license.json"))[\'dependencies\']\n    workhorse_licenses = JSON.parse(File.read("#{Omnibus::Config.source_dir}/gitlab-rails/workhorse/workhorse-license.json"))[\'dependencies\']\n    output = { dependencies: rails_licenses.concat(workhorse_licenses).uniq }\n    File.write("#{install_dir}/licenses/gitlab-rails.json", JSON.pretty_generate(output))\n  end\n\n  # Move folders for caching. GitLab CI permits only relative path for Cache\n  # and Artifacts. So we need these folder in the root directory.\n  move "#{Omnibus::Config.source_dir}/gitlab-rails/tmp/cache", "#{Omnibus::Config.project_root}/assets_cache"\n  move "#{Omnibus::Config.source_dir}/gitlab-rails/node_modules", Omnibus::Config.project_root.to_s\n\n  # Tear down now that gitlab:assets:compile is done.\n  delete \'config/gitlab.yml\'\n  delete \'config/database.yml\'\n  delete \'config/secrets.yml\'\n\n  # Remove auto-generated files\n  delete \'.secret\'\n  delete \'.gitlab_shell_secret\'\n  delete \'.gitlab_workhorse_secret\'\n  delete \'.gitlab_pages_secret\'\n  delete \'.gitlab_kas_secret\'\n  delete \'.gitlab_incoming_email_secret\'\n  delete \'.gitlab_service_desk_email_secret\'\n\n  # Remove directories that will be created by `gitlab-ctl reconfigure`\n  delete \'log\'\n  delete \'tmp\'\n  delete \'public/uploads\'\n\n  # Drop uncompressed sourcemap files. We will keep the gziped versions.\n  command "find public/assets/webpack -name \'*.map\' -type f -print -delete"\n\n  # Cleanup after bundle\n  # Delete all .gem archives\n  command "find #{install_dir} -name \'*.gem\' -type f -print -delete"\n  # Delete all docs\n  command "find #{install_dir}/embedded/lib/ruby/gems -name \'doc\' -type d -print -exec rm -r {} +"\n\n  # Because db/structure.sql is modified by `rake db:migrate` after installation,\n  # keep a copy of structure.sql around in case we need it. (I am looking at you,\n  # mysql-postgresql-converter.)\n  copy \'db/structure.sql\', \'db/structure.sql.bundled\'\n  copy \'ee/db/geo/structure.sql\', \'ee/db/geo/structure.sql.bundled\' if EE\n\n  mkdir "#{install_dir}/embedded/service/gitlab-rails"\n  sync \'./\', "#{install_dir}/embedded/service/gitlab-rails/", exclude: %w(\n    .git\n    .gitignore\n    spec\n    ee/spec\n    features\n    qa\n    rubocop\n    app/assets\n    vendor/assets\n    ee/app/assets\n    workhorse\n  )\n\n  mkdir "#{install_dir}/bin/"\n  mkdir "#{install_dir}/embedded/bin/"\n  # Create a wrapper for the rake tasks of the Rails app\n  erb dest: "#{install_dir}/bin/gitlab-rake",\n      source: \'bundle_exec_wrapper.erb\',\n      mode: 0755,\n      vars: { command: \'rake "$@"\', install_dir: install_dir }\n\n  # Create a wrapper for the rails command, useful for e.g. `rails console`\n  erb dest: "#{install_dir}/bin/gitlab-rails",\n      source: \'bundle_exec_wrapper.erb\',\n      mode: 0755,\n      vars: { command: \'rails "$@"\', install_dir: install_dir }\n\n  # Create a wrapper for the rake command for backup and restore\n  erb dest: "#{install_dir}/bin/gitlab-backup",\n      source: \'rake_backup_wrapper.erb\',\n      mode: 0755,\n      vars: { install_dir: install_dir }\n\n  # Create a wrapper for the ruby command, useful for e.g. `ruby -e \'command\'`\n  erb dest: "#{install_dir}/bin/gitlab-ruby",\n      source: \'bundle_exec_wrapper.erb\',\n      mode: 0755,\n      vars: { command: \'ruby "$@"\', install_dir: install_dir }\n\n  # Generate the combined license file for all gems GitLab is using\n  erb dest: "#{install_dir}/embedded/bin/gitlab-gem-license-generator",\n      source: \'gem_license_generator.erb\',\n      mode: 0755,\n      vars: { install_dir: install_dir, license_file: combined_licenses_file }\n\n  command "#{install_dir}/embedded/bin/ruby #{install_dir}/embedded/bin/gitlab-gem-license-generator"\n  delete "#{install_dir}/embedded/bin/gitlab-gem-license-generator"\nend\n', 'message': 'Build GitLab CE/CI 7.13.5\n', 'author_name': 'Jacob Vosmaer', 'lang': 'rb'}