Skip to content

Commit be534c3

Browse files
fix: search all on-disk indexes for os-compatible packages
1 parent 2452b3f commit be534c3

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ trap - EXIT
216216

217217
echo ""
218218
echo "Vellum installed successfully!"
219-
echo "Run 'source ~/.bashrc' or start a new shell to use vellum."
219+
echo "Run 'exec bash --login' to use vellum."
220220
if [ -n "$OFFLINE_DIR" ]; then
221221
echo ""
222222
echo "Offline install complete. When network is available, run:"

src/commands/add.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,27 @@ fn run_add_directly(apk: &Apk, args: &[String]) {
8080

8181
fn get_index() -> anyhow::Result<Vec<Package>> {
8282
let cache_dir = format!("{VELLUM_ROOT}/etc/apk/cache");
83+
let mut all_packages = Vec::new();
8384

8485
if let Ok(entries) = fs::read_dir(&cache_dir) {
8586
for entry in entries.flatten() {
8687
let path = entry.path();
8788
if let Some(name) = path.file_name().and_then(|n| n.to_str()) {
8889
if name.starts_with("APKINDEX.") && name.ends_with(".tar.gz") {
8990
if let Some(path_str) = path.to_str() {
90-
return parse_index_tar_gz(path_str);
91+
if let Ok(packages) = parse_index_tar_gz(path_str) {
92+
all_packages.extend(packages);
93+
}
9194
}
9295
}
9396
}
9497
}
9598
}
9699

100+
if !all_packages.is_empty() {
101+
return Ok(all_packages);
102+
}
103+
97104
let repo_url = match get_repo_url() {
98105
Some(url) => url,
99106
None => return Err(anyhow::anyhow!("no cached index and could not determine repository URL")),

src/commands/check_os.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,27 @@ pub fn handle_check_os(apk: &Apk, target_os: &str) {
9696

9797
fn get_index() -> anyhow::Result<Vec<Package>> {
9898
let cache_dir = format!("{VELLUM_ROOT}/etc/apk/cache");
99+
let mut all_packages = Vec::new();
99100

100101
if let Ok(entries) = fs::read_dir(&cache_dir) {
101102
for entry in entries.flatten() {
102103
let path = entry.path();
103104
if let Some(name) = path.file_name().and_then(|n| n.to_str()) {
104105
if name.starts_with("APKINDEX.") && name.ends_with(".tar.gz") {
105106
if let Some(path_str) = path.to_str() {
106-
return parse_index_tar_gz(path_str);
107+
if let Ok(packages) = parse_index_tar_gz(path_str) {
108+
all_packages.extend(packages);
109+
}
107110
}
108111
}
109112
}
110113
}
111114
}
112115

116+
if !all_packages.is_empty() {
117+
return Ok(all_packages);
118+
}
119+
113120
let repo_url = get_repo_url().ok_or_else(|| {
114121
anyhow::anyhow!("no cached index and could not determine repository URL")
115122
})?;

src/commands/upgrade.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,27 @@ fn check_os_compatibility_internal(apk: &Apk, target_os: &str) -> Option<Vec<Str
225225

226226
fn get_index() -> anyhow::Result<Vec<Package>> {
227227
let cache_dir = format!("{VELLUM_ROOT}/etc/apk/cache");
228+
let mut all_packages = Vec::new();
228229

229230
if let Ok(entries) = fs::read_dir(&cache_dir) {
230231
for entry in entries.flatten() {
231232
let path = entry.path();
232233
if let Some(name) = path.file_name().and_then(|n| n.to_str()) {
233234
if name.starts_with("APKINDEX.") && name.ends_with(".tar.gz") {
234235
if let Some(path_str) = path.to_str() {
235-
return parse_index_tar_gz(path_str);
236+
if let Ok(packages) = parse_index_tar_gz(path_str) {
237+
all_packages.extend(packages);
238+
}
236239
}
237240
}
238241
}
239242
}
240243
}
241244

245+
if !all_packages.is_empty() {
246+
return Ok(all_packages);
247+
}
248+
242249
let repo_url = match get_repo_url() {
243250
Some(url) => url,
244251
None => return Err(anyhow::anyhow!("no cached index and could not determine repository URL")),

0 commit comments

Comments
 (0)