Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Updated sqitch version to 1.4.1 in omnibus package #3962

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions omnibus/config/software/sqitch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# Copyright 2014 Chef Software, Inc.
#
# 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 "sqitch"
default_version "1.4.1"

skip_transitive_dependency_licensing true

license "MIT"
license_file "https://raw.githubusercontent.com/theory/sqitch/master/README.md"

dependency "perl"
dependency "cpanminus"

# install a LGPL-licensed version of libintl-perl:
dependency "libintl-perl"

# version_list: url=https://github.com/theory/#{name}/releases/download/v#{version}/ filter=app-sqitch-*.tar.gz
version("1.4.1") { source sha256: "caf31cc8f772e3a4c9d4b3ff3a8f684a6eb5b1b3c261f4ddc0f90a88c36007c6" }
version("1.4.0") { source sha256: "b0db387031f77562662e003bc55d7a102a26380b4ad7fdb9a8a3bad5769e501c" }
version("1.3.1") { source sha256: "f5e768d298cd4047ee2ae42319782e8c2cda312737bcbdbfaf580bd47efe8b94" }
version("1.3.0") { source sha256: "7d07635ec77a7faf3c50281c76ec833c68702f14470996cb2203a8bc6abc5bf2" }
version("1.2.1") { source sha256: "020835a13429effd8fda12d5627604ecf99293775918f4f8ba9ccc5ed796e5e7" }
version("1.1.0") { source sha256: "ee146cd75d6300837e6ca559bb0bde247d42123c96b2c5d4b2800f38d3e3d1ab" }
version("0.9999") { source sha256: "f5bfa80206738ab8a70358a3b0557661c7459e11ec07dece23ecafa1f34372b3" }
version("0.973") { source sha256: "95fc7f18fff786c5d2579133e2e3ac56779e54bb3a06a1af1117054e9f49ab32" }

if version >= "1.1.0"
source url: "https://github.com/theory/#{name}/releases/download/v#{version}/app-sqitch-v#{version}.tar.gz"
internal_source url: "#{ENV["ARTIFACTORY_REPO_URL"]}/#{name}/#{name}-#{version}.tar.gz",
authorization: "X-JFrog-Art-Api:#{ENV["ARTIFACTORY_TOKEN"]}"
relative_path "App-Sqitch-v#{version}"
else
source url: "https://github.com/theory/#{name}/releases/download/v#{version}/app-sqitch-#{version}.tar.gz"
internal_source url: "#{ENV["ARTIFACTORY_REPO_URL"]}/#{name}/#{name}-#{version}.tar.gz",
authorization: "X-JFrog-Art-Api:#{ENV["ARTIFACTORY_TOKEN"]}"
relative_path "App-Sqitch-#{version}"
end

# See https://github.com/theory/sqitch for more
build do
env = with_standard_compiler_flags(with_embedded_path)
# Lists-MoreUtils-XS does not build on RHEL 5 or SUSE 11 currently.
# This option is used by the Lists-MoreUtils build configuration to
# decide whether to use the -XS package or a pure perl
# implementation.
env["PERL_MM_OPT"] = "PUREPERL_ONLY=1"
command "perl Build.PL", env: env
command "./Build installdeps --cpan_client 'cpanm -v --notest'", env: env
command "./Build", env: env
command "./Build install", env: env

# Here is another licensing fun. Some of the dependencies of sqitch
# unfortunately have GPL3 and LGPL3 licenses which are requiring us to remove
# them from our packages after installing sqitch. Here we are uninstalling
# them without breaking the licensing information collection.
%w{Test-MockModule}.each do |package_name|
module_name = package_name.gsub("-", "::")

# Here we run cpanm --uninstall with a different PERL_CPANM_HOME. The reason
# for this is to keep the licensing information for sqitch intact. The way
# license_scout works is to look into PERL_CPANM_HOME/latest-build (by
# default ~/.cpanm/latest-build) which contains the modules installed during
# the last install. This directory is a symlink that points to the directory
# contains the information about the latest build. Without changing
# PERL_CPANM_HOME we would overwrite the link and will not be able to
# collect the dependencies installed to our package while doing the actual
# sqitch install.
Dir.mktmpdir do |tmpdir|
command "cpanm --force --uninstall #{module_name}", env: env.merge({
"PERL_CPANM_HOME" => tmpdir,
})
end

# Here we are removing the problematic package from the original
# PERL_CPANM_HOME cache directory. This ensures that we do not add
# licensing information about these components to our package.
cpanm_root = File.expand_path("~/.cpanm/latest-build")
delete "#{cpanm_root}/#{package_name}*"
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
converge_by "Deploying schema from #{new_resource.name}" do
execute "sqitch_deploy_#{new_resource.name}" do
command <<-EOM.gsub(/\s+/, ' ').strip!
sqitch --engine pg
--db-name #{new_resource.database}
sqitch --db-name #{new_resource.database}
--db-host #{new_resource.hostname}
--db-port #{new_resource.port}
--db-user #{new_resource.username}
--top-dir #{new_resource.name}
--chdir #{new_resource.name}
deploy #{target} --verify
EOM
environment 'PERL5LIB' => "/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/lib", # force us to use omnibus perl
Expand Down
5 changes: 2 additions & 3 deletions omnibus/partybus/lib/partybus/migration_api/v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ def run_command(command, options={})
def run_sqitch(target, service, opts = {})
options = default_opts_for_service(service).merge(opts)
command = <<-EOM.gsub(/\s+/," ").strip!
sqitch --engine pg
--db-name #{options[:database]}
sqitch --db-name #{options[:database]}
--db-host #{Partybus.config.postgres['vip']}
--db-port #{Partybus.config.postgres['port']}
--db-user #{options[:username]}
--top-dir /opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/service/#{options[:path]}
--chdir /opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/service/#{options[:path]}
deploy #{target} --verify
EOM
run_command(command, env: {"PGPASSWORD" => options[:password]})
Expand Down
2 changes: 1 addition & 1 deletion omnibus_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
override :perl, version: "5.34.0"
override :redis, version: "5.0.14"
override :runit, version: "2.1.1" #standalone upgrade is failing, Needs to be reverted to 2.1.2 after fixing the umbrella
override :sqitch, version: "0.973"
# override :sqitch, version: "1.4.0"

override :logrotate, version: "3.19.0"

Expand Down
2 changes: 1 addition & 1 deletion src/bookshelf/habitat/config/database-migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ createdb $PG_ARGS $DB "bookshelf"
psql $PG_ARGS --command 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"' $DB

cd "{{pkg.path}}/schema" || exit
sqitch --quiet --engine pg deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
sqitch --quiet deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
3 changes: 2 additions & 1 deletion src/bookshelf/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ pkg_deps=(
core/cacerts
core/coreutils
core/gcc-libs
core/sqitch_pg
core/sqitch
core/postgresql-client
)
pkg_build_deps=(core/make core/git core/gcc)
pkg_bin_dirs=(bin)
Expand Down
3 changes: 2 additions & 1 deletion src/oc-id/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pkg_origin=chef
pkg_maintainer="The Chef Server Maintainers <[email protected]>"
pkg_license=('Apache-2.0')
pkg_deps=(
core/sqitch_pg
core/sqitch
core/postgresql-client
core/curl
core/node14
core/ruby31/3.1.6/20240912144513
Expand Down
2 changes: 1 addition & 1 deletion src/oc_bifrost/habitat/config/database-migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ createdb $PG_ARGS $DB "oc_bifrost"
psql $PG_ARGS --command 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"' $DB

cd "{{pkg.path}}/schema" || exit
sqitch --quiet --engine pg deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
sqitch --quiet deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
3 changes: 2 additions & 1 deletion src/oc_bifrost/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pkg_deps=(
core/coreutils
core/curl
core/gcc-libs
core/sqitch_pg
core/sqitch
core/postgresql-client
)
pkg_build_deps=(core/make core/git core/gcc)
pkg_bin_dirs=(bin)
Expand Down
2 changes: 1 addition & 1 deletion src/oc_bifrost/schema/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setup:
@createdb $(TEST_DB)
@psql --dbname $(TEST_DB) --command 'CREATE EXTENSION pgtap;'
@psql --dbname $(TEST_DB) --single-transaction --set ON_ERROR_STOP=1 --file t/custom_test_functions.sql
@sqitch --engine pg --db-name $(TEST_DB) deploy
@sqitch --db-name $(TEST_DB) deploy
@psql --dbname $(TEST_DB) --single-transaction --set ON_ERROR_STOP=1 --file sql/create_roles.sql
@psql --dbname $(TEST_DB) --single-transaction --set ON_ERROR_STOP=1 --set database_name=$(TEST_DB) --file sql/permissions.sql

Expand Down
4 changes: 2 additions & 2 deletions src/oc_erchef/habitat/config/database-migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ createdb $PG_ARGS $DB "oc_bifrost"
psql $PG_ARGS --command 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"' $DB

cd "{{pkg.path}}/schema/baseline"
sqitch --quiet --engine pg deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
sqitch --quiet deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"

cd "{{pkg.path}}/schema"
sqitch --quiet --engine pg deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
sqitch --quiet deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
3 changes: 2 additions & 1 deletion src/oc_erchef/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ pkg_deps=(
core/openssl
core/gcc-libs
core/ruby31/3.1.6/20240912144513
core/sqitch_pg
core/sqitch
core/postgresql-client
core/gecode
core/libffi
core/glibc
Expand Down
2 changes: 1 addition & 1 deletion src/oc_erchef/schema/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ all : setup_schema setup_tests test
setup_schema:
$(MAKE) -C baseline setup_schema
@echo "Deploying Enterprise Chef Server Schema on top..."
@sqitch --engine pg --db-name $(TEST_DB) deploy --verify
@sqitch --db-name $(TEST_DB) deploy --verify

# Load up all testing functions. pgTAP libraries and open source
# schema test functions are loaded by the open source makefile target
Expand Down
2 changes: 1 addition & 1 deletion src/oc_erchef/schema/baseline/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setup_schema:
@echo "Dropping and recreating database '$(TEST_DB)'"
@psql --dbname template1 --command 'DROP DATABASE IF EXISTS $(TEST_DB)'
@createdb $(TEST_DB)
@sqitch --engine pg --db-name $(TEST_DB) deploy
@sqitch --db-name $(TEST_DB) deploy

setup_tests:
@psql --dbname $(TEST_DB) --command 'CREATE EXTENSION pgtap;'
Expand Down
Loading