From owner-freebsd-questions@FreeBSD.ORG Sat Sep 13 10:12:38 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 356D7683 for ; Sat, 13 Sep 2014 10:12:38 +0000 (UTC) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "ca.infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B38ED7C3 for ; Sat, 13 Sep 2014 10:12:37 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [81.2.117.99]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.9/8.14.9) with ESMTP id s8DACPXh059505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sat, 13 Sep 2014 11:12:26 +0100 (BST) (envelope-from matthew@FreeBSD.org) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=FreeBSD.org DKIM-Filter: OpenDKIM Filter v2.9.2 smtp.infracaninophile.co.uk s8DACPXh059505 Authentication-Results: smtp.infracaninophile.co.uk/s8DACPXh059505; dkim=none reason="no signature"; dkim-adsp=none; dkim-atps=neutral Message-ID: <54141881.20600@FreeBSD.org> Date: Sat, 13 Sep 2014 11:12:17 +0100 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Dan Lists Subject: Re: Repository Search Order References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="s9BGuj9GGvCL5IlCEDtbdHP7Tl6APXX0V" X-Virus-Scanned: clamav-milter 0.98.4 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lucid-nonsense.infracaninophile.co.uk Cc: freebsd-questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Sep 2014 10:12:38 -0000 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--