@@ -42,9 +42,7 @@ pub const STARTUP_UPGRADE_FILE: &str = "/pop-upgrade";
4242/// Packages which need to be removed *before* the sources are reset to defaults
4343/// and updates are applied (e.g. DKMS packages that work with the Pop!_OS kernel when
4444/// installed from third-party sources, but not when installed from the Ubuntu repo).
45- const REMOVE_PACKAGES_EARLY : & [ & str ] = & [
46- "openrazer-driver-dkms" ,
47- ] ;
45+ const REMOVE_PACKAGES_EARLY : & [ & str ] = & [ "openrazer-driver-dkms" ] ;
4846
4947/// Packages which should be removed before upgrading.
5048///
@@ -176,13 +174,19 @@ impl From<UpgradeEvent> for &'static str {
176174 }
177175 UpgradeEvent :: Failure => "an error occurred while setting up the release upgrade" ,
178176 UpgradeEvent :: FetchingPackages => "fetching updated packages for the current release" ,
179- UpgradeEvent :: FetchingPackagesForNewRelease => "fetching updated packages for the new release" ,
180- UpgradeEvent :: FetchingAdditionalPackagesForNewRelease => "fetching additional packages for the new release" ,
177+ UpgradeEvent :: FetchingPackagesForNewRelease => {
178+ "fetching updated packages for the new release"
179+ }
180+ UpgradeEvent :: FetchingAdditionalPackagesForNewRelease => {
181+ "fetching additional packages for the new release"
182+ }
181183 UpgradeEvent :: InstallingPackages => {
182184 "ensuring that system-critical packages are installed"
183185 }
184186 UpgradeEvent :: RemovingConflicts => "removing deprecated and/or conflicting packages" ,
185- UpgradeEvent :: RemovingWacomConflicts => "replacing Surface-tailored Wacom packages with standard ones" ,
187+ UpgradeEvent :: RemovingWacomConflicts => {
188+ "replacing Surface-tailored Wacom packages with standard ones"
189+ }
186190 UpgradeEvent :: Success => "new release is ready to install" ,
187191 UpgradeEvent :: SuccessLive => "new release was successfully installed" ,
188192 UpgradeEvent :: UpdatingPackageLists => "updating package lists" ,
@@ -469,7 +473,7 @@ pub async fn upgrade<'a>(
469473
470474 // Ensure packages are not newer than what's in the repositories.
471475 downgrade_packages ( ) . await ?;
472-
476+
473477 // Replace problematic Wacom packages with supported ones.
474478 remove_wacom_packages ( logger) . await ?;
475479
@@ -493,7 +497,7 @@ pub async fn upgrade<'a>(
493497
494498 // Reset system76-power modprobe configurations to the system defaults.
495499 _ = switchable_graphics:: reset_to_default ( ) ;
496-
500+
497501 // Reset the user shell to /bin/bash in case the shell was removed in upgrade
498502 _ = logins:: reset_shell ( ) ;
499503
@@ -533,17 +537,20 @@ async fn downgrade_packages() -> Result<(), ReleaseError> {
533537 if package. contains ( "pop-upgrade" ) || package. contains ( "pop-system-updater" ) {
534538 continue ;
535539 }
536-
540+
537541 // Papirus's elementary variant must be removed prior to downgrading the main package.
538542 if package. contains ( "papirus-icon-theme" ) {
539543 info ! ( "papirus-icon-theme will be downgraded, so removing epapirus-icon-theme" ) ;
540544 let mut remove_epapirus_cmd = AptGet :: new ( ) . allow_downgrades ( ) . force ( ) . noninteractive ( ) ;
541545 remove_epapirus_cmd. arg ( "remove" ) ;
542546 remove_epapirus_cmd. arg ( "epapirus-icon-theme" ) ;
543- let _remove_epapirus = remove_epapirus_cmd. status ( ) . await
544- . context ( "apt-get remove epapirus-icon-theme" ) . map_err ( ReleaseError :: Downgrade ) ;
547+ let _remove_epapirus = remove_epapirus_cmd
548+ . status ( )
549+ . await
550+ . context ( "apt-get remove epapirus-icon-theme" )
551+ . map_err ( ReleaseError :: Downgrade ) ;
545552 }
546-
553+
547554 // In Ubuntu 22.04, the `ansible` and `ansible-core` packages are not compatible.
548555 // If `ansible-core` is downgradable, check if `ansible` is downgradable;
549556 // if so, remove `ansible-core` and skip adding it to the downgrade command.
@@ -552,11 +559,15 @@ async fn downgrade_packages() -> Result<(), ReleaseError> {
552559 for ( package, _version) in & downgradable {
553560 if package. eq ( "ansible" ) {
554561 info ! ( "ansible will also be downgraded, so removing ansible-core" ) ;
555- let mut remove_ansible_core_cmd = AptGet :: new ( ) . allow_downgrades ( ) . force ( ) . noninteractive ( ) ;
556- remove_ansible_core_cmd. arg ( "remove" ) ;
557- remove_ansible_core_cmd. arg ( "ansible-core" ) ;
558- let _remove_ansible_core = remove_ansible_core_cmd. status ( ) . await
559- . context ( "apt-get remove ansible-core" ) . map_err ( ReleaseError :: Downgrade ) ;
562+ let mut remove_ansible_core_cmd =
563+ AptGet :: new ( ) . allow_downgrades ( ) . force ( ) . noninteractive ( ) ;
564+ remove_ansible_core_cmd. arg ( "remove" ) ;
565+ remove_ansible_core_cmd. arg ( "ansible-core" ) ;
566+ let _remove_ansible_core = remove_ansible_core_cmd
567+ . status ( )
568+ . await
569+ . context ( "apt-get remove ansible-core" )
570+ . map_err ( ReleaseError :: Downgrade ) ;
560571 continue ' downgrades;
561572 }
562573 }
@@ -611,8 +622,9 @@ async fn remove_wacom_packages(logger: &dyn Fn(UpgradeEvent)) -> Result<(), Rele
611622 // This must be done before checking for remoteless packages,
612623 // as other related packages will also be removed.
613624 let mut conflicting_surface = ( async {
614- let ( mut child, package_stream) =
615- DpkgQuery :: new ( ) . show_installed ( [ "libwacom-common-surface" , "libwacom9-surface" ] ) . await ?;
625+ let ( mut child, package_stream) = DpkgQuery :: new ( )
626+ . show_installed ( [ "libwacom-common-surface" , "libwacom9-surface" ] )
627+ . await ?;
616628
617629 futures_util:: pin_mut!( package_stream) ;
618630
@@ -630,7 +642,7 @@ async fn remove_wacom_packages(logger: &dyn Fn(UpgradeEvent)) -> Result<(), Rele
630642 . await
631643 . context ( "check for known-conflicting Wacom/Surface packages" )
632644 . map_err ( ReleaseError :: ConflictRemoval ) ?;
633-
645+
634646 if !conflicting_surface. is_empty ( ) {
635647 apt_lock_wait ( ) . await ;
636648 ( logger) ( UpgradeEvent :: RemovingWacomConflicts ) ;
@@ -643,11 +655,15 @@ async fn remove_wacom_packages(logger: &dyn Fn(UpgradeEvent)) -> Result<(), Rele
643655 . context ( "conflict removal (libwacom Surface packages)" )
644656 . map_err ( ReleaseError :: ConflictRemoval ) ?;
645657 }
646-
658+
647659 Ok ( ( ) )
648660}
649661
650- async fn remove_conflicting_packages ( logger : & dyn Fn ( UpgradeEvent ) , packages : & [ & str ] , remoteless : bool ) -> Result < ( ) , ReleaseError > {
662+ async fn remove_conflicting_packages (
663+ logger : & dyn Fn ( UpgradeEvent ) ,
664+ packages : & [ & str ] ,
665+ remoteless : bool ,
666+ ) -> Result < ( ) , ReleaseError > {
651667 let mut conflicting = ( async {
652668 let ( mut child, package_stream) = DpkgQuery :: new ( ) . show_installed ( packages) . await ?;
653669
@@ -788,9 +804,10 @@ async fn fetch_new_release_packages<'b>(
788804
789805 // If upgrading to 24.04, download an additional package.
790806 if to == "24.04" {
791- //const NEW_PACKAGES &[&str] = &["gnome-online-accounts-gtk"];
792- //new_packages = Some(ExtraPackages::Static(NEW_PACKAGES));
793- additional_fetch ( & Shutdown :: new ( ) , logger, fetch, & [ "gnome-online-accounts-gtk" ] ) . await ?;
807+ // const NEW_PACKAGES &[&str] = &["gnome-online-accounts-gtk"];
808+ // new_packages = Some(ExtraPackages::Static(NEW_PACKAGES));
809+ additional_fetch ( & Shutdown :: new ( ) , logger, fetch, & [ "gnome-online-accounts-gtk" ] )
810+ . await ?;
794811 }
795812
796813 snapd:: hold_transitional_packages ( ) . await ?;
@@ -926,24 +943,23 @@ mod logins {
926943 use std:: process:: { Command , Stdio } ;
927944
928945 fn login_is_disabled ( user : & str ) -> bool {
929- Command :: new ( "getent" )
930- . args ( & [ "passwd" , user] )
931- . stdout ( Stdio :: piped ( ) )
932- . output ( )
933- . map_or ( true , |output| {
946+ Command :: new ( "getent" ) . args ( & [ "passwd" , user] ) . stdout ( Stdio :: piped ( ) ) . output ( ) . map_or (
947+ true ,
948+ |output| {
934949 let stdout = output. stdout . trim_end ( ) ;
935950 stdout. ends_with ( b"/bin/false" ) || stdout. ends_with ( b"/usr/sbin/nologin" )
936- } )
951+ } ,
952+ )
937953 }
938-
954+
939955 /// Reset the user shell to /bin/bash in case the shell was removed in upgrade
940956 pub fn reset_shell ( ) -> anyhow:: Result < ( ) > {
941957 let ( uid_min, uid_max) = crate :: misc:: uid_min_max ( ) ?;
942-
958+
943959 for user in unsafe { uzers:: all_users ( ) } {
944960 if user. uid ( ) >= uid_min && user. uid ( ) <= uid_max {
945961 let name = user. name ( ) ;
946-
962+
947963 if let Some ( name) = name. to_str ( ) {
948964 if !login_is_disabled ( name) {
949965 _ = std:: process:: Command :: new ( "usermod" )
@@ -953,7 +969,7 @@ mod logins {
953969 }
954970 }
955971 }
956-
972+
957973 Ok ( ( ) )
958974 }
959- }
975+ }
0 commit comments