From owner-svn-src-all@FreeBSD.ORG Wed Oct 23 14:23:48 2013 Return-Path: Delivered-To: svn-src-all@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 ESMTP id AE8828C7; Wed, 23 Oct 2013 14:23:48 +0000 (UTC) (envelope-from bapt@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 9B68D22D9; Wed, 23 Oct 2013 14:23:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9NENmdR006257; Wed, 23 Oct 2013 14:23:48 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9NENm8T006256; Wed, 23 Oct 2013 14:23:48 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201310231423.r9NENm8T006256@svn.freebsd.org> From: Baptiste Daroussin Date: Wed, 23 Oct 2013 14:23:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256971 - 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-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2013 14:23:48 -0000 Author: bapt Date: Wed Oct 23 14:23:48 2013 New Revision: 256971 URL: http://svnweb.freebsd.org/changeset/base/256971 Log: Allow to bootstrap by doing pkg add ./a/path/to/a/pkg_package.txz Requested by: many MFC after: 3 days Modified: head/usr.sbin/pkg/pkg.c Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Wed Oct 23 14:15:46 2013 (r256970) +++ head/usr.sbin/pkg/pkg.c Wed Oct 23 14:23:48 2013 (r256971) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -297,7 +298,9 @@ int main(__unused int argc, char *argv[]) { char pkgpath[MAXPATHLEN]; + char pkgstatic[MAXPATHLEN]; bool yes = false; + int fd, ret; snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE); @@ -311,6 +314,19 @@ main(__unused int argc, char *argv[]) if (argv[1] != NULL && strcmp(argv[1], "-N") == 0) errx(EXIT_FAILURE, "pkg is not installed"); + if (argc > 2 && strcmp(argv[1], "add") == 0 && + access(argv[2], R_OK) == 0) { + fd = open(argv[2], O_RDONLY); + if (fd == -1) + err(EXIT_FAILURE, "Unable to open %s", argv[2]); + + if ((ret = extract_pkg_static(fd, pkgstatic, MAXPATHLEN)) == 0) + ret = install_pkg_static(pkgstatic, argv[2]); + close(fd); + if (ret != 0) + exit(EXIT_FAILURE); + exit(EXIT_SUCCESS); + } /* * Do not ask for confirmation if either of stdin or stdout is * not tty. Check the environment to see if user has answer