mirror of
https://github.com/mudler/luet.git
synced 2025-09-10 03:29:16 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
86bd6c5fc0 | ||
|
658612fcf3 |
@@ -41,7 +41,7 @@ var Verbose bool
|
|||||||
var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LuetCLIVersion = "0.17.3"
|
LuetCLIVersion = "0.17.4"
|
||||||
LuetEnvPrefix = "LUET"
|
LuetEnvPrefix = "LUET"
|
||||||
license = `
|
license = `
|
||||||
Luet Copyright (C) 2019-2021 Ettore Di Giacinto
|
Luet Copyright (C) 2019-2021 Ettore Di Giacinto
|
||||||
|
@@ -272,6 +272,15 @@ func (l *LuetInstaller) swap(o Option, syncedRepos Repositories, toRemove pkg.Pa
|
|||||||
if err := l.download(syncedRepos, match); err != nil {
|
if err := l.download(syncedRepos, match); err != nil {
|
||||||
return errors.Wrap(err, "Pre-downloading packages")
|
return errors.Wrap(err, "Pre-downloading packages")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := l.checkFileconflicts(match, false, s); err != nil {
|
||||||
|
if !l.Options.Force {
|
||||||
|
return errors.Wrap(err, "file conflict found")
|
||||||
|
} else {
|
||||||
|
Warning("file conflict found", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if l.Options.DownloadOnly {
|
if l.Options.DownloadOnly {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -756,7 +765,7 @@ func (l *LuetInstaller) getFinalizers(allRepos pkg.PackageDatabase, solution sol
|
|||||||
return toFinalize, nil
|
return toFinalize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LuetInstaller) checkFileconflicts(toInstall map[string]ArtifactMatch, s *System) error {
|
func (l *LuetInstaller) checkFileconflicts(toInstall map[string]ArtifactMatch, checkSystem bool, s *System) error {
|
||||||
Info("Checking for file conflicts..")
|
Info("Checking for file conflicts..")
|
||||||
defer s.Clean() // Release memory
|
defer s.Clean() // Release memory
|
||||||
|
|
||||||
@@ -777,7 +786,7 @@ func (l *LuetInstaller) checkFileconflicts(toInstall map[string]ArtifactMatch, s
|
|||||||
"file conflict between packages to be installed",
|
"file conflict between packages to be installed",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if checkSystem {
|
||||||
exists, p, err := s.ExistsPackageFile(f)
|
exists, p, err := s.ExistsPackageFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed checking into system db")
|
return errors.Wrap(err, "failed checking into system db")
|
||||||
@@ -791,6 +800,7 @@ func (l *LuetInstaller) checkFileconflicts(toInstall map[string]ArtifactMatch, s
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
filesToInstall = append(filesToInstall, files...)
|
filesToInstall = append(filesToInstall, files...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,7 +815,7 @@ func (l *LuetInstaller) install(o Option, syncedRepos Repositories, toInstall ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check file conflicts
|
// Check file conflicts
|
||||||
if err := l.checkFileconflicts(toInstall, s); err != nil {
|
if err := l.checkFileconflicts(toInstall, true, s); err != nil {
|
||||||
if !l.Options.Force {
|
if !l.Options.Force {
|
||||||
return errors.Wrap(err, "file conflict found")
|
return errors.Wrap(err, "file conflict found")
|
||||||
} else {
|
} else {
|
||||||
|
6
tests/fixtures/fileconflicts_upgrade/conflict1/build.yaml
vendored
Normal file
6
tests/fixtures/fileconflicts_upgrade/conflict1/build.yaml
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- mkdir /foo
|
||||||
|
steps:
|
||||||
|
- echo conflict > /foo/test1
|
||||||
|
package_dir: /foo
|
13
tests/fixtures/fileconflicts_upgrade/conflict1/collection.yaml
vendored
Normal file
13
tests/fixtures/fileconflicts_upgrade/conflict1/collection.yaml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
packages:
|
||||||
|
- category: "test1"
|
||||||
|
name: "conflict"
|
||||||
|
version: "1.0"
|
||||||
|
- category: "test2"
|
||||||
|
name: "conflict"
|
||||||
|
version: "1.0"
|
||||||
|
- category: "test1"
|
||||||
|
name: "conflict"
|
||||||
|
version: "1.1"
|
||||||
|
- category: "test2"
|
||||||
|
name: "conflict"
|
||||||
|
version: "1.1"
|
81
tests/integration/32_fileconflicts_upgrade.sh
Executable file
81
tests/integration/32_fileconflicts_upgrade.sh
Executable file
@@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export LUET_NOLOCK=true
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
export tmpdir="$(mktemp -d)"
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeTearDown() {
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
testBuild() {
|
||||||
|
mkdir $tmpdir/testbuild
|
||||||
|
luet build --tree "$ROOT_DIR/tests/fixtures/fileconflicts_upgrade" --destination $tmpdir/testbuild --compression gzip --all
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
assertTrue 'create packages' "[ -e '$tmpdir/testbuild/conflict-test1-1.0.package.tar.gz' ]"
|
||||||
|
assertTrue 'create packages' "[ -e '$tmpdir/testbuild/conflict-test2-1.0.package.tar.gz' ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
testRepo() {
|
||||||
|
assertTrue 'no repository' "[ ! -e '$tmpdir/testbuild/repository.yaml' ]"
|
||||||
|
luet create-repo --tree "$ROOT_DIR/tests/fixtures/fileconflicts_upgrade" \
|
||||||
|
--output $tmpdir/testbuild \
|
||||||
|
--packages $tmpdir/testbuild \
|
||||||
|
--name "test" \
|
||||||
|
--descr "Test Repo" \
|
||||||
|
--urls $tmpdir/testrootfs \
|
||||||
|
--type disk > /dev/null
|
||||||
|
|
||||||
|
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 --force --config $tmpdir/luet.yaml test1/conflict@1.0 test2/conflict@1.0
|
||||||
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test succeded' "$installst" "0"
|
||||||
|
#assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
testUpgrade() {
|
||||||
|
out=$(luet upgrade -y --config $tmpdir/luet.yaml)
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test succeeded' "$installst" "1"
|
||||||
|
assertContains 'does find conflicts' "$out" "Error: file conflict found: file conflict between packages to be installed"
|
||||||
|
|
||||||
|
luet upgrade -y --config $tmpdir/luet.yaml --force
|
||||||
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test succeeded' "$installst" "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load shUnit2.
|
||||||
|
. "$ROOT_DIR/tests/integration/shunit2"/shunit2
|
||||||
|
|
Reference in New Issue
Block a user