Skip to content

Commit 742aa1a

Browse files
twk3balasankarc
andcommitted
Merge branch 'split-info-package' into 'master'
Split Package related information to own class See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7009 Merged-by: DJ Mountney <[email protected]> Approved-by: Andrew Patterson <[email protected]> Approved-by: DJ Mountney <[email protected]> Co-authored-by: Balasankar "Balu" C <[email protected]>
2 parents 9ebd500 + d69e0fe commit 742aa1a

31 files changed

+280
-201
lines changed

config/projects/gitlab.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb"
2424
require "#{Omnibus::Config.project_root}/lib/gitlab/openssl_helper"
2525

26-
gitlab_package_name = Build::Info.package
26+
gitlab_package_name = Build::Info::Package.name
2727
gitlab_package_file = File.join(Omnibus::Config.project_dir, 'gitlab', "#{gitlab_package_name}.rb")
2828

2929
# Include package specific details like package name and descrption (for gitlab-ee/gitlab-ce/etc)
@@ -54,7 +54,7 @@
5454
# https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1007
5555
#
5656
# Also check lib/gitlab/build.rb for Docker version forming
57-
build_version Build::Info.semver_version
57+
build_version Build::Info::Package.semver_version
5858
build_iteration Gitlab::BuildIteration.new.build_iteration
5959

6060
# Openssh needs to be installed

config/software/package-scripts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
skip_transitive_dependency_licensing true
2626

27-
default_version Gitlab::Util.get_env('CI_COMMIT_TAG') || Build::Info.semver_version.split('+')[0]
27+
default_version Gitlab::Util.get_env('CI_COMMIT_TAG') || Build::Info::Package.semver_version.split('+')[0]
2828

2929
build do
3030
# Create the package-script folder. The gitlab.rb project excludes this folder from the package.

lib/gitlab/build/check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def is_auto_deploy_branch?
5656

5757
def is_patch_release?
5858
# Major and minor releases have patch component as zero
59-
Info.semver_version.split(".")[-1] != "0"
59+
Info::Package.semver_version.split(".")[-1] != "0"
6060
end
6161

6262
def is_rc_tag?

lib/gitlab/build/facts.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require_relative 'info/git'
2+
require_relative 'info/package'
23

34
module Build
45
class Facts
@@ -65,7 +66,7 @@ def common_vars
6566
BUILDER_IMAGE_REGISTRY=#{Gitlab::Util.get_env('BUILDER_IMAGE_REGISTRY')}
6667
PUBLIC_BUILDER_IMAGE_REGISTRY=#{Gitlab::Util.get_env('PUBLIC_BUILDER_IMAGE_REGISTRY')}
6768
COMPILE_ASSETS=#{Gitlab::Util.get_env('COMPILE_ASSETS') || 'false'}
68-
EDITION=#{Build::Info.edition.upcase}
69+
EDITION=#{Build::Info::Package.edition.upcase}
6970
ee=#{Build::Check.is_ee? || 'false'}
7071
]
7172
end
@@ -75,7 +76,7 @@ def qa_trigger_vars
7576
QA_RELEASE=#{Build::GitlabImage.gitlab_registry_image_address(tag: Build::Info.docker_tag)}
7677
QA_IMAGE=#{Build::Info.qa_image}
7778
QA_TESTS=#{Gitlab::Util.get_env('QA_TESTS')}
78-
ALLURE_JOB_NAME=#{allure_job_name}-#{Build::Info.edition}
79+
ALLURE_JOB_NAME=#{allure_job_name}-#{Build::Info::Package.edition}
7980
GITLAB_SEMVER_VERSION=#{Build::Info::Git.latest_stable_tag.tr('+', '-')}
8081
RAT_REFERENCE_ARCHITECTURE=#{Gitlab::Util.get_env('RAT_REFERENCE_ARCHITECTURE') || 'omnibus-gitlab-mrs'}
8182
RAT_FIPS_REFERENCE_ARCHITECTURE=#{Gitlab::Util.get_env('RAT_FIPS_REFERENCE_ARCHITECTURE') || 'omnibus-gitlab-mrs-fips-ubuntu'}

lib/gitlab/build/gitlab_image.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class GitlabImage
66
extend Image
77

88
def self.dockerhub_image_name
9-
"gitlab/#{Build::Info.package}"
9+
"gitlab/#{Build::Info::Package.name}"
1010
end
1111

1212
def self.gitlab_registry_image_name
13-
Build::Info.package
13+
Build::Info::Package.name
1414
end
1515
end
1616
end

lib/gitlab/build/info.rb

Lines changed: 8 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
require 'omnibus'
2-
31
require_relative 'info/git'
42
require_relative '../build_iteration'
53
require_relative "../util.rb"
64
require_relative './info/ci'
5+
require_relative './info/package'
76
require_relative 'check'
87
require_relative 'image'
98

@@ -14,48 +13,10 @@ class Info
1413
'PATCH_DEPLOY_ENVIRONMENT' => 'ubuntu-bionic',
1514
'RELEASE_DEPLOY_ENVIRONMENT' => 'ubuntu-focal',
1615
}.freeze
17-
PACKAGE_GLOB = "pkg/**/*.{deb,rpm}".freeze
1816

1917
class << self
20-
def package
21-
return "gitlab-fips" if Check.use_system_ssl?
22-
return "gitlab-ee" if Check.is_ee?
23-
24-
"gitlab-ce"
25-
end
26-
27-
# For auto-deploy builds, we set the semver to the following which is
28-
# derived directly from the auto-deploy tag:
29-
# MAJOR.MINOR.PIPELINE_ID+<ee ref>-<omnibus ref>
30-
# See https://gitlab.com/gitlab-org/release/docs/blob/master/general/deploy/auto-deploy.md#auto-deploy-tagging
31-
#
32-
# For nightly builds we fetch all GitLab components from master branch
33-
# If there was no change inside of the omnibus-gitlab repository, the
34-
# package version will remain the same but contents of the package will be
35-
# different.
36-
# To resolve this, we append a PIPELINE_ID to change the name of the package
37-
def semver_version
38-
if Build::Check.on_tag?
39-
# timestamp is disabled in omnibus configuration
40-
Omnibus.load_configuration('omnibus.rb')
41-
Omnibus::BuildVersion.semver
42-
else
43-
latest_git_tag = Info::Git.latest_tag.strip
44-
latest_version = latest_git_tag && !latest_git_tag.empty? ? latest_git_tag[0, latest_git_tag.match("[+]").begin(0)] : '0.0.1'
45-
commit_sha = Build::Info::Git.commit_sha
46-
ver_tag = "#{latest_version}+" + (Build::Check.is_nightly? ? "rnightly" : "rfbranch")
47-
ver_tag += ".fips" if Build::Check.use_system_ssl?
48-
[ver_tag, Gitlab::Util.get_env('CI_PIPELINE_ID'), commit_sha].compact.join('.')
49-
end
50-
end
51-
52-
def release_version
53-
semver = Info.semver_version
54-
"#{semver}-#{Gitlab::BuildIteration.new.build_iteration}"
55-
end
56-
5718
def docker_tag
58-
Gitlab::Util.get_env('IMAGE_TAG') || Info.release_version.tr('+', '-')
19+
Gitlab::Util.get_env('IMAGE_TAG') || Build::Info::Package.release_version.tr('+', '-')
5920
end
6021

6122
def gitlab_version
@@ -92,18 +53,18 @@ def gitlab_rails_ref(prepend_version: true)
9253

9354
def gitlab_rails_project_path
9455
if Gitlab::Util.get_env('CI_SERVER_HOST') == 'dev.gitlab.org'
95-
package == "gitlab-ee" ? 'gitlab/gitlab-ee' : 'gitlab/gitlabhq'
56+
Build::Info::Package.name == "gitlab-ee" ? 'gitlab/gitlab-ee' : 'gitlab/gitlabhq'
9657
else
9758
namespace = Gitlab::Version.security_channel? ? "gitlab-org/security" : "gitlab-org"
98-
project = package == "gitlab-ee" ? 'gitlab' : 'gitlab-foss'
59+
project = Build::Info::Package.name == "gitlab-ee" ? 'gitlab' : 'gitlab-foss'
9960

10061
"#{namespace}/#{project}"
10162
end
10263
end
10364

10465
def gitlab_rails_repo
10566
gitlab_rails =
106-
if package == "gitlab-ce"
67+
if Build::Info::Package.name == "gitlab-ce"
10768
"gitlab-rails"
10869
else
10970
"gitlab-rails-ee"
@@ -113,11 +74,7 @@ def gitlab_rails_repo
11374
end
11475

11576
def qa_image
116-
Gitlab::Util.get_env('QA_IMAGE') || "#{Gitlab::Util.get_env('CI_REGISTRY')}/#{gitlab_rails_project_path}/#{Build::Info.package}-qa:#{gitlab_rails_ref(prepend_version: false)}"
117-
end
118-
119-
def edition
120-
Info.package.gsub("gitlab-", "").strip # 'ee' or 'ce'
77+
Gitlab::Util.get_env('QA_IMAGE') || "#{Gitlab::Util.get_env('CI_REGISTRY')}/#{gitlab_rails_project_path}/#{Build::Info::Package.name}-qa:#{gitlab_rails_ref(prepend_version: false)}"
12178
end
12279

12380
def release_bucket
@@ -169,8 +126,8 @@ def release_file_contents
169126

170127
contents = []
171128
contents << "PACKAGECLOUD_REPO=#{repo.chomp}\n" if repo && !repo.empty?
172-
contents << "RELEASE_PACKAGE=#{Info.package}\n"
173-
contents << "RELEASE_VERSION=#{Info.release_version}\n"
129+
contents << "RELEASE_PACKAGE=#{Build::Info::Package.name}\n"
130+
contents << "RELEASE_VERSION=#{Build::Info::Package.release_version}\n"
174131
contents << "DOWNLOAD_URL=#{download_url}\n"
175132
contents << "CI_JOB_TOKEN=#{Build::Info::CI.job_token}\n"
176133
contents.join
@@ -203,25 +160,6 @@ def deploy_env
203160

204161
env
205162
end
206-
207-
def package_list
208-
Dir.glob(PACKAGE_GLOB)
209-
end
210-
211-
def name_version
212-
Omnibus.load_configuration('omnibus.rb')
213-
project = Omnibus::Project.load('gitlab')
214-
packager = project.packagers_for_system[0]
215-
216-
case packager
217-
when Omnibus::Packager::DEB
218-
"#{Build::Info.package}=#{packager.safe_version}-#{packager.safe_build_iteration}"
219-
when Omnibus::Packager::RPM
220-
"#{Build::Info.package}-#{packager.safe_version}-#{packager.safe_build_iteration}#{packager.dist_tag}"
221-
else
222-
raise "Unable to detect version"
223-
end
224-
end
225163
end
226164
end
227165
end

lib/gitlab/build/info/ci.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def package_download_url(job_name: "Ubuntu-22.04", arch: 'amd64')
5757
# In EL world, amd64 is called x86_64
5858
arch = 'x86_64' if arch == 'amd64'
5959
folder = 'el-8'
60-
package_file_name = "#{Info.package}-#{Info.release_version.gsub('+', '%2B')}.el8.#{arch}.rpm"
60+
package_file_name = "#{Info::Package.name}-#{Info::Package.release_version.gsub('+', '%2B')}.el8.#{arch}.rpm"
6161
when /Ubuntu-20.04/
6262
folder = 'ubuntu-focal'
63-
package_file_name = "#{Info.package}_#{Info.release_version.gsub('+', '%2B')}_#{arch}.deb"
63+
package_file_name = "#{Info::Package.name}_#{Info::Package.release_version.gsub('+', '%2B')}_#{arch}.deb"
6464
when /Ubuntu-22.04/
6565
folder = 'ubuntu-jammy'
66-
package_file_name = "#{Info.package}_#{Info.release_version.gsub('+', '%2B')}_#{arch}.deb"
66+
package_file_name = "#{Info::Package.name}_#{Info::Package.release_version.gsub('+', '%2B')}_#{arch}.deb"
6767
end
6868

6969
if arch == 'arm64'

lib/gitlab/build/info/package.rb

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
require 'omnibus'
2+
3+
require_relative '../../util'
4+
require_relative '../check'
5+
6+
module Build
7+
class Info
8+
class Package
9+
PACKAGE_GLOB = "pkg/**/*.{deb,rpm}".freeze
10+
11+
class << self
12+
def name
13+
return "gitlab-fips" if Check.use_system_ssl?
14+
return "gitlab-ee" if Check.is_ee?
15+
16+
"gitlab-ce"
17+
end
18+
19+
def edition
20+
# Returns `ee`, `ce`, or `fips`
21+
Info::Package.name.gsub("gitlab-", "").strip
22+
end
23+
24+
# For auto-deploy builds, we set the semver to the following which is
25+
# derived directly from the auto-deploy tag:
26+
# MAJOR.MINOR.PIPELINE_ID+<ee ref>-<omnibus ref>
27+
# See https://gitlab.com/gitlab-org/release/docs/blob/master/general/deploy/auto-deploy.md#auto-deploy-tagging
28+
#
29+
# For nightly builds we fetch all GitLab components from master branch
30+
# If there was no change inside of the omnibus-gitlab repository, the
31+
# package version will remain the same but contents of the package will be
32+
# different.
33+
# To resolve this, we append a PIPELINE_ID to change the name of the package
34+
def semver_version
35+
if Build::Check.on_tag?
36+
# timestamp is disabled in omnibus configuration
37+
Omnibus.load_configuration('omnibus.rb')
38+
Omnibus::BuildVersion.semver
39+
else
40+
latest_git_tag = Info::Git.latest_tag.strip
41+
latest_version = latest_git_tag && !latest_git_tag.empty? ? latest_git_tag[0, latest_git_tag.match("[+]").begin(0)] : '0.0.1'
42+
commit_sha = Build::Info::Git.commit_sha
43+
ver_tag = "#{latest_version}+" + (Build::Check.is_nightly? ? "rnightly" : "rfbranch")
44+
ver_tag += ".fips" if Build::Check.use_system_ssl?
45+
[ver_tag, Gitlab::Util.get_env('CI_PIPELINE_ID'), commit_sha].compact.join('.')
46+
end
47+
end
48+
49+
def release_version
50+
semver = Info::Package.semver_version
51+
"#{semver}-#{Gitlab::BuildIteration.new.build_iteration}"
52+
end
53+
54+
def file_list
55+
Dir.glob(PACKAGE_GLOB)
56+
end
57+
58+
def name_version
59+
# String used by respective package managers to install the specific version of the package
60+
Omnibus.load_configuration('omnibus.rb')
61+
project = Omnibus::Project.load('gitlab')
62+
packager = project.packagers_for_system[0]
63+
64+
case packager
65+
when Omnibus::Packager::DEB
66+
"#{Build::Info::Package.name}=#{packager.safe_version}-#{packager.safe_build_iteration}"
67+
when Omnibus::Packager::RPM
68+
"#{Build::Info::Package.name}-#{packager.safe_version}-#{packager.safe_build_iteration}#{packager.dist_tag}"
69+
else
70+
raise "Unable to detect version"
71+
end
72+
end
73+
end
74+
end
75+
end
76+
end

lib/gitlab/build/qa.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def self.checkout_gitlab_rails
2929
# a to-and-fro `cd`).
3030
version = Build::Info.gitlab_rails_ref
3131

32-
puts "Building from #{Build::Info.package} commit #{version}"
32+
puts "Building from #{Build::Info::Package.name} commit #{version}"
3333

3434
system(*%W[git --git-dir=#{repo_path}/.git --work-tree=#{repo_path} checkout --quiet #{version}])
3535
end

lib/gitlab/build/rat/nightly.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def self.get_params(image: nil)
2020
'token' => Gitlab::Util.get_env('RAT_TRIGGER_TOKEN'),
2121
'variables[REFERENCE_ARCHITECTURE]' => Gitlab::Util.get_env('RAT_REFERENCE_ARCHITECTURE') || 'omnibus-gitlab-mrs',
2222
'variables[NIGHTLY]' => "true",
23-
'variables[PACKAGE_VERSION]' => Build::Info.name_version,
23+
'variables[PACKAGE_VERSION]' => Build::Info::Package.name_version,
2424
'variables[QA_IMAGE]' => Gitlab::Util.get_env('QA_IMAGE') || image || 'gitlab/gitlab-ee-qa:nightly'
2525
}
2626
end

0 commit comments

Comments
 (0)