From owner-svn-src-head@FreeBSD.ORG  Thu Oct 24 10:49:56 2013
Return-Path: <owner-svn-src-head@FreeBSD.ORG>
Delivered-To: svn-src-head@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 ESMTP id DEC775CF;
 Thu, 24 Oct 2013 10:49:56 +0000 (UTC)
 (envelope-from bdrewery@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org
 [IPv6:2001:1900:2254:2068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1.freebsd.org (Postfix) with ESMTPS id B2DA22275;
 Thu, 24 Oct 2013 10:49:56 +0000 (UTC)
Received: from svn.freebsd.org ([127.0.1.70])
 by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9OAnuK6026650;
 Thu, 24 Oct 2013 10:49:56 GMT
 (envelope-from bdrewery@svn.freebsd.org)
Received: (from bdrewery@localhost)
 by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9OAnuW0026643;
 Thu, 24 Oct 2013 10:49:56 GMT
 (envelope-from bdrewery@svn.freebsd.org)
Message-Id: <201310241049.r9OAnuW0026643@svn.freebsd.org>
From: Bryan Drewery <bdrewery@FreeBSD.org>
Date: Thu, 24 Oct 2013 10:49:56 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r257051 - head/usr.sbin/pkg
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Oct 2013 10:49:57 -0000

Author: bdrewery (ports committer)
Date: Thu Oct 24 10:49:55 2013
New Revision: 257051
URL: http://svnweb.freebsd.org/changeset/base/257051

Log:
  Add support for using "pkg+http://" for the PACKAGESITE.
  
  pkg 1.2 is adding this support as well. This should help
  lessen the confusion on why the default SRV PACKAGESITE
  does not load in a browser.
  
  Adapated from:	matthew's upstream pkg change
  Approved by:	bapt
  MFC after:	2 days

Modified:
  head/usr.sbin/pkg/config.c
  head/usr.sbin/pkg/config.h
  head/usr.sbin/pkg/pkg.c

Modified: head/usr.sbin/pkg/config.c
==============================================================================
--- head/usr.sbin/pkg/config.c	Thu Oct 24 10:34:13 2013	(r257050)
+++ head/usr.sbin/pkg/config.c	Thu Oct 24 10:49:55 2013	(r257051)
@@ -62,7 +62,7 @@ static struct config_entry c[] = {
 	[PACKAGESITE] = {
 		PKG_CONFIG_STRING,
 		"PACKAGESITE",
-		"http://pkg.FreeBSD.org/${ABI}/latest",
+		URL_SCHEME_PREFIX "http://pkg.FreeBSD.org/${ABI}/latest",
 		NULL,
 		false,
 	},

Modified: head/usr.sbin/pkg/config.h
==============================================================================
--- head/usr.sbin/pkg/config.h	Thu Oct 24 10:34:13 2013	(r257050)
+++ head/usr.sbin/pkg/config.h	Thu Oct 24 10:49:55 2013	(r257051)
@@ -30,6 +30,7 @@
 #define _PKG_CONFIG_H
 
 #define _LOCALBASE "/usr/local"
+#define URL_SCHEME_PREFIX "pkg+"
 
 typedef enum {
 	PACKAGESITE = 0,

Modified: head/usr.sbin/pkg/pkg.c
==============================================================================
--- head/usr.sbin/pkg/pkg.c	Thu Oct 24 10:34:13 2013	(r257050)
+++ head/usr.sbin/pkg/pkg.c	Thu Oct 24 10:49:55 2013	(r257051)
@@ -168,6 +168,13 @@ bootstrap_pkg(void)
 		warnx("No MIRROR_TYPE defined");
 		return (-1);
 	}
+
+	/* Support pkg+http:// for PACKAGESITE which is the new format
+	   in 1.2 to avoid confusion on why http://pkg.FreeBSD.org has
+	   no A record. */
+	if (strncmp(URL_SCHEME_PREFIX, packagesite,
+	    strlen(URL_SCHEME_PREFIX)) == 0)
+		packagesite += strlen(URL_SCHEME_PREFIX);
 	snprintf(url, MAXPATHLEN, "%s/Latest/pkg.txz", packagesite);
 
 	snprintf(tmppkg, MAXPATHLEN, "%s/pkg.txz.XXXXXX",