Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TUM #266

Merged
merged 20 commits into from
Dec 21, 2024
Merged

TUM #266

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/apt.conf.d/50oma.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
## let apt download Contents and BinContents as well.

Acquire::IndexTargets {
deb::TUM {
MetaKey "updates.json";
ShortDescription "Topic Update Manifest";
Description "Topic Update Manifest";

flatMetaKey "Topic Update Manifest";
flatDescription "Topic Update Manifest";
PDiffs "true";
KeepCompressed "false";
};

deb::Contents-deb {
MetaKey "$(COMPONENT)/Contents-$(ARCHITECTURE)";
ShortDescription "Contents-$(ARCHITECTURE)";
Expand Down
6 changes: 6 additions & 0 deletions i18n/en-US/oma.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,9 @@ topics-unchanged = oma was unable complete topic opt-out operation(s) and has ke
status-pending = Pending
status-downloading = Downloading
status-package = Processing package { $pkg }
update-available = System Update(s) Available
update-available-2 = oma has found the following updates are available for your system:
tum-1 = oma has found { $updates } updates available for your system.
tum-1-with-security = oma has found { $updates } updates available for your system ({ $security } security updates are marked in { $security_str }).
tum-2 = In order to fulfill the operations you specified, oma will need to perform the following changes to your system components. The details are as follows.Details of the component changes for this operation are as follows.
security = security update(s)
4 changes: 4 additions & 0 deletions i18n/zh-CN/oma.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,7 @@ topics-unchanged = oma 在退出测试源时遇到错误,因此未保存测试
status-pending = 等待操作中
status-downloading = 正在下载软件包
status-package = 正在处理软件包 { $pkg }
tum-1 = oma 找到了 { $updates } 个可用系统更新。
tum-1-with-security = oma 找到了 { $updates } 个关键系统更新(含 { $security } 个 { $security_str })。
tum-2 = 根据您指定的操作,oma 还需要对系统组件执行若干变更,变更详情如下。
security = 安全更新
27 changes: 18 additions & 9 deletions oma-refresh/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ impl<'a> IndexTargetConfig<'a> {
for comp in components {
for l in &langs {
if self.template_is_match(template, &c.name, a, comp, l) {
let name_without_ext = Path::new(&c.name).with_extension("");
let name_without_ext =
name_without_ext.to_string_lossy().to_string();
let name_without_ext = uncompress_file_name(&c.name).to_string();

res_map.entry(name_without_ext).or_default().push(
ChecksumDownloadEntry {
item: c.to_owned(),
Expand Down Expand Up @@ -168,16 +167,26 @@ impl<'a> IndexTargetConfig<'a> {
component: &str,
lang: &str,
) -> bool {
let target_without_ext = Path::new(target).with_extension("");
let target_without_ext = target_without_ext.to_string_lossy();
let name = uncompress_file_name(target);

target_without_ext
== self
.replacer
.replace_all(template, &[arch, component, lang, self.native_arch])
name == self
.replacer
.replace_all(template, &[arch, component, lang, self.native_arch])
}
}

fn uncompress_file_name(target: &str) -> Cow<'_, str> {
let name = if compress_file(target) == CompressFile::Nothing {
Cow::Borrowed(target)
} else {
let compress_target_without_ext = Path::new(target).with_extension("");
let compress_target_without_ext = compress_target_without_ext.to_string_lossy().to_string();
compress_target_without_ext.into()
};

name
}

fn get_index_target_tree(config: &Config, key: &str) -> Vec<(String, HashMap<String, String>)> {
get_tree(config, key)
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl CliExecuter for List {
let branches_str = branches.join(",");

printer
.print(format!(
.println(format!(
"{}/{} {} {arch} {s}",
color_formatter().color_str(&name, Action::Emphasis).bold(),
color_formatter().color_str(branches_str, Action::Secondary),
Expand All @@ -229,7 +229,7 @@ impl CliExecuter for List {
.ok();
} else {
printer
.print(serde_json::json!(
.println(serde_json::json!(
{
"name": name,
"branches": branches,
Expand Down
16 changes: 12 additions & 4 deletions src/subcommand/topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ pub struct Topics {
/// Set apt options
#[arg(from_global)]
apt_options: Vec<String>,
/// Always write status to atm file and sources.list
#[arg(long)]
always_write_status: bool,
}

struct TopicChanged {
Expand Down Expand Up @@ -128,6 +131,7 @@ impl CliExecuter for Topics {
apt_options,
all,
no_fix_dpkg_status,
always_write_status,
} = self;

if !dry_run {
Expand Down Expand Up @@ -241,17 +245,21 @@ impl CliExecuter for Topics {
.autoremove(autoremove)
.network_thread(config.network_thread())
.auth_config(&auth_config)
.check_update(true)
.build()
.run()?;

Ok(code)
});

match code {
Ok(0) => RT.block_on(tm.write_enabled())?,
Ok(_) => {
error!("{}", fl!("topics-unchanged"));
revert_sources_list(&tm)?
Ok(x) => {
if x != 0 && !always_write_status {
error!("{}", fl!("topics-unchanged"));
revert_sources_list(&tm)?;
} else {
RT.block_on(tm.write_enabled())?;
}
}
Err(e) => {
error!("{}", fl!("topics-unchanged"));
Expand Down
Loading
Loading