[packagekit] Enabling repository by REPO_URL instead of REPO_ID

Richard Hughes hughsient at gmail.com
Thu Aug 14 00:16:23 PDT 2008


On Wed, 2008-08-13 at 13:37 -0700, Dorian Perkins wrote:
> I would like to write a method which will check to see if a repository
> exists and enable it. My current scenario is that I want to install a
> specific software package from a repo that is in my repo list but
> currently disabled. Currently, the way PackageKit enables repositories
> is by REPO_ID. The method "pk_client_repo_enable()" takes a string
> value which is checked against the REPO_ID's of existing repo's and
> (in Fedora 9 with YUM) if it matches, it sets the "enabled" flag of
> the corresponding repo to "1". This poses a problem for me since I
> want to ensure that the REPO_URL of the repository record on the
> system matches the URL of the repository data I am checking against,
> not just the REPO_ID.

I don't think you need to, see below.

> For example, in the possible occurence that the REPO_ID of a
> repository is not the "standard" REPO_ID name (i.e., if I changed the
> default fedora REPO_ID from "fedora" to "fedora9"), an attempt to call
> the method "pk_client_repo_enable()" using the REPO_ID="fedora" will
> fail with the error "Error: repo-not-found : Error getting repository
> data for fedora, repository not found". Although arbitrary changing of
> the REPO_ID is not likely to happen often, it is possible. 

Right, but when you do GetRepoList() you'll have the repo ID's returned,
so in this case you'll get fedora9 rather than fedora.

> I would like to know if this has been considered at all and/or if a
> workaround exists. Is it currently possible to verify a repository
> exists based upon the URL instead of the REPO_ID? If not, would a
> function such as "pk_client_repo_exists()" using URL matching be
> useful?

A URL isn't a useful classifier as some repos will have local mirrors or
just a mirrorlist as the URL.

>  Or, maybe adding "repo_url" as a variable returned by
> "pk_client_repo_list()" through the "repo-detail" callback signal
> would be better?

Se above, the URL is a really bad ID.

> Please comment and advise on how I may possibly solve this problem.

Well, I would need to know what you're trying to achieve -- certainly I
don't think you should be enabling repositories for the user unless
there's a very good reason to do so. If the user has a custom repository
config with different names for the repositories than what you are
expecting -- then it's probably best you don't try and guess what the
user wants to do.

Richard.






More information about the PackageKit mailing list