From owner-freebsd-cloud@freebsd.org Tue Jan 2 19:35:18 2018 Return-Path: Delivered-To: freebsd-cloud@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1590EEB50BB for ; Tue, 2 Jan 2018 19:35:18 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E43606F10E for ; Tue, 2 Jan 2018 19:35:17 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (203-206-51-137.dyn.iinet.net.au [203.206.51.137] (may be forged)) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id w02JZAlt031432 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 2 Jan 2018 11:35:13 -0800 (PST) (envelope-from julian@freebsd.org) Subject: Re: AMI building AMI To: Rafal Lukawiecki Cc: Colin Percival , freebsd-cloud@freebsd.org References: <085D225B-2E99-4540-B693-223087B14A27@rafal.net> <0100016099578ea7-02da1d5c-997d-47be-9cd8-dc6b75bbeda6-000000@email.amazonses.com> <8BCB67B8-DE56-491A-8E6A-95AFB83F71D6@rafal.net> <0100016099671dff-32d986bf-3979-40a3-accf-4d17c2020403-000000@email.amazonses.com> <8538BFB9-B82C-4520-ADB3-E25040EA1B30@rafal.net> <01000160a0283ad5-12b330d3-3f4b-43ea-9cdc-2524f5f42f4a-000000@email.amazonses.com> <004116c5-0938-5570-f119-fdc21e91b2ad@freebsd.org> <559A9E86-6E97-4A8D-96CC-95FC9180A483@rafal.net> From: Julian Elischer Message-ID: <50f75b01-2ea3-f7fd-24a6-65a4d64ae16d@freebsd.org> Date: Wed, 3 Jan 2018 03:35:01 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <559A9E86-6E97-4A8D-96CC-95FC9180A483@rafal.net> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-cloud@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "FreeBSD on cloud platforms \(EC2, GCE, Azure, etc.\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 19:35:18 -0000 On 3/1/18 3:19 am, Rafal Lukawiecki wrote: > >> On 2 Jan 2018, at 03:05, Julian Elischer > > wrote: >>> #!/bin/sh >>> export ASSUME_ALWAYS_YES=YES >>> PKGS_TO_INSTALL=lots of packages go here >>> pkg -r /mnt fetch -d $PKGS_TO_INSTALL >>> pkg -c /mnt install $PKGS_TO_INSTALL >> please explain to me the use of -r AND -c? >> if you use -r to populate a chroot for -c then should that be pkg >> add rater than pkg install? > > Julian, I am afraid I have blindly followed the suggestion from > http://www.daemonology.net/blog/2015-11-21-FreeBSD-AMI-builder-AMI.html which > suggested this script to preinstall the packages in the system > mounted on /mnt > > #!/bin/sh > export ASSUME_ALWAYS_YES=YES > pkg -r /mnt fetch -d apache24 > pkg -c /mnt install apache24 > echo apache24_enable=YES >> /mnt/etc/rc.conf > mkami "FreeBSD 10.2 w/ Apache 2.4" "FreeBSD with Apache pre-installed" > shutdown -p now > > Perhaps Colin might be able to chime in on the original intent? > > My goal is to have packages installed, together with the patched > kernel, then to power off the machine and use it as a template for > others, saving the 3 minutes of the initial package installation > process, in our case. I have tried your suggestion of “add” but it > did not work, either. I wonder if this somehow related to inability > of pkg -c to resolve names in this AMI. > > When I try this manually, not using the above scripts, these are the > results and errors I get: > > $ pkg -r /mnt update -f > Updating FreeBSD repository catalogue... > pkg: Repository FreeBSD load error: access repo > file(/mnt/var/db/pkg/repo-FreeBSD.sqlite) failed: No such file > or directory > Fetching meta.txz: 100%    944 B   0.9kB/s    00:01 > Fetching packagesite.txz: 100%    6 MiB   6.1MB/s    00:01 > Processing entries: 100% > FreeBSD repository update completed. 26993 packages processed. > All repositories are up to date. > > $ pkg -c /mnt install awscli > Updating FreeBSD repository catalogue... > pkg: http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly/meta.txz: No > address record > repository FreeBSD has no meta file, using default settings > pkg: > http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly/packagesite.txz: > No address record > Unable to update repository FreeBSD > Error updating repositories! this means that either in the jail/chroot or in your machine, dns lookups are failing.. did you remember to copy /etc/resolv.conf into the chroot/jail? > > $ pkg -c /mnt add awscli > pkg: awscli: No such file or directory > pkg: Was 'pkg install awscli' meant? > Failed to install the following 1 package(s): awscli > > Many thanks, everyone. > Rafal pkg install fetches over the network, pkg add installs a prefetched file, so I am guessing that if you use add, and point the preloaded file it may work.. Of course pkg may be smart enough to find the cached copy itself, but it still seems to want to look at the network.