Skip to content

Commit 1e3ba81

Browse files
authored
fix(topics): linux-kernel-* only rel different should downgrade, not remove (#646)
1 parent 0ad2777 commit 1e3ba81

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/subcommand/topics.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,24 @@ impl CliExecuter for Topics {
277277
}
278278

279279
let pkg_name = pkg.name();
280+
let pkginfo = matcher.find_candidate_by_pkgname(pkg_name)?;
280281

281282
// linux-kernel-VER 包在关闭 topic 的时候应该直接删除
282283
if pkg_name.starts_with("linux-kernel-") {
284+
let installed_version = pkg.installed().unwrap();
285+
let installed_version = installed_version.version();
286+
let candidate = pkginfo.version_raw.version();
287+
let (inst_ver_no_rel, _) = installed_version
288+
.split_once('-')
289+
.unwrap_or((installed_version, "0"));
290+
let (cand_ver_no_rel, _) =
291+
candidate.split_once('-').unwrap_or((candidate, "0"));
292+
293+
if inst_ver_no_rel == cand_ver_no_rel {
294+
pkgs.push(pkginfo);
295+
continue;
296+
}
297+
283298
let current_kernel_ver = kernel_ver.get_or_try_init(|| {
284299
System::kernel_version().context("Failed to get kernel version")
285300
})?;
@@ -309,8 +324,6 @@ impl CliExecuter for Topics {
309324
continue;
310325
}
311326

312-
let pkginfo = matcher.find_candidate_by_pkgname(pkg_name)?;
313-
314327
pkgs.push(pkginfo);
315328
}
316329

0 commit comments

Comments
 (0)