Skip to content

Add local metadata - #178

Draft
BraveChicken1 wants to merge 15 commits into
mainfrom
feature/local-metadata
Draft

Add local metadata#178
BraveChicken1 wants to merge 15 commits into
mainfrom
feature/local-metadata

Conversation

@BraveChicken1

Copy link
Copy Markdown
Contributor

This PR implements a local metadata storage to prevent needing network access to load in some information about packages.

Things to still decide on:

  • Do we want to keep it in <package>/.packit? An alternative could be a global directory in the Packit prefix, also preparing for future package specific local metadata.
  • How do we want to handle the packaging and the prebuilds.toml file? I don't think we want to store the prebuilds.toml file, as it is not something that a user normally needs. Maybe we should just require repository connection for packaging?
  • Do we want to put the conflicts_with field in the local metadata, or keep it on the package in the register? Moving it would facilitate a future expansion to conflicts between specific versions, but does require some refactors.
  • How do we want to handle the homepage and description fields of a package.toml file? Should we keep them in the register, or do we also want to include them into the local metadata?

@Max13245

Max13245 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor
  • Yes, I think it would be nice to put .packit into something like <prefix>/local/<package-name>. Then we separate the actual package data from Packit data.
  • Maybe they could just create a prebuild for their own target. Disregarding the prebuilds.toml content. So if we find a prebuild 'match' for a specific target it always works. Alternatively we could only store the correct group of the current target.
  • Why would it not be possible to implement version specific conflicts in the register? The conflicts_with field is difficult, because it is metadata, but it's also installation data. I think it might be more practical/nicer to put it in the local metadata, because then we only compare repo metadata and local metadata (so it would be only metadata, not sometimes metadata other times installation/register data). I'm really not sure though.
  • I think it's nice to put all repository metadata (which is also currently stored in the register) in the local metadata. Then there is a clear division between the two.

@BraveChicken1

Copy link
Copy Markdown
Contributor Author

Thank you! I would then suggest implementing the following things:

  • The local metadata will get stored in <prefix>/local/<package-name>/<package-version>/<metafile>. Although I'm not fully sure if local is the best choice for the directory name, since /usr/local is a default directory on Unix systems with a different meaning.
  • We store the prebuild metadata that is applicable for the current target in the metadata.toml file too.

For conflicts_with, homepage and description, we could add a package local metadata file, however this raises new questions:

  • Do we store this local package metadata in <prefix>/local/metadata.toml?
  • Do we also refresh this package metadata when a package version is refreshed?
  • How do we handle multiple package versions from different repositories here? Their metadata could be different.

We could leave the package local metadata for now, and first try to solve the multiple package versions from different repositories in the current structure.
The conflicts_with could be stored on the package version, instead of the package. But this means we have to refactor the conflict detection code. Another question regarding this is whether we should take action when a new conflicting package is added after refreshing the metadata. Should this trigger an unlink of the current package or conflicting package?

@Max13245 Max13245 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)

Will you also update the docs with local metadata explanations?

Please don't forget to add rust docs and the clippy changes.

Comment thread src/cli/commands/init.rs
exit(1);
};

// Create the repository provider to fetch Packit metadata from

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create the repository provider to fetch Packit metadata from
// Create the repository provider to fetch Packit metadata

Comment on lines +6 to +7
pub use handler::LocalMetadata;
pub use handler::LocalPrebuildMetadata;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't seem to be used?


/// Only refresh the local metadata
#[arg(long)]
refresh_only: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a skip_refresh flag.

disable_prebuilds: false,
};

// TODO: prebuild list and prebuild provider are needed here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a TODO here.

package_name: &PackageName,
package_conflicts: &[PackageName],
) -> Result<Vec<PackageName>> {
let mut conflicting_packages = Vec::new();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a hashset.

&self,
register: &PackageRegister,
package_name: &PackageName,
package_conflicts: &[PackageName],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be a hashset (with some extra changes).

}

// Remove files that are not needed anymore
let removed_files: Vec<_> = before_files.iter().filter(|x| !after_files.contains(x)).collect();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove the collect here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants