mirror of
https://github.com/mudler/luet.git
synced 2025-09-06 01:30:29 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
43db64c089 | ||
|
9423b7c1e3 | ||
|
75dbc2dcb4 | ||
|
f3e2e0a184 | ||
|
8237506bd3 | ||
|
9784d6192a | ||
|
87004c8e78 | ||
|
0fe30ddcfd | ||
|
44d33eceba |
32
cmd/build.go
32
cmd/build.go
@@ -36,8 +36,30 @@ import (
|
|||||||
var buildCmd = &cobra.Command{
|
var buildCmd = &cobra.Command{
|
||||||
Use: "build <package name> <package name> <package name> ...",
|
Use: "build <package name> <package name> <package name> ...",
|
||||||
Short: "build a package or a tree",
|
Short: "build a package or a tree",
|
||||||
Long: `build packages or trees from luet tree definitions. Packages are in [category]/[name]-[version] form`,
|
Long: `Builds one or more packages from a tree (current directory is implied):
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
|
||||||
|
$ luet build utils/busybox utils/yq ...
|
||||||
|
|
||||||
|
Builds all packages
|
||||||
|
|
||||||
|
$ luet build --all
|
||||||
|
|
||||||
|
Builds only the leaf packages:
|
||||||
|
|
||||||
|
$ luet build --full
|
||||||
|
|
||||||
|
Build package revdeps:
|
||||||
|
|
||||||
|
$ luet build --revdeps utils/yq
|
||||||
|
|
||||||
|
Build package without dependencies (needs the images already in the host, or either need to be available online):
|
||||||
|
|
||||||
|
$ luet build --nodeps utils/yq ...
|
||||||
|
|
||||||
|
Build packages specifying multiple definition trees:
|
||||||
|
|
||||||
|
$ luet build --tree overlay/path --tree overlay/path2 utils/yq ...
|
||||||
|
`, PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
viper.BindPFlag("clean", cmd.Flags().Lookup("clean"))
|
viper.BindPFlag("clean", cmd.Flags().Lookup("clean"))
|
||||||
viper.BindPFlag("tree", cmd.Flags().Lookup("tree"))
|
viper.BindPFlag("tree", cmd.Flags().Lookup("tree"))
|
||||||
viper.BindPFlag("destination", cmd.Flags().Lookup("destination"))
|
viper.BindPFlag("destination", cmd.Flags().Lookup("destination"))
|
||||||
@@ -49,6 +71,7 @@ var buildCmd = &cobra.Command{
|
|||||||
viper.BindPFlag("compression", cmd.Flags().Lookup("compression"))
|
viper.BindPFlag("compression", cmd.Flags().Lookup("compression"))
|
||||||
viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
||||||
viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
||||||
|
viper.BindPFlag("values", cmd.Flags().Lookup("values"))
|
||||||
|
|
||||||
viper.BindPFlag("image-repository", cmd.Flags().Lookup("image-repository"))
|
viper.BindPFlag("image-repository", cmd.Flags().Lookup("image-repository"))
|
||||||
viper.BindPFlag("push", cmd.Flags().Lookup("push"))
|
viper.BindPFlag("push", cmd.Flags().Lookup("push"))
|
||||||
@@ -75,6 +98,8 @@ var buildCmd = &cobra.Command{
|
|||||||
databaseType := viper.GetString("database")
|
databaseType := viper.GetString("database")
|
||||||
compressionType := viper.GetString("compression")
|
compressionType := viper.GetString("compression")
|
||||||
imageRepository := viper.GetString("image-repository")
|
imageRepository := viper.GetString("image-repository")
|
||||||
|
values := viper.GetString("values")
|
||||||
|
|
||||||
push := viper.GetBool("push")
|
push := viper.GetBool("push")
|
||||||
pull := viper.GetBool("pull")
|
pull := viper.GetBool("pull")
|
||||||
keepImages := viper.GetBool("keep-images")
|
keepImages := viper.GetBool("keep-images")
|
||||||
@@ -157,7 +182,7 @@ var buildCmd = &cobra.Command{
|
|||||||
opts.KeepImageExport = keepExportedImages
|
opts.KeepImageExport = keepExportedImages
|
||||||
opts.SkipIfMetadataExists = skip
|
opts.SkipIfMetadataExists = skip
|
||||||
opts.PackageTargetOnly = onlyTarget
|
opts.PackageTargetOnly = onlyTarget
|
||||||
|
opts.BuildValuesFile = values
|
||||||
var solverOpts solver.Options
|
var solverOpts solver.Options
|
||||||
if concurrent {
|
if concurrent {
|
||||||
solverOpts = solver.Options{Type: solver.ParallelSimple, Concurrency: concurrency}
|
solverOpts = solver.Options{Type: solver.ParallelSimple, Concurrency: concurrency}
|
||||||
@@ -291,6 +316,7 @@ func init() {
|
|||||||
buildCmd.Flags().Bool("revdeps", false, "Build with revdeps")
|
buildCmd.Flags().Bool("revdeps", false, "Build with revdeps")
|
||||||
buildCmd.Flags().Bool("all", false, "Build all specfiles in the tree")
|
buildCmd.Flags().Bool("all", false, "Build all specfiles in the tree")
|
||||||
buildCmd.Flags().Bool("full", false, "Build all packages (optimized)")
|
buildCmd.Flags().Bool("full", false, "Build all packages (optimized)")
|
||||||
|
buildCmd.Flags().String("values", "", "Build values file to interpolate with each package")
|
||||||
|
|
||||||
buildCmd.Flags().String("destination", path, "Destination folder")
|
buildCmd.Flags().String("destination", path, "Destination folder")
|
||||||
buildCmd.Flags().String("compression", "none", "Compression alg: none, gzip")
|
buildCmd.Flags().String("compression", "none", "Compression alg: none, gzip")
|
||||||
|
@@ -20,6 +20,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
@@ -41,7 +42,41 @@ func CreateRegexArray(rgx []string) ([]*regexp.Regexp, error) {
|
|||||||
return ans, nil
|
return ans, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func packageData(p string) (string, string) {
|
||||||
|
cat := ""
|
||||||
|
name := ""
|
||||||
|
if strings.Contains(p, "/") {
|
||||||
|
packagedata := strings.Split(p, "/")
|
||||||
|
cat = packagedata[0]
|
||||||
|
name = packagedata[1]
|
||||||
|
} else {
|
||||||
|
name = p
|
||||||
|
}
|
||||||
|
return cat, name
|
||||||
|
}
|
||||||
func ParsePackageStr(p string) (*pkg.DefaultPackage, error) {
|
func ParsePackageStr(p string) (*pkg.DefaultPackage, error) {
|
||||||
|
|
||||||
|
if !strings.HasPrefix(p, "=") {
|
||||||
|
ver := ">=0"
|
||||||
|
cat := ""
|
||||||
|
name := ""
|
||||||
|
|
||||||
|
if strings.Contains(p, "@") {
|
||||||
|
packageinfo := strings.Split(p, "@")
|
||||||
|
ver = packageinfo[1]
|
||||||
|
cat, name = packageData(packageinfo[0])
|
||||||
|
} else {
|
||||||
|
cat, name = packageData(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pkg.DefaultPackage{
|
||||||
|
Name: name,
|
||||||
|
Category: cat,
|
||||||
|
Version: ver,
|
||||||
|
Uri: make([]string, 0),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
gp, err := _gentoo.ParsePackageStr(p)
|
gp, err := _gentoo.ParsePackageStr(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
32
cmd/helpers/cli_suite_test.go
Normal file
32
cmd/helpers/cli_suite_test.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright © 2019 Ettore Di Giacinto <mudler@gentoo.org>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package cmd_helpers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/mudler/luet/cmd"
|
||||||
|
config "github.com/mudler/luet/pkg/config"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSolver(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
LoadConfig(config.LuetCfg)
|
||||||
|
RunSpecs(t, "CLI helpers test Suite")
|
||||||
|
}
|
70
cmd/helpers/cli_test.go
Normal file
70
cmd/helpers/cli_test.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
// Copyright © 2019 Ettore Di Giacinto <mudler@gentoo.org>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package cmd_helpers_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/mudler/luet/cmd/helpers"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("CLI Helpers", func() {
|
||||||
|
Context("Can parse package strings correctly", func() {
|
||||||
|
It("accept single package names", func() {
|
||||||
|
pack, err := ParsePackageStr("foo")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pack.GetName()).To(Equal("foo"))
|
||||||
|
Expect(pack.GetCategory()).To(Equal(""))
|
||||||
|
Expect(pack.GetVersion()).To(Equal(">=0"))
|
||||||
|
})
|
||||||
|
It("accept unversioned packages with category", func() {
|
||||||
|
pack, err := ParsePackageStr("cat/foo")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pack.GetName()).To(Equal("foo"))
|
||||||
|
Expect(pack.GetCategory()).To(Equal("cat"))
|
||||||
|
Expect(pack.GetVersion()).To(Equal(">=0"))
|
||||||
|
})
|
||||||
|
It("accept versioned packages with category", func() {
|
||||||
|
pack, err := ParsePackageStr("cat/foo@1.1")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pack.GetName()).To(Equal("foo"))
|
||||||
|
Expect(pack.GetCategory()).To(Equal("cat"))
|
||||||
|
Expect(pack.GetVersion()).To(Equal("1.1"))
|
||||||
|
})
|
||||||
|
It("accept versioned ranges with category", func() {
|
||||||
|
pack, err := ParsePackageStr("cat/foo@>=1.1")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pack.GetName()).To(Equal("foo"))
|
||||||
|
Expect(pack.GetCategory()).To(Equal("cat"))
|
||||||
|
Expect(pack.GetVersion()).To(Equal(">=1.1"))
|
||||||
|
})
|
||||||
|
It("accept gentoo regex parsing without versions", func() {
|
||||||
|
pack, err := ParsePackageStr("=cat/foo")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pack.GetName()).To(Equal("foo"))
|
||||||
|
Expect(pack.GetCategory()).To(Equal("cat"))
|
||||||
|
Expect(pack.GetVersion()).To(Equal(">=0"))
|
||||||
|
})
|
||||||
|
It("accept gentoo regex parsing with versions", func() {
|
||||||
|
pack, err := ParsePackageStr("=cat/foo-1.2")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pack.GetName()).To(Equal("foo"))
|
||||||
|
Expect(pack.GetCategory()).To(Equal("cat"))
|
||||||
|
Expect(pack.GetVersion()).To(Equal("1.2"))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@@ -32,6 +32,22 @@ import (
|
|||||||
var installCmd = &cobra.Command{
|
var installCmd = &cobra.Command{
|
||||||
Use: "install <pkg1> <pkg2> ...",
|
Use: "install <pkg1> <pkg2> ...",
|
||||||
Short: "Install a package",
|
Short: "Install a package",
|
||||||
|
Long: `Installs one or more packages without asking questions:
|
||||||
|
|
||||||
|
$ luet install -y utils/busybox utils/yq ...
|
||||||
|
|
||||||
|
To install only deps of a package:
|
||||||
|
|
||||||
|
$ luet install --onlydeps utils/busybox ...
|
||||||
|
|
||||||
|
To not install deps of a package:
|
||||||
|
|
||||||
|
$ luet install --nodeps utils/busybox ...
|
||||||
|
|
||||||
|
To force install a package:
|
||||||
|
|
||||||
|
$ luet install --force utils/busybox ...
|
||||||
|
`,
|
||||||
Aliases: []string{"i"},
|
Aliases: []string{"i"},
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
||||||
@@ -45,7 +61,6 @@ var installCmd = &cobra.Command{
|
|||||||
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
||||||
},
|
},
|
||||||
Long: `Install packages in parallel`,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var toInstall pkg.Packages
|
var toInstall pkg.Packages
|
||||||
var systemDB pkg.PackageDatabase
|
var systemDB pkg.PackageDatabase
|
||||||
|
156
cmd/replace.go
Normal file
156
cmd/replace.go
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
// Copyright © 2020 Ettore Di Giacinto <mudler@mocaccino.org>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
|
"github.com/mudler/luet/pkg/solver"
|
||||||
|
|
||||||
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
. "github.com/mudler/luet/pkg/config"
|
||||||
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var replaceCmd = &cobra.Command{
|
||||||
|
Use: "replace <pkg1> <pkg2> --for <pkg3> --for <pkg4> ...",
|
||||||
|
Short: "replace a set of packages",
|
||||||
|
Aliases: []string{"r"},
|
||||||
|
Long: `Replaces one or a group of packages without asking questions:
|
||||||
|
|
||||||
|
$ luet replace -y system/busybox ... --for shells/bash --for system/coreutils ...
|
||||||
|
`,
|
||||||
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
||||||
|
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
||||||
|
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
||||||
|
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
||||||
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
|
LuetCfg.Viper.BindPFlag("for", cmd.Flags().Lookup("for"))
|
||||||
|
|
||||||
|
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
||||||
|
},
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
var toUninstall pkg.Packages
|
||||||
|
var toAdd pkg.Packages
|
||||||
|
var systemDB pkg.PackageDatabase
|
||||||
|
|
||||||
|
f := LuetCfg.Viper.GetStringSlice("for")
|
||||||
|
stype := LuetCfg.Viper.GetString("solver.type")
|
||||||
|
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
||||||
|
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
||||||
|
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
||||||
|
force := LuetCfg.Viper.GetBool("force")
|
||||||
|
nodeps := LuetCfg.Viper.GetBool("nodeps")
|
||||||
|
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
||||||
|
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
||||||
|
yes := LuetCfg.Viper.GetBool("yes")
|
||||||
|
|
||||||
|
for _, a := range args {
|
||||||
|
pack, err := helpers.ParsePackageStr(a)
|
||||||
|
if err != nil {
|
||||||
|
Fatal("Invalid package string ", a, ": ", err.Error())
|
||||||
|
}
|
||||||
|
toUninstall = append(toUninstall, pack)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range f {
|
||||||
|
pack, err := helpers.ParsePackageStr(a)
|
||||||
|
if err != nil {
|
||||||
|
Fatal("Invalid package string ", a, ": ", err.Error())
|
||||||
|
}
|
||||||
|
toAdd = append(toAdd, pack)
|
||||||
|
}
|
||||||
|
|
||||||
|
// This shouldn't be necessary, but we need to unmarshal the repositories to a concrete struct, thus we need to port them back to the Repositories type
|
||||||
|
repos := installer.Repositories{}
|
||||||
|
for _, repo := range LuetCfg.SystemRepositories {
|
||||||
|
if !repo.Enable {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
r := installer.NewSystemRepository(repo)
|
||||||
|
repos = append(repos, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
LuetCfg.GetSolverOptions().Type = stype
|
||||||
|
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
||||||
|
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
||||||
|
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
||||||
|
|
||||||
|
if concurrent {
|
||||||
|
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
||||||
|
} else {
|
||||||
|
LuetCfg.GetSolverOptions().Implementation = solver.SingleCoreSimple
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug("Solver", LuetCfg.GetSolverOptions().CompactString())
|
||||||
|
|
||||||
|
// Load config protect configs
|
||||||
|
installer.LoadConfigProtectConfs(LuetCfg)
|
||||||
|
|
||||||
|
inst := installer.NewLuetInstaller(installer.LuetInstallerOptions{
|
||||||
|
Concurrency: LuetCfg.GetGeneral().Concurrency,
|
||||||
|
SolverOptions: *LuetCfg.GetSolverOptions(),
|
||||||
|
NoDeps: nodeps,
|
||||||
|
Force: force,
|
||||||
|
OnlyDeps: onlydeps,
|
||||||
|
PreserveSystemEssentialData: true,
|
||||||
|
Ask: !yes,
|
||||||
|
})
|
||||||
|
inst.Repositories(repos)
|
||||||
|
|
||||||
|
if LuetCfg.GetSystem().DatabaseEngine == "boltdb" {
|
||||||
|
systemDB = pkg.NewBoltDatabase(
|
||||||
|
filepath.Join(LuetCfg.GetSystem().GetSystemRepoDatabaseDirPath(), "luet.db"))
|
||||||
|
} else {
|
||||||
|
systemDB = pkg.NewInMemoryDatabase(true)
|
||||||
|
}
|
||||||
|
system := &installer.System{Database: systemDB, Target: LuetCfg.GetSystem().Rootfs}
|
||||||
|
err := inst.Swap(toUninstall, toAdd, system)
|
||||||
|
if err != nil {
|
||||||
|
Fatal("Error: " + err.Error())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
path, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
Fatal(err)
|
||||||
|
}
|
||||||
|
replaceCmd.Flags().String("system-dbpath", path, "System db path")
|
||||||
|
replaceCmd.Flags().String("system-target", path, "System rootpath")
|
||||||
|
replaceCmd.Flags().String("solver-type", "", "Solver strategy ( Defaults none, available: "+AvailableResolvers+" )")
|
||||||
|
replaceCmd.Flags().Float32("solver-rate", 0.7, "Solver learning rate")
|
||||||
|
replaceCmd.Flags().Float32("solver-discount", 1.0, "Solver discount rate")
|
||||||
|
replaceCmd.Flags().Int("solver-attempts", 9000, "Solver maximum attempts")
|
||||||
|
replaceCmd.Flags().Bool("nodeps", false, "Don't consider package dependencies (harmful!)")
|
||||||
|
replaceCmd.Flags().Bool("onlydeps", false, "Consider **only** package dependencies")
|
||||||
|
replaceCmd.Flags().Bool("force", false, "Skip errors and keep going (potentially harmful)")
|
||||||
|
replaceCmd.Flags().Bool("solver-concurrent", false, "Use concurrent solver (experimental)")
|
||||||
|
replaceCmd.Flags().BoolP("yes", "y", false, "Don't ask questions")
|
||||||
|
replaceCmd.Flags().StringSlice("for", []string{}, "Packages that has to be installed in place of others")
|
||||||
|
|
||||||
|
RootCmd.AddCommand(replaceCmd)
|
||||||
|
}
|
@@ -40,7 +40,7 @@ var Verbose bool
|
|||||||
var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LuetCLIVersion = "0.9.7"
|
LuetCLIVersion = "0.9.9"
|
||||||
LuetEnvPrefix = "LUET"
|
LuetEnvPrefix = "LUET"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ var (
|
|||||||
// RootCmd represents the base command when called without any subcommands
|
// RootCmd represents the base command when called without any subcommands
|
||||||
var RootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
Use: "luet",
|
Use: "luet",
|
||||||
Short: "Package manager for the XXth century!",
|
Short: "Container based package manager",
|
||||||
Long: `Luet is a single-binary package manager based on containers to build packages.
|
Long: `Luet is a single-binary package manager based on containers to build packages.
|
||||||
|
|
||||||
To install a package:
|
To install a package:
|
||||||
|
@@ -23,6 +23,21 @@ var (
|
|||||||
// EventPackagePostBuild is the event fired after a package was built
|
// EventPackagePostBuild is the event fired after a package was built
|
||||||
EventPackagePostBuild pluggable.EventType = "package.post.build"
|
EventPackagePostBuild pluggable.EventType = "package.post.build"
|
||||||
|
|
||||||
|
// Image build
|
||||||
|
|
||||||
|
// EventImagePreBuild is the event fired before a image is being built
|
||||||
|
EventImagePreBuild pluggable.EventType = "image.pre.build"
|
||||||
|
// EventImagePrePull is the event fired before a image is being pulled
|
||||||
|
EventImagePrePull pluggable.EventType = "image.pre.pull"
|
||||||
|
// EventImagePrePush is the event fired before a image is being pushed
|
||||||
|
EventImagePrePush pluggable.EventType = "image.pre.push"
|
||||||
|
// EventImagePostBuild is the event fired after an image is being built
|
||||||
|
EventImagePostBuild pluggable.EventType = "image.post.build"
|
||||||
|
// EventImagePostPull is the event fired after an image is being pulled
|
||||||
|
EventImagePostPull pluggable.EventType = "image.post.pull"
|
||||||
|
// EventImagePostPush is the event fired after an image is being pushed
|
||||||
|
EventImagePostPush pluggable.EventType = "image.post.push"
|
||||||
|
|
||||||
// Repository events
|
// Repository events
|
||||||
|
|
||||||
// EventRepositoryPreBuild is the event fired before a repository is being built
|
// EventRepositoryPreBuild is the event fired before a repository is being built
|
||||||
@@ -42,5 +57,11 @@ var Manager *pluggable.Manager = pluggable.NewManager(
|
|||||||
EventPackagePostBuild,
|
EventPackagePostBuild,
|
||||||
EventRepositoryPreBuild,
|
EventRepositoryPreBuild,
|
||||||
EventRepositoryPostBuild,
|
EventRepositoryPostBuild,
|
||||||
|
EventImagePreBuild,
|
||||||
|
EventImagePrePull,
|
||||||
|
EventImagePrePush,
|
||||||
|
EventImagePostBuild,
|
||||||
|
EventImagePostPull,
|
||||||
|
EventImagePostPush,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@@ -96,6 +96,7 @@ ENV PACKAGE_CATEGORY=app-admin`))
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(dockerfile).To(Equal(`
|
Expect(dockerfile).To(Equal(`
|
||||||
FROM luet/base
|
FROM luet/base
|
||||||
|
WORKDIR /luetbuild
|
||||||
ENV PACKAGE_NAME=enman
|
ENV PACKAGE_NAME=enman
|
||||||
ENV PACKAGE_VERSION=1.4.0
|
ENV PACKAGE_VERSION=1.4.0
|
||||||
ENV PACKAGE_CATEGORY=app-admin
|
ENV PACKAGE_CATEGORY=app-admin
|
||||||
|
@@ -100,7 +100,7 @@ func (*SimpleDocker) DownloadImage(opts compiler.CompilerBackendOptions) error {
|
|||||||
cmd := exec.Command("docker", buildarg...)
|
cmd := exec.Command("docker", buildarg...)
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed building image: "+string(out))
|
return errors.Wrap(err, "Failed pulling image: "+string(out))
|
||||||
}
|
}
|
||||||
Info(":whale: Downloaded image:", name)
|
Info(":whale: Downloaded image:", name)
|
||||||
return nil
|
return nil
|
||||||
|
@@ -87,6 +87,7 @@ ENV PACKAGE_CATEGORY=app-admin`))
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(dockerfile).To(Equal(`
|
Expect(dockerfile).To(Equal(`
|
||||||
FROM luet/base
|
FROM luet/base
|
||||||
|
WORKDIR /luetbuild
|
||||||
ENV PACKAGE_NAME=enman
|
ENV PACKAGE_NAME=enman
|
||||||
ENV PACKAGE_VERSION=1.4.0
|
ENV PACKAGE_VERSION=1.4.0
|
||||||
ENV PACKAGE_CATEGORY=app-admin
|
ENV PACKAGE_CATEGORY=app-admin
|
||||||
|
@@ -27,6 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
bus "github.com/mudler/luet/pkg/bus"
|
bus "github.com/mudler/luet/pkg/bus"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"github.com/mudler/luet/pkg/helpers"
|
"github.com/mudler/luet/pkg/helpers"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
@@ -339,8 +340,6 @@ func (cs *LuetCompiler) buildPackageImage(image, buildertaggedImage, packageImag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info(pkgTag, ":whale: Generating 'builder' image definition from", image)
|
|
||||||
|
|
||||||
// First we create the builder image
|
// First we create the builder image
|
||||||
if err := p.WriteBuildImageDefinition(filepath.Join(buildDir, p.GetPackage().GetFingerPrint()+"-builder.dockerfile")); err != nil {
|
if err := p.WriteBuildImageDefinition(filepath.Join(buildDir, p.GetPackage().GetFingerPrint()+"-builder.dockerfile")); err != nil {
|
||||||
return builderOpts, runnerOpts, errors.Wrap(err, "Could not generate image definition")
|
return builderOpts, runnerOpts, errors.Wrap(err, "Could not generate image definition")
|
||||||
@@ -367,27 +366,38 @@ func (cs *LuetCompiler) buildPackageImage(image, buildertaggedImage, packageImag
|
|||||||
buildAndPush := func(opts CompilerBackendOptions) error {
|
buildAndPush := func(opts CompilerBackendOptions) error {
|
||||||
buildImage := true
|
buildImage := true
|
||||||
if cs.Options.PullFirst {
|
if cs.Options.PullFirst {
|
||||||
if err := cs.Backend.DownloadImage(opts); err == nil {
|
bus.Manager.Publish(bus.EventImagePrePull, opts)
|
||||||
|
err := cs.Backend.DownloadImage(opts)
|
||||||
|
if err == nil {
|
||||||
buildImage = false
|
buildImage = false
|
||||||
|
} else {
|
||||||
|
Warning("Failed to download '" + opts.ImageName + "'. Will keep going and build the image unless you use --fatal")
|
||||||
|
Warning(err.Error())
|
||||||
}
|
}
|
||||||
|
bus.Manager.Publish(bus.EventImagePostPull, opts)
|
||||||
}
|
}
|
||||||
if buildImage {
|
if buildImage {
|
||||||
|
bus.Manager.Publish(bus.EventImagePreBuild, opts)
|
||||||
if err := cs.Backend.BuildImage(opts); err != nil {
|
if err := cs.Backend.BuildImage(opts); err != nil {
|
||||||
return errors.Wrap(err, "Could not build image: "+image+" "+opts.DockerFileName)
|
return errors.Wrap(err, "Could not build image: "+image+" "+opts.DockerFileName)
|
||||||
}
|
}
|
||||||
|
bus.Manager.Publish(bus.EventImagePostBuild, opts)
|
||||||
if cs.Options.Push {
|
if cs.Options.Push {
|
||||||
|
bus.Manager.Publish(bus.EventImagePrePush, opts)
|
||||||
if err = cs.Backend.Push(opts); err != nil {
|
if err = cs.Backend.Push(opts); err != nil {
|
||||||
return errors.Wrap(err, "Could not push image: "+image+" "+opts.DockerFileName)
|
return errors.Wrap(err, "Could not push image: "+image+" "+opts.DockerFileName)
|
||||||
}
|
}
|
||||||
|
bus.Manager.Publish(bus.EventImagePostPush, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info(pkgTag, ":whale: Generating 'builder' image from", image, "as", buildertaggedImage, "with prelude steps")
|
||||||
if err := buildAndPush(builderOpts); err != nil {
|
if err := buildAndPush(builderOpts); err != nil {
|
||||||
return builderOpts, runnerOpts, errors.Wrap(err, "Could not push image: "+image+" "+builderOpts.DockerFileName)
|
return builderOpts, runnerOpts, errors.Wrap(err, "Could not push image: "+image+" "+builderOpts.DockerFileName)
|
||||||
}
|
}
|
||||||
|
Info(pkgTag, ":whale: Generating 'package' image from", buildertaggedImage, "as", packageImage, "with build steps")
|
||||||
if err := buildAndPush(runnerOpts); err != nil {
|
if err := buildAndPush(runnerOpts); err != nil {
|
||||||
return builderOpts, runnerOpts, errors.Wrap(err, "Could not push image: "+image+" "+builderOpts.DockerFileName)
|
return builderOpts, runnerOpts, errors.Wrap(err, "Could not push image: "+image+" "+builderOpts.DockerFileName)
|
||||||
}
|
}
|
||||||
@@ -743,13 +753,25 @@ func (cs *LuetCompiler) FromPackage(p pkg.Package) (CompilationSpec, error) {
|
|||||||
|
|
||||||
raw := packsRaw.Find(pack.GetName(), pack.GetCategory(), pack.GetVersion())
|
raw := packsRaw.Find(pack.GetName(), pack.GetCategory(), pack.GetVersion())
|
||||||
|
|
||||||
dat, err := helpers.RenderHelm(string(dataBuild), raw)
|
d := map[string]interface{}{}
|
||||||
|
if len(cs.Options.BuildValuesFile) > 0 {
|
||||||
|
defBuild, err := ioutil.ReadFile(cs.Options.BuildValuesFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rendering file "+val)
|
||||||
|
}
|
||||||
|
err = yaml.Unmarshal(defBuild, &d)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rendering file "+val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dat, err := helpers.RenderHelm(string(dataBuild), raw, d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "rendering file "+pack.Rel(BuildFile))
|
return nil, errors.Wrap(err, "rendering file "+pack.Rel(BuildFile))
|
||||||
}
|
}
|
||||||
dataresult = []byte(dat)
|
dataresult = []byte(dat)
|
||||||
} else {
|
} else {
|
||||||
out, err := helpers.RenderFiles(pack.Rel(BuildFile), val)
|
out, err := helpers.RenderFiles(pack.Rel(BuildFile), val, cs.Options.BuildValuesFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "rendering file "+pack.Rel(BuildFile))
|
return nil, errors.Wrap(err, "rendering file "+pack.Rel(BuildFile))
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,7 @@ type CompilerOptions struct {
|
|||||||
NoDeps bool
|
NoDeps bool
|
||||||
SolverOptions config.LuetSolverOptions
|
SolverOptions config.LuetSolverOptions
|
||||||
SkipIfMetadataExists bool
|
SkipIfMetadataExists bool
|
||||||
|
BuildValuesFile string
|
||||||
|
|
||||||
PackageTargetOnly bool
|
PackageTargetOnly bool
|
||||||
}
|
}
|
||||||
|
@@ -242,6 +242,7 @@ RUN ` + s
|
|||||||
func (cs *LuetCompilationSpec) RenderStepImage(image string) (string, error) {
|
func (cs *LuetCompilationSpec) RenderStepImage(image string) (string, error) {
|
||||||
spec := `
|
spec := `
|
||||||
FROM ` + image + `
|
FROM ` + image + `
|
||||||
|
WORKDIR /luetbuild
|
||||||
ENV PACKAGE_NAME=` + cs.Package.GetName() + `
|
ENV PACKAGE_NAME=` + cs.Package.GetName() + `
|
||||||
ENV PACKAGE_VERSION=` + cs.Package.GetVersion() + `
|
ENV PACKAGE_VERSION=` + cs.Package.GetVersion() + `
|
||||||
ENV PACKAGE_CATEGORY=` + cs.Package.GetCategory()
|
ENV PACKAGE_CATEGORY=` + cs.Package.GetCategory()
|
||||||
|
@@ -96,6 +96,7 @@ ENV test=1`))
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(dockerfile).To(Equal(`
|
Expect(dockerfile).To(Equal(`
|
||||||
FROM luet/base
|
FROM luet/base
|
||||||
|
WORKDIR /luetbuild
|
||||||
ENV PACKAGE_NAME=enman
|
ENV PACKAGE_NAME=enman
|
||||||
ENV PACKAGE_VERSION=1.4.0
|
ENV PACKAGE_VERSION=1.4.0
|
||||||
ENV PACKAGE_CATEGORY=app-admin
|
ENV PACKAGE_CATEGORY=app-admin
|
||||||
@@ -168,6 +169,7 @@ ENV test=1`))
|
|||||||
|
|
||||||
Expect(dockerfile).To(Equal(`
|
Expect(dockerfile).To(Equal(`
|
||||||
FROM luet/base
|
FROM luet/base
|
||||||
|
WORKDIR /luetbuild
|
||||||
ENV PACKAGE_NAME=a
|
ENV PACKAGE_NAME=a
|
||||||
ENV PACKAGE_VERSION=1.0
|
ENV PACKAGE_VERSION=1.0
|
||||||
ENV PACKAGE_CATEGORY=test
|
ENV PACKAGE_CATEGORY=test
|
||||||
|
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// RenderHelm renders the template string with helm
|
// RenderHelm renders the template string with helm
|
||||||
func RenderHelm(template string, values map[string]interface{}) (string, error) {
|
func RenderHelm(template string, values, d map[string]interface{}) (string, error) {
|
||||||
c := &chart.Chart{
|
c := &chart.Chart{
|
||||||
Metadata: &chart.Metadata{
|
Metadata: &chart.Metadata{
|
||||||
Name: "",
|
Name: "",
|
||||||
@@ -23,7 +23,7 @@ func RenderHelm(template string, values map[string]interface{}) (string, error)
|
|||||||
Values: map[string]interface{}{"Values": values},
|
Values: map[string]interface{}{"Values": values},
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := chartutil.CoalesceValues(c, map[string]interface{}{})
|
v, err := chartutil.CoalesceValues(c, map[string]interface{}{"Values": d})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "while rendering template")
|
return "", errors.Wrap(err, "while rendering template")
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ func RenderHelm(template string, values map[string]interface{}) (string, error)
|
|||||||
|
|
||||||
type templatedata map[string]interface{}
|
type templatedata map[string]interface{}
|
||||||
|
|
||||||
func RenderFiles(toTemplate, valuesFile string) (string, error) {
|
func RenderFiles(toTemplate, valuesFile string, defaultFile string) (string, error) {
|
||||||
raw, err := ioutil.ReadFile(toTemplate)
|
raw, err := ioutil.ReadFile(toTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "reading file "+toTemplate)
|
return "", errors.Wrap(err, "reading file "+toTemplate)
|
||||||
@@ -46,14 +46,26 @@ func RenderFiles(toTemplate, valuesFile string) (string, error) {
|
|||||||
if !Exists(valuesFile) {
|
if !Exists(valuesFile) {
|
||||||
return "", errors.Wrap(err, "file not existing "+valuesFile)
|
return "", errors.Wrap(err, "file not existing "+valuesFile)
|
||||||
}
|
}
|
||||||
def, err := ioutil.ReadFile(valuesFile)
|
val, err := ioutil.ReadFile(valuesFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "reading file "+valuesFile)
|
return "", errors.Wrap(err, "reading file "+valuesFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
var values templatedata
|
var values templatedata
|
||||||
if err = yaml.Unmarshal(def, &values); err != nil {
|
d := templatedata{}
|
||||||
|
if len(defaultFile) > 0 {
|
||||||
|
def, err := ioutil.ReadFile(defaultFile)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "reading file "+valuesFile)
|
||||||
|
}
|
||||||
|
if err = yaml.Unmarshal(def, &d); err != nil {
|
||||||
return "", errors.Wrap(err, "unmarshalling file "+toTemplate)
|
return "", errors.Wrap(err, "unmarshalling file "+toTemplate)
|
||||||
}
|
}
|
||||||
return RenderHelm(string(raw), values)
|
}
|
||||||
|
|
||||||
|
if err = yaml.Unmarshal(val, &values); err != nil {
|
||||||
|
return "", errors.Wrap(err, "unmarshalling file "+toTemplate)
|
||||||
|
}
|
||||||
|
|
||||||
|
return RenderHelm(string(raw), values, d)
|
||||||
}
|
}
|
||||||
|
@@ -16,17 +16,132 @@
|
|||||||
package helpers_test
|
package helpers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
. "github.com/mudler/luet/pkg/helpers"
|
. "github.com/mudler/luet/pkg/helpers"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func writeFile(path string, content string) {
|
||||||
|
err := ioutil.WriteFile(path, []byte(content), 0644)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
var _ = Describe("Helpers", func() {
|
var _ = Describe("Helpers", func() {
|
||||||
Context("RenderHelm", func() {
|
Context("RenderHelm", func() {
|
||||||
It("Renders templates", func() {
|
It("Renders templates", func() {
|
||||||
out, err := RenderHelm("{{.Values.Test}}", map[string]interface{}{"Test": "foo"})
|
out, err := RenderHelm("{{.Values.Test}}{{.Values.Bar}}", map[string]interface{}{"Test": "foo"}, map[string]interface{}{"Bar": "bar"})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(out).To(Equal("foo"))
|
Expect(out).To(Equal("foobar"))
|
||||||
|
})
|
||||||
|
It("Renders templates with overrides", func() {
|
||||||
|
out, err := RenderHelm("{{.Values.Test}}{{.Values.Bar}}", map[string]interface{}{"Test": "foo", "Bar": "baz"}, map[string]interface{}{"Bar": "bar"})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(out).To(Equal("foobar"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("Renders templates", func() {
|
||||||
|
out, err := RenderHelm("{{.Values.Test}}{{.Values.Bar}}", map[string]interface{}{"Test": "foo", "Bar": "bar"}, map[string]interface{}{})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(out).To(Equal("foobar"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("Render files default overrides", func() {
|
||||||
|
testDir, err := ioutil.TempDir(os.TempDir(), "test")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.RemoveAll(testDir)
|
||||||
|
|
||||||
|
toTemplate := filepath.Join(testDir, "totemplate.yaml")
|
||||||
|
values := filepath.Join(testDir, "values.yaml")
|
||||||
|
d := filepath.Join(testDir, "default.yaml")
|
||||||
|
|
||||||
|
writeFile(toTemplate, `{{.Values.foo}}`)
|
||||||
|
writeFile(values, `
|
||||||
|
foo: "bar"
|
||||||
|
`)
|
||||||
|
writeFile(d, `
|
||||||
|
foo: "baz"
|
||||||
|
`)
|
||||||
|
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
res, err := RenderFiles(toTemplate, values, d)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(res).To(Equal("baz"))
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
It("Render files from values", func() {
|
||||||
|
testDir, err := ioutil.TempDir(os.TempDir(), "test")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.RemoveAll(testDir)
|
||||||
|
|
||||||
|
toTemplate := filepath.Join(testDir, "totemplate.yaml")
|
||||||
|
values := filepath.Join(testDir, "values.yaml")
|
||||||
|
d := filepath.Join(testDir, "default.yaml")
|
||||||
|
|
||||||
|
writeFile(toTemplate, `{{.Values.foo}}`)
|
||||||
|
writeFile(values, `
|
||||||
|
foo: "bar"
|
||||||
|
`)
|
||||||
|
writeFile(d, `
|
||||||
|
faa: "baz"
|
||||||
|
`)
|
||||||
|
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
res, err := RenderFiles(toTemplate, values, d)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(res).To(Equal("bar"))
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
It("Render files from values if no default", func() {
|
||||||
|
testDir, err := ioutil.TempDir(os.TempDir(), "test")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.RemoveAll(testDir)
|
||||||
|
|
||||||
|
toTemplate := filepath.Join(testDir, "totemplate.yaml")
|
||||||
|
values := filepath.Join(testDir, "values.yaml")
|
||||||
|
|
||||||
|
writeFile(toTemplate, `{{.Values.foo}}`)
|
||||||
|
writeFile(values, `
|
||||||
|
foo: "bar"
|
||||||
|
`)
|
||||||
|
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
res, err := RenderFiles(toTemplate, values, "")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(res).To(Equal("bar"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("doesn't interpolate if no one provides the values", func() {
|
||||||
|
testDir, err := ioutil.TempDir(os.TempDir(), "test")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.RemoveAll(testDir)
|
||||||
|
|
||||||
|
toTemplate := filepath.Join(testDir, "totemplate.yaml")
|
||||||
|
values := filepath.Join(testDir, "values.yaml")
|
||||||
|
d := filepath.Join(testDir, "default.yaml")
|
||||||
|
|
||||||
|
writeFile(toTemplate, `{{.Values.foo}}`)
|
||||||
|
writeFile(values, `
|
||||||
|
foao: "bar"
|
||||||
|
`)
|
||||||
|
writeFile(d, `
|
||||||
|
faa: "baz"
|
||||||
|
`)
|
||||||
|
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
res, err := RenderFiles(toTemplate, values, d)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(res).To(Equal(""))
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@@ -203,6 +203,25 @@ func (l *LuetInstaller) Swap(toRemove pkg.Packages, toInstall pkg.Packages, s *S
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(toRemove) > 0 {
|
||||||
|
Info(":recycle: Packages that are going to be removed from the system:\n ", Yellow(packsToList(toRemove)).BgBlack().String())
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(toInstall) > 0 {
|
||||||
|
Info(":zap:Packages that are going to be installed in the system:\n ", Green(packsToList(toInstall)).BgBlack().String())
|
||||||
|
}
|
||||||
|
|
||||||
|
if l.Options.Ask {
|
||||||
|
Info("By going forward, you are also accepting the licenses of the packages that you are going to install in your system.")
|
||||||
|
if Ask() {
|
||||||
|
l.Options.Ask = false // Don't prompt anymore
|
||||||
|
return l.swap(syncedRepos, toRemove, toInstall, s)
|
||||||
|
} else {
|
||||||
|
return errors.New("Aborted by user")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return l.swap(syncedRepos, toRemove, toInstall, s)
|
return l.swap(syncedRepos, toRemove, toInstall, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -711,9 +711,12 @@ func (r *LuetSystemRepository) Sync(force bool) (Repository, error) {
|
|||||||
repo.SetPriority(r.GetPriority())
|
repo.SetPriority(r.GetPriority())
|
||||||
repo.SetName(r.GetName())
|
repo.SetName(r.GetName())
|
||||||
InfoC(
|
InfoC(
|
||||||
aurora.Bold(
|
aurora.Yellow(":information_source:").String() +
|
||||||
aurora.Yellow(":information_source: Repository "+repo.GetName()+" priority: ")).String() +
|
aurora.Magenta("Repository: ").String() +
|
||||||
aurora.Bold(aurora.Green(repo.GetPriority())).String() + " - type " +
|
aurora.Green(aurora.Bold(repo.GetName()).String()).String() +
|
||||||
|
aurora.Magenta(" Priority: ").String() +
|
||||||
|
aurora.Bold(aurora.Green(repo.GetPriority())).String() +
|
||||||
|
aurora.Magenta(" Type: ").String() +
|
||||||
aurora.Bold(aurora.Green(repo.GetType())).String(),
|
aurora.Bold(aurora.Green(repo.GetType())).String(),
|
||||||
)
|
)
|
||||||
return repo, nil
|
return repo, nil
|
||||||
|
@@ -24,7 +24,7 @@ func (s *System) ExecuteFinalizers(packs []pkg.Package, force bool) error {
|
|||||||
executedFinalizer := map[string]bool{}
|
executedFinalizer := map[string]bool{}
|
||||||
for _, p := range packs {
|
for _, p := range packs {
|
||||||
if helpers.Exists(p.Rel(tree.FinalizerFile)) {
|
if helpers.Exists(p.Rel(tree.FinalizerFile)) {
|
||||||
out, err := helpers.RenderFiles(p.Rel(tree.FinalizerFile), p.Rel(tree.DefinitionFile))
|
out, err := helpers.RenderFiles(p.Rel(tree.FinalizerFile), p.Rel(tree.DefinitionFile), "")
|
||||||
if err != nil && !force {
|
if err != nil && !force {
|
||||||
return errors.Wrap(err, "reading file "+p.Rel(tree.FinalizerFile))
|
return errors.Wrap(err, "reading file "+p.Rel(tree.FinalizerFile))
|
||||||
}
|
}
|
||||||
|
@@ -202,7 +202,7 @@ func msg(level string, withoutColor bool, msg ...interface{}) {
|
|||||||
case "info":
|
case "info":
|
||||||
levelMsg = message
|
levelMsg = message
|
||||||
case "error":
|
case "error":
|
||||||
levelMsg = Bold(Red(":bomb: " + message + ":fire:")).BgBlack().String()
|
levelMsg = Red(message).String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +248,6 @@ func Error(mess ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Fatal(mess ...interface{}) {
|
func Fatal(mess ...interface{}) {
|
||||||
Error(mess)
|
Error(mess...)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,7 @@ func (r *CompilerRecipe) Load(path string) error {
|
|||||||
compileDefPath := pack.Rel(CompilerDefinitionFile)
|
compileDefPath := pack.Rel(CompilerDefinitionFile)
|
||||||
if helpers.Exists(compileDefPath) {
|
if helpers.Exists(compileDefPath) {
|
||||||
|
|
||||||
dat, err := helpers.RenderFiles(compileDefPath, currentpath)
|
dat, err := helpers.RenderFiles(compileDefPath, currentpath, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err,
|
return errors.Wrap(err,
|
||||||
"Error templating file "+CompilerDefinitionFile+" from "+
|
"Error templating file "+CompilerDefinitionFile+" from "+
|
||||||
@@ -137,7 +137,7 @@ func (r *CompilerRecipe) Load(path string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Error reading file "+currentpath)
|
return errors.Wrap(err, "Error reading file "+currentpath)
|
||||||
}
|
}
|
||||||
dat, err := helpers.RenderHelm(string(buildyaml), raw)
|
dat, err := helpers.RenderHelm(string(buildyaml), raw, map[string]interface{}{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err,
|
return errors.Wrap(err,
|
||||||
"Error templating file "+CompilerDefinitionFile+" from "+
|
"Error templating file "+CompilerDefinitionFile+" from "+
|
||||||
|
7
tests/fixtures/build_values/build.yaml
vendored
Normal file
7
tests/fixtures/build_values/build.yaml
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
image: quay.io/mocaccino/extra
|
||||||
|
steps:
|
||||||
|
- touch /{{.Values.name}}
|
||||||
|
- touch /build-extra-{{.Values.foo}}
|
||||||
|
- touch /{{.Values.name}}-{{.Values.bb}}
|
||||||
|
|
||||||
|
unpack: true
|
13
tests/fixtures/build_values/collection.yaml
vendored
Normal file
13
tests/fixtures/build_values/collection.yaml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
packages:
|
||||||
|
- name: "a"
|
||||||
|
category: "distro"
|
||||||
|
version: "0.1"
|
||||||
|
foo: "baz"
|
||||||
|
- name: "b"
|
||||||
|
category: "distro"
|
||||||
|
version: "0.3"
|
||||||
|
foo: "f"
|
||||||
|
- name: "c"
|
||||||
|
category: "distro"
|
||||||
|
version: "0.3"
|
||||||
|
foo: "bar"
|
2
tests/fixtures/build_values/finalize.yaml
vendored
Normal file
2
tests/fixtures/build_values/finalize.yaml
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
install:
|
||||||
|
- touch /finalize-{{.Values.name}}
|
4
tests/fixtures/build_values/pack/build.yaml
vendored
Normal file
4
tests/fixtures/build_values/pack/build.yaml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
image: quay.io/mocaccino/extra
|
||||||
|
steps:
|
||||||
|
- touch /{{.Values.name}}
|
||||||
|
- touch /{{.Values.name}}-{{.Values.bb}}
|
3
tests/fixtures/build_values/pack/definition.yaml
vendored
Normal file
3
tests/fixtures/build_values/pack/definition.yaml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
name: foo
|
||||||
|
category: test
|
||||||
|
version: "1.1"
|
@@ -58,14 +58,14 @@ EOF
|
|||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c
|
luet install -y --config $tmpdir/luet.yaml test/c
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
}
|
}
|
||||||
|
|
||||||
testReInstall() {
|
testReInstall() {
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertContains 'contains warning' "$output" 'No packages to install'
|
assertContains 'contains warning' "$output" 'No packages to install'
|
||||||
@@ -80,7 +80,7 @@ testUnInstall() {
|
|||||||
|
|
||||||
testInstallAgain() {
|
testInstallAgain() {
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertNotContains 'contains warning' "$output" 'No packages to install'
|
assertNotContains 'contains warning' "$output" 'No packages to install'
|
||||||
|
@@ -12,7 +12,7 @@ oneTimeTearDown() {
|
|||||||
|
|
||||||
testBuild() {
|
testBuild() {
|
||||||
mkdir $tmpdir/testbuild
|
mkdir $tmpdir/testbuild
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c-1.0 > /dev/null
|
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c@1.0 > /dev/null
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
@@ -62,7 +62,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
@@ -70,14 +70,14 @@ testInstall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testReInstall() {
|
testReInstall() {
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml =test/c-1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertContains 'contains warning' "$output" 'No packages to install'
|
assertContains 'contains warning' "$output" 'No packages to install'
|
||||||
}
|
}
|
||||||
|
|
||||||
testUnInstall() {
|
testUnInstall() {
|
||||||
luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0
|
luet uninstall -y --config $tmpdir/luet.yaml =test/c-1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'uninstall test successfully' "$installst" "0"
|
assertEquals 'uninstall test successfully' "$installst" "0"
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
@@ -85,7 +85,7 @@ testUnInstall() {
|
|||||||
|
|
||||||
testInstallAgain() {
|
testInstallAgain() {
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml =test/c-1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertNotContains 'contains warning' "$output" 'No packages to install'
|
assertNotContains 'contains warning' "$output" 'No packages to install'
|
||||||
|
@@ -12,7 +12,7 @@ oneTimeTearDown() {
|
|||||||
|
|
||||||
testBuild() {
|
testBuild() {
|
||||||
mkdir $tmpdir/testbuild
|
mkdir $tmpdir/testbuild
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c-1.0 > /dev/null
|
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c@1.0 > /dev/null
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
@@ -65,22 +65,22 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
}
|
}
|
||||||
|
|
||||||
testReInstall() {
|
testReInstall() {
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertContains 'contains warning' "$output" 'No packages to install'
|
assertContains 'contains warning' "$output" 'No packages to install'
|
||||||
}
|
}
|
||||||
|
|
||||||
testUnInstall() {
|
testUnInstall() {
|
||||||
luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0
|
luet uninstall -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'uninstall test successfully' "$installst" "0"
|
assertEquals 'uninstall test successfully' "$installst" "0"
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
@@ -88,7 +88,7 @@ testUnInstall() {
|
|||||||
|
|
||||||
testInstallAgain() {
|
testInstallAgain() {
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertNotContains 'contains warning' "$output" 'No packages to install'
|
assertNotContains 'contains warning' "$output" 'No packages to install'
|
||||||
|
@@ -12,7 +12,7 @@ oneTimeTearDown() {
|
|||||||
|
|
||||||
testBuild() {
|
testBuild() {
|
||||||
mkdir $tmpdir/testbuild
|
mkdir $tmpdir/testbuild
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c-1.0 > /dev/null
|
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c@1.0 > /dev/null
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
@@ -55,22 +55,22 @@ testRepo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
}
|
}
|
||||||
|
|
||||||
testReInstall() {
|
testReInstall() {
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertContains 'contains warning' "$output" 'No packages to install'
|
assertContains 'contains warning' "$output" 'No packages to install'
|
||||||
}
|
}
|
||||||
|
|
||||||
testUnInstall() {
|
testUnInstall() {
|
||||||
luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0
|
luet uninstall -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'uninstall test successfully' "$installst" "0"
|
assertEquals 'uninstall test successfully' "$installst" "0"
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
@@ -78,7 +78,7 @@ testUnInstall() {
|
|||||||
|
|
||||||
testInstallAgain() {
|
testInstallAgain() {
|
||||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertNotContains 'contains warning' "$output" 'No packages to install'
|
assertNotContains 'contains warning' "$output" 'No packages to install'
|
||||||
|
@@ -12,35 +12,35 @@ oneTimeTearDown() {
|
|||||||
|
|
||||||
testBuild() {
|
testBuild() {
|
||||||
mkdir $tmpdir/testbuild
|
mkdir $tmpdir/testbuild
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b-1.1
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b@1.1
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package B 1.1' "[ -e '$tmpdir/testbuild/b-test-1.1.package.tar.gz' ]"
|
assertTrue 'create package B 1.1' "[ -e '$tmpdir/testbuild/b-test-1.1.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild/a-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild/a-test-1.0.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.1
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.1
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
assertTrue 'create package A 1.1' "[ -e '$tmpdir/testbuild/a-test-1.1.package.tar.gz' ]"
|
assertTrue 'create package A 1.1' "[ -e '$tmpdir/testbuild/a-test-1.1.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.2
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.2
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
assertTrue 'create package A 1.2' "[ -e '$tmpdir/testbuild/a-test-1.2.package.tar.gz' ]"
|
assertTrue 'create package A 1.2' "[ -e '$tmpdir/testbuild/a-test-1.2.package.tar.gz' ]"
|
||||||
|
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/c-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/c@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
||||||
@@ -85,24 +85,24 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/b-1.0
|
luet install -y --config $tmpdir/luet.yaml test/b@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/a-1.0
|
luet install -y --config $tmpdir/luet.yaml test/a@1.0
|
||||||
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/a-1.1
|
luet install -y --config $tmpdir/luet.yaml test/a@1.1
|
||||||
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]"
|
assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
@@ -117,8 +117,8 @@ testUpgrade() {
|
|||||||
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/newc' ]"
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/newc' ]"
|
||||||
assertTrue 'package uninstalled A' "[ ! -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package uninstalled A' "[ ! -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
assertTrue 'package installed new A' "[ -e '$tmpdir/testrootfs/testlatest' ]"
|
assertTrue 'package installed new A' "[ -e '$tmpdir/testrootfs/testlatest' ]"
|
||||||
assertNotContains 'does not contain test/c-1.0' "$upgrade" 'test/c-1.0'
|
assertNotContains 'does not contain test/c@1.0' "$upgrade" 'test/c-1.0'
|
||||||
assertNotContains 'does not attempt to download test/c-1.0' "$upgrade" 'test/c-1.0 downloaded'
|
assertNotContains 'does not attempt to download test/c@1.0' "$upgrade" 'test/c-1.0 downloaded'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load shUnit2.
|
# Load shUnit2.
|
||||||
|
@@ -11,35 +11,35 @@ oneTimeTearDown() {
|
|||||||
|
|
||||||
testBuild() {
|
testBuild() {
|
||||||
mkdir $tmpdir/testbuild
|
mkdir $tmpdir/testbuild
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b-1.1
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b@1.1
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package B 1.1' "[ -e '$tmpdir/testbuild/b-test-1.1.package.tar.gz' ]"
|
assertTrue 'create package B 1.1' "[ -e '$tmpdir/testbuild/b-test-1.1.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild/a-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild/a-test-1.0.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.1
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.1
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
assertTrue 'create package A 1.1' "[ -e '$tmpdir/testbuild/a-test-1.1.package.tar.gz' ]"
|
assertTrue 'create package A 1.1' "[ -e '$tmpdir/testbuild/a-test-1.1.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.2
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.2
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
assertTrue 'create package A 1.2' "[ -e '$tmpdir/testbuild/a-test-1.2.package.tar.gz' ]"
|
assertTrue 'create package A 1.2' "[ -e '$tmpdir/testbuild/a-test-1.2.package.tar.gz' ]"
|
||||||
|
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/c-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/c@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
||||||
@@ -84,24 +84,24 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/b-1.0
|
luet install -y --config $tmpdir/luet.yaml test/b@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/a-1.0
|
luet install -y --config $tmpdir/luet.yaml test/a@1.0
|
||||||
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/a-1.1
|
luet install -y --config $tmpdir/luet.yaml test/a@1.1
|
||||||
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]"
|
assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
|
@@ -21,7 +21,7 @@ testBuild() {
|
|||||||
assertEquals 'builds successfully' "0" "$buildst"
|
assertEquals 'builds successfully' "0" "$buildst"
|
||||||
|
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/versioning" --destination $tmpdir/testbuild --compression gzip '>=dev-libs/libsigc++-2-0'
|
luet build --tree "$ROOT_DIR/tests/fixtures/versioning" --destination $tmpdir/testbuild --compression gzip '=dev-libs/libsigc++-2-2.10.1+1'
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "0" "$buildst"
|
assertEquals 'builds successfully' "0" "$buildst"
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ testInstall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall2() {
|
testInstall2() {
|
||||||
luet install -y --config $tmpdir/luet.yaml '>=dev-libs/libsigc++-2-0'
|
luet install -y --config $tmpdir/luet.yaml '=dev-libs/libsigc++-2-2.10.1+1'
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "0" "$installst"
|
assertEquals 'install test successfully' "0" "$installst"
|
||||||
}
|
}
|
||||||
|
@@ -12,35 +12,35 @@ oneTimeTearDown() {
|
|||||||
|
|
||||||
testBuild() {
|
testBuild() {
|
||||||
mkdir $tmpdir/testbuild
|
mkdir $tmpdir/testbuild
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b-1.1
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/b@1.1
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package B 1.1' "[ -e '$tmpdir/testbuild/b-test-1.1.package.tar.gz' ]"
|
assertTrue 'create package B 1.1' "[ -e '$tmpdir/testbuild/b-test-1.1.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild/a-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package A 1.0' "[ -e '$tmpdir/testbuild/a-test-1.0.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.1
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.1
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
assertTrue 'create package A 1.1' "[ -e '$tmpdir/testbuild/a-test-1.1.package.tar.gz' ]"
|
assertTrue 'create package A 1.1' "[ -e '$tmpdir/testbuild/a-test-1.1.package.tar.gz' ]"
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a-1.2
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/a@1.2
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
assertTrue 'create package A 1.2' "[ -e '$tmpdir/testbuild/a-test-1.2.package.tar.gz' ]"
|
assertTrue 'create package A 1.2' "[ -e '$tmpdir/testbuild/a-test-1.2.package.tar.gz' ]"
|
||||||
|
|
||||||
|
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/c-1.0
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration" --destination $tmpdir/testbuild --compression gzip test/c@1.0
|
||||||
buildst=$?
|
buildst=$?
|
||||||
assertEquals 'builds successfully' "$buildst" "0"
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
||||||
@@ -85,24 +85,24 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/b-1.0
|
luet install -y --config $tmpdir/luet.yaml test/b@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/a-1.0
|
luet install -y --config $tmpdir/luet.yaml test/a@1.0
|
||||||
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/a-1.1
|
luet install -y --config $tmpdir/luet.yaml test/a@1.1
|
||||||
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]"
|
assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]"
|
||||||
|
|
||||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
|
@@ -75,7 +75,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testUpgrade() {
|
testUpgrade() {
|
||||||
luet install -y --config $tmpdir/luet.yaml test/b-1.0
|
luet install -y --config $tmpdir/luet.yaml test/b@1.0
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
||||||
|
@@ -56,7 +56,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
testInstall() {
|
testInstall() {
|
||||||
$ROOT_DIR/tests/integration/bin/luet install -y --config $tmpdir/luet.yaml test/caps-0.1 test/caps2-0.1
|
$ROOT_DIR/tests/integration/bin/luet install -y --config $tmpdir/luet.yaml test/caps@0.1 test/caps2@0.1
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test successfully' "$installst" "0"
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ testDatabase() {
|
|||||||
assertContains 'contains test/c-1.0' "$installed" 'test/c-1.0'
|
assertContains 'contains test/c-1.0' "$installed" 'test/c-1.0'
|
||||||
touch $tmpdir/testrootfs/c
|
touch $tmpdir/testrootfs/c
|
||||||
|
|
||||||
luet database remove --config $tmpdir/luet.yaml test/c-1.0
|
luet database remove --config $tmpdir/luet.yaml test/c@1.0
|
||||||
removetest=$?
|
removetest=$?
|
||||||
assertEquals 'package removed successfully' "$removetest" "0"
|
assertEquals 'package removed successfully' "$removetest" "0"
|
||||||
assertTrue 'file not touched' "[ -e '$tmpdir/testrootfs/c' ]"
|
assertTrue 'file not touched' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
|
133
tests/integration/22_build_values.sh
Executable file
133
tests/integration/22_build_values.sh
Executable file
@@ -0,0 +1,133 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export LUET_NOLOCK=true
|
||||||
|
oneTimeSetUp() {
|
||||||
|
export tmpdir="$(mktemp -d)"
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeTearDown() {
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
testBuild() {
|
||||||
|
cat <<EOF > $tmpdir/default.yaml
|
||||||
|
bb: "ttt"
|
||||||
|
EOF
|
||||||
|
mkdir $tmpdir/testbuild
|
||||||
|
luet build --tree "$ROOT_DIR/tests/fixtures/build_values" --values $tmpdir/default.yaml --destination $tmpdir/testbuild --compression gzip --all
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
assertTrue 'create package B' "[ -e '$tmpdir/testbuild/b-distro-0.3.package.tar.gz' ]"
|
||||||
|
assertTrue 'create package A' "[ -e '$tmpdir/testbuild/a-distro-0.1.package.tar.gz' ]"
|
||||||
|
assertTrue 'create package C' "[ -e '$tmpdir/testbuild/c-distro-0.3.package.tar.gz' ]"
|
||||||
|
assertTrue 'create package foo' "[ -e '$tmpdir/testbuild/foo-test-1.1.package.tar.gz' ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
testRepo() {
|
||||||
|
assertTrue 'no repository' "[ ! -e '$tmpdir/testbuild/repository.yaml' ]"
|
||||||
|
luet create-repo --tree "$ROOT_DIR/tests/fixtures/build_values" \
|
||||||
|
--output $tmpdir/testbuild \
|
||||||
|
--packages $tmpdir/testbuild \
|
||||||
|
--name "test" \
|
||||||
|
--descr "Test Repo" \
|
||||||
|
--urls $tmpdir/testrootfs \
|
||||||
|
--type disk
|
||||||
|
|
||||||
|
createst=$?
|
||||||
|
assertEquals 'create repo successfully' "$createst" "0"
|
||||||
|
assertTrue 'create repository' "[ -e '$tmpdir/testbuild/repository.yaml' ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
testConfig() {
|
||||||
|
mkdir $tmpdir/testrootfs
|
||||||
|
cat <<EOF > $tmpdir/luet.yaml
|
||||||
|
general:
|
||||||
|
debug: true
|
||||||
|
system:
|
||||||
|
rootfs: $tmpdir/testrootfs
|
||||||
|
database_path: "/"
|
||||||
|
database_engine: "boltdb"
|
||||||
|
config_from_host: true
|
||||||
|
repositories:
|
||||||
|
- name: "main"
|
||||||
|
type: "disk"
|
||||||
|
enable: true
|
||||||
|
urls:
|
||||||
|
- "$tmpdir/testbuild"
|
||||||
|
EOF
|
||||||
|
luet config --config $tmpdir/luet.yaml
|
||||||
|
res=$?
|
||||||
|
assertEquals 'config test successfully' "$res" "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
testInstall() {
|
||||||
|
luet install -y --config $tmpdir/luet.yaml distro/a
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/a' ]"
|
||||||
|
# Build time can interpolate on fields which aren't package properties.
|
||||||
|
assertTrue 'extra field on A' "[ -e '$tmpdir/testrootfs/build-extra-baz' ]"
|
||||||
|
assertTrue 'package installed A interpolated with values' "[ -e '$tmpdir/testrootfs/a-ttt' ]"
|
||||||
|
# Finalizers can interpolate only on package field. No extra fields are allowed at this time.
|
||||||
|
assertTrue 'finalizer executed on A' "[ -e '$tmpdir/testrootfs/finalize-a' ]"
|
||||||
|
|
||||||
|
installed=$(luet --config $tmpdir/luet.yaml search --installed .)
|
||||||
|
searchst=$?
|
||||||
|
assertEquals 'search exists successfully' "$searchst" "0"
|
||||||
|
|
||||||
|
assertContains 'contains distro/a-0.1' "$installed" 'distro/a-0.1'
|
||||||
|
|
||||||
|
luet uninstall -y --config $tmpdir/luet.yaml distro/a
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
# We do the same check for the others
|
||||||
|
luet install -y --config $tmpdir/luet.yaml distro/b
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/b' ]"
|
||||||
|
assertTrue 'package installed B interpolated with values' "[ -e '$tmpdir/testrootfs/b-ttt' ]"
|
||||||
|
assertTrue 'extra field on B' "[ -e '$tmpdir/testrootfs/build-extra-f' ]"
|
||||||
|
assertTrue 'finalizer executed on B' "[ -e '$tmpdir/testrootfs/finalize-b' ]"
|
||||||
|
|
||||||
|
installed=$(luet --config $tmpdir/luet.yaml search --installed .)
|
||||||
|
searchst=$?
|
||||||
|
assertEquals 'search exists successfully' "$searchst" "0"
|
||||||
|
|
||||||
|
assertContains 'contains distro/b-0.3' "$installed" 'distro/b-0.3'
|
||||||
|
|
||||||
|
luet uninstall -y --config $tmpdir/luet.yaml distro/b
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
luet install -y --config $tmpdir/luet.yaml distro/c
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
|
assertTrue 'extra field on C' "[ -e '$tmpdir/testrootfs/build-extra-bar' ]"
|
||||||
|
assertTrue 'package installed C interpolated with values' "[ -e '$tmpdir/testrootfs/c-ttt' ]"
|
||||||
|
assertTrue 'finalizer executed on C' "[ -e '$tmpdir/testrootfs/finalize-c' ]"
|
||||||
|
|
||||||
|
installed=$(luet --config $tmpdir/luet.yaml search --installed .)
|
||||||
|
searchst=$?
|
||||||
|
assertEquals 'search exists successfully' "$searchst" "0"
|
||||||
|
|
||||||
|
assertContains 'contains distro/c-0.3' "$installed" 'distro/c-0.3'
|
||||||
|
|
||||||
|
luet uninstall -y --config $tmpdir/luet.yaml distro/c
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
luet install -y --config $tmpdir/luet.yaml test/foo
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
assertTrue 'package installed foo' "[ -e '$tmpdir/testrootfs/foo' ]"
|
||||||
|
assertTrue 'package installed foo interpolated with values' "[ -e '$tmpdir/testrootfs/foo-ttt' ]"
|
||||||
|
}
|
||||||
|
# Load shUnit2.
|
||||||
|
. "$ROOT_DIR/tests/integration/shunit2"/shunit2
|
||||||
|
|
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export LUET_YES=true
|
||||||
export ROOT_DIR="$(git rev-parse --show-toplevel)"
|
export ROOT_DIR="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
pushd $ROOT_DIR
|
pushd $ROOT_DIR
|
||||||
|
Reference in New Issue
Block a user