mirror of
https://github.com/mudler/luet.git
synced 2025-08-11 12:12:19 +00:00
🔧 Allow to perform automatically oscheck after upgrades
This commit is contained in:
parent
163bd77d27
commit
938d41fe9e
@ -43,6 +43,8 @@ var upgradeCmd = &cobra.Command{
|
|||||||
universe, _ := cmd.Flags().GetBool("universe")
|
universe, _ := cmd.Flags().GetBool("universe")
|
||||||
clean, _ := cmd.Flags().GetBool("clean")
|
clean, _ := cmd.Flags().GetBool("clean")
|
||||||
sync, _ := cmd.Flags().GetBool("sync")
|
sync, _ := cmd.Flags().GetBool("sync")
|
||||||
|
osCheck, _ := cmd.Flags().GetBool("oscheck")
|
||||||
|
|
||||||
yes := viper.GetBool("yes")
|
yes := viper.GetBool("yes")
|
||||||
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ var upgradeCmd = &cobra.Command{
|
|||||||
UpgradeNewRevisions: sync,
|
UpgradeNewRevisions: sync,
|
||||||
PreserveSystemEssentialData: true,
|
PreserveSystemEssentialData: true,
|
||||||
Ask: !yes,
|
Ask: !yes,
|
||||||
|
AutoOSCheck: osCheck,
|
||||||
DownloadOnly: downloadOnly,
|
DownloadOnly: downloadOnly,
|
||||||
PackageRepositories: util.DefaultContext.Config.SystemRepositories,
|
PackageRepositories: util.DefaultContext.Config.SystemRepositories,
|
||||||
Context: util.DefaultContext,
|
Context: util.DefaultContext,
|
||||||
@ -97,6 +100,7 @@ func init() {
|
|||||||
upgradeCmd.Flags().Bool("solver-concurrent", false, "Use concurrent solver (experimental)")
|
upgradeCmd.Flags().Bool("solver-concurrent", false, "Use concurrent solver (experimental)")
|
||||||
upgradeCmd.Flags().BoolP("yes", "y", false, "Don't ask questions")
|
upgradeCmd.Flags().BoolP("yes", "y", false, "Don't ask questions")
|
||||||
upgradeCmd.Flags().Bool("download-only", false, "Download only")
|
upgradeCmd.Flags().Bool("download-only", false, "Download only")
|
||||||
|
upgradeCmd.Flags().Bool("oscheck", false, "Perform automatically oschecks after upgrades")
|
||||||
|
|
||||||
RootCmd.AddCommand(upgradeCmd)
|
RootCmd.AddCommand(upgradeCmd)
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ type LuetInstallerOptions struct {
|
|||||||
DownloadOnly bool
|
DownloadOnly bool
|
||||||
Relaxed bool
|
Relaxed bool
|
||||||
PackageRepositories types.LuetRepositories
|
PackageRepositories types.LuetRepositories
|
||||||
|
AutoOSCheck bool
|
||||||
|
|
||||||
Context *types.Context
|
Context *types.Context
|
||||||
}
|
}
|
||||||
@ -494,6 +495,17 @@ func (l *LuetInstaller) checkAndUpgrade(r Repositories, s *System) error {
|
|||||||
Uninstall, Install pkg.Packages
|
Uninstall, Install pkg.Packages
|
||||||
}{Uninstall: uninstall, Install: toInstall, Error: err})
|
}{Uninstall: uninstall, Install: toInstall, Error: err})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if l.Options.AutoOSCheck {
|
||||||
|
packs := s.OSCheck()
|
||||||
|
if len(packs) > 0 {
|
||||||
|
return l.swap(o, r, packs, packs, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
tests/fixtures/upgrade_integration_oscheck/c/build.yaml
vendored
Normal file
10
tests/fixtures/upgrade_integration_oscheck/c/build.yaml
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo c > /c
|
||||||
|
- echo c > /cd
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: ">=1.0"
|
9
tests/fixtures/upgrade_integration_oscheck/c/definition.yaml
vendored
Normal file
9
tests/fixtures/upgrade_integration_oscheck/c/definition.yaml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "c"
|
||||||
|
version: "1.0"
|
||||||
|
# Boom?
|
||||||
|
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: ">=0.1"
|
11
tests/fixtures/upgrade_integration_oscheck/cat/a/a/build.yaml
vendored
Normal file
11
tests/fixtures/upgrade_integration_oscheck/cat/a/a/build.yaml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo artifact3 > /test3
|
||||||
|
- echo artifact4 > /test4
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
8
tests/fixtures/upgrade_integration_oscheck/cat/a/a/definition.yaml
vendored
Normal file
8
tests/fixtures/upgrade_integration_oscheck/cat/a/a/definition.yaml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: "1.1"
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: ">=0.1"
|
||||||
|
|
11
tests/fixtures/upgrade_integration_oscheck/cat/a/a1.0/build.yaml
vendored
Normal file
11
tests/fixtures/upgrade_integration_oscheck/cat/a/a1.0/build.yaml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo artifact3 > /testaa
|
||||||
|
- echo artifact4 > /testaa2
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
3
tests/fixtures/upgrade_integration_oscheck/cat/a/a1.0/definition.yaml
vendored
Normal file
3
tests/fixtures/upgrade_integration_oscheck/cat/a/a1.0/definition.yaml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: "1.0"
|
11
tests/fixtures/upgrade_integration_oscheck/cat/a/alatest/build.yaml
vendored
Normal file
11
tests/fixtures/upgrade_integration_oscheck/cat/a/alatest/build.yaml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo artifact3 > /testlatest
|
||||||
|
- echo artifact4 > /testlatest2
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
3
tests/fixtures/upgrade_integration_oscheck/cat/a/alatest/definition.yaml
vendored
Normal file
3
tests/fixtures/upgrade_integration_oscheck/cat/a/alatest/definition.yaml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: "1.2"
|
9
tests/fixtures/upgrade_integration_oscheck/cat/b-1.1/build.yaml
vendored
Normal file
9
tests/fixtures/upgrade_integration_oscheck/cat/b-1.1/build.yaml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo artifact5 > /newc
|
||||||
|
- echo artifact6 > /newnewc
|
||||||
|
- chmod +x generate.sh
|
||||||
|
- ./generate.sh
|
3
tests/fixtures/upgrade_integration_oscheck/cat/b-1.1/definition.yaml
vendored
Normal file
3
tests/fixtures/upgrade_integration_oscheck/cat/b-1.1/definition.yaml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.1"
|
1
tests/fixtures/upgrade_integration_oscheck/cat/b-1.1/generate.sh
vendored
Normal file
1
tests/fixtures/upgrade_integration_oscheck/cat/b-1.1/generate.sh
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
echo generated > /sonewc
|
9
tests/fixtures/upgrade_integration_oscheck/cat/b/build.yaml
vendored
Normal file
9
tests/fixtures/upgrade_integration_oscheck/cat/b/build.yaml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
image: "alpine"
|
||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo artifact5 > /test5
|
||||||
|
- echo artifact6 > /test6
|
||||||
|
- chmod +x generate.sh
|
||||||
|
- ./generate.sh
|
3
tests/fixtures/upgrade_integration_oscheck/cat/b/definition.yaml
vendored
Normal file
3
tests/fixtures/upgrade_integration_oscheck/cat/b/definition.yaml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "b"
|
||||||
|
version: "1.0"
|
1
tests/fixtures/upgrade_integration_oscheck/cat/b/generate.sh
vendored
Normal file
1
tests/fixtures/upgrade_integration_oscheck/cat/b/generate.sh
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
echo generated > /artifact42
|
9
tests/fixtures/upgrade_integration_oscheck/z/build.yaml
vendored
Normal file
9
tests/fixtures/upgrade_integration_oscheck/z/build.yaml
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
prelude:
|
||||||
|
- echo foo > /test
|
||||||
|
- echo bar > /test2
|
||||||
|
steps:
|
||||||
|
- echo z > /z
|
||||||
|
requires:
|
||||||
|
- category: "test"
|
||||||
|
name: "a"
|
||||||
|
version: ">=1.0"
|
3
tests/fixtures/upgrade_integration_oscheck/z/definition.yaml
vendored
Normal file
3
tests/fixtures/upgrade_integration_oscheck/z/definition.yaml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
category: "test"
|
||||||
|
name: "z"
|
||||||
|
version: "1.0"
|
131
tests/integration/05_upgrade_oscheck.sh
Executable file
131
tests/integration/05_upgrade_oscheck.sh
Executable file
@ -0,0 +1,131 @@
|
|||||||
|
#!/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/upgrade_integration_oscheck" --destination $tmpdir/testbuild --compression gzip test/b@1.0
|
||||||
|
buildst=$?
|
||||||
|
assertTrue 'create package B 1.0' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration_oscheck" --destination $tmpdir/testbuild --compression gzip test/b@1.1
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
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_oscheck" --destination $tmpdir/testbuild --compression gzip test/a@1.0
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
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_oscheck" --destination $tmpdir/testbuild --compression gzip test/a@1.1
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
|
||||||
|
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_oscheck" --destination $tmpdir/testbuild --compression gzip test/a@1.2
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
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_oscheck" --destination $tmpdir/testbuild --compression gzip test/z@1.0
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
assertTrue 'create package Z 1.0' "[ -e '$tmpdir/testbuild/z-test-1.0.package.tar.gz' ]"
|
||||||
|
|
||||||
|
luet build --tree "$ROOT_DIR/tests/fixtures/upgrade_integration_oscheck" --destination $tmpdir/testbuild --compression gzip test/c@1.0
|
||||||
|
buildst=$?
|
||||||
|
assertEquals 'builds successfully' "$buildst" "0"
|
||||||
|
assertTrue 'create package C 1.0' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
testRepo() {
|
||||||
|
assertTrue 'no repository' "[ ! -e '$tmpdir/testbuild/repository.yaml' ]"
|
||||||
|
luet create-repo --tree "$ROOT_DIR/tests/fixtures/upgrade_integration_oscheck" \
|
||||||
|
--output $tmpdir/testbuild \
|
||||||
|
--packages $tmpdir/testbuild \
|
||||||
|
--name "test" \
|
||||||
|
--descr "Test Repo" \
|
||||||
|
--urls $tmpdir/testrootfs \
|
||||||
|
--type http
|
||||||
|
|
||||||
|
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 --relax --config $tmpdir/luet.yaml test/b@1.0
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]"
|
||||||
|
|
||||||
|
luet install -y --relax --config $tmpdir/luet.yaml test/z@1.0
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
assertTrue 'package installed Z' "[ -e '$tmpdir/testrootfs/z' ]"
|
||||||
|
|
||||||
|
luet install -y --relax --config $tmpdir/luet.yaml test/a@1.0
|
||||||
|
assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
|
||||||
|
luet install -y --relax --config $tmpdir/luet.yaml test/c@1.0
|
||||||
|
installst=$?
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
testUpgrade() {
|
||||||
|
rm -rf $tmpdir/testrootfs/z
|
||||||
|
assertTrue 'package Z corrupted' "[ ! -e '$tmpdir/testrootfs/z' ]"
|
||||||
|
|
||||||
|
upgrade=$(luet --config $tmpdir/luet.yaml upgrade --oscheck -y)
|
||||||
|
installst=$?
|
||||||
|
echo "$upgrade"
|
||||||
|
assertEquals 'install test successfully' "$installst" "0"
|
||||||
|
assertTrue 'package uninstalled B' "[ ! -e '$tmpdir/testrootfs/test5' ]"
|
||||||
|
assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/newc' ]"
|
||||||
|
assertTrue 'package uninstalled A' "[ ! -e '$tmpdir/testrootfs/testaa' ]"
|
||||||
|
assertTrue 'package Z restored' "[ -e '$tmpdir/testrootfs/z' ]"
|
||||||
|
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 attempt to download test/c@1.0' "$upgrade" 'test/c-1.0 downloaded'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load shUnit2.
|
||||||
|
. "$ROOT_DIR/tests/integration/shunit2"/shunit2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user