@@ -17,6 +17,7 @@ use tauri::utils::config::{Updater, V1Compatible};
17
17
18
18
const UPDATER_PRIVATE_KEY : & str = "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5TlFOMFpXYzJFOUdjeHJEVXY4WE1TMUxGNDJVUjNrMmk1WlR3UVJVUWwva0FBQkFBQUFBQUFBQUFBQUlBQUFBQUpVK3ZkM3R3eWhyN3hiUXhQb2hvWFVzUW9FbEs3NlNWYjVkK1F2VGFRU1FEaGxuRUtlell5U0gxYS9DbVRrS0YyZVJGblhjeXJibmpZeGJjS0ZKSUYwYndYc2FCNXpHalM3MHcrODMwN3kwUG9SOWpFNVhCSUd6L0E4TGRUT096TEtLR1JwT1JEVFU9Cg==" ;
19
19
const UPDATED_EXIT_CODE : i32 = 0 ;
20
+ const ERROR_EXIT_CODE : i32 = 1 ;
20
21
const UP_TO_DATE_EXIT_CODE : i32 = 2 ;
21
22
22
23
#[ derive( Serialize ) ]
@@ -45,7 +46,7 @@ struct Update {
45
46
platforms : HashMap < String , PlatformUpdate > ,
46
47
}
47
48
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 > ) {
49
50
let mut command = Command :: new ( "cargo" ) ;
50
51
command
51
52
. args ( [ "tauri" , "build" , "--debug" , "--verbose" ] )
@@ -55,19 +56,20 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa
55
56
. env ( "TAURI_SIGNING_PRIVATE_KEY_PASSWORD" , "" )
56
57
. current_dir ( cwd) ;
57
58
59
+ command. args ( [ "--bundles" ] ) ;
58
60
#[ cfg( target_os = "linux" ) ]
59
- command. args ( [ "--bundles" , target . name ( ) ] ) ;
61
+ command. args ( targets . into_iter ( ) . map ( |t| t . name ( ) ) . collect :: < Vec < & str > > ( ) ) ;
60
62
#[ cfg( target_os = "macos" ) ]
61
- command. args ( [ "--bundles" , target. name ( ) ] ) ;
63
+ command. args ( [ target. name ( ) ] ) ;
62
64
63
65
if bundle_updater {
64
66
#[ cfg( windows) ]
65
- command. args ( [ "--bundles" , " msi", "nsis" ] ) ;
67
+ command. args ( [ "msi" , "nsis" ] ) ;
66
68
67
- command. args ( [ "--bundles" , " updater"] ) ;
69
+ command. args ( [ "updater" ] ) ;
68
70
} else {
69
71
#[ cfg( windows) ]
70
- command. args ( [ "--bundles" , target. name ( ) ] ) ;
72
+ command. args ( [ target. name ( ) ] ) ;
71
73
}
72
74
73
75
let status = command
@@ -82,6 +84,8 @@ fn build_app(cwd: &Path, config: &Config, bundle_updater: bool, target: BundleTa
82
84
#[ derive( Copy , Clone ) ]
83
85
enum BundleTarget {
84
86
AppImage ,
87
+ Deb ,
88
+ Rpm ,
85
89
86
90
App ,
87
91
@@ -93,32 +97,82 @@ impl BundleTarget {
93
97
fn name ( self ) -> & ' static str {
94
98
match self {
95
99
Self :: AppImage => "appimage" ,
100
+ Self :: Deb => "deb" ,
101
+ Self :: Rpm => "rpm" ,
96
102
Self :: App => "app" ,
97
103
Self :: Msi => "msi" ,
98
104
Self :: Nsis => "nsis" ,
99
105
}
100
106
}
101
107
}
102
108
103
- impl Default for BundleTarget {
104
- fn default ( ) -> Self {
109
+ impl BundleTarget {
110
+ fn get_targets ( ) -> Vec < Self > {
105
111
#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
106
- return Self :: App ;
112
+ return vec ! [ Self :: App ] ;
107
113
#[ cfg( target_os = "linux" ) ]
108
- return Self :: AppImage ;
114
+ return vec ! [ Self :: AppImage , Self :: Deb , Self :: Rpm ] ;
109
115
#[ 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
+ }
111
151
}
112
152
}
113
153
114
154
#[ cfg( target_os = "linux" ) ]
115
155
fn 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
+ ]
122
176
}
123
177
124
178
#[ cfg( target_os = "macos" ) ]
@@ -161,7 +215,6 @@ fn bundle_paths(root_dir: &Path, version: &str) -> Vec<(BundleTarget, PathBuf)>
161
215
}
162
216
163
217
#[ test]
164
- #[ ignore]
165
218
fn update_app ( ) {
166
219
let target =
167
220
tauri_plugin_updater:: target ( ) . expect ( "running updater test in an unsupported platform" ) ;
@@ -188,7 +241,7 @@ fn update_app() {
188
241
) ;
189
242
190
243
// bundle app update
191
- build_app ( & manifest_dir, & config, true , Default :: default ( ) ) ;
244
+ build_app ( & manifest_dir, & config, true , BundleTarget :: get_targets ( ) ) ;
192
245
193
246
let updater_zip_ext = if v1_compatible {
194
247
if cfg ! ( windows) {
@@ -249,14 +302,13 @@ fn update_app() {
249
302
"/" => {
250
303
let mut platforms = HashMap :: new ( ) ;
251
304
252
- platforms. insert (
305
+ insert_plaforms (
306
+ bundle_target,
307
+ & mut platforms,
253
308
target. clone ( ) ,
254
- PlatformUpdate {
255
- signature : signature. clone ( ) ,
256
- url : "http://localhost:3007/download" ,
257
- with_elevated_task : false ,
258
- } ,
309
+ signature. clone ( ) ,
259
310
) ;
311
+
260
312
let body = serde_json:: to_vec ( & Update {
261
313
version : "1.0.0" ,
262
314
date : time:: OffsetDateTime :: now_utc ( )
@@ -293,11 +345,13 @@ fn update_app() {
293
345
config. version = "0.1.0" ;
294
346
295
347
// bundle initial app version
296
- build_app ( & manifest_dir, & config, false , bundle_target) ;
348
+ build_app ( & manifest_dir, & config, false , vec ! [ bundle_target] ) ;
297
349
298
350
let status_checks = if matches ! ( bundle_target, BundleTarget :: Msi ) {
299
351
// for msi we can't really check if the app was updated, because we can't change the install path
300
352
vec ! [ UPDATED_EXIT_CODE ]
353
+ } else if matches ! ( bundle_target, BundleTarget :: Rpm ) {
354
+ vec ! [ ERROR_EXIT_CODE ]
301
355
} else {
302
356
vec ! [ UPDATED_EXIT_CODE , UP_TO_DATE_EXIT_CODE ]
303
357
} ;
0 commit comments