Skip to content

Commit 3612ec4

Browse files
committed
Make flist contents paths relative to flist path
1 parent 9602516 commit 3612ec4

File tree

2 files changed

+61
-71
lines changed

2 files changed

+61
-71
lines changed

src/config.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,6 @@ pub struct PartialSources {
604604
pub files: Vec<PartialSourceFile>,
605605
/// The list of external flists to include.
606606
pub external_flists: Option<Vec<String>>,
607-
/// The absolute prefix for the external flists to include. Not intended to be user-modifiable.
608-
pub external_flist_prefix: Option<PathBuf>,
609607
/// Unknown extra fields
610608
#[serde(flatten)]
611609
extra: HashMap<String, Value>,
@@ -621,7 +619,6 @@ impl PartialSources {
621619
defines: None,
622620
files: Vec::new(),
623621
external_flists: None,
624-
external_flist_prefix: None,
625622
extra: HashMap::new(),
626623
}
627624
}
@@ -635,10 +632,6 @@ impl PrefixPaths for PartialSources {
635632
defines: self.defines,
636633
files: self.files.prefix_paths(prefix)?,
637634
external_flists: self.external_flists.prefix_paths(prefix)?,
638-
external_flist_prefix: match self.external_flist_prefix {
639-
Some(_) => self.external_flist_prefix.prefix_paths(prefix)?,
640-
None => Some(prefix.to_path_buf()),
641-
},
642635
extra: self.extra,
643636
})
644637
}
@@ -652,7 +645,6 @@ impl From<Vec<PartialSourceFile>> for PartialSources {
652645
defines: None,
653646
files: v,
654647
external_flists: None,
655-
external_flist_prefix: None,
656648
extra: HashMap::new(),
657649
}
658650
}
@@ -670,7 +662,7 @@ impl Validate for PartialSources {
670662
.map(|path| env_path_from_string(path.to_string()))
671663
.collect();
672664

673-
let external_flist_list: Result<Vec<Vec<String>>> = external_flists?
665+
let external_flist_list: Result<Vec<(PathBuf, Vec<String>)>> = external_flists?
674666
.into_iter()
675667
.map(|filename| {
676668
let file = File::open(&filename).map_err(|cause| {
@@ -691,13 +683,13 @@ impl Validate for PartialSources {
691683
})
692684
})
693685
.collect::<Result<Vec<String>>>()?;
694-
Ok(lines)
686+
Ok((filename.parent().unwrap().to_path_buf(), lines))
695687
})
696688
.collect();
697689

698690
let external_flist_groups: Result<Vec<PartialSourceFile>> = external_flist_list?
699691
.into_iter()
700-
.map(|flist| {
692+
.map(|(flist_dir, flist)| {
701693
Ok(PartialSourceFile::Group(Box::new(PartialSources {
702694
target: None,
703695
include_dirs: Some(
@@ -711,9 +703,7 @@ impl Validate for PartialSources {
711703
None
712704
}
713705
})
714-
.map(|dir| {
715-
dir.prefix_paths(self.external_flist_prefix.as_ref().unwrap())
716-
})
706+
.map(|dir| dir.prefix_paths(&flist_dir))
717707
.collect::<Result<_>>()?,
718708
),
719709
defines: Some(
@@ -746,10 +736,9 @@ impl Validate for PartialSources {
746736
Some(PartialSourceFile::File(file))
747737
}
748738
})
749-
.map(|file| file.prefix_paths(self.external_flist_prefix.as_ref().unwrap()))
739+
.map(|file| file.prefix_paths(&flist_dir))
750740
.collect::<Result<Vec<_>>>()?,
751741
external_flists: None,
752-
external_flist_prefix: None,
753742
extra: HashMap::new(),
754743
})))
755744
})

src/sess.rs

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::fs::canonicalize;
2222
use dunce::canonicalize;
2323

2424
use async_recursion::async_recursion;
25-
use futures::future::{self, join_all};
25+
use futures::future::join_all;
2626
use futures::TryFutureExt;
2727
use indexmap::{IndexMap, IndexSet};
2828
use semver::Version;
@@ -539,35 +539,36 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
539539
// Initialize.
540540
self.sess.stats.num_database_init.increment();
541541
// TODO MICHAERO: May need throttle
542-
future::lazy(|_| {
543-
stageln!("Cloning", "{} ({})", name2, url2);
544-
Ok(())
545-
})
546-
.and_then(|_| git.clone().spawn_with(|c| c.arg("init").arg("--bare")))
547-
.and_then(|_| {
548-
git.clone()
549-
.spawn_with(|c| c.arg("remote").arg("add").arg("origin").arg(url))
550-
})
551-
.and_then(|_| git.clone().fetch("origin"))
552-
.and_then(|_| async {
553-
if let Some(reference) = fetch_ref {
554-
git.clone().fetch_ref("origin", reference).await
555-
} else {
556-
Ok(())
557-
}
558-
})
559-
.await
560-
.map_err(move |cause| {
561-
if url3.contains("git@") {
562-
warnln!("Please ensure your public ssh key is added to the git server.");
563-
}
564-
warnln!("Please ensure the url is correct and you have access to the repository.");
565-
Error::chain(
566-
format!("Failed to initialize git database in {:?}.", db_dir),
567-
cause,
568-
)
569-
})
570-
.map(move |_| git)
542+
stageln!("Cloning", "{} ({})", name2, url2);
543+
git.clone()
544+
.spawn_with(|c| c.arg("init").arg("--bare"))
545+
.await?;
546+
git.clone()
547+
.spawn_with(|c| c.arg("remote").arg("add").arg("origin").arg(url))
548+
.await?;
549+
git.clone()
550+
.fetch("origin")
551+
.and_then(|_| async {
552+
if let Some(reference) = fetch_ref {
553+
git.clone().fetch_ref("origin", reference).await
554+
} else {
555+
Ok(())
556+
}
557+
})
558+
.await
559+
.map_err(move |cause| {
560+
if url3.contains("git@") {
561+
warnln!("Please ensure your public ssh key is added to the git server.");
562+
}
563+
warnln!(
564+
"Please ensure the url is correct and you have access to the repository."
565+
);
566+
Error::chain(
567+
format!("Failed to initialize git database in {:?}.", db_dir),
568+
cause,
569+
)
570+
})
571+
.map(move |_| git)
571572
} else {
572573
// Update if the manifest has been modified since the last fetch.
573574
let db_mtime = try_modification_time(db_dir.join("FETCH_HEAD"));
@@ -577,30 +578,30 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
577578
}
578579
self.sess.stats.num_database_fetch.increment();
579580
// TODO MICHAERO: May need throttle
580-
future::lazy(|_| {
581-
stageln!("Fetching", "{} ({})", name2, url2);
582-
Ok(())
583-
})
584-
.and_then(|_| git.clone().fetch("origin"))
585-
.and_then(|_| async {
586-
if let Some(reference) = fetch_ref {
587-
git.clone().fetch_ref("origin", reference).await
588-
} else {
589-
Ok(())
590-
}
591-
})
592-
.await
593-
.map_err(move |cause| {
594-
if url3.contains("git@") {
595-
warnln!("Please ensure your public ssh key is added to the git server.");
596-
}
597-
warnln!("Please ensure the url is correct and you have access to the repository.");
598-
Error::chain(
599-
format!("Failed to update git database in {:?}.", db_dir),
600-
cause,
601-
)
602-
})
603-
.map(move |_| git)
581+
stageln!("Fetching", "{} ({})", name2, url2);
582+
git.clone()
583+
.fetch("origin")
584+
.and_then(|_| async {
585+
if let Some(reference) = fetch_ref {
586+
git.clone().fetch_ref("origin", reference).await
587+
} else {
588+
Ok(())
589+
}
590+
})
591+
.await
592+
.map_err(move |cause| {
593+
if url3.contains("git@") {
594+
warnln!("Please ensure your public ssh key is added to the git server.");
595+
}
596+
warnln!(
597+
"Please ensure the url is correct and you have access to the repository."
598+
);
599+
Error::chain(
600+
format!("Failed to update git database in {:?}.", db_dir),
601+
cause,
602+
)
603+
})
604+
.map(move |_| git)
604605
}
605606
}
606607

@@ -1612,7 +1613,7 @@ pub struct DependencyEntry {
16121613

16131614
impl DependencyEntry {
16141615
/// Obtain the dependency version for this entry.
1615-
pub fn version(&self) -> DependencyVersion {
1616+
pub fn version(&self) -> DependencyVersion<'_> {
16161617
match self.source {
16171618
DependencySource::Registry => unimplemented!(),
16181619
DependencySource::Path(_) => DependencyVersion::Path,

0 commit comments

Comments
 (0)