@@ -712,7 +712,7 @@ def install_previous(self, downgrade=False):
712
712
arch = "amd64"
713
713
714
714
pathlib .Path ("/etc/apt/keyrings" ).mkdir (parents = True , exist_ok = True )
715
- gpg_full_path = "/etc/apt/keyrings/salt-archive-keyring.gpg "
715
+ gpg_full_path = "/etc/apt/keyrings/salt-archive-keyring.pgp "
716
716
717
717
# download the gpg pub key
718
718
download_file (
@@ -724,28 +724,37 @@ def install_previous(self, downgrade=False):
724
724
) as fp :
725
725
fp .write (
726
726
f"deb [signed-by={ gpg_full_path } arch={ arch } ] "
727
- f"{ root_url } /saltproject-deb/ { self . distro_codename } main"
727
+ f"{ root_url } /saltproject-deb/ stable main"
728
728
)
729
729
self ._check_retcode (ret )
730
+ pref_file = pathlib .Path ("/etc" , "apt" , "preferences.d" , "salt-pin-1001" )
731
+ pref_file .parent .mkdir (exist_ok = True )
732
+ pin = f"{ self .prev_version .rsplit ('.' , 1 )[0 ]} .*"
733
+ if downgrade :
734
+ pin = self .prev_version
735
+ with salt .utils .files .fopen (pref_file , "w" ) as fp :
736
+ fp .write (
737
+ f"Package: salt-*\n " f"Pin: version { pin } \n " f"Pin-Priority: 1001"
738
+ )
730
739
731
740
cmd = [self .pkg_mngr , "install" , * self .salt_pkgs , "-y" ]
732
741
733
- if downgrade :
734
- pref_file = pathlib .Path ("/etc" , "apt" , "preferences.d" , "salt.pref " )
735
- pref_file .parent .mkdir (exist_ok = True )
736
- # TODO: There's probably something I should put in here to say what version
737
- # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs
738
- pref_file .write_text (
739
- textwrap .dedent (
740
- f"""\
741
- Package: salt*
742
- Pin: origin "{ root_url } /saltproject-deb"
743
- Pin-Priority: 1001
744
- """
745
- ),
746
- encoding = "utf-8" ,
747
- )
748
- cmd .append ("--allow-downgrades" )
742
+ # if downgrade:
743
+ # pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt-pin-1001 ")
744
+ # pref_file.parent.mkdir(exist_ok=True)
745
+ # # TODO: There's probably something I should put in here to say what version
746
+ # # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs
747
+ # pref_file.write_text(
748
+ # textwrap.dedent(
749
+ # f"""\
750
+ # Package: salt*
751
+ # Pin: origin "{root_url}/saltproject-deb"
752
+ # Pin-Priority: 1001
753
+ # """
754
+ # ),
755
+ # encoding="utf-8",
756
+ # )
757
+ cmd .append ("--allow-downgrades" )
749
758
env = os .environ .copy ()
750
759
env ["DEBIAN_FRONTEND" ] = "noninteractive"
751
760
extra_args = [
@@ -757,18 +766,20 @@ def install_previous(self, downgrade=False):
757
766
self .proc .run (self .pkg_mngr , "update" , * extra_args , env = env )
758
767
759
768
cmd .extend (extra_args )
760
-
769
+ log . error ( "Run cmd %s" , cmd )
761
770
ret = self .proc .run (* cmd , env = env )
771
+ log .error ("cmd return %r" , ret )
762
772
# Pre-relenv packages down get downgraded to cleanly programmatically
763
773
# They work manually, and the install tests after downgrades will catch problems with the install
774
+ self ._check_retcode (ret )
764
775
# Let's not check the returncode if this is the case
765
- if not (
766
- downgrade
767
- and packaging .version .parse (self .prev_version )
768
- < packaging .version .parse ("3006.0" )
769
- ):
770
- self ._check_retcode (ret )
771
- if downgrade :
776
+ # if not (
777
+ # downgrade
778
+ # and packaging.version.parse(self.prev_version)
779
+ # < packaging.version.parse("3006.0")
780
+ # ):
781
+ # self._check_retcode(ret)
782
+ if downgrade and not self . no_uninstall :
772
783
pref_file .unlink ()
773
784
self .stop_services ()
774
785
elif platform .is_windows ():
0 commit comments