From owner-freebsd-questions@FreeBSD.ORG Sat Sep 13 02:14:52 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B1109400 for ; Sat, 13 Sep 2014 02:14:52 +0000 (UTC) Received: from mail-qa0-x229.google.com (mail-qa0-x229.google.com [IPv6:2607:f8b0:400d:c00::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6DC40989 for ; Sat, 13 Sep 2014 02:14:52 +0000 (UTC) Received: by mail-qa0-f41.google.com with SMTP id f12so1655585qad.14 for ; Fri, 12 Sep 2014 19:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=wHYFG7CeaqZgctn7q8VMJr016q1zEC6xy42dCYyv8EE=; b=ezyjoNLelOay+J8oyF0FOts3wEykVcz/Kq5lA9XoGTJTKjU7CfeuXbK7u7k4/AefcZ RkUmlxCYodlqpqQM6lIBxxqNWEKj0sobqh1kOdMlGoyYmxVN8YIJSxGFZyzt9Wdi8TdO wkLhzHbNWixDoV+VmyJl9mgWMyKqAqzWi+5KSgs1ZQUXhgR79/TTyl+QqnezxhucWzT3 tQ0w7wBpqgSi59w2e933o/CRgIYtM9areX4GC8qdFYHKQ7NcKoaTVK3MLJKwtwBEadpM GgGYG6GNbvBBRQYpoJwVrSm+CBnhmfsDkXa2LkbI/VfUfsxeZPL4DtjhwM0Xvqc9guKw GPTg== MIME-Version: 1.0 X-Received: by 10.140.96.86 with SMTP id j80mr12655978qge.106.1410574491335; Fri, 12 Sep 2014 19:14:51 -0700 (PDT) Received: by 10.224.10.198 with HTTP; Fri, 12 Sep 2014 19:14:51 -0700 (PDT) In-Reply-To: References: Date: Fri, 12 Sep 2014 21:14:51 -0500 Message-ID: Subject: Re: Repository Search Order From: Dan Lists To: freebsd-questions Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 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 02:14:52 -0000 Attached is a proof of concept patch that handles the sorting. For production, the repos array would need bounds checking, and the 1024 should be a define. On Fri, Sep 12, 2014 at 8:02 PM, Dan Lists wrote: > man pkg.conf states: > > Repositories are prioritized in the order they are found on the > REPOS_DIR > search path, with individual repository configuration files in the > same > directory processed in alphabetical order. Earlier files take prece- > dence, meaning that packages will be downloaded from them > preferentially > where the same package is available from several repositories. > > This is not true, but I would like it to be. > > # ls /usr/local/etc/pkg/repos/ > 00_Local.conf 80_zzz.conf 90_fff.conf 99_mmm.conf FreeBSD.conf > > So the order should be local, zzz, fff, mmm. > > Repositories: > mmm: { > url : "http://some.dom/freebsd:8:x86:64/mmm", > enabled : yes > } > fff: { > url : "http://some.dom/freebsd:8:x86:64/fff", > enabled : yes > } > local: { > url : "file:///usr/ports/packages", > enabled : yes > } > zzz: { > url : "http://some.dom/freebsd:8:x86:64/zzz", > enabled : yes > } > > The order has no relation to alphabetical order at all. Interestingly, > if I use find (unsorted), it matches the repository order! > > # find /usr/local/etc/pkg/repos > /usr/local/etc/pkg/repos > /usr/local/etc/pkg/repos/FreeBSD.conf > /usr/local/etc/pkg/repos/99_mmm.conf > /usr/local/etc/pkg/repos/90_fff.conf > /usr/local/etc/pkg/repos/00_Local.conf > /usr/local/etc/pkg/repos/80_zzz.conf > > I quick look at the source shows that load_repo_files is just reading the > files in the order they are in the directory table: > > while ((ent = readdir(d))) { > ... > } > > Can we get the repo config files sorted like the docs say? >