diff --git a/flake.nix b/flake.nix index f324f12962..b27e354e0c 100644 --- a/flake.nix +++ b/flake.nix @@ -81,6 +81,16 @@ go = super.go_1_22; test-env = final.callPackage ./nix/testenv.nix { }; bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { }; + # make-tarball don't follow symbolic links to avoid duplicate file, the bundle should have no external references. + # reset the ownership and permissions to make the extract result more normal. + make-tarball = drv: final.runCommand "tarball-${drv.name}" + { + nativeBuildInputs = with final.buildPackages; [ gnutar gzip ]; + } '' + tar cfv - -C "${drv}" \ + --owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \ + | gzip -9 > $out + ''; bundle-win-exe = drv: final.callPackage ./nix/bundle-win-exe.nix { cronosd = drv; }; } // (with final; let diff --git a/integration_tests/configs/upgrade-test-package.nix b/integration_tests/configs/upgrade-test-package.nix index 46382ce42e..e0fc52cf30 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -19,10 +19,9 @@ let # release/v1.1.x released = (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default; current = pkgs.callPackage ../../. { }; - farm = pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis/bin"; path = "${released0}/bin"; } - { name = "v1.1.0/bin"; path = "${released}/bin"; } - { name = "v1.2/bin"; path = "${current}/bin"; } - ]; in -pkgs.make-tarball farm +pkgs.linkFarm "upgrade-test-package" [ + { name = "genesis"; path = released0; } + { name = "v1.1.0"; path = released; } + { name = "v1.2"; path = current; } +] diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index a430883f6b..e77b80fa0b 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -1,4 +1,6 @@ import json +import shutil +import stat import subprocess from contextlib import contextmanager from datetime import datetime, timedelta @@ -72,35 +74,29 @@ def setup_cronos_test(tmp_path_factory): port = 26200 nix_name = "upgrade-test-package" cfg_name = "cosmovisor" + configdir = Path(__file__).parent cmd = [ "nix-build", - Path(__file__).parent / f"configs/{nix_name}.nix", - "-o", - path / "upgrades.tar.gz", + configdir / f"configs/{nix_name}.nix", ] print(*cmd) subprocess.run(cmd, check=True) - # extract the tarball so the directory is writable. - (path / "upgrades").mkdir() - subprocess.run( - [ - "tar", - "xfz", - path / "upgrades.tar.gz", - "-C", - path / "upgrades", - ], - check=True, - ) + # copy the content so the new directory is writable. + upgrades = path / "upgrades" + shutil.copytree("./result", upgrades) + mod = stat.S_IRWXU + upgrades.chmod(mod) + for d in upgrades.iterdir(): + d.chmod(mod) # init with genesis binary with contextmanager(setup_custom_cronos)( path, port, - Path(__file__).parent / f"configs/{cfg_name}.jsonnet", + configdir / f"configs/{cfg_name}.jsonnet", post_init=post_init, - chain_binary=str(path / "upgrades/genesis/bin/cronosd"), + chain_binary=str(upgrades / "genesis/bin/cronosd"), ) as cronos: yield cronos diff --git a/nix/build_overlay.nix b/nix/build_overlay.nix index 749d3e9e03..476654e669 100644 --- a/nix/build_overlay.nix +++ b/nix/build_overlay.nix @@ -1,21 +1,4 @@ # some basic overlays nessesary for the build final: super: { rocksdb = final.callPackage ./rocksdb.nix { }; - - # make-tarball don't follow symbolic links to avoid duplicate file, the bundle should have no external references. - # reset the ownership and permissions to make the extract result more normal. - make-tarball = final.callPackage - ({ buildPackages - , runCommand - }: drv: runCommand "tarball-${drv.name}" - { - nativeBuildInputs = with buildPackages; [ gnutar gzip ]; - } - '' - tar cfv - -C "${drv}" \ - --owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \ - | gzip -9 > $out - '' - ) - { }; }