summaryrefslogtreecommitdiffstats
path: root/src/repository/repository.rs
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-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-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-26Reimplement repository loadingMatthias 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-15Fix clippy: single-character string constant used as patternMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-15Fix clippy: unneeded `return` statementMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-13Add LICENSE file and license headersMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-10Fix: Ignore non-package filesMatthias Beyer
This patch fixes a behaviour where non-package files were not ignored, which resulted in error messages where a directory was tried to parse (which of course is not valid). Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-08Remove unused imports, sort importsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-06Fix: Do not search hidden directories for package filesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-04Remove all non-equality "Version constraint" implementationMatthias Beyer
This patch removes the idea of "version constraints" except for the equality constraint. This is due to the fact, that everything else might result in impurities. This might be reverted in the future and actual operators ("<" or ">" or ranges...) might be implemented. Thus, we keep the "=" equality sign as prefix for a version string, to be extensible here. This commit also fixes (automatically, because the implementation changed from the ground up) the issue that there was no difference between a version string and a version constraint string. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-29Add Repository::packages() to get iterator over all packages in RepositoryMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-26Move helper functions to appropriate moduleMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-26Implement tests for Repository typeMatthias Beyer
This patch also implements helper functions (cfg(test)-gated) on various types so we can instantiate them properly in the tests. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-13Replace use of deprecated functionMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-12Fix typo in method nameMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-12Let Repository::find() return Vec<_> to be compatible with other find_* methodsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-12Add progress reporting to repository loading mechanismMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-12Implement RepositoryMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>