Skip to content

Commit 62bbf8a

Browse files
patapenka-alexeybigbes
authored andcommitted
cartridge: remove from build, pack
This patch removes cartridge support from `build` and `pack` commands. Closes TNTP-6976
1 parent 611e830 commit 62bbf8a

File tree

13 files changed

+45
-626
lines changed

13 files changed

+45
-626
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ for machine-readable output.
1919
- `tt init`: tarantoolctl support removed.
2020
- tarantoolctl layout is no longer supported.
2121
- `tt init/create`: cartridge support removed.
22+
- `tt build/pack`: cartridge support removed.
2223

2324
### Fixed
2425

cli/build/local.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const (
2020

2121
var (
2222
// PreBuildScripts is a list of pre-build script names.
23-
PreBuildScripts = []string{"tt.pre-build", "cartridge.pre-build"}
23+
PreBuildScripts = []string{"tt.pre-build"}
2424
// PostBuildScripts is a list of post-build script names.
25-
PostBuildScripts = []string{"tt.post-build", "cartridge.post-build"}
25+
PostBuildScripts = []string{"tt.post-build"}
2626
)
2727

2828
// runBuildHook runs first existing executable from hookNames list.

cli/build/local_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func TestRunHooks(t *testing.T) {
3131
assert.NoError(t, os.Remove(filepath.Join(workDir, "tt.post-build")))
3232

3333
require.NoError(t, runBuildHook(&buildCtx, PreBuildScripts))
34-
assert.FileExists(t, filepath.Join(workDir, "cartridge-pre-build-invoked"))
34+
assert.NoFileExists(t, filepath.Join(workDir, "cartridge-pre-build-invoked"))
3535
assert.NoFileExists(t, filepath.Join(workDir, "tt-pre-build-invoked"))
3636

3737
require.NoError(t, runBuildHook(&buildCtx, PostBuildScripts))
38-
assert.FileExists(t, filepath.Join(workDir, "cartridge-post-build-invoked"))
38+
assert.NoFileExists(t, filepath.Join(workDir, "cartridge-post-build-invoked"))
3939
assert.NoFileExists(t, filepath.Join(workDir, "tt-post-build-invoked"))
4040
}
4141

cli/cmd/pack.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ The supported types are: tgz, deb, rpm`,
4141
"tt and tcm binaries to the result package")
4242
packCmd.Flags().BoolVar(&packCtx.WithBinaries, "with-binaries", packCtx.WithoutBinaries,
4343
"Include tarantool, tt and tcm binaries to the result package")
44-
packCmd.Flags().BoolVar(&packCtx.CartridgeCompat, "cartridge-compat", false,
45-
"Pack cartridge cli compatible archive (only for tgz type)")
4644
packCmd.Flags().BoolVar(&packCtx.WithoutModules, "without-modules",
4745
packCtx.WithoutModules, "Don't include external modules to the result package")
4846

cli/init/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func Run(initCtx *InitCtx) error {
156156

157157
var sourceCfg configData
158158

159-
if !util.IsApp(".") && sourceCfg.instancesEnabled == "" {
159+
if !util.IsApp(".") {
160160
// Current directory is not app dir, instances enabled dir will be used.
161161
sourceCfg.instancesEnabled = configure.InstancesEnabledDirName
162162
}

cli/pack/common.go

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ func getAppNamesToPack(packCtx *PackCtx, cliOpts *config.CliOpts) []string {
199199

200200
// updateEnvPath sets base path for the tt environment in temporary package directory.
201201
// By default it is a base directory passed as an argument. Or an application name sub-dir
202-
// in case of cartridge compat or single application environment.
202+
// in case of single application environment.
203203
func updateEnvPath(basePath string, packCtx *PackCtx, cliOpts *config.CliOpts) (string, error) {
204-
if cliOpts.Env.InstancesEnabled == "." || packCtx.CartridgeCompat {
204+
if cliOpts.Env.InstancesEnabled == "." {
205205
basePath = util.JoinPaths(basePath, packCtx.Name)
206206
if err := os.MkdirAll(basePath, dirPermissions); err != nil {
207207
return basePath, fmt.Errorf("cannot create bundle directory %q: %s", basePath, err)
@@ -212,7 +212,7 @@ func updateEnvPath(basePath string, packCtx *PackCtx, cliOpts *config.CliOpts) (
212212

213213
// copyEnvModules copies tt modules.
214214
func copyEnvModules(bundleEnvPath string, packCtx *PackCtx, cliOpts, newOpts *config.CliOpts) {
215-
if packCtx.WithoutModules || packCtx.CartridgeCompat || cliOpts.Modules == nil ||
215+
if packCtx.WithoutModules || cliOpts.Modules == nil ||
216216
len(cliOpts.Modules.Directories) == 0 {
217217

218218
return
@@ -253,11 +253,7 @@ func copyBinaries(bundleEnvPath string, packCtx *PackCtx, cmdCtx *cmdcontext.Cmd
253253
return nil
254254
}
255255

256-
pkgBin := bundleEnvPath
257-
if !packCtx.CartridgeCompat {
258-
// In cartridge compat mode copy binaries directly to the env dir.
259-
pkgBin = util.JoinPaths(bundleEnvPath, newOpts.Env.BinDir)
260-
}
256+
pkgBin := util.JoinPaths(bundleEnvPath, newOpts.Env.BinDir)
261257

262258
if err := os.MkdirAll(pkgBin, dirPermissions); err != nil {
263259
return fmt.Errorf("failed to create binaries directory in bundle: %s", err)
@@ -300,7 +296,7 @@ func copyBinaries(bundleEnvPath string, packCtx *PackCtx, cmdCtx *cmdcontext.Cmd
300296
func getDestAppDir(bundleEnvPath, appName string,
301297
packCtx *PackCtx, cliOpts *config.CliOpts,
302298
) string {
303-
if packCtx.CartridgeCompat || cliOpts.Env.InstancesEnabled == "." {
299+
if cliOpts.Env.InstancesEnabled == "." {
304300
return bundleEnvPath
305301
}
306302
return filepath.Join(bundleEnvPath, appName)
@@ -334,7 +330,7 @@ func copyApplications(bundleEnvPath string, packCtx *PackCtx,
334330
}
335331
}
336332

337-
if !packCtx.CartridgeCompat && newOpts.Env.InstancesEnabled != "." {
333+
if newOpts.Env.InstancesEnabled != "." {
338334
// Create applications symlink in instances enabled.
339335
if err = os.MkdirAll(util.JoinPaths(bundleEnvPath, newOpts.Env.InstancesEnabled),
340336
dirPermissions); err != nil {
@@ -418,18 +414,6 @@ func prepareBundle(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx,
418414
}
419415
}
420416

421-
if packCtx.CartridgeCompat {
422-
// Generate VERSION file.
423-
if err := generateVersionFile(bundleEnvPath, cmdCtx, packCtx); err != nil {
424-
log.Warnf("Failed to generate VERSION file: %s", err)
425-
}
426-
427-
// Generate VERSION.lua file.
428-
if err := generateVersionLuaFile(bundleEnvPath, packCtx); err != nil {
429-
log.Warnf("Failed to generate VERSION.lua file: %s", err)
430-
}
431-
}
432-
433417
if packCtx.Archive.All {
434418
if err = copyArtifacts(*packCtx, bundleEnvPath, newOpts, packCtx.AppsInfo); err != nil {
435419
return "", fmt.Errorf("failed copying artifacts: %s", err)
@@ -443,7 +427,7 @@ func prepareBundle(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx,
443427
}
444428
}
445429

446-
writeEnv(newOpts, bundleEnvPath, packCtx.CartridgeCompat)
430+
writeEnv(newOpts, bundleEnvPath)
447431
if err != nil {
448432
return "", err
449433
}
@@ -487,7 +471,7 @@ func copyArtifacts(packCtx PackCtx, basePath string, newOpts *config.CliOpts,
487471
for _, inst := range appsInfo[appName] {
488472
appDirName := filepath.Base(inst.AppDir)
489473
destAppDir := util.JoinPaths(basePath, newOpts.Env.InstancesEnabled, appDirName)
490-
if packCtx.CartridgeCompat || newOpts.Env.InstancesEnabled == "." {
474+
if newOpts.Env.InstancesEnabled == "." {
491475
destAppDir = basePath
492476
}
493477

@@ -571,16 +555,11 @@ func createNewOpts(opts *config.CliOpts, packCtx PackCtx) *config.CliOpts {
571555
cliOptsNew.App.WalDir = configure.VarWalPath
572556
}
573557

574-
if packCtx.CartridgeCompat {
575-
cliOptsNew.Env.InstancesEnabled = "."
576-
cliOptsNew.Env.BinDir = "."
577-
}
578-
579558
return cliOptsNew
580559
}
581560

582561
// writeEnv writes CLI options to a tt.yaml file.
583-
func writeEnv(cliOpts *config.CliOpts, destPath string, cartridgeCompat bool) error {
562+
func writeEnv(cliOpts *config.CliOpts, destPath string) error {
584563
file, err := os.Create(filepath.Join(destPath, configure.ConfigName))
585564
if err != nil {
586565
return err
@@ -645,7 +624,7 @@ func cleanupAfterBuild(appDir string) {
645624
func buildAppRocks(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx,
646625
cliOpts *config.CliOpts, bundlePath string,
647626
) error {
648-
if cliOpts.Env.InstancesEnabled == "." || packCtx.CartridgeCompat {
627+
if cliOpts.Env.InstancesEnabled == "." {
649628
if err := buildAppInBundle(cmdCtx, cliOpts, bundlePath); err != nil {
650629
return err
651630
}
@@ -668,32 +647,19 @@ func buildAppRocks(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx,
668647
// getVersion returns a version of the package.
669648
// The version depends on passed pack context.
670649
func getVersion(packCtx *PackCtx, opts *config.CliOpts, defaultVersion string) string {
671-
packageVersion := defaultVersion
672-
if packCtx.Version == "" {
673-
// Get version from git only if packing an application from the current directory,
674-
// or packing with cartridge-compat enabled.
675-
appPath := opts.Env.InstancesEnabled
676-
if opts.Env.InstancesEnabled != "." && packCtx.CartridgeCompat {
677-
appPath = filepath.Join(appPath, packCtx.Name)
678-
}
679-
if opts.Env.InstancesEnabled == "." || packCtx.CartridgeCompat {
680-
version, err := util.CheckVersionFromGit(appPath)
681-
if err == nil {
682-
packageVersion = version
683-
if packCtx.CartridgeCompat {
684-
if normalVersion, err := normalizeGitVersion(packageVersion); err == nil {
685-
packageVersion = normalVersion
686-
}
687-
}
688-
}
689-
}
690-
if packCtx.CartridgeCompat {
691-
packCtx.Version = packageVersion
650+
if packCtx.Version != "" {
651+
return packCtx.Version
652+
}
653+
654+
// Try to get version from git only if packing an application from the current directory.
655+
if opts.Env.InstancesEnabled == "." {
656+
version, err := util.CheckVersionFromGit(opts.Env.InstancesEnabled)
657+
if err == nil {
658+
return version
692659
}
693-
} else {
694-
packageVersion = packCtx.Version
695660
}
696-
return packageVersion
661+
662+
return defaultVersion
697663
}
698664

699665
// normalizeGitVersion edits raw version from `git describe` command.
@@ -742,11 +708,6 @@ func getPackageFileName(packCtx *PackCtx, opts *config.CliOpts, suffix string,
742708
var packageName string
743709

744710
if packCtx.FileName != "" {
745-
if packCtx.CartridgeCompat {
746-
// Need to collect info about version
747-
// for generating VERSION and VERSION.lua files.
748-
getVersion(packCtx, opts, defaultLongVersion)
749-
}
750711
return packCtx.FileName, nil
751712
} else if packCtx.Name != "" {
752713
packageName = packCtx.Name

cli/pack/common_test.go

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -557,108 +557,6 @@ func Test_prepareBundle(t *testing.T) {
557557
{assert.NoDirExists, "instances.enabled/script_app/var/run"},
558558
},
559559
},
560-
{
561-
name: "Packing cartridge compat",
562-
params: params{
563-
configPath: "testdata/env1/tt.yaml",
564-
tntExecutable: "testdata/env1/bin/tarantool",
565-
packCtx: PackCtx{
566-
AppList: []string{"multi"},
567-
CartridgeCompat: true,
568-
Archive: ArchiveCtx{},
569-
TarantoolIsSystem: false,
570-
},
571-
},
572-
wantErr: false,
573-
checks: []check{
574-
// Root.
575-
{assert.NoDirExists, "instances.enabled"},
576-
{assert.NoDirExists, "include"},
577-
{assert.NoDirExists, "modules"},
578-
{assert.NoDirExists, "var"},
579-
{assert.NoFileExists, "tt.yaml"},
580-
581-
// Multi-inst app.
582-
{assert.DirExists, "multi"},
583-
{assert.FileExists, "multi/init.lua"},
584-
{assert.FileExists, "multi/instances.yaml"},
585-
{assert.FileExists, "multi/tt.yaml"},
586-
{assert.FileExists, "multi/tarantool"},
587-
{assert.FileExists, "multi/tt"},
588-
{assert.NoDirExists, "multi/var/lib/"},
589-
{assert.NoDirExists, "multi/var/log/"},
590-
},
591-
},
592-
{
593-
name: "Packing cartridge compat, no tarantool executable",
594-
params: params{
595-
configPath: "testdata/env1/tt.yaml",
596-
tntExecutable: "",
597-
packCtx: PackCtx{
598-
AppList: []string{"multi"},
599-
CartridgeCompat: true,
600-
Archive: ArchiveCtx{},
601-
TarantoolIsSystem: false,
602-
},
603-
},
604-
wantErr: false,
605-
checks: []check{
606-
// Root.
607-
{assert.NoDirExists, "instances.enabled"},
608-
{assert.NoDirExists, "include"},
609-
{assert.NoDirExists, "modules"},
610-
{assert.NoDirExists, "var"},
611-
{assert.NoFileExists, "tt.yaml"},
612-
613-
// Multi-inst app.
614-
{assert.DirExists, "multi"},
615-
{assert.FileExists, "multi/init.lua"},
616-
{assert.FileExists, "multi/instances.yaml"},
617-
{assert.FileExists, "multi/tt.yaml"},
618-
{assert.NoFileExists, "multi/tarantool"},
619-
{assert.NoDirExists, "multi/tarantool"},
620-
{assert.FileExists, "multi/tt"},
621-
{assert.NoDirExists, "multi/var/lib/"},
622-
{assert.NoDirExists, "multi/var/log/"},
623-
},
624-
},
625-
{
626-
name: "Packing cartridge compat with artifacts",
627-
params: params{
628-
configPath: "testdata/env1/tt.yaml",
629-
tntExecutable: "testdata/env1/bin/tarantool",
630-
packCtx: PackCtx{
631-
AppList: []string{"multi"},
632-
CartridgeCompat: true,
633-
Archive: ArchiveCtx{
634-
All: true,
635-
},
636-
TarantoolIsSystem: false,
637-
},
638-
},
639-
wantErr: false,
640-
checks: []check{
641-
// Root.
642-
{assert.NoDirExists, "instances.enabled"},
643-
{assert.NoDirExists, "include"},
644-
{assert.NoDirExists, "modules"},
645-
{assert.NoDirExists, "var"},
646-
{assert.NoFileExists, "tt.yaml"},
647-
648-
// Multi-inst app.
649-
{assert.DirExists, "multi"},
650-
{assert.FileExists, "multi/init.lua"},
651-
{assert.FileExists, "multi/instances.yaml"},
652-
{assert.FileExists, "multi/tt.yaml"},
653-
{assert.FileExists, "multi/tarantool"},
654-
{assert.FileExists, "multi/var/lib/inst1/00000000000000000000.snap"},
655-
{assert.FileExists, "multi/var/lib/inst1/00000000000000000000.xlog"},
656-
{assert.FileExists, "multi/var/lib/inst2/00000000000000000000.snap"},
657-
{assert.FileExists, "multi/var/lib/inst2/00000000000000000000.xlog"},
658-
{assert.FileExists, "multi/var/log/inst1/tt.log"},
659-
{assert.FileExists, "multi/var/log/inst2/tt.log"},
660-
},
661-
},
662560
{
663561
name: "Packing env with instances.enabled:.",
664562
params: params{
@@ -792,42 +690,6 @@ func Test_prepareBundle(t *testing.T) {
792690
{assert.FileExists, "single_app_no_binaries/tt.yaml"},
793691
},
794692
},
795-
{
796-
name: "Packing env with CartridgeCompat and instances.enabled:.",
797-
params: params{
798-
configPath: "testdata/single_app/tt.yml",
799-
tntExecutable: "testdata/single_app/bin/tarantool",
800-
packCtx: PackCtx{
801-
TarantoolIsSystem: false,
802-
CartridgeCompat: true,
803-
},
804-
},
805-
wantErr: false,
806-
checks: []check{
807-
{assert.NoDirExists, "instances.enabled"},
808-
{assert.NoFileExists, "tt.yaml"},
809-
{assert.NoFileExists, "tt.yml"},
810-
{assert.NoDirExists, "include"},
811-
812-
{assert.NoDirExists, "single_app/instances.enabled"},
813-
{assert.NoDirExists, "single_app/include"},
814-
{assert.NoDirExists, "single_app/templates"},
815-
{assert.NoDirExists, "single_app/modules"},
816-
{assert.NoDirExists, "single_app/templates"},
817-
{assert.NoDirExists, "single_app/distfiles"},
818-
{assert.NoFileExists, "single_app/bin/tarantool"},
819-
{assert.NoFileExists, "single_app/bin/tt"},
820-
{assert.FileExists, "single_app/init.lua"},
821-
{assert.FileExists, "single_app/tt.yaml"},
822-
{assert.FileExists, "single_app/VERSION.lua"},
823-
{assert.FileExists, "single_app/VERSION"},
824-
{assert.NoFileExists, "single_app/tt.yml"},
825-
{assert.NoFileExists, "single_app/single_app_0.1.0.0-1_x86_64.deb"},
826-
{assert.NoFileExists, "single_app/single_app-0.1.0.0-1.x86_64.rpm"},
827-
{assert.NoFileExists, "single_app/single_app-0.1.0.0.x86_64.tar.gz"},
828-
{assert.FileExists, "single_app/single_app-0.1.0.0.x86_64.zip"},
829-
},
830-
},
831693
{
832694
name: "Packing app and build rocks",
833695
params: params{
@@ -858,8 +720,6 @@ func Test_prepareBundle(t *testing.T) {
858720
{assert.NoFileExists, "app_with_rockspec/app_with_rockspec-scm-1.rockspec"},
859721
{assert.NoFileExists, "app_with_rockspec/tt.pre-build"},
860722
{assert.NoFileExists, "app_with_rockspec/tt.post-build"},
861-
{assert.NoFileExists, "app_with_rockspec/cartridge.pre-build"},
862-
{assert.NoFileExists, "app_with_rockspec/cartridge.post-build"},
863723
},
864724
},
865725
{
@@ -893,8 +753,6 @@ func Test_prepareBundle(t *testing.T) {
893753
{assert.NoFileExists, "app/app_with_rockspec-scm-1.rockspec"},
894754
{assert.NoFileExists, "app/tt.pre-build"},
895755
{assert.NoFileExists, "app/tt.post-build"},
896-
{assert.NoFileExists, "app/cartridge.pre-build"},
897-
{assert.NoFileExists, "app/cartridge.post-build"},
898756
},
899757
},
900758
{

0 commit comments

Comments
 (0)