Skip to content

Commit e688ee1

Browse files
committed
initialize sbuilder
1 parent 59c6981 commit e688ee1

12 files changed

Lines changed: 2710 additions & 158 deletions

File tree

Cargo.lock

Lines changed: 1787 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
resolver = "2"
33
members = [
4+
"sbuilder",
45
"sbuild-linter"
56
]
67

sbuild-linter/src/build_config/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod visitor;
1515
pub struct BuildConfig {
1616
pub _disabled: bool,
1717
pub pkg: String,
18-
pub pkg_id: Option<String>,
18+
pub pkg_id: String,
1919
pub pkg_type: Option<String>,
2020
pub pkgver: Option<String>,
2121
pub app_id: Option<String>,
@@ -52,11 +52,9 @@ impl BuildConfig {
5252
config._disabled = values.get("_disabled").unwrap().as_bool().unwrap();
5353
config.pkg = values.get("pkg").unwrap().as_str().unwrap().to_string();
5454
if let Some(val) = values.get("pkg_id") {
55-
config.pkg_id = val.as_str().map(String::from);
55+
config.pkg_id = val.as_str().unwrap().to_string();
5656
} else {
57-
config.pkg_id = Some(get_pkg_id(
58-
&to_string_vec(values.get("src_url").unwrap()).unwrap()[0],
59-
));
57+
config.pkg_id = get_pkg_id(&to_string_vec(values.get("src_url").unwrap()).unwrap()[0]);
6058
}
6159
if let Some(val) = values.get("pkg_type") {
6260
config.pkg_type = val.as_str().map(String::from);
@@ -166,9 +164,7 @@ impl BuildConfig {
166164
writeln!(writer, "{}pkg: \"{}\"", indent_str, self.pkg)?;
167165

168166
write_field_comments(writer, "pkg_id")?;
169-
if let Some(ref pkg_id) = self.pkg_id {
170-
writeln!(writer, "{}pkg_id: \"{}\"", indent_str, pkg_id)?;
171-
}
167+
writeln!(writer, "{}pkg_id: \"{}\"", indent_str, self.pkg_id)?;
172168

173169
write_field_comments(writer, "pkg_type")?;
174170
if let Some(ref pkg_type) = self.pkg_type {

sbuild-linter/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ pub const VALID_CATEGORIES: &str = include_str!("categories");
4141

4242
#[derive(Debug, Deserialize, Clone)]
4343
pub struct BuildAsset {
44-
url: String,
45-
out: String,
44+
pub url: String,
45+
pub out: String,
4646
}
4747

4848
pub struct Linter {
@@ -179,7 +179,7 @@ impl Linter {
179179
pub fn generate_pkgver(&self, config: &BuildConfig, pkgver_path: &str) -> bool {
180180
let logger = &self.logger;
181181
let x_exec = &config.x_exec;
182-
let mut success = true;
182+
let mut success = false;
183183

184184
match config.pkgver {
185185
Some(ref pkgver) => {
@@ -193,6 +193,7 @@ impl Linter {
193193
pkgver,
194194
pkgver_path.bright_cyan()
195195
));
196+
success = true;
196197
}
197198
None => {
198199
if let Some(ref pkgver) = x_exec.pkgver {
@@ -214,7 +215,6 @@ impl Linter {
214215
if !cmd.stderr.is_empty() {
215216
logger.error("x.exec.pkgver script produced error.");
216217
logger.error(&String::from_utf8_lossy(&cmd.stderr));
217-
success = false;
218218
} else {
219219
let out = cmd.stdout;
220220
let output_str = String::from_utf8_lossy(&out);
@@ -228,18 +228,17 @@ impl Linter {
228228
output_str.lines().for_each(|line| {
229229
logger.info(&format!("-> {}", line.trim()));
230230
});
231-
success = false;
232231
} else {
233232
let file = File::create(pkgver_path).unwrap();
234233
let mut writer = BufWriter::new(file);
235234
let _ = writer.write_all(output_str.as_bytes());
236235

237236
logger.success(&format!("Fetched version ({}) using x_exec.pkgver written to {}", &output_str, pkgver_path.bright_cyan()));
237+
success = true;
238238
}
239239
}
240240
} else {
241241
logger.error(&format!("{} -> Failed to read output from pkgver script. Please make sure the script is valid.", "x_exec.pkgver".bold()));
242-
success = false;
243242
if !cmd.stderr.is_empty() {
244243
logger.error(&String::from_utf8_lossy(&cmd.stderr));
245244
}
@@ -251,7 +250,6 @@ impl Linter {
251250
"x_exec.pkgver".bold(),
252251
err
253252
));
254-
success = false;
255253
}
256254
}
257255
}
@@ -260,11 +258,13 @@ impl Linter {
260258
"{} -> pkgver script timed out after 15 seconds",
261259
"x_exec.pkgver".bold()
262260
));
263-
success = false;
264261
}
265262
}
266263

267264
fs::remove_file(tmp).expect("Failed to delete temporary script file");
265+
} else {
266+
// we don't care if the pkgver is not set
267+
success = true;
268268
}
269269
}
270270
}

sbuilder/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "sbuilder"
3+
version = "0.1.0"
4+
authors.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
7+
description.workspace = true
8+
repository.workspace = true
9+
keywords.workspace = true
10+
11+
[dependencies]
12+
blake3 = "1.5.5"
13+
colored = "2.1.0"
14+
futures = "0.3.31"
15+
goblin = { version = "0.9.2", features = ["elf64", "elf32", "endian_fd", "std"] }
16+
indexmap = "2.6.0"
17+
nanoid = "0.4.0"
18+
reqwest = { version = "0.12.9", features = ["blocking", "http2", "rustls-tls", "stream"], default-features = false }
19+
sbuild-linter = { version = "0.3.0", path = "../sbuild-linter" }
20+
serde = { version = "1.0.215", features = ["derive"] }
21+
serde_json = { version = "1.0.133", features = ["indexmap"] }
22+
serde_yml = "0.0.12"
23+
squishy = { version = "0.3.0", features = ["appimage", "rayon"] }
24+
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread"] }
25+
which = "7.0.0"

0 commit comments

Comments
 (0)