Solved pkg install (kickstart)

I am looking for a way to create a kickstart installation script for packages.
  • What I currently have: The database that contains all the packages I need to install pkg.sql.
  • What I am missing: A way to generate a pkg install script from that db.
I have searched all over the Internet but so far I have not found anything relevant.

Any ideas?
 
If this database file is derived from (or even better a copy of) the file /var/db/pkg/local.sqlite of an operational FreeBSD pkg installation, then you could do something like:
# sqlite3 -list pkg.sql 'select origin from packages;' | xargs pkg install

The exact sql query depends on the structure of your database file, and in addition, if it is not a sqlite database but a MySQL or PostgreSQL database then you need to use the respective command line client to generate a simple list of the entries that can be passed by the way of xargs(1) to pkg install.

Here comes the result of the above command on my machine without feeding it into pkg install:
Code:
# sqlite3 -list /var/db/pkg/local.sqlite 'select origin from packages;' | xargs

archivers/libarchive archivers/liblz4 archivers/libzip archivers/lzo2 archivers/php70-phar archivers/php70-zip archivers/php70-zlib archivers/unzip audio/alsa-lib converters/base64 converters/libiconv converters/php70-iconv converters/php70-mbstring databases/db5 databases/gdbm databases/ldb databases/php70-pdo databases/php70-pdo_pgsql databases/php70-pgsql databases/php70-sqlite3 databases/postgresql93-client databases/postgresql93-contrib databases/postgresql93-server databases/py-psycopg2 databases/py-sqlobject databases/sqlite3 databases/tdb devel/apr1 devel/autoconf devel/autoconf-wrapper devel/automake devel/automake-wrapper devel/cvsps devel/gamin devel/gettext devel/gettext-runtime devel/gettext-tools devel/git devel/glib20 devel/gmake devel/icu devel/libdevq devel/libedit devel/libevent2 devel/libffi devel/libinotify devel/libltdl devel/libpciaccess devel/libpthread-stubs devel/libtool devel/llvm37 devel/m4 devel/oniguruma5 devel/p5-Locale-gettext devel/p5-Parse-Pidl devel/p5-Parse-Yapp devel/pcre devel/pecl-pthreads devel/php70-intl devel/php70-json devel/pkgconf devel/popt devel/py-babel devel/py-cffi devel/py-cheetah devel/py-configargparse devel/py-configobj devel/py-dateutil devel/py-enum34 devel/py-funcsigs devel/py-lxml devel/py-mock devel/py-parsedatetime devel/py-pbr devel/py-pip devel/py-pyasn1 devel/py-pycparser devel/py-pyparsing devel/py-pyrfc3339 devel/py-python2-pythondialog devel/py-pytz devel/py-setuptools27 devel/py-simplejson devel/py-six devel/py-yaml devel/py-zope.component devel/py-zope.event devel/py-zope.interface devel/subversion devel/talloc devel/tevent dns/libidn dns/py-dnspython dns/py-idna editors/nano emulators/tpm-emulator ftp/curl ftp/php70-curl graphics/cairo graphics/gbm graphics/gd graphics/giflib graphics/graphite2 graphics/graphviz graphics/jbigkit graphics/jpeg-turbo graphics/libdrm graphics/libEGL graphics/libGL graphics/libglapi graphics/png graphics/py-pillow graphics/py-pydot graphics/tiff graphics/webp java/java-zoneinfo java/javavmwrapper java/openjdk8 lang/p5-Error lang/perl5.20 lang/php70 lang/php_doc lang/py-mx-base lang/python lang/python2 lang/python27 lang/tcl86 mail/dovecot2 mail/greyfix mail/libspf2 mail/p5-Net-SMTP-SSL mail/postfix math/gmp math/php70-bcmath misc/help2man misc/pciids net/isc-dhcp43-server net/mDNSResponder net/mpd5 net/netatalk3 net/openldap24-client net/openntpd net/p5-IO-Socket-IP net/p5-Socket net/php70-sockets net/py-ipaddress net/py-ndg_httpsclient net/rsync net/samba43 ports-mgmt/dialog4ports ports-mgmt/pkg ports-mgmt/pkg-rmleaf ports-mgmt/portmaster print/freetype2 print/harfbuzz print/indexinfo print/py-reportlab2 security/ca_root_nss security/cyrus-sasl2 security/gnutls security/libgcrypt security/libgpg-error security/libtasn1 security/nettle security/p11-kit security/p5-Authen-SASL security/p5-Digest-HMAC security/p5-GSSAPI security/p5-IO-Socket-SSL security/p5-Net-SSLeay security/php70-filter security/php70-hash security/php70-openssl security/py-acme security/py-cryptography security/py-letsencrypt security/py-openssl security/py-python-openid security/strongswan security/sudo security/trousers sysutils/apcupsd sysutils/ataidle sysutils/cdrtools-devel sysutils/fusefs-libs sysutils/libsunacl sysutils/php70-fileinfo sysutils/py-psutil sysutils/smartmontools sysutils/tmux textproc/expat2 textproc/libxml2 textproc/libxslt textproc/libyaml textproc/pecl-yaml textproc/php70-dom textproc/php70-xml textproc/py-libxml2 textproc/py-mako textproc/py-markdown textproc/py-MarkupSafe www/apache24 www/mod_php70 www/p5-Mozilla-CA www/php70-session www/py-beaker www/py-cherrypy www/py-formencode www/py-pywebdav www/py-requests www/py-werkzeug www/serf www/squid x11-fonts/dejavu x11-fonts/encodings x11-fonts/font-bh-ttf x11-fonts/font-misc-ethiopic x11-fonts/font-misc-meltho x11-fonts/font-util x11-fonts/fontconfig x11-fonts/libfontenc x11-fonts/libXft x11-fonts/mkfontdir x11-fonts/mkfontscale x11-fonts/xorg-fonts-truetype x11-toolkits/libXaw x11-toolkits/libXmu x11-toolkits/libXt x11-toolkits/pango x11-toolkits/py-tkinter x11-toolkits/tk86 x11/damageproto x11/dri2proto x11/fixesproto x11/glproto x11/inputproto x11/kbproto x11/libICE x11/libSM x11/libX11 x11/libXau x11/libxcb x11/libXdamage x11/libXdmcp x11/libXext x11/libXfixes x11/libXi x11/libXp x11/libXpm x11/libXrender x11/libXScrnSaver x11/libxshmfence x11/libXtst x11/libXv x11/libXvMC x11/libXxf86vm x11/pixman x11/printproto x11/recordproto x11/renderproto x11/scrnsaverproto x11/videoproto x11/xcb-util x11/xcb-util-renderutil x11/xextproto x11/xf86vidmodeproto x11/xproto
 
You can use pkg query directly by altering the environment and point pkg to the copy of that database:

env PKG_DBDIR=/othersystem/var/db/pkg pkg query "%o"

Edit: Didn't read the first reply...
 
Back
Top