Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Sep 2014 11:12:17 +0100
From:      Matthew Seaman <matthew@FreeBSD.org>
To:        Dan Lists <lists.dan@gmail.com>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Repository Search Order
Message-ID:  <54141881.20600@FreeBSD.org>
In-Reply-To: <CAPW8bZ21B=rgDmwuYN4ezbTV6d3Z8FroPTWRkLJhDASyGBR7ew@mail.gmail.com>
References:  <CAPW8bZ3tnUk_FhR5oS-p7K-Cy3kY1rL8YDzdK11O860tjfcjpw@mail.gmail.com> <CAPW8bZ3gfX_YMfLi0_7WnOMyJhT%2BvrWG17dJtkvyv334nc5pXA@mail.gmail.com> <CAPW8bZ21B=rgDmwuYN4ezbTV6d3Z8FroPTWRkLJhDASyGBR7ew@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--s9BGuj9GGvCL5IlCEDtbdHP7Tl6APXX0V
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


Can you open an issue on github concerning this please?
https://github.com/freebsd/pkg/issues

Bonus points if you can generate a pull request.

On 13/09/2014 05:09, Dan Lists wrote:
> Looks like the list scrubbed the attachment.  Here is the patch.
>=20
> --- libpkg/pkg_config.c.orig    2014-09-12 20:02:24.292995291 -0500
> +++ libpkg/pkg_config.c    2014-09-12 21:08:07.945030287 -0500
> @@ -592,6 +592,13 @@
>      ucl_object_unref(obj);
>  }
>=20
> +int cmp(const void *a, const void *b)
> +{
> +  const char **ia =3D (const char **)a;
> +  const char **ib =3D (const char **)b;
> +  return strcmp(*ia, *ib);
> +}
> +
>  static void
>  load_repo_files(const char *repodir)
>  {
> @@ -600,6 +607,8 @@
>      char *p;
>      size_t n;
>      char path[MAXPATHLEN];
> +    char *repos[1024];
> +    int r=3D0;
>=20
>      if ((d =3D opendir(repodir)) =3D=3D NULL)
>          return;
> @@ -610,14 +619,26 @@
>              continue;
>          p =3D &ent->d_name[n - 5];
>          if (strcmp(p, ".conf") =3D=3D 0) {
> -            snprintf(path, sizeof(path), "%s%s%s",
> +          repos[r]=3Dmalloc(n+1);
> +          snprintf(repos[r], n+1, ent->d_name);

I think asprintf() would be a better choice here.

> +          r++;
> +        }
> +    }
> +    closedir(d);
> +
> +    if( r =3D=3D 0 )
> +      return;
> +
> +    qsort(repos, r, sizeof(char *), cmp);
> +
> +    for( int i=3D0 ; i < r ; i++ ){
> +            snprintf(path, sizeof(path), "%s%s%s",
>                  repodir,
>                  repodir[strlen(repodir) - 1] =3D=3D '/' ? "" : "/",
> -                ent->d_name);
> +                repos[i]);
>              load_repo_file(path);
> +            free(repos[i]);
>          }
> -    }
> -    closedir(d);
>  }
>=20
>  static void
>=20

While changing the order that the repo configuration files load seems to
be a useful approach, I think that it works, if at all, by chance.  It
will be fragile in the sense that an unrelated change elsewhere in
dependency solving could easily destroy any effect from the order that
config files are processed.

Repository data is downloaded and processed into a number of sqlite
databases each named after the tag in the repo.conf -- it strikes me
that imposing some preference ordering based on the repository tag at
the point that data about available packages is pulled out of the repo
databases would be a more robust approach.

	Cheers,

	Matthew


--=20
Dr Matthew J Seaman MA, D.Phil.
PGP: http://www.infracaninophile.co.uk/pgpkey



--s9BGuj9GGvCL5IlCEDtbdHP7Tl6APXX0V
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)

iQJ8BAEBCgBmBQJUFBiJXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ2NTNBNjhCOTEzQTRFNkNGM0UxRTEzMjZC
QjIzQUY1MThFMUE0MDEzAAoJELsjr1GOGkATpR4QAKaYPZjevhcMXPVzmBrx6VRk
IZLj3TqmdH2T+O9+15M7hY5xVDo9SlMsG1lX3ZgYZ073yUBRNaikrzUm7h1dGVVO
/7DV8uQpQkWso9nlzhQAVGVE7cSdwp0CpKPZGjMjEoNG/L3H7pHPZgrS2Z4b3qtk
GXdCT3yKWXeZPOAVsIOP8jJi4iD2VJ6aZTfdqdUQ3fFTv/91dr8pRLtQ4gNk4YXh
uD+/daaLAL8btuCtkHy+qzCLIBDW6mxV+nGfWEO5dsrztr2sgyw+Mbh0VDTWCi/A
vnP0hEFzITZEtzXSi4Jr2t0DxzU3LgWPYb4P8hu+fpz1HwTVRY8YJCA5ajgRQR68
SfrRu59hhKktayR3F7CvJVNrGQynC5eUp+N1XQnYCH349U1nD6/dV/qd0tr4gFeN
uYlSlPRtmFnpR+uH8IOrK8MmwkCa0EYvkHgKpUAene9b7Ql1f512AMiCVLOoXnFu
qcHNea8yToRggqgMW6QyR0HNshAd+38rS+4w+ZB5IIRkEsgFBl4I9u+1RcfFAhOC
18rupP2wmvJvWN10JiAQrJkM4qJFmMxShd/sF9NeqQxSwfhKwTADgIZ9NO40tuqR
TO5JwEzvqBkcQnsPKd0tcP51DfIeFiAbo3Tw53WCRQlVhOEWua6KU3w70KXKodNy
rm6lOCjWt/gQl6+HnJOM
=X/lm
-----END PGP SIGNATURE-----

--s9BGuj9GGvCL5IlCEDtbdHP7Tl6APXX0V--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54141881.20600>