summaryrefslogtreecommitdiffstats
path: root/src/repository
AgeCommit message (Collapse)Author
2021-11-19Update Copyright string to 2020-2022Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-16Fix clippy: Remove needless borrowMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-16Fix clippy: Remove needless borrowMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-30Merge branch 'fix-patch-loading'Matthias Beyer
2021-08-30Fix clippy: Use or_insert_with() for less runtime costMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-30Fix clippy: Use character constantMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-30Fix: implement unimplemented!()Matthias Beyer
This fixes a missed unimplemented!() in the codebase. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-30Fix: Do not join patch path with root directory pathMatthias Beyer
This fixes the relative pathes for the patch files by not joining it with the root directory path. The exists-check was removed, because the filtering before that already does that. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-27Fix: Remove unused importsMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-27Fix: Replace unimplemented!() match arm with bail!()Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-27Optimize: If there is a PathComponent::PkgToml, we can return true right awayMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-27Split repository::fs into modules and expose only necessary interfaceMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-27Add documentation to repository::fs moduleMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Reimplement Repository::load() with parallelismMatthias Beyer
A quick test showed that the parallel approach here reduced the loading time by approx 10%. Not good, but better than before. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Make sure we open as many files as possible in the recursionMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Fix: Do not push the full (absolute) path but only the relative oneMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Fix: do not filter out directoriesMatthias Beyer
Because the filter_entry() method is expected for the recursion to happen, we should not filter out directories here (except hidden ones). Rather filter them out later in the process. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add getter for FileSystemRepresentation::rootMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Reimplement repository loadingMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Return the path to the file that was loaded as wellMatthias Beyer
Because we need that to find the patches the file may reference. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add PathComponent::dir_name() helper fnMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add getter for FileSystemRepresentation::filesMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Derive Debug for filesystem interface typesMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add tests for Filesystem content aggregation codeMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Allow unused code for nowMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add an intermediate pkg.toml file content file collecting contentsMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add helper fn to check whether a file is a leafMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add method to get all pkg.toml file contents for a pathMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Store pathes to pkg.toml files as wellMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-26Add Filesystem layer for loading files from FS without parsingMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-18Fix indentationMatthias Beyer
The last few refactorings did not fix the indentation (on purpose), so that the actual diff of the refactoring is more visible. This commit now cleans up on that by fixing _only_ the indentation. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-08-18Refactor iteration to be less nestedMatthias Beyer
Split closure into two distinct map calls, to reduce nesting here and improve readability. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-08-18Refactor getting patches and ignoring NotFound errorMatthias Beyer
Use `Result::or_else()` and match for error kinds instead of matching the whole `Result`, for less nesting. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-08-18Refactor patch mapping to pathMatthias Beyer
Move mapping into `String` one level up for less nesting. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-08-18Use anyhow!() to create errors instead of format!()Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-06-09Revert "Fix: Make patch path absolute"Matthias Beyer
This fix was actually buggy. The problem here is that the `Package` struct is used to fill variables in the script. If we overwrite the patch pathes with their absolute variant, the script gets interpolated with the absolute paths, resulting in things like patch -p0 < /patches//home/user/package_repository/software/p.patch but the copy-to-container process copies (should copy) the patch file to /patches/software/p.patch This reverts commit dcc8b42810d34b2b906f0307c26c4826d16ad997. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-06-07Fix: Make patch path absoluteMatthias Beyer
This patch changes the patch-path collecting to make the pathes to patches absolute. This fixes a bug where executing butido from a sub directory of the package repository failed to find the patch files when loading the repository files. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-09Fix: Patch file finding algorithmMatthias Beyer
Because commit 5c36c119f9448baf6bfe5245c6ebac1aa09d5b43 was not enough and was actually buggy, this fixes the patch-file-finding algorithm _again_. The approach changed a bit. It actually introduces even more overhead to the loading algorithm, because of constant type-conversions. But it's as good as it can be right now. So first of all, we're collecting the patches before the merge into a Vec<PathBuf>. Each of those are existing. Then we check whether the new patch exists, and if it not does, we check whether the file actually exists in the patches from before the merge (by filename). If it does, it seems that we dragged the entry from the previous recursion. In this case, the patches from before the merge were valid, and the recursion invalidated the path. I.E.: /pkg.toml with patches = [ "a" ] /a /sub/pkg.toml with no patches=[] in the recursion for /sub/pkg.toml, we get a ["a"] in the patches array, because that's how the layered configuration works. But because the path is invalid, we check whether before the merge (so, the patches array from /pkg.toml) has a file named equally - which it does. So the array before the merge is the correct one. I did some tests on this and it seems to work correctly, but more edge-cases may exist. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net> Fixes: 5c36c119f9448baf6bfe5245c6ebac1aa09d5b43 ("Fix: Error out if a patch file is missing")
2021-04-09Fix: Error message should be less technical hereMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-08Fix: Error out if a patch file is missingMatthias Beyer
This patch fixes a bug where a patch file is not there. Before this patch, we were simply ignoring non-existing files in the iterator, because during development of this algorithm, it seemed to be the right idea because of the recursion that is happending. The patch-branch-patching that is happening in the recursion, that rewrites the pathes to the patches during the recursive loading of the packages, used to yield invalid pathes at some point, which simply could be ignored. That happened before that patch. But because during the development of the recursive loading, the scheme how this all works was changed, it does not yield invalid pathes anymore. Hence, we can be sure that either the file is here or it is not - which is an error then. I have to say that I'm not particularly good with recursion, but as far as my tests go, this seems to work as intended now. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-17Add check whether package name or version is emptyMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-10Add comments on patch-path-fixing algorithmMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-10Refactor for more readabilityMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-10Re-write patch postprocessingMatthias Beyer
This patch rewrites patch post-processing with a new setter in the config-rs crate: Config::set_once() That is introduced on a PR I've written for the crate. The PR: https://github.com/mehcode/config-rs/pull/172 The new function is more likely to land on the config-rs master branch than the old one, as it does not introduce more exported types from the config-rs crate. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-09Implement patch-path rewritingMatthias Beyer
This patch ensures that pathes for patches are always relative to the repository root, when loading the packages layered from the repository. The problem is well described in the comment in the code, so this commit message ends here. This patch was written using an proposed feature for the config-rs dependency: https://github.com/mehcode/config-rs/pull/165 This PR added a `Config::get_value_mut()` function and exported the `config::value::ValueKind` type in config-rs public API. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-15Add logging what is searchedMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-15Add logging what is loadedMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-18Run `cargo fmt`Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-15Allow module inception in this instanceMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-15Fix clippy: single-character string constant used as patternMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>