@@ -17,6 +17,7 @@ use tauri::utils::config::{Updater, V1Compatible};
1717
1818const UPDATER_PRIVATE_KEY : & str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5TlFOMFpXYzJFOUdjeHJEVXY4WE1TMUxGNDJVUjNrMmk1WlR3UVJVUWwva0FBQkFBQUFBQUFBQUFBQUlBQUFBQUpVK3ZkM3R3eWhyN3hiUXhQb2hvWFVzUW9FbEs3NlNWYjVkK1F2VGFRU1FEaGxuRUtlell5U0gxYS9DbVRrS0YyZVJGblhjeXJibmpZeGJjS0ZKSUYwYndYc2FCNXpHalM3MHcrODMwN3kwUG9SOWpFNVhCSUd6L0E4TGRUT096TEtLR1JwT1JEVFU9Cg==" ;
1919const UPDATED_EXIT_CODE : i32 = 0 ;
20+ const ERROR_EXIT_CODE : i32 = 1 ;
2021const UP_TO_DATE_EXIT_CODE : i32 = 2 ;
2122
2223#[ derive( Serialize ) ]
@@ -45,7 +46,7 @@ struct Update {
4546 platforms : HashMap < String , PlatformUpdate > ,
4647}
4748
48- fn build_app ( cwd : & Path , config : & Config , bundle_updater : bool , target : BundleTarget ) {
49+ fn build_app ( cwd : & Path , config : & Config , bundle_updater : bool , targets : Vec < BundleTarget > ) {
4950 let mut command = Command :: new ( "cargo" ) ;
5051 command
5152 . args ( [ "tauri" , "build" , "--debug" , "--verbose" ] )
@@ -55,19 +56,20 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa
5556 . env ( "TAURI_SIGNING_PRIVATE_KEY_PASSWORD" , "" )
5657 . current_dir ( cwd) ;
5758
59+ command. args ( [ "--bundles" ] ) ;
5860 #[ cfg( target_os = "linux" ) ]
59- command. args ( [ "--bundles" , target . name ( ) ] ) ;
61+ command. args ( targets . into_iter ( ) . map ( |t| t . name ( ) ) . collect :: < Vec < & str > > ( ) ) ;
6062 #[ cfg( target_os = "macos" ) ]
61- command. args ( [ "--bundles" , target. name ( ) ] ) ;
63+ command. args ( [ target. name ( ) ] ) ;
6264
6365 if bundle_updater {
6466 #[ cfg( windows) ]
65- command. args ( [ "--bundles" , " msi", "nsis" ] ) ;
67+ command. args ( [ "msi" , "nsis" ] ) ;
6668
67- command. args ( [ "--bundles" , " updater"] ) ;
69+ command. args ( [ "updater" ] ) ;
6870 } else {
6971 #[ cfg( windows) ]
70- command. args ( [ "--bundles" , target. name ( ) ] ) ;
72+ command. args ( [ target. name ( ) ] ) ;
7173 }
7274
7375 let status = command
@@ -82,6 +84,8 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa
8284#[ derive( Copy , Clone ) ]
8385enum BundleTarget {
8486 AppImage ,
87+ Deb ,
88+ Rpm ,
8589
8690 App ,
8791
@@ -93,32 +97,82 @@ impl BundleTarget {
9397 fn name ( self ) -> & ' static str {
9498 match self {
9599 Self :: AppImage => "appimage" ,
100+ Self :: Deb => "deb" ,
101+ Self :: Rpm => "rpm" ,
96102 Self :: App => "app" ,
97103 Self :: Msi => "msi" ,
98104 Self :: Nsis => "nsis" ,
99105 }
100106 }
101107}
102108
103- impl Default for BundleTarget {
104- fn default ( ) -> Self {
109+ impl BundleTarget {
110+ fn get_targets ( ) -> Vec < Self > {
105111 #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
106- return Self :: App ;
112+ return vec ! [ Self :: App ] ;
107113 #[ cfg( target_os = "linux" ) ]
108- return Self :: AppImage ;
114+ return vec ! [ Self :: AppImage , Self :: Deb , Self :: Rpm ] ;
109115 #[ cfg( windows) ]
110- return Self :: Nsis ;
116+ return vec ! [ Self :: Nsis ] ;
117+ }
118+ }
119+
120+ fn insert_plaforms (
121+ bundle_target : BundleTarget ,
122+ platforms : & mut HashMap < String , PlatformUpdate > ,
123+ target : String ,
124+ signature : String ,
125+ ) {
126+ match bundle_target {
127+ // Should use deb, no fallback
128+ BundleTarget :: Deb => {
129+ platforms. insert (
130+ format ! ( "{target}-deb" ) ,
131+ PlatformUpdate {
132+ signature,
133+ url : "http://localhost:3007/download" ,
134+ with_elevated_task : false ,
135+ } ,
136+ ) ;
137+ }
138+ // Should fail
139+ BundleTarget :: Rpm => { }
140+ // AppImage should use fallback
141+ _ => {
142+ platforms. insert (
143+ target,
144+ PlatformUpdate {
145+ signature,
146+ url : "http://localhost:3007/download" ,
147+ with_elevated_task : false ,
148+ } ,
149+ ) ;
150+ }
111151 }
112152}
113153
114154#[ cfg( target_os = "linux" ) ]
115155fn bundle_paths ( root_dir : & Path , version : & str ) -> Vec < ( BundleTarget , PathBuf ) > {
116- vec ! [ (
117- BundleTarget :: AppImage ,
118- root_dir. join( format!(
119- "target/debug/bundle/appimage/app-updater_{version}_amd64.AppImage"
120- ) ) ,
121- ) ]
156+ vec ! [
157+ (
158+ BundleTarget :: AppImage ,
159+ root_dir. join( format!(
160+ "target/debug/bundle/appimage/app-updater_{version}_amd64.AppImage"
161+ ) ) ,
162+ ) ,
163+ (
164+ BundleTarget :: Deb ,
165+ root_dir. join( format!(
166+ "target/debug/bundle/deb/app-updater_{version}_amd64.deb"
167+ ) ) ,
168+ ) ,
169+ (
170+ BundleTarget :: Rpm ,
171+ root_dir. join( format!(
172+ "target/debug/bundle/rpm/app-updater_{version}_amd64.rpm"
173+ ) ) ,
174+ ) ,
175+ ]
122176}
123177
124178#[ cfg( target_os = "macos" ) ]
@@ -161,7 +215,6 @@ fn bundle_paths(root_dir: &Path, version: &str) -> Vec<(BundleTarget, PathBuf)>
161215}
162216
163217#[ test]
164- #[ ignore]
165218fn update_app ( ) {
166219 let target =
167220 tauri_plugin_updater:: target ( ) . expect ( "running updater test in an unsupported platform" ) ;
@@ -188,7 +241,7 @@ fn update_app() {
188241 ) ;
189242
190243 // bundle app update
191- build_app ( & manifest_dir, & config, true , Default :: default ( ) ) ;
244+ build_app ( & manifest_dir, & config, true , BundleTarget :: get_targets ( ) ) ;
192245
193246 let updater_zip_ext = if v1_compatible {
194247 if cfg ! ( windows) {
@@ -249,14 +302,13 @@ fn update_app() {
249302 "/" => {
250303 let mut platforms = HashMap :: new ( ) ;
251304
252- platforms. insert (
305+ insert_plaforms (
306+ bundle_target,
307+ & mut platforms,
253308 target. clone ( ) ,
254- PlatformUpdate {
255- signature : signature. clone ( ) ,
256- url : "http://localhost:3007/download" ,
257- with_elevated_task : false ,
258- } ,
309+ signature. clone ( ) ,
259310 ) ;
311+
260312 let body = serde_json:: to_vec ( & Update {
261313 version : "1.0.0" ,
262314 date : time:: OffsetDateTime :: now_utc ( )
@@ -293,11 +345,13 @@ fn update_app() {
293345 config. version = "0.1.0" ;
294346
295347 // bundle initial app version
296- build_app ( & manifest_dir, & config, false , bundle_target) ;
348+ build_app ( & manifest_dir, & config, false , vec ! [ bundle_target] ) ;
297349
298350 let status_checks = if matches ! ( bundle_target, BundleTarget :: Msi ) {
299351 // for msi we can't really check if the app was updated, because we can't change the install path
300352 vec ! [ UPDATED_EXIT_CODE ]
353+ } else if matches ! ( bundle_target, BundleTarget :: Rpm ) {
354+ vec ! [ ERROR_EXIT_CODE ]
301355 } else {
302356 vec ! [ UPDATED_EXIT_CODE , UP_TO_DATE_EXIT_CODE ]
303357 } ;
0 commit comments