openSUSE-Rust / obs-service-cargo

OBS Source Service and utilities for Rust software packaging
Mozilla Public License 2.0
17 stars 9 forks source link

Refactor imminent #97

Open uncomfyhalomacro opened 1 month ago

uncomfyhalomacro commented 1 month ago

Because of the hastiness I did for the project, I haven't architectured this correctly e.g. give accurate error messages i.e. if src is missing it gives error message that it is unsupported format.

I will begin refactoring the entirety of the project from scratch but this will be a low priority effort.

This will supersede and close #96 (false alarm)

Now that we understood how cargo works when building, we can finally fix some minor bugs and improve code quality. Yay! 🫠

The current structure of the project is overall okay-ish though so we can take advantage of that.

Agenda

Find alternatives to vendoring

I find it amusing that we have to go left and right about vendoring when we can "vendor" $CARGO_HOME/registry. If this will do great, we can use this as an alternative to the vendoring process and (ab)use $CARGO_HOME directly.

The process of vendoring $CARGO_HOME is as follows.

  1. Create desired directory for where to put $CARGO_HOME. We can ideally use $PWD/.cargo in the new vendoring process
  2. Set environmental variable $CARGO_HOME
  3. Run cargo fetch or cargo update if desired.
  4. "Vendor" $PWD/.cargo
  5. Win in the specfile by setting $CARGO_HOME as desired e.g. at the root of the extracted tarball then run build and checks with --offline flag

Tested on jay and it does work!

From now on we go with this :pray:. @Firstyear thoughts for this alternative approach?

Firstyear commented 1 month ago

Sounds really good! I look forward to reviewing it :)