harder and harder to avoid pkg

Roger Marquis marquis at roble.com
Tue Oct 11 20:58:20 UTC 2016


On Tue, 11 Oct 2016, Julian Elischer wrote:
> *manually* (scripted) copy out only the files I need, and then copy the pkg 
> database, so that when run on the running appliance, pkg THINKS all the 
> packages are loaded

We do something similar using prebuilt (pkg fetch) or locally built
(make package) packages by:

  1) untarring the .pkg:
     cd /tmp && tar xzvf {/usr/ports/packages/All,/var/cache/pkg}/...

  2) unpacking the manifests:
    cat -- +COMPACT_MANIFEST | jq -a 'del(.shlibs_required,.deps)' > \
        COMPACT_MANIFEST.tmp
    cat -- +MANIFEST | jq '.' > MANIFEST.tmp

  3) removing unecessary files and dependencies:
     vi *MANIFEST.tmp
       :s/DOCS": "on/DOCS": "off/
       :g,share/doc,d
       ...
     rm -rf ./usr/local/{same files and deps as vi}

  4) and repacking into a new, minimal pkg:
     mv COMPACT_MANIFEST.tmp +COMPACT_MANIFEST && \
     mv MANIFEST.tmp +MANIFEST && \
     tar cf - ... | (cd / && tar xfBp -) && \
     pkg create -M +MANIFEST

This tends to be easier than patching port/{Makefile,pkg-plist,files/...},
keeps /var/db/pkg/local.sqlite valid and works well with 'pkg audit'.
Should also, theoretically, be easy enough to roll into a metaport.

Thanks to Devin for the original idea.

YMMV,
Roger


More information about the freebsd-ports mailing list