Skip to content

Commit

Permalink
added ipkSize and installedSize for manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Feb 5, 2024
1 parent 509c5da commit 247c003
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 164 deletions.
270 changes: 131 additions & 139 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ members = [
]

[workspace.dependencies]
clap = "4.4.6"
regex = "1.9.5"
serde = "1.0.188"
serde_json = "1.0.107"
semver = "1.0.19"
clap = "4.4.18"
debpkg = "0.6.0"
path-slash = "0.2.1"
regex = "1.10.3"
serde = "1.0.196"
serde_json = "1.0.113"
semver = "1.0.21"
tempfile = "3.8.0"
2 changes: 1 addition & 1 deletion common/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.1"
edition = "2021"

[dependencies]
elf = "0.7.2"
elf = "0.7.4"
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
semver = { workspace = true }
Expand Down
11 changes: 5 additions & 6 deletions common/bin/src/library.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::cmp::Ordering;
use std::ops::Deref;

use elf::{abi, ElfStream, ParseError};
use elf::dynamic::Dyn;
use elf::endian::AnyEndian;
use elf::symbol::Symbol;
use elf::{abi, ElfStream, ParseError};

use crate::LibraryInfo;

Expand All @@ -22,7 +21,7 @@ const IGNORED_SYMBOLS: &[&str] = &[

impl LibraryInfo {
pub fn has_name(&self, name: &str) -> bool {
return self.name == name || self.names.iter().find(|n| n.deref() == name).is_some();
return self.name == name || self.names.iter().find(|n| *n == name).is_some();
}

pub fn has_symbol(&self, symbol: &str) -> bool {
Expand All @@ -42,9 +41,9 @@ impl LibraryInfo {
}

pub fn parse<S, N>(source: S, with_undefined: bool, name: N) -> Result<Self, ParseError>
where
S: std::io::Read + std::io::Seek,
N: AsRef<str>,
where
S: std::io::Read + std::io::Seek,
N: AsRef<str>,
{
let mut needed = Vec::<String>::new();
let mut elf = ElfStream::<AnyEndian, S>::open_stream(source)?;
Expand Down
4 changes: 2 additions & 2 deletions common/ipk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
debpkg = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
debpkg = "0.6.0"
tempfile = "3.8.0"
tempfile = { workspace = true }
path-slash = { workspace = true }
common-path = "1.0.0"

Expand Down
9 changes: 6 additions & 3 deletions common/ipk/src/ipk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ impl Package {
}

pub fn parse<R>(read: R) -> Result<Self, Error>
where
R: Read,
where R: Read,
{
let mut deb = DebPkg::parse(read).map_err(Self::deb_err)?;
let control = Control::extract(deb.control().unwrap()).map_err(Self::deb_err)?;
let mut data = deb.data().map_err(Self::deb_err)?;

let id = String::from(control.name());
let installed_size = control.get("Installed-Size").filter(|s| *s != "1234")
.map(|s| u64::from_str_radix(s, 10).ok()).flatten();

let tmp = tempfile::TempDir::new()?;
let mut links = HashMap::new();
for entry in data.entries()? {
Expand Down Expand Up @@ -67,7 +70,7 @@ impl Package {
)?;
services.push(service);
}
return Ok(Self { id, app, services });
return Ok(Self { id, installed_size, app, services });
}

fn deb_err(e: debpkg::Error) -> Error {
Expand Down
1 change: 1 addition & 0 deletions common/ipk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod links;
#[derive(Debug)]
pub struct Package {
pub id: String,
pub installed_size: Option<u64>,
pub app: Component<AppInfo>,
pub services: Vec<Component<ServiceInfo>>,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/elf-verify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ serde_json = { workspace = true }
semver = { workspace = true }

[dependencies.clap]
version = "4.3.23"
workspace = true
features = ["derive"]

[dependencies.bin-lib]
Expand Down
2 changes: 1 addition & 1 deletion packages/fw-extract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fw-lib = { path = "../../common/fw" }
bin-lib = { path = "../../common/bin" }

[dependencies.clap]
version = "4.3.23"
workspace = true
features = ["derive"]

[features]
Expand Down
4 changes: 2 additions & 2 deletions packages/gen-manifest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gen-manifest"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
description = "Command line tool for generating manifest for publish from an IPK file"
authors = ["Mariotaku Lee <[email protected]>"]
Expand All @@ -13,7 +13,7 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
clap = { workspace = true, features = ["derive"] }
ipk-lib = { path = "../../common/ipk" }
sha256 = "1.4.0"
sha256 = { version = "1.5.0", default-features = false }

[package.metadata.deb]
name = "webosbrew-toolbox-gen-manifest"
Expand Down
4 changes: 4 additions & 0 deletions packages/gen-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ struct HomebrewManifest {
root_required: Option<RootRequired>,
ipk_url: String,
ipk_hash: IpkHash,
ipk_size: u64,
installed_size: Option<u64>
}

fn main() {
Expand All @@ -86,6 +88,8 @@ fn main() {
root_required: args.root,
ipk_url: String::from(args.pkgfile.file_name().unwrap().to_string_lossy()),
ipk_hash: IpkHash::from(&args.pkgfile).unwrap(),
ipk_size: args.pkgfile.metadata().unwrap().len(),
installed_size: package.installed_size,
};
if let Some(output) = args.output {
serde_json::to_writer_pretty(&mut File::create(&output).unwrap(), &manifest).unwrap();
Expand Down
8 changes: 4 additions & 4 deletions packages/ipk-verify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ license = "Apache-2.0"
[dependencies]
serde = { workspace = true }
serde_json = { workspace = true }
debpkg = "0.6.0"
tempfile = "3.8.0"
debpkg = { workspace = true }
tempfile = { workspace = true }
path-slash = { workspace = true }
prettytable-rs = "^0.10"
semver = { workspace = true }
is-terminal = "0.4.9"
is-terminal = "0.4.10"
term = "0.7.0"
clap = { version = "4.4.6", features = ["derive"] }
clap = { workspace = true, features = ["derive"] }
verify-lib = { path = "../../common/verify", features = ["ipk"] }

[dependencies.fw-lib]
Expand Down

0 comments on commit 247c003

Please sign in to comment.