pull: reject malformed --ppa values instead of silently using the archive
A --ppa value that was not exactly 'user/name' (full URL, extra segment, empty halves) made base_url None and pulled the package from the main archive without any warning. Error out naming the expected format instead, and document the format in --help.
This commit is contained in:
+6
-6
@@ -47,7 +47,7 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.arg(arg!(-v --version <version> "Target package version").required(false))
|
.arg(arg!(-v --version <version> "Target package version").required(false))
|
||||||
.arg(arg!(--archive "Only use the archive to download package source, not git").required(false))
|
.arg(arg!(--archive "Only use the archive to download package source, not git").required(false))
|
||||||
.arg(arg!(--ppa <ppa> "Download the package from a specific PPA").required(false))
|
.arg(arg!(--ppa <ppa> "Download the package from a specific PPA (format: user/ppa_name)").required(false))
|
||||||
.arg(arg!(--repository <url> "Download the package from an external flat repository, given as its full suite URL (e.g. https://pkg.noctalia.dev/deb/resolute/)").required(false)
|
.arg(arg!(--repository <url> "Download the package from an external flat repository, given as its full suite URL (e.g. https://pkg.noctalia.dev/deb/resolute/)").required(false)
|
||||||
.conflicts_with("ppa"))
|
.conflicts_with("ppa"))
|
||||||
.arg(arg!(-p --pocket <pocket> "Target package distribution pocket (updates, security, proposed)").required(false))
|
.arg(arg!(-p --pocket <pocket> "Target package distribution pocket (updates, security, proposed)").required(false))
|
||||||
@@ -152,14 +152,14 @@ fn main() {
|
|||||||
let (pb, progress_callback) = pkh::ui::create_progress_bar(&multi);
|
let (pb, progress_callback) = pkh::ui::create_progress_bar(&multi);
|
||||||
|
|
||||||
// Convert PPA to base URL if provided
|
// Convert PPA to base URL if provided
|
||||||
let base_url = ppa.and_then(|ppa_str| {
|
let base_url = ppa.map(|ppa_str| {
|
||||||
// PPA format: user/ppa_name
|
// PPA format: user/ppa_name
|
||||||
let parts: Vec<&str> = ppa_str.split('/').collect();
|
let parts: Vec<&str> = ppa_str.split('/').collect();
|
||||||
if parts.len() == 2 {
|
if parts.len() != 2 || parts[0].is_empty() || parts[1].is_empty() {
|
||||||
Some(pkh::package_info::ppa_to_base_url(parts[0], parts[1]))
|
error!("Invalid PPA format: '{}'. Expected: user/ppa_name", ppa_str);
|
||||||
} else {
|
std::process::exit(1);
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
pkh::package_info::ppa_to_base_url(parts[0], parts[1])
|
||||||
});
|
});
|
||||||
|
|
||||||
// Since pull is async, we need to block on it
|
// Since pull is async, we need to block on it
|
||||||
|
|||||||
Reference in New Issue
Block a user